Просмотр исходного кода

Merge branch 'dev' into 'test'

h5注册流程修改头像

See merge request quanshu/mp-ui-user!65
世轩 2 лет назад
Родитель
Сommit
4f9e9365b4
2 измененных файлов с 44 добавлено и 20 удалено
  1. 20 11
      src/packageOther/avatar/index.vue
  2. 24 9
      src/pages/login/code.vue

+ 20 - 11
src/packageOther/avatar/index.vue

@@ -3,18 +3,27 @@
 		<!-- #ifdef MP-ALIPAY -->
 		<u-navbar :placeholder="true" bgColor="#fff" :autoBack="true" :border="true" title="个人信息"
 			leftIconSize="0"></u-navbar>
+		<!-- #endif -->
+		<!-- #ifdef MP-WEIXIN -->
+		<view v-if="pagesNum > 1">
+			<u-navbar :placeholder="true" bgColor="#fff" :autoBack="true" :border="true" title="个人信息" />
+		</view>
+		<view v-else>
+			<u-navbar leftIconSize="0" :placeholder="true" bgColor="#fff" :border="true" title="个人信息">
+				<view class="nav-left flex" slot="left" @click="">
+					<u-icon name="arrow-left" size="20" color="#333"></u-icon>
+				</view>
+			</u-navbar>
+		</view>
 		<!-- #endif -->
-		<!-- #ifdef MP-WEIXIN -->
-		<u-navbar :placeholder="true" bgColor="#fff" :autoBack="true" :border="true" title="个人信息"></u-navbar>
-		<!-- #endif -->
-		<!-- #ifndef MP-WEIXIN || MP-ALIPAY -->
+		<!-- #ifndef MP-ALIPAY || MP-WEIXIN -->
 		<view v-if="pagesNum > 1">
 			<u-navbar :placeholder="true" bgColor="#fff" :autoBack="true" :border="true" title="个人信息" />
 		</view>
 		<view v-else>
 			<u-navbar leftIconSize="0" :placeholder="true" bgColor="#fff" :border="true" title="个人信息">
-				<view class="nav-left flex" slot="left" @click="$toIndex()">
-					<u-icon name="arrow-left" size="20" color="#333"></u-icon>
+				<view class="nav-left flex" slot="left">
+					<u-icon name="arrow-left" size="20" color="#fff"></u-icon>
 				</view>
 			</u-navbar>
 		</view>
@@ -26,7 +35,7 @@
 				<!-- <view><u-avatar :src="avatarUrl"></u-avatar></view> -->
 				<!-- #ifdef H5 -->
 				<button type="button" class="button" @click="onChooseImage">
-					<u-avatar :src="avatarUrl+ '?imageView2/2/w/80'" mode="aspectFill"></u-avatar>
+					<u-avatar :src="avatarUrl" mode="aspectFill"></u-avatar>
 				</button>
 				<!-- #endif -->
 
@@ -71,7 +80,7 @@
 			this.getInfo()
 			// this.userInfo = uni.getStorageSync('userInfo')
 			// this.avatarUrl = env.filePublic + this.userInfo.avatar
-			// this.avatar = this.userInfo.avatar
+			// this.avatar = this.userInfo.avatar 
 		},
 		methods: {
 			// 我的信息
@@ -95,9 +104,9 @@
 					title: '加载中'
 				});
 				let data = {
-					nickName: this.userInfo.nickName, //昵称
-					userId: this.userInfo.userId, //用户id
-					avatar: this.avatar, //文件地址
+					nickName: this.userInfo.nickName ? this.userInfo.nickName : '默认昵称', //昵称
+					userId: this.userInfo.userId, //用户id
+					avatar: this.avatar ? this.avatar : ((process.env.NODE_ENV == 'development') || (process.env.NODE_ENV == 'staging') ? 'EQX15D97SFN4OUMORGGH.jpg' :  'static/avatar.jpeg'), //文件地址
 				}
 				$http.post('/api/v1/mp/user/mine/updateUserInfo', data).then(res => {
 					uni.hideLoading();

+ 24 - 9
src/pages/login/code.vue

@@ -140,21 +140,36 @@
 						// #ifdef H5 
 						uni.$u.toast('登录成功');
 						uni.setStorageSync('token', res.token)
-						setTimeout(() => {
-							if(this.pagesNum > 2) {
-								uni.navigateBack({
-									delta: 2
-								})
-							}else {
-								this.toIndex()
-							}
-						}, 500)
+						_this.getInfoAvatar()
 						// #endif
 					}
 				}).catch(() => {
 					_this.loading = false
 				})
 			},
+			
+			getInfoAvatar() {
+				$http.post('/api/v1/mp/user/getLoginUserinfo', { appSource: appId }).then(res => {
+					if(res.code == 0) {
+						//判断有没有头像
+						if(res.data.avatar) {
+							setTimeout(() => {
+								if(this.pagesNum > 2) {
+									uni.navigateBack({
+										delta: 2
+									})
+								}else {
+									this.toIndex()
+								}
+							}, 500)
+						}else{
+							uni.reLaunch({
+								url: '/packageOther/avatar/index'
+							})
+						}
+					}
+				})
+			},
 
 			getBaseInfo() {
 				$http.post('/api/v1/mp/user/getLoginUserinfo', { appSource: appId }).then(res => {