Parcourir la source

feat(KIP-11819): Temp parking frontend |websocket 交互变更 |wx.miniProgram.redirectTo

john il y a 1 an
Parent
commit
0243172cf2

+ 15 - 13
src/pages/parkingFeeV2/mixins/parkingFee.js

@@ -139,7 +139,7 @@ export default {
   },
   async mounted() {
     // console.log(114, 99999999999);
-    const platform = getPlatform();
+    // const platform = getPlatform();
     // if (platform === 'micromessenger') {
     //   await initWxJsSdkConfig(['checkJsApi', 'scanQRCode']);
     // }
@@ -162,9 +162,11 @@ export default {
       this.showSq = true;
     }
     try {
-      setTimeout(async () => {
-        await initWxJsSdkConfig(['checkJsApi', 'scanQRCode']);
-      }, 1500)
+      if(!isAlipayClient) {
+        setTimeout(async () => {
+          await initWxJsSdkConfig(['checkJsApi', 'scanQRCode']);
+        }, 1500)
+      }
     } catch (e) {
       console.log(e)
     }
@@ -624,22 +626,22 @@ export default {
           }
         };
         // 微信小程序
-        const platform = getPlatform();
-        if (platform === 'miniprogram') {
+        // const platform = getPlatform();
+        if (isAlipayClient) {
           // 判断微信小程序与 h5 是否正常通信
-          const isReload = await theCommunicationBetweenWechatAndH5IsNormal()
-          if(!isReload) {
-            uni.setStorageSync('isReload', 1)
-            window.location.reload()
-            return
-          }
+          // const isReload = await theCommunicationBetweenWechatAndH5IsNormal()
+          // if(!isReload) {
+          //   uni.setStorageSync('isReload', 1)
+          //   window.location.reload()
+          //   return
+          // }
           window.toWXSendMsg({
             type: 'scanQRCode',
           });
           // TODO 兼容支付宝无牌车扫码
           window.subscribe('scanQRCodeOver', (options) => {
             console.log('微信扫码结束之后的返回参数', options);
-            runScanFn(options);
+            runScanFn(options.options);
           });
         } else {
           this.$wx.scanQRCode({

+ 4 - 49
src/pages/parkingFeeV2/mixins/parkingFeePaperCoupon.js

@@ -88,30 +88,6 @@ export default {
     },
     // 扫码
    async scanCode() {
-    // scanQRCode
-    // console.log(929292, WeixinJSBridge);
-    // console.log(9393939393, this.$wx);
-    // wx.miniProgram.scanQRCode(function(res) {
-    //   console.log(949494949494, res) // true
-    // })
-
-    this.$wx.scanQRCode({
-      desc: 'scanQRCode desc',
-      needResult: 1, // 默认为0,扫描结果由微信处理,1则直接返回扫描结果,
-      // scanType: ['qrCode', 'barCode'], // 可以指定扫二维码还是一维码,默认二者都有
-      success: ( res ) => {
-        console.log(237,res);
-        // runScanFn(res);∑
-        // this.formMsg.deviceCode = res.resultStr;
-      },
-      error: ( res ) => {
-        console.log(242,res);
-      },
-    });
-    
-    
-    return
-    
       const runScanFn = ( res ) => {
         if ( res.scanType == 'QR_CODE' && res.scanType || (isAlipayClient && res.scanType == 'QR')) {
           console.log(res.result);
@@ -129,36 +105,15 @@ export default {
           }
         }
       };
-      this.$wx.scanQRCode({
-        desc: 'scanQRCode desc',
-        needResult: 1, // 默认为0,扫描结果由微信处理,1则直接返回扫描结果,
-        // scanType: ['qrCode', 'barCode'], // 可以指定扫二维码还是一维码,默认二者都有
-        success: ( res ) => {
-          console.log(237,res);
-          // runScanFn(res);
-          // this.formMsg.deviceCode = res.resultStr;
-        },
-        error: ( res ) => {
-          console.log(242,res);
-        },
-      });
-      return
-      // 微信小程序
-      const platform = getPlatform();
-      if ( platform === 'miniprogram' ) {
-        // 判断微信小程序与 h5 是否正常通信
-        const isReload = await theCommunicationBetweenWechatAndH5IsNormal()
-        if(!isReload) {
-          uni.setStorageSync('isReload', 1)
-          window.location.reload()
-          return
-        }
+      // 支付宝小程序
+      // const platform = getPlatform();
+      if ( isAlipayClient ) {
         window.toWXSendMsg({
           type: 'scanQRCode',
         });
         window.subscribe('scanQRCodeOver',( options ) => {
           console.log('微信扫码结束之后的返回参数',options);
-          runScanFn(isAlipayClient ? options.options : options);
+          runScanFn(options.options);
         });
       } else {
         this.$wx.scanQRCode({

+ 9 - 9
src/pages/parkingFeeV2/parkingFeeMsg.vue

@@ -138,22 +138,22 @@ export default {
         }
       };
       // 微信小程序
-      const platform = getPlatform();
-      if (platform === 'miniprogram') {
+      // const platform = getPlatform();
+      if (isAlipayClient) {
         // 判断微信小程序与 h5 是否正常通信
-        const isReload = await theCommunicationBetweenWechatAndH5IsNormal()
-        if(!isReload) {
-          uni.setStorageSync('isReload', 1)
-          window.location.reload()
-          return
-        }
+        // const isReload = await theCommunicationBetweenWechatAndH5IsNormal()
+        // if(!isReload) {
+        //   uni.setStorageSync('isReload', 1)
+        //   window.location.reload()
+        //   return
+        // }
         window.toWXSendMsg({
           type: 'scanQRCode',
         });
         // TODO 兼容支付宝无牌车扫码
         window.subscribe('scanQRCodeOver', (options) => {
           // console.log('微信扫码结束之后的返回参数', options);
-          runScanFn(options);
+          runScanFn(options.options);
         });
       } else {
         this.$wx.scanQRCode({