shuchang 3 tháng trước cách đây
mục cha
commit
592b47b6e5

+ 9 - 2
common/config/api.js

@@ -14,6 +14,14 @@ export const applyUrl = (params, config = {}) => http.post('/dev-api/care/applic
 export const getPersonListUrl = (data) => http.get('/dev-api/care/persons/list', data);
 // 获取所在医院列表
 export const getHospitalListUrl = (data) => http.get('/dev-api/care/hospital/list', data);
+// 上传
+export const uploadAvatarUrl = (params, config = {}) => http.upload('/dev-api/system/user/profile/avatar', params,
+	config);
+
+
+
+
+
 
 // 注册
 export const registerUrl = (params, config = {}) => http.post('/xc-order/api//order/user/register', params, config);
@@ -48,8 +56,7 @@ export const changePwdUrl = (params, config = {}) => http.put('/system/user/rese
 export const getVillageUrl = (data) => http.get('/system/user/deptTree', data);
 // 实名认证
 export const authUrl = (params, config = {}) => http.put('/system/user/realName', params, config);
-// 上传
-export const uploadImgUrl = (params, config = {}) => http.upload('/common/upload', params, config);
+
 // 新增助学申请
 export const addApplyUrl = (params, config = {}) => http.post('/deal/dmsStudyHelp', params, config);
 // 助学申请列表

+ 10 - 1
pages/subpack/pages/bindInfo/bindInfo.vue

@@ -108,6 +108,14 @@
 				if (!uni.$u.test.mobile(this.phone)) {
 					return uni.$u.toast('请输入正确的手机号码')
 				}
+
+				let avatar = '';
+				if (this.avatarImg.startsWith('/')) {
+					avatar = '';
+				} else {
+					avatar = this.avatarImg
+				}
+
 				uni.showLoading({
 					title: '用户认证中...'
 				})
@@ -115,7 +123,8 @@
 				bindInfoUrl({
 						params: {
 							openId: this.openId,
-							phone: this.phone
+							phone: this.phone,
+							avatar
 						}
 					})
 					.then(res => {

+ 29 - 4
pages/subpack/pages/myInfo/info.vue

@@ -2,13 +2,12 @@
 	<view>
 		<u-navbar class="u-navbar-box" title="个人信息" placeholder bgColor="transparent" autoBack />
 		<u-cell-group :border="false" :customStyle="{background: '#fff', margin: '30rpx',  borderRadius: '20rpx'}">
-			<u-cell title="头像" isLink>
+			<u-cell title="头像" isLink @click="changeAvatar">
 				<template #value>
-					<up-avatar size="116rpx" :src="vuex_user.avatar" defaultUrl="/static/mine/avatar-def.png"
-						bgColor="#305BFF" />
+					<up-avatar :src="vuex_user.avatar" defaultUrl="/static/mine/avatar-def.png" bgColor="#305BFF" />
 				</template>
 			</u-cell>
-			<u-cell title="姓名" isLink :border="false">
+			<u-cell title="姓名" :isLink="false" :border="false">
 				<template #value>
 					<view>{{vuex_user.nickName}}</view>
 				</template>
@@ -27,6 +26,9 @@
 </template>
 
 <script setup>
+	import {
+		uploadAvatarUrl
+	} from '@/common/config/api.js';
 	import {
 		onMounted,
 		ref,
@@ -48,6 +50,29 @@
 		nickName: ' '
 	})
 
+	const changeAvatar = () => {
+		// console.log('更换头像');
+		uni.chooseMedia({
+			count: 1,
+			mediaType: ['image'],
+			sizeType: ['compressed'],
+			success: (e) => {
+				console.log(e.tempFiles[0].tempFilePath);
+				uploadAvatarUrl({
+						avatarfile: e.tempFiles[0].tempFilePath,
+						filePath: e.tempFiles[0].tempFilePath,
+						name: 'file'
+					})
+					.then(res => {
+						console.log('您猜怎么着');
+					})
+					.catch(err => {
+						console.log('上传Err', err);
+					})
+			}
+		})
+	}
+
 	// 登出
 	const logout = () => {
 		uni.showModal({

+ 1 - 1
pages/tabbar/application/application.vue

@@ -83,7 +83,7 @@
 					.then(res => {
 						console.log('用户信息', res);
 						let user = {
-							avatar: this.vuex_user.avatar || '',
+							avatar: res.user.avatar,
 							nickName: res.user.nickName,
 							phonenumber: res.user.phonenumber,
 							roles: res.roles