| | |
| | | import {
|
| | | fly
|
| | | } from '@/common/request/fly.js' |
| | | const base = "http://192.168.21.3:9999" |
| | | // const base = "https://lanpucloud.cn" |
| | | // const base = "http://192.168.21.3:9999" |
| | | const base = "http://lanpucloud.cn" |
| | |
|
| | | //配置请求基地址
|
| | | fly.config.baseURL = base + ""
|
| | | fly.config.baseURL = base + "/herb" |
| | | // fly.config.baseURL = base + ""
|
| | | const ip = uni.getStorageSync('lan_ip');
|
| | | if (ip) {
|
| | | fly.config.baseURL = "http://" + ip + ":9999"
|
| | |
| | | }
|
| | | let opts = {
|
| | | // #ifdef H5
|
| | | url: 'wss://' + this.$api.mqttBaseUrl + ':8084/mqtt',
|
| | | url: 'ws://' + this.$api.mqttBaseUrl + ':8083/mqtt',
|
| | | // #endif
|
| | | // #ifdef MP-WEIXIN
|
| | | url: 'wxs://' + this.$api.mqttBaseUrl + ':8084/mqtt', // 微信小程序强制 WSS
|
| | | // #endif
|
| | | // #ifdef APP-PLUS
|
| | | url: 'wxs://' + this.$api.mqttBaseUrl + ':8084/mqtt', // Android/iOS 用普通 WebSocket
|
| | | url: 'wx://' + this.$api.mqttBaseUrl + ':8083/mqtt', // Android/iOS 用普通 WebSocket
|
| | | // #endif
|
| | | clientId: deviceid,
|
| | | username: account.username,
|
| | | password: account.password
|
| | | // username: account.username,
|
| | | // password: account.password, |
| | | //统一使用租户登录 TODO 添加多租户用户 |
| | | username: 'tongjitang', |
| | | password: '123456'
|
| | | }
|
| | | if (!this.$mqttTool.client) {
|
| | | this.$mqttTool.client = await this.$mqttTool.connect(opts);
|
| | |
| | | loading: true,
|
| | | // v-model绑定的这个变量不要在分页请求结束中自己赋值!!!
|
| | | dataList: [],
|
| | | curDate: uni.$u.timeFormat(new Date(), 'yyyy-mm-dd'),
|
| | | curDate: dayjs().format('YYYY-MM-DD HH:mm:ss'),
|
| | | isProcessing: false,
|
| | | // key->设备租户+code
|
| | | dataMap: new Map(),
|
| | |
|
| | | alarmEquCount: 0,
|
| | | faultEquCount: 0,
|
| | | timer: null
|
| | | timer: null,
|
| | | mqttThrottleMs: 1000,
|
| | | lastMqttTs: 0,
|
| | | dateTimer: null
|
| | |
|
| | | }
|
| | | },
|
| | | onShow() {
|
| | | this.startTimer()
|
| | | this.startDateTimer()
|
| | | this.mqttData()
|
| | | },
|
| | | onHide() {
|
| | | this.stopTimer()
|
| | | this.stopDateTimer()
|
| | | uni.$off(this.$constant.MQTT_TOPIC_MESSAGE)
|
| | | },
|
| | | onTabItemTap: function(e) {
|
| | |
| | | stopTimer() {
|
| | | clearInterval(this.timer);
|
| | | },
|
| | | startDateTimer() {
|
| | | this.dateTimer = setInterval(() => {
|
| | | this.curDate = dayjs().format('YYYY-MM-DD HH:mm:ss')
|
| | | }, 1000);
|
| | | },
|
| | | stopDateTimer() {
|
| | | clearInterval(this.dateTimer);
|
| | | },
|
| | | queryRealFaultData() {
|
| | | //发送数据
|
| | | const message = {
|
| | |
| | | mqttData() {
|
| | | uni.$on(this.$constant.MQTT_TOPIC_MESSAGE, (data) => {
|
| | | try {
|
| | | const now = Date.now();
|
| | | if (now - this.lastMqttTs < this.mqttThrottleMs) return;
|
| | | this.lastMqttTs = now;
|
| | | // 1. 数据解析和验证
|
| | | const {
|
| | | data: wdata,
|