|
@@ -2,18 +2,15 @@
|
|
|
{
|
|
|
layout: 'default',
|
|
|
style: {
|
|
|
- navigationBarTitleText: 'My Profile',
|
|
|
+ navigationBarTitleText: '%myProfile.title%',
|
|
|
navigationBarBackgroundColor: '#fff',
|
|
|
},
|
|
|
}
|
|
|
</route>
|
|
|
|
|
|
<script lang="ts" setup>
|
|
|
-// 必须导入需要用到的页面生命周期(即使在当前页面上没有直接使用到)
|
|
|
-// eslint-disable-next-line unused-imports/no-unused-imports
|
|
|
-import { onPageScroll, onReachBottom } from '@dcloudio/uni-app'
|
|
|
-import useZPaging from 'z-paging/components/z-paging/js/hooks/useZPaging.js'
|
|
|
import { updateInfo } from '@/api/login'
|
|
|
+import { t } from '@/locale'
|
|
|
import { useUserStore } from '@/store'
|
|
|
import { getEnvBaseUploadUrl } from '@/utils'
|
|
|
import { toast } from '@/utils/toast'
|
|
@@ -27,11 +24,6 @@ const userInfo = computed(() => {
|
|
|
return getUserInfoHook()
|
|
|
})
|
|
|
|
|
|
-// z-paging
|
|
|
-const paging = ref(null)
|
|
|
-// 类似mixins,如果是页面滚动务必要写这一行,并传入当前ref绑定的paging,注意此处是paging,而非paging.value
|
|
|
-useZPaging(paging)
|
|
|
-
|
|
|
const uploading = ref(false)
|
|
|
|
|
|
// 更新头像
|
|
@@ -58,13 +50,13 @@ async function updateAvatar() {
|
|
|
// 检查文件大小(限制为5MB)
|
|
|
const maxSize = 5 * 1024 * 1024
|
|
|
if (tempFile.size > maxSize) {
|
|
|
- toast.error('Image size cannot exceed 5MB')
|
|
|
+ toast.error(t('myProfile.upload.sizeLimit'))
|
|
|
return
|
|
|
}
|
|
|
|
|
|
uploading.value = true
|
|
|
await uni.showLoading({
|
|
|
- title: 'Uploading...',
|
|
|
+ title: t('myProfile.upload.uploading'),
|
|
|
mask: true,
|
|
|
})
|
|
|
|
|
@@ -82,7 +74,7 @@ async function updateAvatar() {
|
|
|
// 解析上传结果
|
|
|
const uploadData = JSON.parse(uploadRes.data)
|
|
|
if (uploadData.code !== 200) {
|
|
|
- throw new Error(uploadData.message || 'Upload failed')
|
|
|
+ throw new Error(uploadData.message)
|
|
|
}
|
|
|
|
|
|
const avatarUrl = uploadData.data.url
|
|
@@ -95,12 +87,12 @@ async function updateAvatar() {
|
|
|
userStore.setUserInfo(newUserInfo)
|
|
|
|
|
|
uni.hideLoading()
|
|
|
- toast.success('Avatar updated successfully')
|
|
|
+ toast.success(t('myProfile.upload.success'))
|
|
|
}
|
|
|
catch (error: any) {
|
|
|
uni.hideLoading()
|
|
|
console.error('Update avatar failed:', error)
|
|
|
- toast.error(error.message || 'Failed to update avatar')
|
|
|
+ toast.error(error.message || t('myProfile.upload.error'))
|
|
|
}
|
|
|
finally {
|
|
|
uploading.value = false
|
|
@@ -109,10 +101,10 @@ async function updateAvatar() {
|
|
|
</script>
|
|
|
|
|
|
<template>
|
|
|
- <z-paging ref="paging" refresher-only use-page-scroll>
|
|
|
+ <z-paging>
|
|
|
<view class="py-20rpx">
|
|
|
<wd-cell-group custom-class="mb-20rpx" border>
|
|
|
- <wd-cell title="Avatar" center>
|
|
|
+ <wd-cell :title="t('myProfile.avatar')" center>
|
|
|
<view class="flex items-center justify-end" @click="updateAvatar">
|
|
|
<view class="relative flex items-center justify-center">
|
|
|
<wd-img width="64rpx" height="64rpx" round :src="userInfo.headPic" />
|
|
@@ -123,14 +115,14 @@ async function updateAvatar() {
|
|
|
<wd-icon name="arrow-right" custom-class="ml-10rpx" size="36rpx" />
|
|
|
</view>
|
|
|
</wd-cell>
|
|
|
- <wd-cell title="User ID" :value="userInfo.userId" />
|
|
|
- <wd-cell title="User Name" :value="userInfo.name" />
|
|
|
- <wd-cell title="Mobile Number" :value="userInfo.phoneNo" />
|
|
|
+ <wd-cell :title="t('myProfile.userId')" :value="userInfo.userId" />
|
|
|
+ <wd-cell :title="t('myProfile.userName')" :value="userInfo.name" />
|
|
|
+ <wd-cell :title="t('myProfile.mobileNumber')" :value="userInfo.phoneNo" />
|
|
|
</wd-cell-group>
|
|
|
<wd-cell-group custom-class="mb-20rpx" border>
|
|
|
- <wd-cell title="Bank Name" :value="userInfo.bank" />
|
|
|
- <wd-cell title="Bank Account Name" :value="userInfo.bankAccountName" />
|
|
|
- <wd-cell title="Bank Account No." :value="userInfo.bankAccount" />
|
|
|
+ <wd-cell :title="t('myProfile.bankName')" :value="userInfo.bank" />
|
|
|
+ <wd-cell :title="t('myProfile.bankAccountName')" :value="userInfo.bankAccountName" />
|
|
|
+ <wd-cell :title="t('myProfile.bankAccountNo')" :value="userInfo.bankAccount" />
|
|
|
</wd-cell-group>
|
|
|
</view>
|
|
|
</z-paging>
|