Kaynağa Gözat

Merge branch 'main' of https://gitlab.com/tea28/client

hejie 3 yıl önce
ebeveyn
işleme
1439ee5a36

+ 2 - 18
src/components/authorize-module/index.vue

@@ -27,10 +27,10 @@
 				
 				<view class="btnBar flex_r flex_ac flex_jb">
 					<button class='no-authorize_btn unSetBtn' @tap="onSoHAuth">{{isGetTel ? "暂不授权" : "暂不登录"}}</button>
-					<button open-type="getPhoneNumber" class='no-authorize_btn' @getphonenumber="onGotPhoneNumber" lang="zh_CN" v-if="!isGetUserInfo">立即登录</button>
+					<button open-type="getPhoneNumber" class='no-authorize_btn' @getphonenumber="onGotPhoneNumber" lang="zh_CN">立即登录</button>
 					<!-- <button open-type="getUserInfo" class='no-authorize_btn' @getuserinfo="onGotUserInfo" lang="zh_CN" v-else>获取用户信息</button> -->
-                    <button  @tap="getUserProfile" v-else> 获取头像昵称 </button>
 					<!-- <button open-type="getUserInfo" class='no-authorize_btn' @tap="onGotUserInfo" lang="zh_CN">立即登录</button> -->
+                    <!-- <button  @tap="getUserProfile" v-else> 获取头像昵称 </button> -->
 				</view>
 			</view>
 		</view>
@@ -60,10 +60,6 @@
 			        }
 			    }
 			},
-			isGetUserInfo:{
-				type:Boolean,
-				default:false
-			}
 		},
 		data() {
 			return{
@@ -88,18 +84,6 @@
 			    var value = e.detail.value;
 			    this.isDisabled = value.length == 0
 			},
-            getUserProfile(e) {
-                // 推荐使用wx.getUserProfile获取用户信息,开发者每次通过该接口获取用户个人信息均需用户确认
-                // 开发者妥善保管用户快速填写的头像昵称,避免重复弹窗
-                uni.getUserProfile({
-                    desc: '用于完善会员资料', // 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写
-                    success: (res) => {
-                        console.log("==============================");
-                        console.log(res);
-                        console.log("==============================");
-                    }
-                })
-            },
 		}
 	}
 </script>

+ 2 - 7
src/pages/my/index.vue

@@ -235,8 +235,7 @@
 		<!-- 功能列表-end -->
 
 		<!-- 授权 -->
-		<authorize-module v-if="showAuth" :shopInfo="shopInfo" :isGetUserInfo='isGetUserInfo' @authGetTelSuccess="onauthGetTelSuccess" @authSuccess="autoGetUserInfo">
-		</authorize-module>
+		<authorize-module v-if="showAuth" :shopInfo="shopInfo" @authGetTelSuccess="onauthGetTelSuccess" />
 		<!-- 授权-end -->
 		<!-- <newauthorize ref="newauthorize" /> -->
 	</view>
@@ -274,7 +273,7 @@
 
 				unid: "",
 				
-				isGetUserInfo:false,
+				// isGetUserInfo:false,
 				invited:'',
 
 				updataUserimg: {},
@@ -349,10 +348,6 @@
 					}
 				});
 			},
