Browse Source

逻辑修改

lilei 4 years ago
parent
commit
16f491a356
3 changed files with 28 additions and 10 deletions
  1. 2 2
      App.vue
  2. 23 2
      pages/work/index/index.vue
  3. 3 6
      store/index.js

+ 2 - 2
App.vue

@@ -1,6 +1,6 @@
 <script>
-	// const uat_URL = 'https://carwash.test.zyucgj.com/cw-wechat/' // 预发布
-	const uat_URL = 'http://192.168.16.103:8103/cw-wechat/' // 本地
+	const uat_URL = 'https://carwash.test.zyucgj.com/cw-wechat/' // 预发布
+	// const uat_URL = 'http://192.168.16.103:8103/cw-wechat/' // 本地
 	const pro_URL = 'https://carwash.zyucgj.com/saas/clz/'  // 生产
 	const buildType = 0 // 打包环境对应类型,1 生产 0 预发布
 	const buildURL = buildType ? pro_URL : uat_URL // 打包后实际对应的url

+ 23 - 2
pages/work/index/index.vue

@@ -145,7 +145,10 @@ export default {
 		console.log("onLoad")
 		// 创建websocket
 		this.$store.commit('$webSocket')
-		
+		uni.showLoading({
+			title: '正在连接...',
+			mask: true
+		})
 		// 获取用户及订单信息
 		let orderInfo = this.$store.state.vuex_orderInfo
 		this.washCarType = orderInfo.itemCode
@@ -153,17 +156,26 @@ export default {
 		this.washDuration = orderInfo.duration
 		// 记录当前的时间
 		this.$store.state.orderDjs = new Date().getTime()
+		
 		// 监听消息
 		uni.$on('wsMessage',(e)=>{
 			if(typeof e == 'string'){
 				// 连接成功
 				if(e=='connected'){
-					
+					console.log('connected')
+					uni.hideLoading()
 				}
 			}
+			console.log(typeof e)
 			if(typeof e == 'object' && e.type == 'xcz'){
 				console.log(e.data.level,e.data.msgCode,e.data.msgCodeInfo)
 				console.log("--------------------------------------------")
+				// 启动超时
+				if(e.data.level == 'O'){
+					if(e.data.msgCode == "PAUSE"){
+						this.startWashCarFail()
+					}
+				}
 				// 进度消息
 				if(e.data.level == 'C'&&this.status!="reseting"){
 					 // 启动成功
@@ -262,6 +274,15 @@ export default {
 				});
 			}
 		},
+		// 启动超时
+		startWashCarFail(){
+			this.showStart = false;
+			uni.showModal({
+			    title: '提示',
+			    content: '设备启动超时,请重新点击启动',
+				showCancel: false,
+			});
+		},
 		// 启动成功
 		startWashCarSuccess(){
 			// 进度条,服务时间根据不同的服务类型而不同

+ 3 - 6
store/index.js

@@ -125,13 +125,10 @@ const store = new Vuex.Store({
 			})
 			// 接受消息
 			state.vuex_socket.onMessage(function(e) {
-				if (typeof(e.data) == 'object') {
-					let ret = JSON.parse(e.data)
-					console.log('ws接收消息!', ret)
-					uni.$emit('wsMessage', ret)
-				}
-				if (typeof(e.data) == 'string') {
+				if (e.data == 'pong' || e.data == 'connected') {
 					uni.$emit('wsMessage', e.data)
+				}else{
+					uni.$emit('wsMessage', JSON.parse(e.data))
 				}
 			})
 			// 发送心跳包