shish 1 год назад
Родитель
Сommit
1a001389ea

+ 12 - 1
ghsPad/src/pages/home/cash.vue

@@ -102,6 +102,18 @@ export default {
 			}
 		}
 	},
+	onShow(){
+		//放回前台时,增加监听扫码动作
+		if(this.$refs.rightItemRef){
+			this.$refs.rightItemRef.addListenScan()
+		}
+	},
+	onHide(){
+		//放在后台时,移除监听扫码动作
+		if(this.$refs.rightItemRef){
+			this.$refs.rightItemRef.removeListenScan()
+		}
+	},
 	watch:{
 		getLoginInfo: {
 			handler(newValue) {
@@ -109,7 +121,6 @@ export default {
 					this.isLogin = 1
 
 					if(newValue.skCustomId && newValue.skCustomId>0){
-						console.log('this.customId'+newValue.skCustomId)
 						this.customId = newValue.skCustomId
 						this.customName = '快捷开单'
 					}

+ 6 - 0
ghsPad/src/pages/home/components/rightItem.vue

@@ -99,6 +99,12 @@ export default {
 			this.globalRightItemCustomId = customId
 			this.itemRefresh()
             this.listenScanItem()
+        },
+        removeListenScan(){
+            uni.$off('listenGetScanCode')   
+        },
+        addListenScan(){
+            this.listenScanItem()
         }
     }
 }

+ 12 - 0
hdPad/src/pages/home/cash.vue

@@ -93,6 +93,18 @@ export default {
 	onUnload(){
 		clearInterval(this.T)
 	},
+	onShow(){
+		//放回前台时,增加监听扫码动作
+		if(this.$refs.rightItemRef){
+			this.$refs.rightItemRef.addListenScan()
+		}
+	},
+	onHide(){
+		//放在后台时,移除监听扫码动作
+		if(this.$refs.rightItemRef){
+			this.$refs.rightItemRef.removeListenScan()
+		}
+	},
 	mounted() {
 		if(this.$util.isEmpty(this.getLoginInfo.admin) || this.getLoginInfo.admin.currentShopId == 0){
 			this.isLogin = 0

+ 6 - 0
hdPad/src/pages/home/components/rightItem.vue

@@ -99,6 +99,12 @@ export default {
             this.globalRightItemCustomId = customId
             this.globalItemRefresh(customId)
             this.listenScanItem()
+        },
+        removeListenScan(){
+            uni.$off('listenGetScanCode')   
+        },
+        addListenScan(){
+            this.listenScanItem()
         }
     }
 }