谢杰标 2 anni fa
parent
commit
089a135fbc
3 ha cambiato i file con 73 aggiunte e 30 eliminazioni
  1. 14 1
      common/httpList/wxpay.js
  2. 23 22
      pages/index/index.vue
  3. 36 7
      pages2/order/confirm_pay.vue

+ 14 - 1
common/httpList/wxpay.js

@@ -25,5 +25,18 @@ export default {
 			data: data
 		})
 	},
-	
+	checkBindGzh(data) {
+		return myRequest({
+			url: '/app/user/checkBindGzh',
+			method: 'get',
+			data: data
+		})
+	},
+	OfficialLogin(data) {
+		return myRequest({
+			url: '/app/user/gzh_bind',
+			method: 'post',
+			data: data
+		})
+	},
 }

+ 23 - 22
pages/index/index.vue

@@ -447,28 +447,29 @@ export default {
   },
   onShow() {
     // #ifdef H5
-    if (location.search) {
-      console.log("url值:", location.search);
-      let arrs = location.search.slice(1).split("&");
-      for (let i = 0; i < arrs.length; i++) {
-        this.optObj[arrs[i].split("=")[0]] = arrs[i].split("=")[1];
-      }
-      console.log("获取的optObj:", this.optObj);
-      uni.setStorageSync("h5_code", this.optObj.code);
-      this.OfficialLogin();
-    } else {
-      // 没有code,就重定向到地址https://www.xyyxt.net?ask_type=h.xyyxt.net 去获取code,授权后就会把code带上然后访问域名
-      // h.gdzzkj.net
-      // !uni.getStorageSync("h5_code") &&
-      if (process.env.NODE_ENV !== "development") {
-        location.replace(
-          "https://" +
-            window.location.host +
-            "/?ask_type=" +
-            window.location.host
-        );
-      }
-    }
+    // if (location.search) {
+    //   console.log("url值:", location.search);
+    //   let arrs = location.search.slice(1).split("&");
+    //   for (let i = 0; i < arrs.length; i++) {
+    //     this.optObj[arrs[i].split("=")[0]] = arrs[i].split("=")[1];
+    //   }
+    //   console.log("获取的optObj:", this.optObj);
+    //   uni.setStorageSync("h5_code", this.optObj.code);
+    //   this.OfficialLogin();
+    // } else {
+    //   // 没有code,就重定向到地址https://www.xyyxt.net?ask_type=h.xyyxt.net 去获取code,授权后就会把code带上然后访问域名
+    //   if (
+    //     !uni.getStorageSync("h5_code") &&
+    //     process.env.NODE_ENV !== "development"
+    //   ) {
+    //     location.replace(
+    //       "https://" +
+    //         window.location.host +
+    //         "/?ask_type=" +
+    //         window.location.host
+    //     );
+    //   }
+    // }
     // #endif
     this.getInfo(); // 判断有没有关注公众号
     this.isClickOff(); //关注公众号,每天最多显示1次;当天学员关闭弹窗后,无需再显示

+ 36 - 7
pages2/order/confirm_pay.vue

@@ -140,24 +140,53 @@ export default {
       showConfirmButton: false,
       totalPrice: 0,
       confirmText: "",
+      optObj: {},
     };
   },
   onPullDownRefresh() {},
   onLoad(option) {
-    console.log(this.sac, 666);
     let self = this;
     this.fromCart = option.fromCart;
-    console.log(self.shoppingCartList, 6);
     let list = self.shoppingCartList;
-    console.log(list, 66);
     this.isBK = option.isBK;
     for (let i = 0; i < list.length; i++) {
       this.totalPrice += Number(list[i].standPrice);
     }
-    console.log(this.isBK == "1");
   },
-  onShow() {},
+  onShow() {
+    // #ifdef H5
+    if (location.search.includes("code")) {
+      let arrs = location.search.slice(1).split("&");
+      for (let i = 0; i < arrs.length; i++) {
+        this.optObj[arrs[i].split("=")[0]] = arrs[i].split("=")[1];
+      }
+      uni.setStorageSync("h5_code", this.optObj.code);
+      this.OfficialLogin();
+    } else {
+      // 没有code,就重定向到地址https://www.xyyxt.net?ask_type=h.xyyxt.net 去获取code,授权后就会把code带上然后访问域名
+      // ?fromCart=&code=061F5a1w3aolh03SLe1w3sMsCF4F5a16&state=STATE
+      this.$api.checkBindGzh().then((res) => {
+        if (!res.data.data && process.env.NODE_ENV !== "development") {
+          location.replace(
+            "https://www.xyyxt.net/?ask_type=" + window.location.host
+          );
+        }
+      });
+    }
+    // #endif
+  },
   methods: {
+    OfficialLogin() {
+      this.$api
+        .OfficialLogin({
+          code: this.optObj.code,
+        })
+        .then((res) => {
+          if (res.data.code !== 200) {
+            this.$u.toast(res.data.msg);
+          }
+        });
+    },
     postOrder() {
       console.log(12312312321);
       let list = this.shoppingCartList;
@@ -407,7 +436,7 @@ export default {
   components: { ClassTimeTip },
 };
 </script>
-<style >
+<style>
 ::-webkit-scrollbar {
   width: 0;
   height: 0;
@@ -576,4 +605,4 @@ page {
     color: #fff;
   }
 }
-</style>
+</style>