Ver Fonte

bug 修复

lilei há 4 anos atrás
pai
commit
0309cc7a2e
6 ficheiros alterados com 116 adições e 118 exclusões
  1. 3 1
      App.vue
  2. 14 14
      pages/getOrder/getOrder.vue
  3. 2 2
      pages/index/index.vue
  4. 7 13
      pages/store/storeDetail.vue
  5. 74 72
      pages/work/index/index.vue
  6. 16 16
      store/index.js

+ 3 - 1
App.vue

@@ -25,6 +25,8 @@
 		},
 		onLaunch: function() {
 			 console.log('App onLaunch')
+			 console.log(this.$store.state.vuex_bizId,'---------')
+			 console.log(this.$store.state.vuex_token)
 		},
 		onShow: function() {
 			const pages = getCurrentPages(); // 获取加载的页面
@@ -32,7 +34,7 @@
 			let url = currentPage ? currentPage.route :''; // 当前页面url
 			// console.log(url,'App Show')
 			// 用户扫描二维码后进入下单页面 未支付时,切换小程序至后台,再次显示时 进入首页
-			if(this.$store.state.vuex_orderInfo.orderStatus != 'PAID'&&url=='pages/getOrder/getOrder') {
+			if(this.$store.state.vuex_orderStatus != 'PAID'&&url=='pages/getOrder/getOrder') {
 				uni.reLaunch({
 					url: '/pages/index/index'
 				})

+ 14 - 14
pages/getOrder/getOrder.vue

@@ -170,13 +170,13 @@
 				let storeId = scene.split(",")[0];
 				let bizId = scene.split(',')[1];
 				//其他逻辑处理。。。。。
-				this.$store.state.vuex_orderInfo.bizId = bizId
-				this.$store.state.vuex_orderInfo.storeId = storeId
+				this.$u.vuex('vuex_bizId',bizId)
+				this.$u.vuex('vuex_storeId',storeId)
 				// 判断当前门店是否已运营
 				this.getStoreStatus(storeId,bizId)
 			} else {
 				// 判断是否扫码过
-				if (this.$store.state.vuex_orderInfo.bizId != '') {
+				if (this.$store.state.vuex_bizId != '') {
 					this.dataInit()
 				} else {
 					// 返回首页
@@ -256,7 +256,7 @@
 			// 获取服务列表
 			getServerList() {
 				this.status = 'loading'
-				let storeId = this.$store.state.vuex_orderInfo.storeId
+				let storeId = this.$store.state.vuex_storeId
 				getStoreItems({
 					storeId: storeId
 				}).then(res => {
@@ -357,8 +357,8 @@
 					mask: true
 				})
 				let item = this.itemList[this.serverIndex]
-				let storeId = this.$store.state.vuex_orderInfo.storeId
-				let deviceNo = this.$store.state.vuex_orderInfo.bizId
+				let storeId = this.$store.state.vuex_storeId
+				let deviceNo = this.$store.state.vuex_bizId
 				let params = {
 					"itemId": item.itemId, // 服务id
 					"itemCode": item.itemCode,
@@ -377,9 +377,8 @@
 						let data = res.data
 						// 保存成功后 请求预支付返回吊起微信支付所需参数
 						this.getPayData(data)
-						this.$store.state.vuex_orderInfo.itemCode = data.itemCode
-						this.$store.state.vuex_orderInfo.orderNo = data.orderNo
-						this.$store.state.vuex_orderInfo.duration = item.duration
+						this.$u.vuex('vuex_itemCode',data.itemCode)
+						this.$u.vuex('vuex_orderNo',data.orderNo)
 					} else {
 						uni.hideLoading()
 						// 刷新服务项
@@ -425,10 +424,11 @@
 			},
 			// 付款成功后
 			paySuccess(){
-				this.$store.state.vuex_orderInfo.orderStatus = 'PAID'
-				this.$store.state.vuex_orderDjs = 0
-				this.$store.state.vuex_workStep = 0
-				this.$store.state.vuex_workStatus = 'linking'
+				this.$u.vuex('vuex_orderStatus','PAID')
+				this.$u.vuex('vuex_orderDjs',0)
+				this.$u.vuex('vuex_workStep',0)
+				this.$u.vuex('vuex_workStatus','linking')
+				 
 				// 付款成功后开始洗车
 				uni.redirectTo({
 					url: `/pages/work/index/index`
@@ -436,7 +436,7 @@
 			},
 			// 付款失败或取消
 			payFail(err){
-				this.$store.state.vuex_orderInfo.orderStatus = 'FAIL'
+				this.$u.vuex('vuex_orderStatus','FAIL')
 				let content = '支付失败,请重新下单'
 				if(err.errMsg.indexOf("cancel")>=0){
 					content = '支付取消,请重新下单'

+ 2 - 2
pages/index/index.vue

@@ -108,9 +108,9 @@
 						this.workStatus = 'show'
 						// 还未启动
 						if(res.data.dataStatus == "PAID"){
-							this.$store.state.vuex_workStatus = 'linking'
+							this.$u.vuex('vuex_workStatus','linking')
 						}else{
-							this.$store.state.vuex_workStatus = 'working'
+							this.$u.vuex('vuex_workStatus','working')
 						}
 					}else{
 						this.workStatus = 'hide'

+ 7 - 13
pages/store/storeDetail.vue

@@ -55,6 +55,9 @@
 			<button type="warn" :loading="loading" plain @click="getWaitPhoto">排队情况</button>
 			<button type="warn" @click="openLocation">立刻导航</button>
 		</view>
+		<u-popup v-model="showPop" mode="center" width="90%" height="60%" closeable>
+			<image mode="aspectFit" class="pop-img" :src="waitPhoto"></image>
+		</u-popup>
 	</view>
 </template>
 
@@ -70,8 +73,10 @@
 					lat: '36.636193',
 					lng: '101.760521'
 				},
+				showPop: false, // 是否显示排队弹窗
 				storeInfo: null, // 网点详细信息
 				labelList: [], // 网点标签
+				waitPhoto: '',  // 排队照片
 				loading: false  // 是否显示排队按钮loading
 			}
 		},
@@ -160,19 +165,8 @@
 					this.loading = false
 					if(res.status==200) {
 						if (res.data) {
-							// 预览图片
-							uni.previewImage({
-								urls: [res.data],
-								longPressActions: {
-									itemList: ['发送给朋友', '保存图片', '收藏'],
-									success: function(data) {
-										console.log('选中了第' + (data.tapIndex + 1) + '个按钮,第' + (data.index + 1) + '张图片');
-									},
-									fail: function(err) {
-										console.log(err.errMsg);
-									}
-								}
-							});
+							this.waitPhoto = res.data
+							this.showPop=true
 						} else {
 							this.toashMsg('暂无数据')
 						}

+ 74 - 72
pages/work/index/index.vue

@@ -1,5 +1,6 @@
 <template>
 	<view class="work-pages">
+		<u-no-network></u-no-network>
 		<!-- 工作控制按钮及进度 -->
 		<view class="work-cons flex-center" style="flex-direction: column;">
 			<!-- 操作按钮组件 -->
@@ -82,18 +83,8 @@
 				</view>
 			</view>
 		</u-popup>
-		<!-- 错误提示 -->
-		<u-popup v-model="showError" :mask-close-able="false" border-radius="10" mode="center" width="500rpx">
-			<view style="padding: 30rpx;display: flex;justify-content: center;text-align: center;">
-				<view>
-					<u-image width="64px" height="64px" src="/static/img/end.png"></u-image>
-					<view style="padding: 10px 0 20px;">洗车已完成</view>
-					<view>
-						<u-button long type="success">确定</u-button>
-					</view>
-				</view>
-			</view>
-		</u-popup>
+		<!-- 洗车完成 -->
+		<u-modal v-model="showTips" @confirm="confirmFun" :content="content"></u-modal>
 		<!-- 急停提示弹框 -->
 		<u-popup v-model="showStop" :mask-close-able="false" border-radius="10" mode="center" width="80%">
 			<view style="padding: 30rpx;text-align: center;">
@@ -111,7 +102,7 @@
 					</view>
 					<view style="display: flex;padding: 20rpx 0;justify-content: center;">
 						<u-button @click="callPhone" style="width: 45%;border-radius: 0;margin-right: 5%;">联系客服</u-button>
-						<u-button @click="sendCmdRabt('reset')" style="width: 45%;" type="error">洗车机归位</u-button>
+						<u-button :disabled="disabledResetBtn" @click="sendCmdRabt('reset')" style="width: 45%;" type="error">洗车机归位</u-button>
 					</view>
 				</view>
 			</view>
@@ -129,7 +120,10 @@ export default {
 			step: 0, // 进度条增值,共60步
 			status: 'linking', // 状态,linking 连接中,start 开始启动, starting 启动中,working 正在工作,stoping 停止中, reset 归位,reseting 归位中, end 洗车完成,error-end 异常结束
 			curWorkStutesText: '设备准备就绪', // 当前机器运行的进度提示
-			showError: false, // 错误提示
+			showTips: false, // 错误提示
+			content: '', // 消息内容
+			confirmFun: function(){}, // 消息确认弹框
+			disabledResetBtn: false, 
 			showStart: false ,// 启动弹框提示
 			showStop: false, // 急停提示
 			washCarType: '', // 洗车服务类型,不同的类型对应的时间不一样
@@ -149,21 +143,32 @@ export default {
 		console.log("onLoad")
 		// 创建websocket
 		this.$store.commit('$webSocket')
-		// uni.showLoading({
-		// 	title: '正在连接...',
-		// 	mask: true
-		// })
+		uni.showLoading({
+			title: '正在连接...',
+			mask: true
+		})
+		
+		// 监听网络状态
+		uni.onNetworkStatusChange(function (res) {
+		    console.log(res.isConnected);
+		    console.log(res.networkType);
+			if(res.isConnected){
+				uni.showLoading({
+					title: '正在连接...',
+					mask: true
+				})
+			}
+		});
 		
 		// 第一次进入洗车页面
 		if(this.$store.state.vuex_orderDjs == 0){
 			// 记录当前的时间
-			this.$store.state.vuex_orderDjs = new Date().getTime()
+			this.$u.vuex('vuex_orderDjs',new Date().getTime())
 		}
 		 
 		// 获取用户及订单信息
-		let orderInfo = this.$store.state.vuex_orderInfo
-		this.washCarType = orderInfo.itemCode
-		this.orderNo = orderInfo.orderNo
+		this.washCarType = this.$store.state.vuex_itemCode
+		this.orderNo = this.$store.state.vuex_orderNo
 		 
 		// 监听消息
 		uni.$on('wsMessage', this.watchMessage)
@@ -174,6 +179,14 @@ export default {
 		uni.$off('wsMessage', this.watchMessage)
 	},
 	methods: {
+		// 提示弹框
+		showModal(content, fun){
+			this.showTips = true
+			this.content = content
+			this.confirmFun = fun || function(){
+				this.showTips=false
+			}
+		},
 		// 电话客服
 		callPhone () {
 			uni.makePhoneCall({
@@ -204,7 +217,7 @@ export default {
 					uni.hideLoading()
 					if(this.$store.state.vuex_workStatus == 'linking'){
 						this.status = 'start'
-						this.$store.state.vuex_workStatus = 'start'
+						this.$u.vuex('vuex_workStatus','start')
 					}
 				}
 				// 重连连接打开时发送获取当前状态的命令
@@ -223,11 +236,7 @@ export default {
 					}
 					// 停车位置不正确,
 					if(e.data.msgCode=="TCWZ_CW"){
-						uni.showModal({
-							title: '提示',
-							content: e.data.msgCodeInfo,
-							showCancel: false,
-						});
+						this.showModal(e.data.msgCodeInfo)
 					}
 					// 重新进入页面且还未启动洗车时
 					if(e.data.msgCode == "PAID"){
@@ -243,8 +252,10 @@ export default {
 				// 进度消息
 				if(e.data.level == 'C'&&this.status!="reseting"){
 					this.curWorkStutesText= e.data.msgCodeInfo
-					// 启动成功
-					this.startWashCarSuccess()
+					if(e.data.msgCodeInfo != '开始洗车'){
+						// 启动成功
+						this.startWashCarSuccess()
+					}
 					// 更新进度条
 					this.step = e.data.msgCodeSrc?Number(e.data.msgCodeSrc.split('-')[1]):0
 					this.$store.state.vuex_workStep = this.step
@@ -269,8 +280,10 @@ export default {
 						// 显示复位提示弹框
 						this.showReset()
 					}else{
-						if(this.status != "error-end"){
+						if(this.status == 'working'){
 							this.devError()
+						}else{
+							this.showModal(e.data.msgCodeInfo)
 						}
 					}
 				}
@@ -286,9 +299,8 @@ export default {
 					}
 					// 设备离线,设备异常,暂停营业或复位失败,设备使用中
 					else if(e.data.msgCode=="PAUSE" || e.data.msgCode == "FW_FAIL" || e.data.msgCode == 'ERROR' || e.data.msgCode == 'SB_SYZ'){
-						if(this.status != "error-end"){
-							this.devError(e.data.msgCodeInfo)
-						}
+						this.devError(e.data.msgCodeInfo)
+						this.disabledResetBtn = false
 					}
 				}
 			}
@@ -336,25 +348,22 @@ export default {
 		starting(){
 			this.showStart = true;
 			this.status = 'starting';
-			this.$store.state.vuex_workStatus = 'starting';
+			this.$u.vuex('vuex_workStatus','starting')
 			this.curWorkStutesText='设备启动中';
 		},
 		// 启动成功
 		startWashCarSuccess(){
 			this.showStart = false;
 			this.status = 'working';
-			this.$store.state.vuex_workStatus = 'working';
+			this.$u.vuex('vuex_workStatus','working')
 		},
 		// 启动超时
 		startWashCarFail(){
 			this.showStart = false;
 			this.status = 'start';
-			this.$store.state.vuex_workStatus = 'start';
-			this.curWorkStutesText='设备启动超时,请重新点击启动'
-			uni.showToast({
-				title: "设备启动超时",
-				duration: 3000
-			})
+			this.$u.vuex('vuex_workStatus','start')
+			this.curWorkStutesText='设备启动超时'
+			this.showModal('设备启动超时,请稍后重试或联系客服')
 		},
 		// 发送命令,start 启动,stop 急停,reset 归位
 		sendCmdRabt(cmdCode){
@@ -365,12 +374,17 @@ export default {
 				washType: this.washCarType,// 洗车模式
 			}
 			this.$store.commit("$sendWebsocket",JSON.stringify(cmd))
+			
+			// 点击复位后
+			if(cmdCode == 'reset'){
+				this.disabledResetBtn = true
+			}
 		},
 		// 停止中
 		stoping(){
 			this.showStart = true;
 			this.status = 'stoping';
-			this.$store.state.vuex_workStatus = 'stoping';
+			this.$u.vuex('vuex_workStatus','stoping')
 			this.curWorkStutesText='设备停止中';
 		},
 		// 停止成功后或有F类错误时,显示复位弹框
@@ -378,21 +392,22 @@ export default {
 			this.showStart = false;
 			this.showStop = true;
 			this.status = 'reset';
-			this.$store.state.vuex_workStatus = 'reset'
+			this.$u.vuex('vuex_workStatus','reset')
 			this.resetLoadingStatus();
 		},
 		// 归位中
 		reseting(){
 			this.status = 'reseting';
-			this.$store.state.vuex_workStatus = 'reseting';
+			this.$u.vuex('vuex_workStatus','reseting')
 			this.showStart = true;
 			this.showStop = false;
+			this.disabledResetBtn = false
 		},
 		// 归位结束后
 		resetRabtSuccess(){
 			this.curWorkStutesText='设备已归位';
 			this.status = 'end';
-			this.$store.state.vuex_workStatus = 'end';
+			this.$u.vuex('vuex_workStatus','end')
 			// 关闭socket
 			this.$store.commit("$closeWebsocket");
 			// 跳转到复位成功页面
@@ -403,41 +418,28 @@ export default {
 		// 洗车完成
 		washCarSuccess(){
 			this.status = 'end';
-			this.$store.state.vuex_workStatus = 'end';
+			this.$u.vuex('vuex_workStatus','end')
 			this.curWorkStutesText='洗车已结束';
 			this.resetLoadingStatus();
-			// uni.showModal({
-			//     title: '提示',
-			//     content: '洗车已结束',
-			// 	showCancel: false,
-			//     success: function (res) {
-			//         if (res.confirm) {
-			// 			// 跳转到成功页面
-			// 			uni.redirectTo({
-			// 				url:"/pages/work/success/success?type=0"
-			// 			})
-			//         }
-			//     }
-			// });
-			this.showError = true
+			// 显示弹框
+			this.showModal('洗车已结束',function(){
+				// 跳转到成功页面
+				uni.redirectTo({
+					url:"/pages/work/success/success?type=0"
+				})
+			})
 			// 关闭socket
 			this.$store.commit("$closeWebsocket")
 		},
 		// 设备异常
 		devError(msg){
 			this.status = "error-end";
-			this.$store.state.vuex_workStatus = 'error-end'
+			this.$u.vuex('vuex_workStatus','error-end')
 			this.resetLoadingStatus();
-			uni.showModal({
-				title: '提示',
-				content: msg || '设备异常,请联系客服',
-				showCancel: false,
-				success: function (res) {
-					if (res.confirm) {
-						uni.navigateBack()
-					}
-				}
-			});
+			// 显示弹框
+			this.showModal(msg || '设备异常,请联系客服',function () {
+					uni.navigateBack()
+		    })
 			// 关闭socket
 			this.$store.commit("$closeWebsocket");
 		},

+ 16 - 16
store/index.js

@@ -19,7 +19,11 @@ let saveStateKeys = [
 	'vuex_payType',
 	'vuex_payStatus',
 	'vuex_storeLabel',
-	'vuex_orderInfo',
+	'vuex_storeId',
+	'vuex_bizId',
+	'vuex_itemCode',
+	'vuex_orderNo',
+	'vuex_orderStatus',
 	'vuex_workStatus',
 	'vuex_orderDjs',
 	'vuex_workStep',
@@ -103,26 +107,22 @@ const store = new Vuex.Store({
 		vuex_payType: lifeData.vuex_payType ? lifeData.vuex_payType : [], // 支付方式数据字典
 		vuex_payStatus: lifeData.vuex_payStatus ? lifeData.vuex_payStatus : [], // 支付状态数据字典
 		vuex_storeLabel: lifeData.vuex_storeLabel ? lifeData.vuex_storeLabel : [], // 网点标签数据字典
+		vuex_workStatus: lifeData.vuex_workStatus ? lifeData.vuex_workStatus : 'linking',// 设备是否正在运行中
+		// 设备运行页面的计时器
+		vuex_orderDjs: lifeData.vuex_orderDjs ? lifeData.vuex_orderDjs : 0, // 订单完成倒计时
+		vuex_workStep: lifeData.vuex_workStep ? lifeData.vuex_workStep : 0, // 进度条步骤
+		// 订单信息
+		vuex_storeId: lifeData.vuex_storeId ? lifeData.vuex_storeId : '',// 网点id
+		vuex_bizId: lifeData.vuex_bizId ? lifeData.vuex_bizId : '',// 设备编号
+		vuex_itemCode: lifeData.vuex_itemCode ? lifeData.vuex_itemCode : '',// 服务类型
+		vuex_orderNo: lifeData.vuex_orderNo ? lifeData.vuex_orderNo : '',// 订单编号
+		vuex_orderStatus: lifeData.vuex_orderStatus ? lifeData.vuex_orderStatus : '',// 订单状态
 		// 如果无需保存到本地永久存储,无需lifeData.xx方式
 		vuex_socket: null,
 		vuex_wsMessageData: '',
 		vuex_heartInterId: null,
 		// 当前网络连接状态
 		vuex_netStatus: '',
-		// 设备是否正在运行中
-		vuex_workStatus: lifeData.vuex_workStatus ? lifeData.vuex_workStatus : 'linking',
-		// 订单信息
-		vuex_orderInfo: lifeData.vuex_orderInfo ? lifeData.vuex_orderInfo : {
-			storeId: '', // 网点id
-			bizId: '', // 设备编号
-			itemCode: '', // 服务类型
-			duration: 0, // 不同服务的机器运行时间
-			orderNo: '', // 订单编号
-			orderStatus: '' // 订单状态
-		},
-		// 设备运行页面的计时器
-		vuex_orderDjs: lifeData.vuex_orderDjs ? lifeData.vuex_orderDjs : 0, // 订单完成倒计时
-		vuex_workStep: lifeData.vuex_workStep ? lifeData.vuex_workStep : 0, // 进度条步骤
 		// 优惠券相关信息
 		vuex_couponInfo: {
 			storeId: '', // 网点id
@@ -156,7 +156,7 @@ const store = new Vuex.Store({
 			let _this = this
 			let url = getApp().globalData.baseUrl
 			let wsBaseUrl = url.indexOf("https:") >= 0 ? url.replace("https:", "wss:") : url.replace("http:", "ws:")
-			let wsUrl = wsBaseUrl + 'websocket/weixin/' + state.vuex_orderInfo.bizId
+			let wsUrl = wsBaseUrl + 'websocket/weixin/' + state.vuex_bizId
 			console.log(wsUrl,'wsUrl')
 			SocketInit(_this,state,wsUrl)
 		},