Jelajahi Sumber

优化重复打卡逻辑

yanj 1 bulan lalu
induk
melakukan
7aff81d049
1 mengubah file dengan 37 tambahan dan 6 penghapusan
  1. 37 6
      pages/user/index.vue

+ 37 - 6
pages/user/index.vue

@@ -107,6 +107,7 @@ import {getAdInfo} from '@/api'
 import store from "@/store";
 import {qrcodeDecode} from "@/api/checkIn";
 import Toast from "@/wxcomponents/vant/toast/toast";
+import Dialog from "@/wxcomponents/vant/dialog/dialog";
 
 export default {
   options: {
@@ -188,13 +189,43 @@ export default {
       wx.scanCode({
         onlyFromCamera: true,
         success (res) {
+          if (!res.path) {
+            Dialog.alert({
+              message: '该二维码不能进行核销',
+            }).then(() => {
+            });
+            return false
+          }
           let scene = res.path.split('scene=')
-          const decoded = decodeURIComponent(scene[1])
-              .replace(/\%/g, '%25'); // 防止二次解码丢失%
-          const finalStr = decodeURIComponent(decoded);
-          that.qrcodeDecodeEvent(finalStr,()=>{
-            that.prizeShow = true
-          })
+          if (scene && scene[1]) {
+            const decoded = decodeURIComponent(scene[1])
+                .replace(/\%/g, '%25'); // 防止二次解码丢失%
+            if (decoded.indexOf('&t=') > -1) {
+              let type = decoded.split('&t=')
+              console.log(type)
+              if (type[1] === "0") {
+                Dialog.alert({
+                  message: '该二维码不能进行核销',
+                }).then(() => {
+                });
+              }
+              if (type[1] === "1") {
+                that.qrcodeDecodeEvent(decoded,()=>{
+                  that.prizeShow = true
+                })
+              }
+            } else {
+              Dialog.alert({
+                message: '该二维码不能进行核销',
+              }).then(() => {
+              });
+            }
+          } else {
+            Dialog.alert({
+              message: '该二维码不能进行核销',
+            }).then(() => {
+            });
+          }
         }
       })
     },