| | |
| | | <driver-index v-if="roleType == 3" ref="driverIndexRef" :indexdriverBillOfLoadingData="indexdriverBillOfLoadingData"></driver-index> |
| | | <tab-bar :current="0"></tab-bar> |
| | | <!-- 推送消息弹窗 --> |
| | | <u-modal :show="messagePushShow" :title="messageList.title" :content="messageList.content" @confirm="messageconfirm"></u-modal> |
| | | <u-modal :show="messagePushShow" :title="messageList.title" @confirm="messageconfirm"> |
| | | <view class="slot-content"><rich-text :nodes="messageList.content"></rich-text></view> |
| | | </u-modal> |
| | | </view> |
| | | </template> |
| | | |
| | |
| | | } |
| | | this.userAuthorization(); |
| | | }, |
| | | onHide() { |
| | | console.log('页面隐藏'); |
| | | if (!this.isconnect) { |
| | | this.initWebsocket(); |
| | | } |
| | | }, |
| | | onUnload() { |
| | | console.log('页面卸载'); |
| | | socket.close(); |
| | | clearInterval(this.intervalId); |
| | | }, |
| | | methods: { |
| | | ...mapMutations(['pushMessage', 'changeWeigh', 'changeinfraredStatus']), |
| | | messagePage() { |
| | |
| | | }); |
| | | socket.onOpen(() => { |
| | | console.log('onOpen'); |
| | | this.intervalId = setInterval(() => { |
| | | socket.send({ |
| | | data: JSON.stringify({ type: 'ping' }), |
| | | success(e) { |
| | | console.log(e, '发送心跳成功'); |
| | | } |
| | | }); |
| | | }, 30000); |
| | | }); |
| | | |
| | | // 获取服务器传来的数据,做相应处理 |
| | | socket.onMessage(res => { |
| | | console.log('socketWeigh', res); |
| | | console.log('message', res); |
| | | if (res.data.startsWith('weigh')) { |
| | | let nowWeighObj = JSON.parse(res.data.slice(7)); |
| | | if (this.globalweighHouseCode && nowWeighObj.eqCode == this.globalweighHouseCode) { |
| | |
| | | this.changeWeigh(nowWeighObj.weigh); |
| | | } |
| | | } |
| | | } else { |
| | | } else if (res.data.startsWith('msg')) { |
| | | this.messageList = JSON.parse(res.data.slice(5)); |
| | | this.messagePushShow = true; |
| | | } else { |
| | | console.log('websocket还在活着'); |
| | | } |
| | | }); |
| | | socket.onClose(() => { |
| | | console.log('webSocketClose'); |
| | | socket.onClose(e => { |
| | | console.log('webSocketClose', e); |
| | | this.$u.toast('连接已断开,请重新进入该页面,重试!!'); |
| | | this.isconnect = false; |
| | | }); |
| | | socket.onError(err => { |