谢杰标 3 лет назад
Родитель
Сommit
8804fc564f
5 измененных файлов с 58 добавлено и 40 удалено
  1. 5 0
      common/authorize.js
  2. 18 18
      pages/bill/index.vue
  3. 17 13
      pages/login/login.vue
  4. 14 6
      pages/login/register.vue
  5. 4 3
      pages/vcard/index.vue

+ 5 - 0
common/authorize.js

@@ -1,5 +1,6 @@
 import { getWxConfig, getMobileConfig, OfficialLogin } from "@/utils/user";
 import { getOpenId } from "@/utils/login";
+
 export function getQueryString(name) {
   const url = location.search; //获取url中"?"符后的字串
   let theRequest = new Object();
@@ -17,12 +18,16 @@ export function getQueryString(name) {
 }
 // 授权
 export function authorize(url = window.location.href) {
+
   if (!isWechat()) {
     return;
   }
   if (uni.getStorageSync("openid")) {
     return;
   }
+  if (getQueryString("code")) {
+    return;
+  }
   // 没有code,就重定向到地址https://www.xyyxt.net?ask_type=https://api.xyyxt.net/pages2/order/confirm_pay 去获取code,授权后就会把code带上然后访问域名
   // ?fromCart=&code=061F5a1w3aolh03SLe1w3sMsCF4F5a16&state=STATE
   getMobileConfig().then((res) => {

+ 18 - 18
pages/bill/index.vue

@@ -1,26 +1,26 @@
 <template>
   <view class="bill-ward">
-    <view v-for="(item, index) in posterConfig" :key="index">
+    <view
+      v-for="(item, index) in posterConfig"
+      :key="index"
+      :style="backPosition(item)"
+    >
       <image
         :style="item.css"
-        v-if="item.type == 0 && item.checked"
-        :src="$method.splitImgHost(item.name, true)"
+        v-if="(item.type == 0 || item.type == 2) && item.checked"
+        :src="$method.splitImgHost(item.name)"
         mode=""
       />
-      <view :style="backPosition(item)" style="white-space: pre-wrap">
-        <view :style="item.css" v-if="item.type == 1">
-          {{ item.name }}
-        </view>
-      </view>
-      <view :style="backPosition(item)">
-        <image
-          :style="item.css"
-          v-if="item.type == 2"
-          :src="$method.splitImgHost(item.name, true)"
-          mode=""
-        />
+
+      <view
+        :style="item.css"
+        v-if="item.type == 1"
+        style="white-space: pre-wrap"
+      >
+        {{ item.name }}
       </view>
-      <view class="code-box" v-if="item.type == 3" :style="backPosition(item)">
+
+      <view class="code-box" v-if="item.type == 3">
         <tki-qrcode
           :cid="item.codeUrl"
           ref="qrcode"
@@ -56,13 +56,13 @@ export default {
   },
   onLoad(options) {
     this.options = options;
-    this.getSharePoster();
     this.share();
     uni.setStorageSync("BillHerf", window.location.href);
-    authorize();
   },
   onShow() {
     backOpenId(this.login);
+    authorize();
+    this.getSharePoster();
   },
   components: {
     tkiQrcode,

+ 17 - 13
pages/login/login.vue

@@ -181,10 +181,10 @@ export default {
   },
   onLoad(options) {
     this.options = options;
-    authorize();
   },
   onShow() {
     backOpenId(this.openidLogin);
+    authorize();
   },
   onReady() {
     this.$refs.uForm1.setRules(this.rules);
@@ -199,10 +199,13 @@ export default {
     addParams() {
       let str = "?";
       if (this.options.backBill) {
-        str += "backBill=" + this.options.backBill;
+        str += "&backBill=" + this.options.backBill;
       }
       if (this.options.isBack) {
-        str += "isBack=" + this.options.isBack;
+        str += "&isBack=" + this.options.isBack;
+      }
+      if (this.options.shareCode) {
+        str += "&shareCode=" + this.options.shareCode;
       }
       return str;
     },
@@ -225,7 +228,7 @@ export default {
       })
         .then((data) => {
           this.$u.toast("登录成功");
-          this.openid && this.bindOpenId();
+          this.bindOpenId();
           this.loginCallback(data);
         })
         .finally(() => {
@@ -272,18 +275,19 @@ export default {
     },
     // 绑定openid和unionid
     bindOpenId() {
-      checkBindGzh().then((res) => {
-        if (!res) {
-          OfficialLogin({
-            gzhOpenid: this.openid,
-            unionId: uni.getStorageSync("unionid"),
-          });
-        }
-      });
+      this.openid &&
+        checkBindGzh().then((res) => {
+          if (!res) {
+            OfficialLogin({
+              gzhOpenid: this.openid,
+              unionId: uni.getStorageSync("unionid"),
+            });
+          }
+        });
     },
     loginCallback(data) {
       this.$store.commit("LOGIN_CB", data);
-      this.openid && this.bindOpenId();
+      this.bindOpenId();
       this.$store.dispatch("getUserInfo").then((res) => {
         if (this.options.backBill) {
           let href = uni.getStorageSync("BillHerf");

+ 14 - 6
pages/login/register.vue

@@ -72,7 +72,7 @@ import {
   accountLogin,
   OfficialLogin,
 } from "@/utils/login";
-import { authorize, backCode } from "@/common/authorize";
+import { authorize, backOpenId } from "@/common/authorize";
 export default {
   data() {
     return {
@@ -141,7 +141,7 @@ export default {
       },
       isUse: false,
       options: {},
-      code: "",
+      openid: "",
     };
   },
   methods: {
@@ -150,6 +150,7 @@ export default {
         .validate()
         .then((res) => {
           this.isUse = true;
+          this.form.shareCode = this.options.shareCode;
           registerUser(this.form).then(
             (res) => {
               this.isUse = false;
@@ -164,8 +165,7 @@ export default {
                     pwd: encryptor(this.form.pwd),
                   }).then((data) => {
                     this.$store.commit("LOGIN_CB", data);
-                    // 绑定code==>openid
-                    this.code && OfficialLogin({ code: this.code });
+                    this.bindOpenId();
                     this.$store.dispatch("getUserInfo").then((res) => {
                       if (this.options.backBill) {
                         let href = uni.getStorageSync("BillHerf");
@@ -198,6 +198,14 @@ export default {
           console.log(errors);
         });
     },
+    // 绑定openid和unionid
+    bindOpenId() {
+      this.openid &&
+        OfficialLogin({
+          gzhOpenid: this.openid,
+          unionId: uni.getStorageSync("unionid"),
+        });
+    },
     codeChange(text) {
       this.codeTips = text;
     },
@@ -231,8 +239,8 @@ export default {
     authorize();
   },
   onShow() {
-    backCode((code) => {
-      this.code = code;
+    backOpenId((openid) => {
+      this.openid = openid;
     });
   },
 };

+ 4 - 3
pages/vcard/index.vue

@@ -16,7 +16,7 @@
           <view class="info-name"> {{ userInfo.realname }} </view>
           <view class="info-item fl">
             <image src="../../static/image/icon-phone.png" mode=""></image>
-            <view class=""> {{ userInfo.telphone }} </view>
+            <view class=""> {{ userInfo.phonenumber }} </view>
           </view>
           <view class="info-item fll">
             <image src="../../static/image/icon-business.png" mode=""></image>
@@ -56,16 +56,17 @@ export default {
     },
     toLogin() {
       uni.navigateTo({
-        url: "/pages/login/login?backBill=1",
+        url: "/pages/login/login?backBill=1&shareCode=" + this.shareCode,
       });
     },
     toRegister() {
       uni.navigateTo({
-        url: "/pages/login/register?backBill=1",
+        url: "/pages/login/register?backBill=1&shareCode=" + this.shareCode,
       });
     },
   },
   onLoad(option) {
+    this.shareCode = option.shareCode;
     this.getInfoByShareCode(option.shareCode);
   },
 };