hejie il y a 3 ans
Parent
commit
91b5012a91
3 fichiers modifiés avec 47 ajouts et 31 suppressions
  1. 2 0
      src/App.vue
  2. 8 3
      src/components/authorize-module/index.vue
  3. 37 28
      src/pages/my/index.vue

+ 2 - 0
src/App.vue

@@ -231,6 +231,8 @@
 		                province: res.userInfo.province || '',
 		                country: res.userInfo.country || ''
 		            };
+					console.log(userinfo,"aaaaaaaaa")
+					return
 		            that.globalData.systemUserInfo = userinfo;
 		            var data = {
 		                agentId: that.globalData.agentId,

+ 8 - 3
src/components/authorize-module/index.vue

@@ -27,7 +27,8 @@
 				
 				<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">立即登录</button>
+					<button open-type="getPhoneNumber" class='no-authorize_btn' @getphonenumber="onGotPhoneNumber" lang="zh_CN" v-if="!isGetUserInfo">立即登录</button>
+					<button open-type="getUserInfo" class='no-authorize_btn' @getuserinfo="onGotUserInfo" lang="zh_CN" v-else>获取用户信息</button>
 					<!-- <button open-type="getUserInfo" class='no-authorize_btn' @tap="onGotUserInfo" lang="zh_CN">立即登录</button> -->
 				</view>
 			</view>
@@ -57,6 +58,10 @@
 			            // this.clickDom = false
 			        }
 			    }
+			},
+			isGetUserInfo:{
+				type:Boolean,
+				default:false
 			}
 		},
 		data() {
@@ -72,8 +77,8 @@
 			closeAuthCom(){
 			    this.$emit('closeAuthCom');
 			},
-			onGotUserInfo: function (e) {
-			    this.$emit('authSuccess');
+			onGotUserInfo (e) {
+			    this.$emit('authSuccess',e);
 			},
 			onGotPhoneNumber(e){
                 this.$emit('authGetTelSuccess', e);

+ 37 - 28
src/pages/my/index.vue

@@ -3,7 +3,7 @@
 		<view class="content" :style="userinfo.is_authentication == 1 ? 'padding-top:30rpx;' : ''">
 			<!-- 用户信息 -->
 			<view class="uerInfo mar_t16 flex_r">
-				<view class="user_img" @click="login">
+				<view class="user_img" @click="updateUserInfo">
 					<image class="image" :src="
               userinfo && userinfo.head_pic != ''
                 ? userinfo.head_pic
@@ -18,7 +18,7 @@
 				</view>
 				<block v-if="userinfo && userinfo != ''">
 					<view class="user_con flex_c">
-						<view class="user_name flex_r flex_ae ellipsis" @click="login">{{ userinfo.nickname
+						<view class="user_name flex_r flex_ae ellipsis" @click="updateUserInfo">{{ userinfo.nickname
               }}<text>({{
                   userinfo.is_authentication == 0 ? "未实名" : "已实名"
                 }})</text></view>
@@ -244,7 +244,7 @@
 		<!-- 功能列表-end -->
 
 		<!-- 授权 -->
-		<authorize-module v-if="showAuth" :shopInfo="shopInfo" @authGetTelSuccess="onauthGetTelSuccess">
+		<authorize-module v-if="showAuth" :shopInfo="shopInfo" :isGetUserInfo='isGetUserInfo' @authGetTelSuccess="onauthGetTelSuccess" @authSuccess="autoGetUserInfo">
 		</authorize-module>
 		<!-- 授权-end -->
 		<!-- <newauthorize ref="newauthorize" /> -->
@@ -282,6 +282,8 @@
 				userinfo: undefined, // 获取用户信息
 
 				unid: "",
+				
+				isGetUserInfo:false,
 			};
 		},
 		onLoad: function(options) {
@@ -351,31 +353,38 @@
 					}
 				});
 			},
-			login() {
-				uni.getUserProfile({
-					desc: '登录',
-					success: (response) => {
-						console.log('response', response)
-						try {
-							uni.showLoading({
-								title: '登录中...'
-							});
-							//请求后台,成功并隐藏加载
-							uni.hideLoading({})
-						} catch (e) {
-							uni.showToast({
-								title: "微信登录失败",
-								icon: "none"
-							});
-						}
-					},
-					fail: (res) => {
-						uni.showToast({
-							title: "您已取消授权",
-							icon: "none"
-						});
-					}
-				});
+			autoGetUserInfo(res){
+				this.showAuth = false;
+				this.isGetUserInfo = false
+				console.log(res,"获取到的用户信息")
+			},
+			updateUserInfo() {
+				// uni.getUserProfile({
+				// 	desc: '登录',
+				// 	success: (response) => {
+				// 		console.log('response', response)
+				// 		try {
+				// 			uni.showLoading({
+				// 				title: '登录中...'
+				// 			});
+				// 			//请求后台,成功并隐藏加载
+				// 			uni.hideLoading({})
+				// 		} catch (e) {
+				// 			uni.showToast({
+				// 				title: "微信登录失败",
+				// 				icon: "none"
+				// 			});
+				// 		}
+				// 	},
+				// 	fail: (res) => {
+				// 		uni.showToast({
+				// 			title: "您已取消授权",
+				// 			icon: "none"
+				// 		});
+				// 	}
+				// });\
+	            this.isGetUserInfo = true;
+				this.showAuth = true
 			},
 			getuserInfo() {
 				post("/user/userinfo").then((res) => {