Browse Source

bug 修复

lilei 4 years ago
parent
commit
0ab64262a3
2 changed files with 22 additions and 6 deletions
  1. 18 3
      pages/work/index/index.vue
  2. 4 3
      store/index.js

+ 18 - 3
pages/work/index/index.vue

@@ -114,18 +114,26 @@ export default {
 			showStart: false ,// 启动弹框提示
 			showStop: false, // 急停提示
 			washCarType: 1, // 洗车服务类型,不同的类型对应的时间不一样
+			orderNo: '',// 订单编号
 		};
 	},
-	onLoad() {
+	onLoad(options) {
 		// 创建websocket
 		this.$store.commit('$webSocket');
+		this.washCarType = options.washCarType
+		this.orderNo = options.orderNo
+	},
+	watch: {
+		'state.vuex_wsMessageData'(newValue, oldValue) {
+			console.log(newValue)
+		}
 	},
 	methods: {
 		// 倒计时结束时,自动完成洗车订单
 		endDtime() {
 			this.washCarSuccess()
 		},
-		// 启动,急停按钮
+		// 操作按钮
 		startWork() {
 			let _this = this
 			// 启动
@@ -141,7 +149,14 @@ export default {
 		startWashCar(){
 			this.step= 0;
 			this.showStart = true;
-			this.$store.commit("$sendWebsocket",'start')
+			
+			// 启动命令
+			let cmd = {
+				orderNo: this.orderNo, // 订单编号
+				operateType: 'start', //操作命令
+				washType: this.washCarType,// 洗车模式
+			}
+			this.$store.commit("$sendWebsocket",JSON.stringify(cmd))
 			// 启动成功
 			setTimeout(() => {
 				this.status = 'working';

+ 4 - 3
store/index.js

@@ -41,6 +41,8 @@ const store = new Vuex.Store({
 		vuex_socket: null,
 		vuex_wsMessageData: '',
 		vuex_heartInterId: null,
+		// 设备信息
+		vuex_bizId: '1646545', // 编号
 	},
 	mutations: {
 		$uStore(state, payload) {
@@ -69,8 +71,7 @@ const store = new Vuex.Store({
 			let token = getApp().globalData.token
 			let url = getApp().globalData.baseUrl
 			let wsBaseUrl = url.indexOf("https:")>=0 ? url.replace("https:","wss:") : url.replace("http:","ws:")
-			let wsUrl = wsBaseUrl + 'websocket/16546'
-			console.log(token,wsUrl)
+			let wsUrl = wsBaseUrl + 'websocket/weixin/' + state.vuex_bizId
 			// 开始连接
 			state.vuex_socket = uni.connectSocket({
 				header: {'X-AUTH-TOKEN':token},
@@ -95,7 +96,7 @@ const store = new Vuex.Store({
 			state.vuex_socket.onMessage(function(e){
 				if (e.data != 'pong'){
 				  let ret = JSON.parse(e.data)
-				  console.log('ws接收!', ret)
+				  console.log('ws接收消息!', ret)
 				  state.vuex_wsMessageData = ret
 				}
 			})