-			autoGetUserInfo(res){
-				this.showAuth = false;
-				this.isGetUserInfo = false
-			},
 			getuserInfo() {
 				post("/user/userinfo").then((res) => {
 					if (res.code === 0) {

+ 57 - 27
src/pages/product/p_details.vue

@@ -77,7 +77,7 @@
     </view>
     <!-- 底部导航组件-end -->
     <!-- 授权 -->
-    <!-- <authorize-module v-if="showAuth" :shopInfo="shopInfo" @authSuccess="onAuthSuccess" @onGotUserInfo="onGotUserInfo" ></authorize-module> -->
+		<authorize-module v-if="showAuth" :shopInfo="shopInfo" @authGetTelSuccess="onauthGetTelSuccess" />
     <!-- 授权-end -->
 
     <!-- 购买或加入购物车弹窗 -->
@@ -200,10 +200,12 @@ export default {
       checked: false, //是否选中协议
       buyNum: 1, //购买数量
       pfway: "1", // 批发
+      shopInfo: {}, // 商铺信息
       showAuth: false,
 
       userinfo: {},
       goodsDa: {},
+      unid: '',
     };
   },
   onLoad: function (e) {
@@ -211,6 +213,8 @@ export default {
     this.goodsDa = e;
     this.userinfo = uni.getStorageSync("userinfo");
     this.loadData(e);
+
+    if(e.invite && !uni.getStorageSync("token")) this.login(e.invite);
   },
   onShow: function () {},
   methods: {
@@ -239,16 +243,6 @@ export default {
         }
       });
     },
-
-    //授权并登录
-    onAuthSuccess: function () {
-      var that = this;
-      uni.showLoading({ mask: true });
-      appEv.setData((res) => {
-        uni.hideLoading();
-        that.showAuth = false;
-      });
-    },
     // 去购买
     ToPayPage: function () {
       if (!this.checked) {
@@ -320,30 +314,66 @@ export default {
       this.$refs.shopping.close();
     },
     getProPage() {
-      // if (this.type == 1 || this.type == 2) {
-      //   uni.navigateTo({
-      //     url: "/pages/protocol/index?type=" + this.type,
-      //   });
-      // } else if (this.type == 4) {
-      //   uni.navigateTo({
-      //     url: "/pages/protocol/index?type=" + 3,
-      //   });
-      // } else if (this.type == 3) {
-      //   uni.navigateTo({
-      //     url: "/pages/protocol/index?type=" + 5,
-      //   });
-      // }
-      console.log("aaaaaaaaaa");
       uni.navigateTo({
         url: "/pages/pay-agreement/index",
       });
     },
+
+    
+    login(invite) {
+      let that = this;
+      // #ifdef  MP-WEIXIN
+      wx.login({
+        success(res) {
+          if (res.code) {
+            post("appletLogin", {
+              invite,
+              code: res.code,
+            }).then((res) => {
+              if (res.code === 0) {
+                if (res.data.token) {
+                  uni.setStorageSync("token", res.data.token);
+                  that.getuserInfo();
+                } else {
+                  that.unid = res.data.unid;
+                  // setTimeout(() => {
+                    that.shopInfo = app.globalData.shopInfo;
+                    that.showAuth = true;
+                  // }, 1000);
+                }
+              }
+            });
+          }
+        },
+      });
+      // #endif
+    },
+    onauthGetTelSuccess(da) {
+      this.showAuth = false;
+      post("getMobile", {
+        unid: this.unid,
+        ...da.detail
+      }).then((res) => {
+        if (res.code === 0) {
+          uni.setStorageSync("token", res.data.token);
+          this.getuserInfo();
+        }
+      });
+    },
+    getuserInfo() {
+      post("/user/userinfo").then((res) => {
+        if (res.code === 0) {
+          uni.setStorageSync("userinfo", res.data.data);
+          this.userinfo = res.data.data;
+        }
+      });
+    },
   },
   onShareAppMessage: function () {
     let userinfo = uni.getStorageSync("userinfo");
     var path = "/pages/product/p_details?agentId=1" + '&id=' + this.goodsDa.id + '&type=' + this.goodsDa.type;
-    if (userinfo.user_id) {
-      path = "/pages/product/p_details?agentId=" + userinfo.user_id + '&id=' + this.goodsDa.id + '&type=' + this.goodsDa.type;
+    if (userinfo.invite) {
+      path = "/pages/product/p_details?invite=" + userinfo.invite + '&id=' + this.goodsDa.id + '&type=' + this.goodsDa.type;
     }
     var title = `让数字经济赋能美好生活!`;
     return {