| | |
| | | console.log('App Launch')
|
| | | },
|
| | | onShow: function() {
|
| | | //console.log('App Show')
|
| | | console.log('App Show') |
| | | // this.conn() |
| | | |
| | |
|
| | | },
|
| | | onHide: function() {
|
| | | //console.log('App Hide')
|
| | | console.log('App Hide') |
| | | // this.disconn()
|
| | | }, |
| | | methods:{ |
| | | //å¤çæçº¿éè¿ |
| | | conn(){ |
| | | console.log(this.$mqttTool.client) |
| | | if(this.$mqttTool.client){ |
| | | console.log(this.$mqttTool.client.connected) |
| | | } |
| | | if(this.$mqttTool.client && !this.$mqttTool.client.connected){ |
| | | console.info("å¼å§éè¿") |
| | | this.$mqttTool.reconnect() |
| | | }else { |
| | | |
| | | } |
| | | }, |
| | | disconn(){ |
| | | console.log(this.$mqttTool.client) |
| | | if(this.$mqttTool.client){ |
| | | console.log(this.$mqttTool.client.connected) |
| | | } |
| | | // if(this.$mqttTool.client){ |
| | | // this.$mqttTool.end().then(res =>{ |
| | | // console.log('ç»æ¢ï¼') |
| | | // }) |
| | | |
| | | // } |
| | | } |
| | | |
| | | },
|
| | | mounted() {
|
| | |
| | | fly
|
| | | } from '@/common/request/fly.js'
|
| | | //é
置请æ±åºå°å
|
| | | fly.config.baseURL = "http://192.168.2.6:8800/herb"
|
| | | fly.config.baseURL = "http://192.168.12.20:9999"
|
| | | const url = uni.getStorageSync('baseurl');
|
| | | if (url) {
|
| | | fly.config.baseURL = url + "/herb"
|
| | | }
|
| | |
|
| | | const mqttBaseUrl = "223.241.221.20"; |
| | | const emqxBaseUrl = "http://"+mqttBaseUrl +":18083/api/v5"
|
| | |
|
| | | // æµè¯
|
| | | function test(params) {
|
| | |
| | | fly.config.loading = true
|
| | | return fly.get('/dry/dryOrder/list', params);
|
| | | }
|
| | |
|
| | | //设å¤å表 |
| | | function queryEquList(params){ |
| | | fly.config.loading = true |
| | | return fly.get('/mobile/equ/list', params); |
| | | }
|
| | |
|
| | | //
|
| | | function getMonth(params) {
|
| | |
| | | }
|
| | |
|
| | |
|
| | | //emqx æ¥å£ |
| | | function emqxClients() {
|
| | | fly.config.loading = true
|
| | | return fly.get(emqxBaseUrl + "/clients", { |
| | | auth: { |
| | | username: "a3dc6758f6abc41a", |
| | | password: "FvBwJcmqhAuQ0aBg4FLl5gQA9A9BE64bpl0oJTg9A6I0bK" |
| | | }, |
| | | headers: { |
| | | 'Content-Type': 'application/json', |
| | | }, |
| | | });
|
| | | }
|
| | |
|
| | |
|
| | |
|
| | | export default {
|
| | |
| | | getRealTimeData,
|
| | | getAnalyList,
|
| | | getOrderList,
|
| | | queryEquList,
|
| | | getMonth,
|
| | | sendCommand
|
| | | sendCommand, |
| | | |
| | | emqxClients, |
| | | mqttBaseUrl
|
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | //ä¸è¡æä»¤åç¼
|
| | | const MOBILE_UP = "mobile/up"
|
| | | //è¯·æ±æ¥è¯¢è®¾å¤ç¶æ
|
| | | const MOBILE_QUERY_EQU_STATU = MOBILE_UP + "/query/equ/statu" |
| | | |
| | | //åéæä½æä»¤ |
| | | const MOBILE_REQ_EQU_CMD = MOBILE_UP + "/req/equ/cmd"
|
| | |
|
| | | //è§£ææ¶equæ¿æ¢æçå®è®¾å¤å¯ä¸æ è¯
|
| | | //ä¸è¡æä»¤åç¼
|
| | | const SERVICE_DOWN = "service/down/res" |
| | | //è¯·æ±æ¥è¯¢è®¾å¤ç¶æ
|
| | | const SERVICE_RES_EQU_STATU = SERVICE_DOWN + "/equ/statu" |
| | | //æ¥æ¶æä»¤ååº |
| | | const SERVICE_RES_EQU_CMD = SERVICE_DOWN + "/equ/cmd";
|
| | |
|
| | |
|
| | |
|
| | | /***********************ç¼åç¸å
³********************************/
|
| | | |
| | | //设å¤id(uni.getSystemInfo)
|
| | | const DEVICE_ID = "device_id"
|
| | |
|
| | |
|
| | | export default {
|
| | | MOBILE_QUERY_EQU_STATU, |
| | | SERVICE_RES_EQU_STATU, |
| | | SERVICE_DOWN, |
| | | MOBILE_REQ_EQU_CMD, |
| | | SERVICE_RES_EQU_CMD,
|
| | |
|
| | |
|
| | |
|
| | | DEVICE_ID
|
| | | } |
| | |
| | |
|
| | | fly.config.loading = true;
|
| | | //å®ä¾çº§é
ç½®
|
| | | //fly.config.timeout=6000;
|
| | | fly.config.timeout=10000;
|
| | | //æ·»å æ¦æªå¨
|
| | | fly.interceptors.request.use((config, promise) => {
|
| | | console.info(fly.config.loading)
|
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | /* main.js 项ç®ä¸»å
¥å£æ³¨å
¥å®ä¾ */ |
| | | // import mqttTool from './lib/mqttTool.js' |
| | | // Vue.prototype.$mqttTool = mqttTool |
| | | |
| | | /* 使ç¨èä¾è§ /pages/index/index.vue */ |
| | | // mqttåè®®ï¼H5使ç¨ws/wss APP-PLUS使ç¨wx/wxs |
| | | |
| | | var mqtt = require('mqtt/dist/mqtt.js') |
| | | |
| | | //客æ·ç«¯ |
| | | let mqttTool = { |
| | | client: null |
| | | } |
| | | |
| | | //è¿æ¥æ¯ |
| | | mqttTool.connect = function(params){ |
| | | let options = { |
| | | clientId: params.clientId, |
| | | username: params.username, |
| | | password: params.password, |
| | | clean: true, |
| | | keepalive:10, //å¿è·³ åä½ï¼s |
| | | connectTimeout: 10*1000, //è¿æ¥è¶
æ¶ åä½ï¼ms |
| | | cleanSession: true |
| | | } |
| | | let client = mqtt.connect(params.url, options); |
| | | mqttTool.client = client |
| | | return client; |
| | | } |
| | | |
| | | mqttTool.end = function(){ |
| | | return new Promise((resolve, reject) => { |
| | | if(mqttTool.client == null){ |
| | | resolve('æªè¿æ¥') |
| | | console.log('App_text' + ":end æªè¿æ¥") |
| | | return; |
| | | } |
| | | mqttTool.client.end() |
| | | mqttTool.client = null |
| | | resolve('è¿æ¥ç»æ¢') |
| | | }) |
| | | } |
| | | |
| | | mqttTool.reconnect = function(){ |
| | | return new Promise((resolve, reject) => { |
| | | if(mqttTool.client == null){ |
| | | resolve('æªè¿æ¥') |
| | | console.log('App_text' + ":reconnect æªè¿æ¥") |
| | | return; |
| | | } |
| | | mqttTool.client.reconnect() |
| | | }) |
| | | } |
| | | |
| | | mqttTool.subscribe = function(params){ |
| | | return new Promise((resolve, reject) => { |
| | | if(mqttTool.client == null){ |
| | | resolve('æªè¿æ¥') |
| | | console.log('App_text' + ":unconnect æªè¿æ¥") |
| | | return; |
| | | } |
| | | mqttTool.client.subscribe(params.topic, {qos:params.qos}, function(err,res) { |
| | | console.log(err,res) |
| | | if (!err && res.length>0) { |
| | | resolve('订é
æå') |
| | | console.log('App_text' + ":subscribe success 订é
æå") |
| | | }else{ |
| | | resolve('订é
失败') |
| | | console.log('App_text' + ":subscribe failed 订é
失败") |
| | | return; |
| | | } |
| | | }) |
| | | }) |
| | | } |
| | | |
| | | mqttTool.unsubscribe = function(params){ |
| | | return new Promise((resolve, reject) => { |
| | | if(mqttTool.client == null){ |
| | | resolve('æªè¿æ¥') |
| | | console.log('App_text' + ":unconnect æªè¿æ¥") |
| | | return; |
| | | } |
| | | mqttTool.client.unsubscribe(params.topic, function(err) { |
| | | if (!err) { |
| | | resolve('åæ¶è®¢é
æå') |
| | | console.log('App_text' + ":unsubscribe success åæ¶è®¢é
æå") |
| | | }else{ |
| | | resolve('åæ¶è®¢é
失败') |
| | | console.log('App_text' + ":unsubscribe failed åæ¶è®¢é
失败") |
| | | return; |
| | | } |
| | | }) |
| | | }) |
| | | } |
| | | |
| | | mqttTool.publish = function(params){ |
| | | return new Promise((resolve, reject) => { |
| | | if(mqttTool.client == null){ |
| | | resolve('æªè¿æ¥') |
| | | console.log('App_text' + ":unconnect æªè¿æ¥") |
| | | return; |
| | | } |
| | | mqttTool.client.publish(params.topic, params.message, function(err){ |
| | | if (!err) { |
| | | resolve(params.topic + '-' + params.message + '-åéæå') |
| | | console.log('App_text' + ":publish success åéæå") |
| | | }else{ |
| | | resolve(params.topic + '-' + params.message + '-åé失败') |
| | | console.log('App_text' + ":publish failed åé失败") |
| | | return; |
| | | } |
| | | }) |
| | | }) |
| | | } |
| | | |
| | | //æ¶æ¯å¤ç |
| | | mqttTool.message = function(){ |
| | | return new Promise((resolve, reject) => { |
| | | if(mqttTool.client == null){ |
| | | resolve('æªè¿æ¥') |
| | | console.log('App_text' + ":unconnect æªè¿æ¥") |
| | | return; |
| | | } |
| | | if(mqttTool.client != null && ! mqttTool.client.connected){ |
| | | mqttTool.client.reconnect() |
| | | } |
| | | |
| | | mqttTool.client.on('message', function(topic, message, buffer) { |
| | | console.info(topic) |
| | | console.info(message) |
| | | setTimeout(() => { |
| | | resolve({topic, message, buffer }) |
| | | }, 300) |
| | | }) |
| | | |
| | | }) |
| | | } |
| | | |
| | | |
| | | |
| | | export default mqttTool |
| | |
| | | // å
¨å±æè½½åä½¿ç¨ |
| | | Vue.prototype.$api = api |
| | | |
| | | import constant from '@/common/constant.js' |
| | | // å
¨å±æè½½åä½¿ç¨ |
| | | Vue.prototype.$constant = constant |
| | | |
| | | |
| | | import lget from '@/common/loadshget.js' |
| | | // å
¨å±æè½½åä½¿ç¨ |
| | | Vue.prototype.$lget = lget |
| | |
| | | </view>
|
| | | <view class="h-tr h-tr-2">
|
| | | <view class="h-td">
|
| | | <u-tag size="mini" text="å¨çº¿" type="success" plain plainFill></u-tag>
|
| | | <u-tag v-if="connected" size="mini" text="å¨çº¿" type="success" plain
|
| | | plainFill></u-tag>
|
| | | <u-tag v-else size="mini" text="离线" type="error" plain plainFill></u-tag>
|
| | | </view>
|
| | | <view class="h-td">
|
| | | <template v-if="runStatu">
|
| | | <u-tag size="mini" text="æ£å¨å¹²ç¥" type="success" plain plainFill></u-tag>
|
| | | </template>
|
| | | <template v-else>
|
| | | <u-tag size="mini" text="å¾
æº" type="error" plain plainFill></u-tag>
|
| | | </template>
|
| | | </view>
|
| | | <view class="h-td">{{$lget(model,'windTemp')}}</view>
|
| | | <view class="h-td">{{$lget(model,'windTemp')}}</view>
|
| | |
| | |
|
| | | </view>
|
| | | <view class="h-tr h-tr-2">
|
| | | <view class="h-td">çå°é»</view>
|
| | | <view class="h-td">{{$lget(model,'herbName')}}</view>
|
| | | <view class="h-td">{{$lget(model,'envTemp') == "" ? "--" : $lget(model,'envTemp')}}m³
|
| | | </view>
|
| | | <view class="h-td">{{$lget(model,'envHum') == "" ? "--" :$lget(model,'envHum') }}kg
|
| | |
| | | <uni-section title="æä»¤" type="line">
|
| | | <view class="flex justify-center padding-lg bg-white">
|
| | | <view class="margin-right-sm">
|
| | | <u-button text="弿º" type="success" @click="$u.throttle(showModal(), 500)"></u-button>
|
| | | <u-button :disabled="connected" text="弿º" type="success"
|
| | | @click="$u.throttle(showModal(1), 500)"></u-button>
|
| | | </view>
|
| | |
|
| | | <view class="margin-left-sm">
|
| | | <u-button text="å
³æº" type="error" :disabled="true"></u-button>
|
| | | <u-button :disabled="!connected" text="å
³æº" type="error"
|
| | | @click="$u.throttle(showModal(2), 500)"></u-button>
|
| | | </view>
|
| | |
|
| | |
|
| | |
| | |
|
| | | <uni-section title="æ§å¶å°" type="line" class="margin-top-sm ">
|
| | | <view class="padding-left-sm padding-right-sm padding-bottom-sm">
|
| | | <view class="text-sm text-gray">12:00:20: <弿º>æä»¤æä½æå</view>
|
| | | <view class="text-sm text-gray margin-top-sm">12:00:10: åé<弿º>æä»¤</view>
|
| | | <view class="text-sm text-gray" :class="{'margin-top-sm':index>0}" v-for="(log,index) in logList">{{log}}</view>
|
| | | <!-- <view class="text-sm text-gray margin-top-sm">12:00:10: åé<弿º>æä»¤</view> -->
|
| | | </view>
|
| | |
|
| | | </uni-section>
|
| | |
| | | </swiper>
|
| | |
|
| | |
|
| | |
|
| | |
|
| | |
|
| | | <u-modal :show="show" title="éªè¯äºçº§å¯ç " @confirm="confirm" :showCancelButton="true" @cancel="show=false"
|
| | | ref="uModal" :asyncClose="true">
|
| | | <u-modal :show="show" @confirm="confirm" :showCancelButton="true" @cancel="show=false" ref="uModal"
|
| | | :asyncClose="true">
|
| | |
|
| | | <slot>
|
| | | <view>
|
| | | <u--input style="width: 100%;" placeholder="请è¾å
¥äºçº§å¯ç " border="surround" password
|
| | | <view style="width: 100%;height:100%;">
|
| | | <view style="color:red">
|
| | | è¿ç¨æ§å¶æä½å¯è½åå¨å®å
¨é£é©ï¼è¯·è°¨æ
æä½
|
| | | </view>
|
| | | <u--input style="width: 100%;" placeholder="请è¾å
¥äºçº§å®å
¨å¯ç " border="surround" password
|
| | | clearable></u--input>
|
| | | </view>
|
| | | </slot>
|
| | |
| | | export default {
|
| | | data() {
|
| | | return {
|
| | | //ä¸ä¸ªé¡µé¢ä¼ éè¿æ¥çæ°æ®
|
| | | option: {},
|
| | | //æä½æä»¤log
|
| | | logList: [],
|
| | | //å½å设å¤è¿æ¥ç¶æ
|
| | | connected: false,
|
| | | //å¼å
³æºæä»¤ 1-弿º 2-å
³æº
|
| | | cmd: -1,
|
| | | show: false,
|
| | | swiperList: ["çæµ", "æ§å¶"],
|
| | | swiperCurrent: 0,
|
| | |
| | | notice: "2023-03-1812:00:001å·æºå°ä½æ¸©æ¥è¦",
|
| | | model: {},
|
| | | queryParam: {
|
| | | machineid: "GM001",
|
| | | tenantid: 1003
|
| | | machineid: "",
|
| | | tenantid: null
|
| | | },
|
| | | bannerList: [{
|
| | | imageUrl: '../../static/image/zcy_gzj1.png'
|
| | |
| | | }
|
| | | },
|
| | | onShow() {
|
| | | console.info("onShow")
|
| | | this.startTimer()
|
| | |
|
| | | },
|
| | |
|
| | | onLoad(e) {
|
| | | onLoad(option) {
|
| | | const userinfo = uni.getStorageSync('userinfo');
|
| | | this.option = option
|
| | | this.option.tenantid = userinfo.loginTenantId
|
| | | this.option.username = userinfo.username
|
| | |
|
| | |
|
| | | //åå§åæ¥è¯¢åæ°
|
| | | this.queryParam.machineid = option.code
|
| | | this.queryParam.tenantid = userinfo.loginTenantId
|
| | |
|
| | | },
|
| | | onBackPress() {
|
| | |
| | | },
|
| | | onReady() {
|
| | | //this.getServerData()
|
| | | // this.$mqttTool.message().then(res => {
|
| | | // console.error("è§£ææ°æ®")
|
| | | // if (res.topic == this.$constant.SERVICE_RES_EQU_STATU) {
|
| | | // const msgstr = res.message.toString();
|
| | | // const message = JSON.parse(msgstr);
|
| | | // console.error(message)
|
| | | // console.error(message.success)
|
| | | // }
|
| | | // })
|
| | | let _this = this
|
| | | this.$mqttTool.client.on('message', function(topic, message, buffer) {
|
| | |
|
| | | },
|
| | | methods: {
|
| | | showModal() {
|
| | | this.show = true;
|
| | | },
|
| | | confirm() {
|
| | | console.error("è§£ææ°æ®")
|
| | | const msg = JSON.parse(message);
|
| | | console.error(topic)
|
| | | console.error(msg)
|
| | | console.error(msg.success)
|
| | | if (topic == _this.$constant.SERVICE_RES_EQU_STATU.replace('equ', _this.deviceId)) {
|
| | | if (msg.success) {
|
| | | _this.connected = msg.connected
|
| | | } else {
|
| | | _this.connected = false
|
| | | }
|
| | | } else if (topic == _this.$constant.SERVICE_RES_EQU_CMD.replace('equ', _this.deviceId)) { |
| | | //åéæä»¤æ¶å°ååº |
| | | //æ·»å log |
| | | let log = this.getCurrentTime() +'è¿åï¼' + + 'æä»¤' ; |
| | | this.logList.push(log) |
| | | |
| | | setTimeout(() => {
|
| | | // 3ç§åèªå¨å
³é |
| | | uni.showToast({ |
| | | title: 'æä½æå~', |
| | | title: msg.msg,
|
| | | icon: 'none', |
| | | mask: true |
| | | });
|
| | | this.show = false;
|
| | | }, 3000)
|
| | | _this.show = false;
|
| | | }, 1000)
|
| | | }
|
| | | })
|
| | |
|
| | | this.queryEquStatu()
|
| | |
|
| | | },
|
| | | methods: {
|
| | | //MQTT
|
| | | queryEquStatu() {
|
| | |
|
| | | //1.æ¥è¯¢è®¾å¤å®æ¶ç¶æ
|
| | | const message = {
|
| | | clientId: this.option.clientId,
|
| | | timestamp: new Date(),
|
| | | req: this.deviceId
|
| | | }
|
| | | let opts = {
|
| | | topic: this.$constant.MOBILE_QUERY_EQU_STATU,
|
| | | message: JSON.stringify(message),
|
| | | }
|
| | |
|
| | | this.$mqttTool.publish(opts).then(res => {
|
| | | console.error(res)
|
| | | })
|
| | |
|
| | | },
|
| | |
|
| | | sendEquCmd() {
|
| | | //æ·»å log
|
| | | let log = this.getCurrentTime() +'åé' + (this.cmd == 1 ? "ï¼ã弿ºã" : "ï¼ãå
³æºã") + 'æä»¤' ;
|
| | | this.logList.push(log)
|
| | | |
| | | //1.åéå¼å
³æºæä»¤ 1-弿º 2-å
³æº
|
| | | const message = {
|
| | | clientId: this.option.clientId,
|
| | | cmd: this.cmd,
|
| | | timestamp: new Date(),
|
| | | req: this.deviceId
|
| | | }
|
| | | let opts = {
|
| | | topic: this.$constant.MOBILE_REQ_EQU_CMD,
|
| | | message: JSON.stringify(message),
|
| | | }
|
| | |
|
| | | this.$mqttTool.publish(opts).then(res => {
|
| | | console.error(res)
|
| | | })
|
| | |
|
| | | },
|
| | |
|
| | | showModal(cmd) {
|
| | | this.show = true;
|
| | | this.cmd = cmd;
|
| | | },
|
| | | confirm() {
|
| | | this.sendEquCmd()
|
| | | // setTimeout(() => {
|
| | | // // 3ç§åèªå¨å
³é
|
| | | // uni.showToast({
|
| | | // title: 'æä½æå~',
|
| | | // icon: 'none',
|
| | | // mask: true
|
| | | // });
|
| | | // this.show = false;
|
| | | // }, 3000)
|
| | |
|
| | |
|
| | |
|
| | |
|
| | | },
|
| | | startTimer() {
|
| | | console.info("çæ§é¡µé¢æ¾ç¤º")
|
| | | this.getRealData()
|
| | | //ä¸é´ææ¥è¯¢å¾
æä½å¹²ç¥æºçç¶æï¼å®æ¶æ´æ°
|
| | | //this.queryEquStatu()
|
| | | if (!this.$monitorTimer) {
|
| | | this.$monitorTimer = setInterval(() => {
|
| | | console.info("宿¶å¨å·¥ä½")
|
| | | console.info(this.$monitorTimer)
|
| | | this.getRealData()
|
| | |
|
| | | /**
|
| | | * TODO 使ç¨last_will代æ¿è½®è¯¢
|
| | | */
|
| | | //ä¸é´ææ¥è¯¢å¾
æä½å¹²ç¥æºçç¶æï¼å®æ¶æ´æ° |
| | | //this.queryEquStatu()
|
| | |
|
| | | }, 1000 * 12)
|
| | | }
|
| | |
|
| | |
| | | this.swiperCurrent = e.detail.current;
|
| | | console.log(e.detail.current)
|
| | | this.$refs.tabs.unlockDx();
|
| | | },
|
| | | getCurrentTime() {
|
| | | // è·åå½åæ¶é´ |
| | | let now = new Date();
|
| | | // æ ¼å¼åæ¶é´ |
| | | let year = now.getFullYear();
|
| | | let month = (now.getMonth() + 1).toString().padStart(2, '0');
|
| | | let day = now.getDate().toString().padStart(2, '0');
|
| | | let hours = now.getHours().toString().padStart(2, '0');
|
| | | let minutes = now.getMinutes().toString().padStart(2, '0');
|
| | | let seconds = now.getSeconds().toString().padStart(2, '0');
|
| | |
|
| | | // è¿åç»æ |
| | | return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
|
| | | },
|
| | | getServerData() {
|
| | | //模æä»æå¡å¨è·åæ°æ®æ¶çå»¶æ¶
|
| | |
| | | }
|
| | | },
|
| | | computed: {
|
| | | deviceId() {
|
| | | return uni.getStorageSync(this.$constant.DEVICE_ID);
|
| | | },
|
| | | //è¿è¡ç¶æ
|
| | | runStatu() {
|
| | | let stop = this.$lget(this.model, 'stop');
|
| | |
| | | data() {
|
| | | return {
|
| | | model: {
|
| | | username: "",
|
| | | password: ""
|
| | | username: "tongjitang",
|
| | | password: "123456"
|
| | | },
|
| | | rules: {
|
| | | 'username': {
|
| | |
| | | },
|
| | |
|
| | | methods: {
|
| | | |
| | | forget() {
|
| | | uni.navigateTo({
|
| | | url: "/pages/tabBar/demo"
|
| | | })
|
| | | },
|
| | | submit() {
|
| | |
|
| | | if (this.model.username.startsWith("http")) {
|
| | | uni.setStorageSync('baseurl', this.model.username);
|
| | | this.model.username = null
|
| | |
| | | this.$api.login(this.model).then((res) => {
|
| | | if (res.success) {
|
| | |
|
| | |
|
| | | console.log('request success', res)
|
| | | uni.showToast({
|
| | | title: 'ç»å½æå',
|
| | |
| | | uni.setStorageSync('userinfo', res.result.userInfo);
|
| | | uni.setStorageSync('token', res.result.token);
|
| | |
|
| | |
|
| | | uni.switchTab({
|
| | | url: '/pages/tabBar/general'
|
| | | })
|
| | |
| | | <view class="title">æ»è§</view>
|
| | | </view>
|
| | | <view>
|
| | | <text class="text-gray margin-right-lg">2024-07-14</text>
|
| | | <text
|
| | | class="text-gray margin-right-lg">{{new Date().toLocaleDateString().replace(/\//g, '-')}}</text>
|
| | | </view>
|
| | |
|
| | | </view>
|
| | |
| | | <view class="flex">
|
| | | <view class="flex-sub flex flex-direction text-center">
|
| | | <text class="text-df">è®¾å¤æ»æ°</text>
|
| | | <text class="text-bold text-sl margin-top-xs text-gray margin-top-sm">20
|
| | | <text class="text-bold text-sl margin-top-xs text-gray margin-top-sm">{{equCount}}
|
| | | <text class="text-gray text-sm margin-left-xs">å°</text></text>
|
| | | </view> |
| | | |
| | | <view class="flex-sub flex flex-direction text-center"> |
| | | <text class="text-df">弿ºè®¾å¤</text> |
| | | <text class="text-bold text-sl margin-top-xs text-gray margin-top-sm">10 |
| | | <text class="text-bold text-sl margin-top-xs text-gray margin-top-sm">{{onlineCount}}
|
| | | <text class="text-gray text-sm margin-left-xs">å°</text></text> |
| | | </view> |
| | | |
| | | <view class="flex-sub flex flex-direction text-center"> |
| | | <text class="text-df">è¿è¡è®¾å¤</text> |
| | | <text class="text-bold text-sl margin-top-xs text-cyan margin-top-sm">10 |
| | | <text class="text-bold text-sl margin-top-xs text-cyan margin-top-sm">{{onlineCount}}
|
| | | <text class="text-gray text-sm margin-left-xs">å°</text></text> |
| | | </view>
|
| | | </view>
|
| | |
| | | |
| | | |
| | | |
| | | <u-skeleton |
| | | class=" " |
| | | rows="20" |
| | | :loading="loading" |
| | | :title="false" |
| | | > |
| | | <u-skeleton class=" " rows="20" :loading="loading" :title="false">
|
| | | <!-- 妿叿å
¶ä»viewè·ç页颿»å¨ï¼å¯ä»¥æ¾å¨z-pagingæ ç¾å
-->
|
| | | <view class="card-box dynamic shadow" v-for="(item,index) in dataList" :key="index"
|
| | | @click="itemClick(item)">
|
| | | <view class="title-box">
|
| | | <view class="left flex-sub">
|
| | | <uni-text class="cuIcon-titles text-blue"></uni-text>
|
| | | <view class="title text-cut">1#æºè½å¹²ç¥æº</view>
|
| | | <view class="title text-cut">{{$lget(item,'name')}}</view>
|
| | | <view class="flex title text-green text-sm">
|
| | | <u-tag size="mini" text="å¨çº¿" type="success" plain plainFill></u-tag> |
| | | <u-tag class="margin-left-xs" size="mini" text="åæº" type="error" plain plainFill></u-tag>
|
| | | <u-tag v-if="item.online" size="mini" text="å¨çº¿" type="success" plain plainFill></u-tag>
|
| | | <u-tag v-else class="" size="mini" text="åæº" type="error" plain plainFill></u-tag>
|
| | | </view>
|
| | | </view>
|
| | | <view class="right" style="min-width: 240rpx;">
|
| | | <!-- <u-badge :isDot="true" type="success"></u-badge> -->
|
| | | <view class="title text-gray text-sm">弿ºæ¶é´:</view>
|
| | | <view class="title text-gray text-sm">10:00:10</view>
|
| | | <!-- <view class="title text-gray text-sm">弿ºæ¶é´:</view> -->
|
| | | <view class="title text-gray text-sm">{{$lget(item,'upTime')}}</view>
|
| | | </view>
|
| | | </view>
|
| | |
|
| | | <view class="info-box">
|
| | | <view class="left flex-sub">
|
| | | <view class="title text-sm">çå¹²è¯æ:</view>
|
| | | <view class="title text-sm">çå°é»</view>
|
| | | <view class="title text-sm text-gray">--</view>
|
| | | </view>
|
| | | <view class="right" style="min-width: 240rpx;">
|
| | | <view class="title text-sm">çå¹²æ¶é´:</view>
|
| | | <view class="title text-sm">01:20:00</view>
|
| | | <view class="title text-sm text-gray">--</view>
|
| | | </view>
|
| | | </view>
|
| | |
|
| | |
| | | <view class="left flex-sub">
|
| | | <view class="title text-sm text-cut">æ¥è¦ä¿¡æ¯:</view>
|
| | | <view class="flex title text-sm">
|
| | | <template v-if="item.online && !item.fault">
|
| | | <u-tag size="mini" text="æ£å¸¸" type="success" plain plainFill></u-tag>
|
| | | </template>
|
| | | <template v-else-if="item.fault">
|
| | | <u-tag size="mini" text="æ¸©åº¦ä¼ æå¨æ¥è¦" type="warning" plain plainFill></u-tag>
|
| | | <u-tag size="mini" class="margin-left-xs" text="å鍿ªå
³" type="warning" plain
|
| | | plainFill></u-tag>
|
| | | <u-tag size="mini" class="margin-left-xs" text="é£ç®±ä½ä½æ¥è¦" type="error" plain
|
| | | plainFill></u-tag>
|
| | | </template>
|
| | | <template v-else>
|
| | | </template>
|
| | | </view>
|
| | | </view>
|
| | |
|
| | |
| | | return { |
| | | loading:true,
|
| | | // v-modelç»å®çè¿ä¸ªåéä¸è¦å¨å页请æ±ç»æä¸èªå·±èµå¼ï¼ï¼ï¼
|
| | | dataList: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
|
| | | dataList: [],
|
| | | }
|
| | | },
|
| | | methods: {
|
| | |
| | | // ç»ä»¶å è½½æ¶ä¼èªå¨è§¦åæ¤æ¹æ³ï¼å æ¤é»è®¤é¡µé¢å è½½æ¶ä¼èªå¨è§¦åï¼æ éæå¨è°ç¨
|
| | | // è¿éçpageNoåpageSizeä¼èªå¨è®¡ç®å¥½ï¼ç´æ¥ä¼ ç»æå¡å¨å³å¯
|
| | | // 模æè¯·æ±æå¡å¨è·ååé¡µæ°æ®ï¼è¯·æ¿æ¢æèªå·±çç½ç»è¯·æ±
|
| | | // const params = {
|
| | | // pageNo: pageNo,
|
| | | // pageSize: pageSize,
|
| | | // }
|
| | | // this.$request.queryList(params).then(res => {
|
| | | const params = {
|
| | | pageNo: pageNo,
|
| | | pageSize: pageSize,
|
| | | }
|
| | | this.$api.queryEquList(params).then((res) => {
|
| | | // // å°è¯·æ±çç»ææ°ç»ä¼ éç»z-paging
|
| | | this.$refs.paging.complete(this.dataList);
|
| | | // }).catch(res => {
|
| | | // // å¦æè¯·æ±å¤±è´¥åthis.$refs.paging.complete(false);
|
| | | // // 注æï¼æ¯æ¬¡é½éè¦å¨catchä¸åè¿å¥è¯å¾éº»ç¦ï¼z-pagingæä¾äºæ¹æ¡å¯ä»¥å
¨å±ç»ä¸å¤ç
|
| | | // // å¨åºå±çç½ç»è¯·æ±æåºå¼å¸¸æ¶ï¼åuni.$emit('z-paging-error-emit');å³å¯
|
| | | // this.$refs.paging.complete(false);
|
| | | // }) |
| | | setTimeout(() => { |
| | | this.$refs.paging.complete(res.result.records);
|
| | | this.loading = false |
| | | }, 1000)
|
| | | }).catch(res => {
|
| | | // å¦æè¯·æ±å¤±è´¥åthis.$refs.paging.complete(false);
|
| | | // 注æï¼æ¯æ¬¡é½éè¦å¨catchä¸åè¿å¥è¯å¾éº»ç¦ï¼z-pagingæä¾äºæ¹æ¡å¯ä»¥å
¨å±ç»ä¸å¤ç
|
| | | // å¨åºå±çç½ç»è¯·æ±æåºå¼å¸¸æ¶ï¼åuni.$emit('z-paging-error-emit');å³å¯
|
| | | this.$refs.paging.complete(false);
|
| | | this.loading = false
|
| | | })
|
| | |
|
| | | }, |
| | | itemClick(item){ |
| | | uni.navigateTo({ |
| | | url:"/pages/device/control" |
| | | url: "/pages/device/control?code="+item.code+"&clientId="+item.clientId
|
| | | }) |
| | | }
|
| | |
|
| | | },onReady() { |
| | | },
|
| | | onReady() {
|
| | | |
| | | setTimeout(() => { |
| | | this.loading = false |
| | | }, 1000) |
| | | },
|
| | | computed: {
|
| | | equCount() {
|
| | | return this.dataList.length
|
| | | },
|
| | | onlineCount() {
|
| | | const list = this.dataList.filter(item => item.online)
|
| | | return list.length
|
| | | }
|
| | | }
|
| | | }
|
| | | </script>
|
| | |
| | | <view class="flex">
|
| | | <text>ä¸èè¯</text>
|
| | | <text>丨</text>
|
| | | <text @click="showLongName(showValue(item.herbName))" class="text-cut flex-twice">{{showValue(item.herbName)}}</text>
|
| | | <text @click="showLongName(showValue(item.herbName))"
|
| | | class="text-cut flex-twice">{{showValue(item.herbName)}}</text>
|
| | | <!-- <view class="margin-lr-sm">
|
| | | <u-tag text="æ¥è¦ä¸æ¬¡" plain size="mini" type="warning"></u-tag>
|
| | | </view> -->
|
| | |
| | |
|
| | | },
|
| | | onReady() {
|
| | | const userinfo = uni.getStorageSync('userinfo');
|
| | | const tenantid = userinfo.loginTenantId
|
| | | uni.getSystemInfo({
|
| | | success: (res) => {
|
| | | let deviceId = res.deviceId
|
| | | if (!deviceId) {
|
| | | deviceId = 'mobile-' + tenantid + '-' + Date.parse(new Date())
|
| | | }
|
| | | uni.setStorageSync(this.$constant.DEVICE_ID, 'mobile-' + tenantid + '-' + res.deviceId);
|
| | | }
|
| | | })
|
| | | this.startConnect();
|
| | |
|
| | |
|
| | |
|
| | | let month = uni.$u.timeFormat(new Date(), 'yyyy-mm')
|
| | | this.getMonth(month)
|
| | |
|
| | |
| | |
|
| | | },
|
| | | methods: { |
| | | /* è¿æ¥MQTT */
|
| | | async startConnect() {
|
| | | var _this = this
|
| | | const account = uni.getStorageSync('account');
|
| | | const deviceid = uni.getStorageSync(this.$constant.DEVICE_ID);
|
| | |
|
| | | if (!account) {
|
| | |
|
| | | return false
|
| | | }
|
| | | let opts = {
|
| | | // #ifdef H5
|
| | | url: 'ws://' + this.$api.mqttBaseUrl + ':8083/mqtt',
|
| | | // #endif
|
| | | // #ifdef APP-PLUS
|
| | | url: 'wx://' + this.$api.mqttBaseUrl + ':8083/mqtt',
|
| | | // #endif
|
| | | clientId: deviceid,
|
| | | username: account.username,
|
| | | password: account.password
|
| | | }
|
| | | if (!this.$mqttTool.client) {
|
| | | var client = await this.$mqttTool.connect(opts);
|
| | | }
|
| | | //订é
æ¥è¯¢è®¾å¤ç¶æè¿åæ°æ®
|
| | | this.$mqttTool.subscribe({
|
| | | topic: this.$constant.SERVICE_DOWN + '/' + deviceid + '/#',
|
| | | qos: 0
|
| | | }).then(res => {
|
| | | console.error(res)
|
| | | })
|
| | | //订é
åéæä»¤è¿åç»æ
|
| | | // this.$mqttTool.subscribe({
|
| | | // topic: this.$constant.SERVICE_RES_EQU_CMD,
|
| | | // qos: 0
|
| | | // }).then(res => {
|
| | | // console.error(res)
|
| | | // })
|
| | | // if (!client) {
|
| | | // return false
|
| | | // }
|
| | |
|
| | | client.on('connect', function(res) {
|
| | | console.error('è¿æ¥æå')
|
| | | })
|
| | | client.on('reconnect', function(res) {
|
| | | console.error('éæ°è¿æ¥')
|
| | | })
|
| | | client.on('error', function(res) {
|
| | | console.info('è¿æ¥é误')
|
| | | })
|
| | | client.on('close', function(res) {
|
| | |
|
| | | console.error('å
³éæå')
|
| | |
|
| | | })
|
| | | client.on('message', function(topic, message, buffer) {
|
| | | //console.info(message)
|
| | | })
|
| | | },
|
| | |
|
| | |
|
| | | showLongName(longName){ |
| | | this.$refs.uToast.show({ |
| | | type: 'default', |