Explorar el Código

feat(SCRM-6123): 【DE】【C端】【支付宝】临停首页-无牌车缴费页面,点击“扫描进场二维码领取无牌车号牌”,不能调起摄像头2

lock.qiu@kerryprops.com hace 1 año
padre
commit
c91f432d74
Se han modificado 2 ficheros con 119 adiciones y 3 borrados
  1. 1 1
      src/main.js
  2. 118 2
      src/pages/parkingFeeV2/mixins/parkingFee.js

+ 1 - 1
src/main.js

@@ -7,7 +7,7 @@ import '@/common/css/quill.snow.css'; // 引入对富文本的支持
 // 开发环境和qa环境 打开debug
 // const debug = /dev-t?-?|qa-t?-?|sl-t?-?|2486/.test(window.location.origin);
 let debug = false;
-const keys = ['https://dev-','https://qa-','https://lt-','https://sl-','http://127.0.0.1', 'http://localhost:8080'];
+const keys = ['https://dev-','https://qa-','https://lt-','https://sl-','http://127.0.0.1', 'http://localhost:8080', 'http://192.168.3.9:8080'];
 keys.forEach(key => {
   if(!debug && window.location.origin.indexOf(key) > -1) {
     debug = true

+ 118 - 2
src/pages/parkingFeeV2/mixins/parkingFee.js

@@ -5,7 +5,7 @@ import {mapState} from 'vuex';
 import {initWxJsSdkConfig} from '@/utils/login';
 import {getUrlParams, isHZ, isAlipay} from '@/utils';
 import wxPointsAuth from '@/components/wx-points-auth/wx-points-auth.vue'
-
+import CacheTool from '@/utils/cache-tool'
 const app = {
   globalData: {
     regSource: '',
@@ -772,6 +772,107 @@ export default {
         })
       }
     },
+    getParam(url, key) {
+      let u = url.split('?')[1]
+      let l = u.split('&')
+      let o = {}
+      l.forEach(i => {
+        let key = i.split('=')[0]
+        let value = i.split('=')[1]
+        if (key == 'type') {
+          if (value != 'test') {
+            o[key] = value
+          }
+        } else {
+          o[key] = value
+        }
+      })
+      return o[key]
+    },
+    get_sa_utm(options) {
+      return new Promise((resolve) => {
+        try {
+          let temp = ''
+          // #ifdef MP-WEIXIN
+          if (options.q) {
+            temp = decodeURIComponent(options.q)
+          }
+          // #endif
+          // #ifdef MP-ALIPAY
+           // 如果是支付宝这边已经解析过了,则返回false,不做二次解析
+          // const query = CacheTool.getMiniAppOptionsQuery()
+          console.log('options.options::::', options.options)
+          if (options.options.qrCode) {
+            temp = decodeURIComponent(options.options.qrCode)
+          }
+          
+          // #endif
+          // temp = https://crm.kerryplus.com/t-parking?sa_utm=iE
+          if (temp && temp.indexOf('?') > -1) {
+            const sa_utm = this.getParam(temp, 'sa_utm');
+            console.log('utm参数', sa_utm)
+            return resolve(sa_utm || false)
+          }
+          console.log('二码合一参数解析失败', temp);
+          return resolve(false)
+        } catch (err) {
+          resolve(false)
+        }
+      })
+    },
+    asyncRequest(url, data, method = 'GET') {
+      return new Promise((resolve, reject) => {
+        uni.request({
+          url: url,
+          data: data,
+          header: JSON.parse(uni.getStorageSync('handleUser') || "{}"),
+          method: method,
+          success: (res) => {
+            resolve(res.data);
+          },
+          fail: (err) => {
+            reject(err);
+          }
+        });
+      });
+    },
+    // 在异步函数中调用异步请求
+    fetchData(id) {
+      return new Promise(async (resolve, reject) => {
+        try {
+          const res = await this.asyncRequest(`${'https://pq.kerryplus.com'}/c/${id}`);
+          console.log('baseURLQrCode:::', res)
+          // console.log('baseURLQrCodebaseURLQrCode::', res.data);
+          if (res?.code == 200) {
+            // console.log('77777777', res, queryStringToObject(res.data.url));
+            // const [baseURL, key, value] = res.data.url.match(/(.*)=(.*)/)
+            if (res?.data?.url) {
+              // resolve({ key, value })
+              const insideUrl =
+              `/pages/package-parkingFee/parkingFeeWebViewLogin?${res.data.url}`
+            
+              // resolve(queryStringToObject(`t-page?${res.data.url}`))
+              my.navigateTo({
+                url: `/pages/package-parkingFee/parkingFeeWebViewLogin?${res.data.url}`,
+                complete: function (res) {
+                  console.log('回调::', res)
+                },
+                success: function (res) {
+                  console.log('跳转成功::', res)
+                },
+                fail: function (err) {
+                  console.log('跳转失败::', res)
+                }
+              });
+            } else {
+              reject(false)
+            }
+          }
+        } catch (error) {
+          console.error('请求失败', error);
+        }
+      })
+    },
     // 无牌车闸机扫码
     async scanCarCode() {
       try {
@@ -844,10 +945,25 @@ export default {
             window.toWXSendMsg({
               type: 'scanQRCode',
             });
+            console.log('二码合一参数::::')
+            
+            // runScanFn({type: "scanQRCodeOver", options: {imageChannel: "camera", qrCode: "https://crm.kerryplus.com/t-parking?sa_utm=mJ", rawData: "aHR0cHM6Ly9jcm0ua2VycnlwbHVzLmNvbS90LXBhcmtpbmc/c2FfdXRtPW1K", result: "https://crm.kerryplus.com/t-parking?sa_utm=mJ", scanType: "QR", errMsg: "scanCode:ok"}});
             // TODO 兼容支付宝无牌车扫码
           window.subscribe('scanQRCodeOver', (options) => {
             console.log('微信扫码结束之后的返回参数', options);
-            runScanFn(options);
+              const sa_utm =  this.get_sa_utm(options);
+              console.log('sa_utm:::', sa_utm)
+              if (sa_utm) {
+                const params =  this.fetchData(sa_utm)
+                console.log('params:::', params)
+                this.redirect = {
+                  ...this.redirect,
+                  ...params,
+                }
+                console.log('二码合一参数::::', params)
+              }
+            
+            // runScanFn(options);
           });
             // AlipayJSBridge.call('scan', {}, (result) => {
             //   console.log('监听后的扫描结果:', result);