Procházet zdrojové kódy

Merge branch 'dev' into 'test'

注册流程自定义头像

See merge request quanshu/mp-ui-user!64
世轩 před 2 roky
rodič
revize
585fde7163

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

@@ -26,7 +26,7 @@
 				<!-- <view><u-avatar :src="avatarUrl"></u-avatar></view> -->
 				<!-- #ifdef H5 -->
 				<button type="button" class="button" @click="onChooseImage">
-					<u-avatar :src="avatarUrl" mode="aspectFill"></u-avatar>
+					<u-avatar :src="avatarUrl+ '?imageView2/2/w/80'" mode="aspectFill"></u-avatar>
 				</button>
 				<!-- #endif -->
 
@@ -119,17 +119,16 @@
 					count: 1, //默认9
 					sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
 					sourceType: ['album'], //从相册选择
-					success: (res) => {
-						console.log(res.tempFilePaths[0]);
-						_this.avatarUrl = res.tempFilePaths[0] // 将选择的图片路径预览
-						$http.upload(res.tempFilePaths[0]).then(res2 => {
-							uni.hideLoading();
-							console.log('res2',res2);
-							if (res.code == 0) {
-								_this.avatar = res2.data.fileName
-							}
-						}).catch(() => {
-							uni.hideLoading();
+					success: (res) => {
+						_this.avatarUrl = res.tempFilePaths[0] // 将选择的图片路径预览
+						$http.upload(res.tempFilePaths[0]).then(res2 => {
+							uni.hideLoading();
+							if (res2.code == 0) {
+								this.avatarUrl = res.tempFilePaths[0]
+								this.avatar = res2.data.fileName
+							}
+						}).catch(() => {
+							uni.hideLoading();
 						})
 					}
 				});

+ 5 - 2
src/pages/login/code.vue

@@ -194,8 +194,11 @@
 			authClose() {
 				this.authShow = false
 				setTimeout(() => {
-					uni.navigateBack({
-						delta: 2
+					// uni.navigateBack({
+					// 	delta: 2
+					// })
+					uni.reLaunch({
+						url: '/packageOther/avatar/index'
 					})
 				}, 500)
 			},

+ 5 - 2
src/pages/login/index.vue

@@ -175,8 +175,11 @@
 			authClose() {
 				this.authShow = false
 				setTimeout(() => {
-					uni.navigateBack({
-						delta: 1
+					// uni.navigateBack({
+					// 	delta: 1
+					// })
+					uni.reLaunch({
+						url: '/packageOther/avatar/index'
 					})
 				}, 500)
 			},

+ 1 - 1
src/pages/user/index.vue

@@ -7,7 +7,7 @@
 		<!-- 账户信息 -->
 		<view class="account">
 			<view class="flex account-ava">
-				<image :src="avatar" mode="aspectFill" v-if="loginState" @click="toSetAvatar()"></image>
+				<image :src="avatar + '?imageView2/2/w/150'" mode="aspectFill" v-if="loginState" @click="toSetAvatar()"></image>
 				<view class="no-ava" v-else @click="toLogin"></view>
 				<view class="account-ava-name" v-if="loginState" @click="toSetAvatar()">{{ userInfo.nickName }}</view>
 				<view class="account-ava-no" @click="toLogin" v-else>登录</view>

+ 2 - 0
src/utils/request.js

@@ -65,7 +65,9 @@ const $upload = (fileUrl, type) => {
 		uni.uploadFile({
 			url: getSignUrl(`/api/v1/mp/image/remote/upload/post/${type || 0}`, {}, timestamp),
 			header: {
+				// #ifndef H5
 				'Content-Type': 'multipart/form-data',
+				// #endif
 				'Authorization': uni.getStorageSync('token') ?
 					`Bearer ${uni.getStorageSync('token')}` : '',
 				'x-zz-timestamp': timestamp