zaijin vor 3 Jahren
Ursprung
Commit
56742dc3c0
2 geänderte Dateien mit 11 neuen und 59 gelöschten Zeilen
  1. 5 2
      h5_web/pages/mine/mine.vue
  2. 6 57
      h5_web/pages/phoneLogin/phoneLogin.vue

+ 5 - 2
h5_web/pages/mine/mine.vue

@@ -7,8 +7,8 @@
 				<view class="user-info">
 					<view class="user-info-left">
 						<view class="user-info-left-avatar" @click="jumpPage('/pages/personalModify/personalModify')">
-							<u-avatar :src="userInfo.avatar" mode="square" size="111"></u-avatar>
-							<view class="name">{{ userInfo.nickName }}</view>
+							<u-avatar :src="vuex_user.avatar" mode="square" size="111"></u-avatar>
+							<view class="name">{{ vuex_user.userName }}</view>
 						</view>
 						<view class="user-info-left-attribute">
 							<view class="veterans">
@@ -102,6 +102,9 @@
 				}
 			}
 		},
+		onShow() {
+			console.log(this.vuex_user)
+		},
 		methods: {
 			/**
 			 * 跳转到指定页面

+ 6 - 57
h5_web/pages/phoneLogin/phoneLogin.vue

@@ -49,20 +49,13 @@ export default {
 			// messageError:false
 		}
 	},
-	onLoad(page) {
-		//  如果存在code 则认为是微信登录完成后跳转过来的,直接获取信息跳转首页或者指定页面
-		let locationLocaturl = window.location.search;
-		this.code = getUrlParams(locationLocaturl, "code"); // 截取code
-		if (this.code) {
-			this.handleGetWXInfo(this.code) //把code传给后台获取用户信息
-		}
-		console.log('backUrl',localStorage.getItem('backUrl'))
-	},
+	onLoad(page) {},
 	onShow() {
+		// 判断是否登录 已登录直接跳转首页
 		if(this.vuex_hasLogin){
-			// uni.switchTab({
-			// 	url: '../index/index'
-			// })
+			uni.switchTab({
+				url: '../index/index'
+			})
 		}
 	},
 	computed: {
@@ -166,16 +159,6 @@ export default {
 				this.showToast();
 			});
 		},
-		// 微信登录
-		wechatLogin() {
-			this.jumpIndex()
-			// const openId = this.$store.state.vuex_wxinfo?.openId
-			// if (openId) {
-			// 	this.jumpIndex()
-			// } else {
-			// 	this.getCode()
-			// }
-		},
 		veteEducCheck(){
 			this.$u.api.getVeteEducCheck().then(res=>{
 				console.log('res',res);
@@ -188,7 +171,7 @@ export default {
 				}
 			})
 		},
-		// 微信已登录则跳转到首页
+		// 跳转到首页
 		jumpIndex() {
 			let ret = localStorage.getItem('backUrl')
 			if (ret && ret.indexOf('phoneLogin') < 0) {
@@ -222,40 +205,6 @@ export default {
 				})
 			}
 		},
-		// 获取code
-		getCode () {
-			const local = window.location.href // 获取页面url
-			let locationLocaturl = window.location.search;
-			this.code = getUrlParams(locationLocaturl, "code"); // 截取code
-			if (this.code) { // 如果没有code,则去请求
-				this.handleGetWXInfo(this.code) //把code传给后台获取用户信息
-			} else {
-				window.location.href = `https://open.weixin.qq.com/connect/oauth2/authorize?appid=${this.config.wxAppid}&redirect_uri=${encodeURIComponent(local)}&response_type=code&scope=snsapi_userinfo&#wechat_redirect`
-			}
-		},
-		// 通过code获取 openId等用户信息,/api/user/wechat/login 为后台接口
-		handleGetWXInfo (code) {
-			uni.showLoading({
-			    title: '加载中'
-			})
-			this.$u.api.getWXInfo(code).then((res) => {
-				if (res.code === 200 ) {
-					this.$u.vuex('vuex_wxinfo', res.data);
-					this.jumpIndex()
-				} else {
-					this.$refs.uToast.show({
-						title: '获取用户信息失败!',
-						type: 'error',
-					});
-				}
-				uni.hideLoading()
-			}).catch((err) => {
-				this.$refs.uToast.show({
-					title: '获取用户信息失败!',
-					type: 'error',
-				});
-			})
-		},
 		/**
 		 * 跳转页面
 		 * */