Browse Source

监听消息

lilei 4 năm trước cách đây
mục cha
commit
6bb48398a7
2 tập tin đã thay đổi với 6 bổ sung6 xóa
  1. 5 5
      pages/work/index/index.vue
  2. 1 1
      store/index.js

+ 5 - 5
pages/work/index/index.vue

@@ -122,11 +122,11 @@ export default {
 		this.$store.commit('$webSocket')
 		this.washCarType = options.washCarType
 		this.orderNo = options.orderNo
-	},
-	watch: {
-		'state.vuex_wsMessageData'(newValue, oldValue) {
-			console.log(newValue)
-		}
+		
+		// 监听消息
+		uni.$on('wsMessage',(e)=>{
+			console.log(e)
+		})
 	},
 	methods: {
 		// 倒计时结束时,自动完成洗车订单

+ 1 - 1
store/index.js

@@ -97,7 +97,7 @@ const store = new Vuex.Store({
 				if (e.data != 'pong'){
 				  let ret = JSON.parse(e.data)
 				  console.log('ws接收消息!', ret)
-				  state.vuex_wsMessageData = ret
+				  uni.$emit('wsMessage',ret)
 				}
 			})
 			// 发送心跳包