瀏覽代碼

测试多门店扫码

zhujindu 1 年之前
父節點
當前提交
92ac94b21f
共有 1 個文件被更改,包括 27 次插入24 次删除
  1. 27 24
      src/components/storeCode.vue

+ 27 - 24
src/components/storeCode.vue

@@ -9,11 +9,11 @@
 </template>
 </template>
 
 
 <script>
 <script>
-import axios from "axios";
-import { getOptionByResult } from "@/api/index";
+import axios from 'axios';
+import { getOptionByResult } from '@/api/index';
 
 
 export default {
 export default {
-  name: "uploadImg",
+  name: 'uploadImg',
   props: {
   props: {
     index: {
     index: {
       type: Number,
       type: Number,
@@ -21,7 +21,7 @@ export default {
     },
     },
     tid: {
     tid: {
       type: String,
       type: String,
-      default: "",
+      default: '',
     },
     },
     cid: {
     cid: {
       type: Number,
       type: Number,
@@ -29,35 +29,35 @@ export default {
     },
     },
     code: {
     code: {
       type: String,
       type: String,
-      default: "",
+      default: '',
     },
     },
     index1: {
     index1: {
       type: [String, Number],
       type: [String, Number],
-      default: "",
+      default: '',
     },
     },
     index2: {
     index2: {
       type: [String, Number],
       type: [String, Number],
-      default: "",
+      default: '',
     },
     },
     index3: {
     index3: {
       type: [String, Number],
       type: [String, Number],
-      default: "",
+      default: '',
     },
     },
     index4: {
     index4: {
       type: [String, Number],
       type: [String, Number],
-      default: "",
+      default: '',
     },
     },
     taskId: {
     taskId: {
       type: String,
       type: String,
-      default: "",
+      default: '',
     },
     },
     collectionId: {
     collectionId: {
       type: String,
       type: String,
-      default: "",
+      default: '',
     },
     },
     type: {
     type: {
       type: String,
       type: String,
-      default: "",
+      default: '',
     },
     },
     insert: {
     insert: {
       type: Boolean,
       type: Boolean,
@@ -67,7 +67,7 @@ export default {
   data() {
   data() {
     return {
     return {
       shows: false,
       shows: false,
-      url: "",
+      url: '',
     };
     };
   },
   },
   methods: {
   methods: {
@@ -78,9 +78,9 @@ export default {
       let qiyeData;
       let qiyeData;
 
 
       const instance = axios.create();
       const instance = axios.create();
-      instance.defaults.headers.common["userId"] = localStorage.getItem("loginName");
+      instance.defaults.headers.common['userId'] = localStorage.getItem('loginName');
       instance
       instance
-        .get(process.env.VUE_APP_BASE_API + "mobile/wx/ticket", {
+        .get(process.env.VUE_APP_BASE_API + 'mobile/wx/ticket', {
           params: {
           params: {
             url: url,
             url: url,
           },
           },
@@ -95,22 +95,25 @@ export default {
               timestamp: qiyeData.timestamp, // 必填,生成签名的时间戳
               timestamp: qiyeData.timestamp, // 必填,生成签名的时间戳
               nonceStr: qiyeData.nonceStr, // 必填,生成签名的随机串
               nonceStr: qiyeData.nonceStr, // 必填,生成签名的随机串
               signature: qiyeData.signature, // 必填,签名,见 附录-JS-SDK使用权限签名算法
               signature: qiyeData.signature, // 必填,签名,见 附录-JS-SDK使用权限签名算法
-              jsApiList: ["ready", "scanQRCode"],
+              jsApiList: ['ready', 'scanQRCode'],
             });
             });
             wx.ready(function () {
             wx.ready(function () {
               wx.scanQRCode({
               wx.scanQRCode({
-                desc: "scanQRCode desc",
+                desc: 'scanQRCode desc',
                 needResult: 1,
                 needResult: 1,
-                scanType: ["barCode"],
+                scanType: ['barCode'],
                 success: function (res) {
                 success: function (res) {
+                  console.log(res);
                   var result = res.resultStr;
                   var result = res.resultStr;
+                  console.log(result);
+                  console.log(that.code);
                   var success = false;
                   var success = false;
-                  if (that.code == result && that.code != "" && that.code != null) {
+                  if (that.code == result && that.code != '' && that.code != null) {
                     success = true;
                     success = true;
                   }
                   }
                   let loading1 = that.$toast.loading({
                   let loading1 = that.$toast.loading({
                     duration: 0,
                     duration: 0,
-                    message: "数据加载中...",
+                    message: '数据加载中...',
                     forbidClick: true,
                     forbidClick: true,
                   });
                   });
                   getOptionByResult({
                   getOptionByResult({
@@ -120,13 +123,13 @@ export default {
                   }).then((response) => {
                   }).then((response) => {
                     loading1.clear();
                     loading1.clear();
                     if (response.code == 200) {
                     if (response.code == 200) {
-                      that.$emit("newcode", {
+                      that.$emit('newcode', {
                         cid: response.data.collectionId,
                         cid: response.data.collectionId,
                         cpid: response.data.collectionOptionId,
                         cpid: response.data.collectionOptionId,
                         nocpid: response.data.diffCollectionOptionId,
                         nocpid: response.data.diffCollectionOptionId,
                         type: that.type,
                         type: that.type,
                         index: that.index,
                         index: that.index,
-                        code: that.code + "," + result,
+                        code: that.code + ',' + result,
                         success: success,
                         success: success,
                         index1: that.index1,
                         index1: that.index1,
                         index2: that.index2,
                         index2: that.index2,
@@ -137,8 +140,8 @@ export default {
                   });
                   });
                 },
                 },
                 error: function (res) {
                 error: function (res) {
-                  if (res.errMsg.indexOf("function_not_exist") > 0) {
-                    alert("版本过低请升级");
+                  if (res.errMsg.indexOf('function_not_exist') > 0) {
+                    alert('版本过低请升级');
                   }
                   }
                 },
                 },
               });
               });