Ver Fonte

扫码部分完成

shish há 4 anos atrás
pai
commit
670666266c

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

@@ -73,19 +73,6 @@ export default {
 	},
 	onPullDownRefresh() {
 	},
-	onShow() {
-        var that = this
-		//避免重复,每次进来先移除全局自定义事件监听器
-        uni.$off('listenGetScanCode') 
-        uni.$on('listenGetScanCode',function(data){
-			console.log(data.code+'111')
-			that.$msg(data.code)
-        })
-	},
-	onunload(){
-		// 移除监听事件
-		uni.$off('listenGetScanCode')
-	},
 	mounted() {
 		if(this.$util.isEmpty(this.getLoginInfo.admin) || this.getLoginInfo.admin.currentShopId == 0){
 			this.isLogin = 0

+ 11 - 7
hdPad/src/pages/home/components/console.vue

@@ -25,7 +25,7 @@
 
     <!-- 扫码付款 -->
     <uni-popup ref="toPayRef" background-color="#fff" type="center" :animation="false" :is-mask-click="false">
-        <toPayWay @cancelPay="cancelPay()" @selectPayWayBack="selectPayWayBack"></toPayWay>
+        <toPayWay @cancelPay="cancelPay()" @selectPayWayBack="selectPayWayBack" :orderId.sync="orderId"></toPayWay>
     </uni-popup>
 
 </view>
@@ -47,14 +47,16 @@ export default {
     },
     data(){
         return {
-            totalShop:{ bigUnit: 0, smallUnit:0, totalPrice: 0 }
+            totalShop:{ bigUnit: 0, smallUnit:0, totalPrice: 0 },
+			orderId:0
         }
     },
-    created(){
-		
-    },
-	watch:{
-
+	created(){
+		//避免重复,每次进来先移除全局自定义事件监听器
+        uni.$off('listenGetScanCode') 
+        uni.$on('listenGetScanCode',function(data){
+			console.log(data.code)
+        })
 	},
     methods:{
 		changeProperty(property){
@@ -74,7 +76,9 @@ export default {
 			createCreateOrder({...params,product:JSON.stringify(product)}).then(res=>{
 				uni.hideLoading()
 				if(res.code == 1){
+					console.log(res.data)
 					this.$refs.settlePopRef.close()
+					this.orderId = res.data.id
 					this.$refs.toPayRef.open('center')
 				}
 			})

+ 2 - 2
hdPad/src/pages/home/components/nav.vue

@@ -34,9 +34,9 @@ export default {
   },
   methods: {
 		getScan(item){
-			let hasScanCode = uni.getStorageSync('hasScanCode')
+      let hasScanCode = uni.getStorageSync('hasScanCode')
       let code = item.key || ''
-      if(!this.$util.isEmpty(code)){
+      if(!this.$util.isEmpty(code) && code != 'Unidentified'){
         if(code != 'Enter'){
           uni.setStorageSync('hasScanCode', hasScanCode+code)
         }else{

+ 1 - 1
hdPad/src/pages/home/components/rightItem.vue

@@ -60,7 +60,7 @@ export default {
             default:0
         }
     },
-    created(){
+    mounted(){
         this.init()
     },
     watch:{

+ 28 - 0
hdPad/src/pages/home/components/toPay.vue

@@ -20,6 +20,7 @@
     </view>
 </template>
 <script>
+import { codePay} from "@/api/order/index";
 export default {
     name:'toPayWay',
     components:{
@@ -29,7 +30,34 @@ export default {
             showSuccess:false
         }
     },
+	props: {
+		orderId: {
+			type: Number,
+			default: 0
+		}
+    },
+	mounted(){
+        let that = this
+		//避免重复,每次进来先移除全局自定义事件监听器
+        uni.$off('listenGetScanCode') 
+        uni.$on('listenGetScanCode',function(data){
+			that.requestCodePay(data.code)
+        })
+	},
     methods:{
+        //付款码付款
+        requestCodePay(authCode){
+            let that = this
+            uni.showLoading({title: '正在付款',mask:true})
+            codePay({id:this.orderId,authCode:authCode}).then(res=>{
+                uni.hideLoading()
+                if(res.code == 1){
+                    if(res.data.returnStatus == 'SUCCESS'){
+
+                    }
+                }
+            })
+        },
         cancelPay(){
             this.$emit('cancelPay')
         }