解决冲突

This commit is contained in:
2025-11-27 14:35:11 +08:00
28 changed files with 705 additions and 1059 deletions

View File

@@ -44,7 +44,7 @@
<view class="vip-card wallet_l">
<view class="assets">
<view @click="goVirtualList">
<view class="assets_row">天医币</view>
<view class="assets_row">{{ t('global.coin') }}</view>
<view>{{userInfo.peanutCoin ?? 1}}</view>
</view>
<view @click="goPointsList">
@@ -157,15 +157,12 @@
userStore.setUserInfo(userRes.result)
}
// 获取VIP信息
const vipRes = await getVipInfo()
if (vipRes.vipInfo) {
vipInfo.value = vipRes.vipInfo
}
} catch (error) {
console.error('获取数据失败:', error)
// 获取VIP信息
const vipRes = await getVipInfo()
if (vipRes.vipInfo) {
vipInfo.value = vipRes.vipInfo
}
}
}}
/**
* 跳转到设置页面

View File

@@ -27,7 +27,7 @@
<ProductInfo v-if="order.orderType === 'abroadBook'" :data="order.bookEntity" :type="order.orderType" />
<ProductInfo v-if="order.orderType === 'vip'" :data="order.vipBuyConfigEntity" :type="order.orderType" />
<!-- 三种订单类型商品信息 end -->
<view class="order-item-total-price">实付款{{ order.orderMoney }} 天医币</view>
<view class="order-item-total-price">实付款{{ order.orderMoney }} {{ t('global.coin') }}</view>
<template #footer>
<view>

View File

@@ -199,14 +199,10 @@ const avatarUrl = ref('')
*/
const userInfo = ref<any>({}) // 用户信息
const getData = async () => {
try {
const res = await getUserInfo()
if (res.result) {
userStore.setUserInfo(res.result)
userInfo.value = res.result
}
} catch (error) {
console.error('获取用户信息失败:', error)
const res = await getUserInfo()
if (res.result) {
userStore.setUserInfo(res.result)
userInfo.value = res.result
}
}
@@ -324,16 +320,12 @@ const sendCode = async () => {
return
}
try {
await sendEmailCode(editForm.value.email)
uni.showToast({
title: t('user.sendCodeSuccess'),
icon: 'none'
})
startCountdown()
} catch (error) {
console.error('发送验证码失败:', error)
}
await sendEmailCode(editForm.value.email)
uni.showToast({
title: t('user.sendCodeSuccess'),
icon: 'none'
})
startCountdown()
}
/**
@@ -398,92 +390,88 @@ const checkPasswordStrength = () => {
const handleSubmit = async () => {
const key = currentField.value?.key
try {
// 构建更新数据对象
let updateData: any = Object.assign({}, userInfo.value)
// 构建更新数据对象
let updateData: any = Object.assign({}, userInfo.value)
switch (key) {
case 'email':
// 更新邮箱
if (!editForm.value.email || !editForm.value.code) {
uni.showToast({
title: t('user.pleaseInputCode'),
icon: 'none'
})
return
}
await updateEmail(userInfo.value.id, editForm.value.email, editForm.value.code)
break
case 'password':
// 更新密码
if (!passwordOk.value) {
uni.showToast({
title: passwordNote.value,
icon: 'none'
})
return
}
if (editForm.value.password !== editForm.value.confirmPassword) {
uni.showToast({
title: t('user.passwordNotMatch'),
icon: 'none'
})
return
}
await updatePassword(userInfo.value.id, editForm.value.password)
break
case 'avatar':
// 更新头像
console.log('avatarUrl.value:', avatarUrl.value)
if (!avatarUrl.value) {
uni.showToast({
title: t('common.pleaseSelect') + t('user.avatar'),
icon: 'none'
})
return
}
// 如果是新上传的图片,需要先上传
updateData.avatar = avatarUrl.value
await updateUserInfo(updateData)
break
case 'sex':
// 更新性别
updateData.sex = editValue.value
await updateUserInfo(updateData)
break
default:
// 更新其他字段
if (!editValue.value) {
uni.showToast({
title: getPlaceholder(key),
icon: 'none'
})
return
}
updateData[key] = editValue.value
await updateUserInfo(updateData)
break
}
uni.showToast({
title: t('user.updateSuccess'),
icon: 'success'
})
closeModal()
// 刷新数据
setTimeout(() => {
getData()
}, 500)
} catch (error) {
console.error('更新失败:', error)
switch (key) {
case 'email':
// 更新邮箱
if (!editForm.value.email || !editForm.value.code) {
uni.showToast({
title: t('user.pleaseInputCode'),
icon: 'none'
})
return
}
await updateEmail(userInfo.value.id, editForm.value.email, editForm.value.code)
break
case 'password':
// 更新密码
if (!passwordOk.value) {
uni.showToast({
title: passwordNote.value,
icon: 'none'
})
return
}
if (editForm.value.password !== editForm.value.confirmPassword) {
uni.showToast({
title: t('user.passwordNotMatch'),
icon: 'none'
})
return
}
await updatePassword(userInfo.value.id, editForm.value.password)
break
case 'avatar':
// 更新头像
console.log('avatarUrl.value:', avatarUrl.value)
if (!avatarUrl.value) {
uni.showToast({
title: t('common.pleaseSelect') + t('user.avatar'),
icon: 'none'
})
return
}
// 如果是新上传的图片,需要先上传
updateData.avatar = avatarUrl.value
await updateUserInfo(updateData)
break
case 'sex':
// 更新性别
updateData.sex = editValue.value
await updateUserInfo(updateData)
break
default:
// 更新其他字段
if (!editValue.value) {
uni.showToast({
title: getPlaceholder(key),
icon: 'none'
})
return
}
updateData[key] = editValue.value
await updateUserInfo(updateData)
break
}
uni.showToast({
title: t('user.updateSuccess'),
icon: 'success'
})
closeModal()
// 刷新数据
setTimeout(() => {
getData()
}, 500)
}
/**