lilei vor 4 Jahren
Ursprung
Commit
66fc9669e4
2 geänderte Dateien mit 15 neuen und 27 gelöschten Zeilen
  1. 7 21
      libs/axios.js
  2. 8 6
      pages/userCenter/index.vue

+ 7 - 21
libs/axios.js

@@ -39,27 +39,13 @@ const request = (opts, hasToken) => {
 				if(ret.status == '200'){
 					resolve(ret)
 				}else{
-					if(ret.status == '401'){  //  未登录或登录过期
-					    uni.showToast({
-					    	icon:'none',
-					    	title: '未登录或登录已过期,请重新登录',
-					    	duration: 5000 
-					    })
-					    setTimeout(function() {
-					      const currentRoute = getRoutePath();
-					      const url = `/pages/login/login?lanuch=${currentRoute.lanuch}&path=` + encodeURIComponent(currentRoute.url);
-					      uni.redirectTo({ url });
-					    }, 1000);
-					}
-					else{
-						if(ret.status == 500){
-							uni.showToast({
-								icon:'none',
-								title: ret.message,
-								mask: true,
-								duration: 3000 
-							})
-						}
+					if(ret.status == 500 || ret.status == 401 || ret.status == '9001'){
+						uni.showToast({
+							icon:'none',
+							title: ret.message,
+							mask: true,
+							duration: 3000 
+						})
 					}
 					resolve(ret)
 				}

+ 8 - 6
pages/userCenter/index.vue

@@ -3,12 +3,12 @@
 		<!-- 头部 -->
 		<view class="user-head" @click="toUserPage">
 			<view class="user-photo">
-				<text v-if="hasLogin"><open-data type="userAvatarUrl"></open-data></text>
-				<u-image v-else src="/static/logo.png" width="100" height="100"></u-image>
+				<open-data type="userAvatarUrl"></open-data>
+				<u-image v-show="!hasLogin" src="/static/logo.png" width="100" height="100"></u-image>
 			</view>
 			<view class="user-info">
-				<text v-if="hasLogin"><open-data type="userNickName"></open-data></text>
-				<u-button v-else plain size="mini" shape="circle" @click="toLoginPage">登录</u-button>
+				<text v-show="hasLogin">{{userData.mobile||'--'}}</text>
+				<u-button v-show="!hasLogin" plain size="mini" shape="circle" @click="toLoginPage">登录</u-button>
 			</view>
 			<view v-if="hasLogin">
 				<u-icon name="arrow-right" color="#fff"></u-icon>
@@ -42,12 +42,13 @@
 	export default {
 		data() {
 			return {
-				hasLogin: false
+				hasLogin: false,
+				userData: {}
 			};
 		},
 		onShow() {
 			checkLogin().then(res => {
-				console.log(res)
+				console.log(res,'checkLogin')
 				this.hasLogin = res.status == 200
 				if(this.hasLogin){
 					this.getUserInfo()
@@ -63,6 +64,7 @@
 					console.log(res,'getUserInfo')
 					if(res.status == 200){
 						this.$u.vuex("vuex_userData",res.data)
+						this.userData = res.data
 					}
 				})
 			},