【移动端】修复头像上传bug
This commit is contained in:
parent
f1a80f7c5e
commit
caea6872a6
|
|
@ -3,8 +3,7 @@
|
||||||
<!-- 头部修改头像 -->
|
<!-- 头部修改头像 -->
|
||||||
<view class="header bg-white pt-[30rpx]">
|
<view class="header bg-white pt-[30rpx]">
|
||||||
<view class="flex justify-center">
|
<view class="flex justify-center">
|
||||||
<image @click="uploaderAvatar"
|
<image @click="uploaderAvatar" :src="userInfo?.avatar"></image>
|
||||||
:src="userInfo?.avatar ? userInfo?.avatar : '/static/images/icon_default_user.png'"></image>
|
|
||||||
</view>
|
</view>
|
||||||
<view class="mt-[20rpx] text-center text-muted text-xs" @click="uploaderAvatar">点击修改头像</view>
|
<view class="mt-[20rpx] text-center text-muted text-xs" @click="uploaderAvatar">点击修改头像</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
@ -242,8 +241,8 @@
|
||||||
|
|
||||||
// 修改用户账号
|
// 修改用户账号
|
||||||
const changeUserNameConfirm = () => {
|
const changeUserNameConfirm = () => {
|
||||||
if (newUsername.value == '') return toast('账号不能为空')
|
if (newUsername.value == '') return uni.$u.toast('账号不能为空')
|
||||||
if (newUsername.value.length > 10) return toast('账号长度不得超过十位数')
|
if (newUsername.value.length > 10) return uni.$u.toast('账号长度不得超过十位数')
|
||||||
|
|
||||||
fieldType.value = FieldType.USERNAME
|
fieldType.value = FieldType.USERNAME
|
||||||
setUserInfoFun(newUsername.value)
|
setUserInfoFun(newUsername.value)
|
||||||
|
|
@ -252,8 +251,8 @@
|
||||||
|
|
||||||
// 修改用户昵称
|
// 修改用户昵称
|
||||||
const changeNameConfirm = () => {
|
const changeNameConfirm = () => {
|
||||||
if (newNickname.value == '') return toast('昵称不能为空')
|
if (newNickname.value == '') return uni.$u.toast('昵称不能为空')
|
||||||
if (newNickname.value.length > 10) return toast('昵称长度不得超过十位数')
|
if (newNickname.value.length > 10) return uni.$u.toast('昵称长度不得超过十位数')
|
||||||
showNickName.value = false
|
showNickName.value = false
|
||||||
fieldType.value = FieldType.NICKNAME
|
fieldType.value = FieldType.NICKNAME
|
||||||
setUserInfoFun(newNickname.value)
|
setUserInfoFun(newNickname.value)
|
||||||
|
|
@ -295,11 +294,11 @@
|
||||||
uploadFile(path)
|
uploadFile(path)
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
uni.hideLoading()
|
uni.hideLoading()
|
||||||
setUserInfoFun(res.uri)
|
setUserInfoFun(res.url)
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
uni.hideLoading()
|
uni.hideLoading()
|
||||||
toast('上传失败')
|
uni.$u.toast('上传失败')
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -113,7 +113,7 @@ export function uploadFile(path: any) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
const token = getToken()
|
const token = getToken()
|
||||||
uni.uploadFile({
|
uni.uploadFile({
|
||||||
url: `${import.meta.env.VITE_APP_BASE_URL}/api/Upload/image`,
|
url: `${import.meta.env.VITE_APP_BASE_URL}/api/upload/image`,
|
||||||
filePath: path,
|
filePath: path,
|
||||||
name: 'file',
|
name: 'file',
|
||||||
header: {
|
header: {
|
||||||
|
|
@ -123,7 +123,8 @@ export function uploadFile(path: any) {
|
||||||
success: (res) => {
|
success: (res) => {
|
||||||
console.log('uploadFile res ==> ', res)
|
console.log('uploadFile res ==> ', res)
|
||||||
const data = JSON.parse(res.data)
|
const data = JSON.parse(res.data)
|
||||||
if (data.code == 1) {
|
console.log('data.code', data.code)
|
||||||
|
if (data.code == 200) {
|
||||||
resolve(data.data)
|
resolve(data.data)
|
||||||
} else {
|
} else {
|
||||||
reject()
|
reject()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue