|
@@ -2,7 +2,7 @@
|
|
|
{
|
|
|
layout: 'default',
|
|
|
style: {
|
|
|
- navigationBarTitleText: 'Address Book',
|
|
|
+ navigationBarTitleText: '%addressBook.title%',
|
|
|
navigationBarBackgroundColor: '#fff',
|
|
|
},
|
|
|
}
|
|
@@ -15,6 +15,7 @@ import { onPageScroll, onReachBottom } from '@dcloudio/uni-app'
|
|
|
import useZPaging from 'z-paging/components/z-paging/js/hooks/useZPaging.js'
|
|
|
import { divisionsTreeList } from '@/api/common'
|
|
|
import { addressAdd, addressDetail, addressUpdate } from '@/api/mine'
|
|
|
+import { t } from '@/locale'
|
|
|
import { getPageParams, goBack } from '@/utils/page'
|
|
|
import { toast } from '@/utils/toast'
|
|
|
|
|
@@ -97,7 +98,7 @@ const originalAddressData = ref<any>(null)
|
|
|
async function getAddressDetail() {
|
|
|
try {
|
|
|
await uni.showLoading({
|
|
|
- title: 'Loading...',
|
|
|
+ title: t('addressBook.operate.loading'),
|
|
|
})
|
|
|
|
|
|
const res = await addressDetail({ id: addressId.value })
|
|
@@ -130,12 +131,12 @@ async function getAddressDetail() {
|
|
|
console.log('Display text:', addressDisplayText.value)
|
|
|
}
|
|
|
else {
|
|
|
- toast.error(res.message || 'Failed to load address details')
|
|
|
+ toast.error(res.message || t('addressBook.operate.error.loadFailed'))
|
|
|
}
|
|
|
}
|
|
|
catch (error: any) {
|
|
|
console.error('Get address detail error:', error)
|
|
|
- toast.error(error.message || 'Failed to load address details')
|
|
|
+ toast.error(error.message || t('addressBook.operate.error.loadFailed'))
|
|
|
}
|
|
|
finally {
|
|
|
uni.hideLoading()
|
|
@@ -147,34 +148,34 @@ async function save() {
|
|
|
try {
|
|
|
// 自定义校验
|
|
|
if (!model.value.realName?.trim()) {
|
|
|
- toast.info('Please enter full name')
|
|
|
+ toast.info(t('addressBook.operate.error.emptyName'))
|
|
|
return
|
|
|
}
|
|
|
|
|
|
if (!model.value.phone?.trim()) {
|
|
|
- toast.info('Please enter phone number')
|
|
|
+ toast.info(t('addressBook.operate.error.emptyPhone'))
|
|
|
return
|
|
|
}
|
|
|
|
|
|
// 在新增模式下必须选择地址,编辑模式下可以使用原有地址
|
|
|
if (!isEditMode.value && (!model.value.areaCodes || model.value.areaCodes.length === 0)) {
|
|
|
- toast.info('Please select province/district')
|
|
|
+ toast.info(t('addressBook.operate.error.emptyDistrict'))
|
|
|
return
|
|
|
}
|
|
|
|
|
|
if (!model.value.detail?.trim()) {
|
|
|
- toast.info('Please enter detailed address')
|
|
|
+ toast.info(t('addressBook.operate.error.emptyStreet'))
|
|
|
return
|
|
|
}
|
|
|
|
|
|
if (!model.value.postCode?.trim()) {
|
|
|
- toast.info('Please enter postcode')
|
|
|
+ toast.info(t('addressBook.operate.error.emptyPostcode'))
|
|
|
return
|
|
|
}
|
|
|
|
|
|
// 显示加载提示
|
|
|
await uni.showLoading({
|
|
|
- title: 'Saving...',
|
|
|
+ title: t('addressBook.operate.saving'),
|
|
|
})
|
|
|
|
|
|
// 处理地址数据
|
|
@@ -221,7 +222,7 @@ async function save() {
|
|
|
uni.hideLoading()
|
|
|
|
|
|
if (res.code === '200') {
|
|
|
- toast.success(isEditMode.value ? 'Address updated successfully' : 'Address saved successfully')
|
|
|
+ toast.success(isEditMode.value ? t('addressBook.operate.success.update') : t('addressBook.operate.success.save'))
|
|
|
|
|
|
// 延迟返回上一页
|
|
|
setTimeout(() => {
|
|
@@ -229,13 +230,13 @@ async function save() {
|
|
|
}, 1500)
|
|
|
}
|
|
|
else {
|
|
|
- toast.error(res.message || 'Save failed, please try again')
|
|
|
+ toast.error(res.message || t('addressBook.operate.error.saveFailed'))
|
|
|
}
|
|
|
}
|
|
|
catch (error: any) {
|
|
|
uni.hideLoading()
|
|
|
console.error('Save address error:', error)
|
|
|
- toast.error(error.message || 'Save failed, please try again')
|
|
|
+ toast.error(error.message || t('addressBook.operate.error.saveFailed'))
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -253,7 +254,7 @@ onLoad(async (options: any) => {
|
|
|
addressId.value = params.id
|
|
|
// 设置页面标题
|
|
|
uni.setNavigationBarTitle({
|
|
|
- title: 'Edit Address',
|
|
|
+ title: t('addressBook.operate.title.edit'),
|
|
|
})
|
|
|
// 获取地址详情
|
|
|
await getAddressDetail()
|
|
@@ -261,7 +262,7 @@ onLoad(async (options: any) => {
|
|
|
else {
|
|
|
// 新增模式
|
|
|
uni.setNavigationBarTitle({
|
|
|
- title: 'Add Address',
|
|
|
+ title: t('addressBook.operate.title.add'),
|
|
|
})
|
|
|
}
|
|
|
}
|
|
@@ -279,28 +280,28 @@ onLoad(async (options: any) => {
|
|
|
<wd-cell-group>
|
|
|
<wd-input
|
|
|
v-model="model.realName"
|
|
|
- label="Full Name"
|
|
|
+ :label="t('addressBook.operate.form.fullName')"
|
|
|
label-width="240rpx"
|
|
|
custom-label-class="text-28rpx"
|
|
|
clearable
|
|
|
- placeholder="Full Name"
|
|
|
+ :placeholder="t('addressBook.operate.form.fullName')"
|
|
|
required
|
|
|
/>
|
|
|
<wd-input
|
|
|
v-model="model.phone"
|
|
|
- label="Phone Number"
|
|
|
+ :label="t('addressBook.operate.form.phone')"
|
|
|
label-width="240rpx"
|
|
|
custom-label-class="text-28rpx"
|
|
|
clearable
|
|
|
- placeholder="+88"
|
|
|
+ :placeholder="t('addressBook.operate.form.phone.placeholder')"
|
|
|
required
|
|
|
/>
|
|
|
- <wd-cell title="Privince/District" required vertical>
|
|
|
+ <wd-cell :title="t('addressBook.operate.form.district')" required vertical>
|
|
|
<wd-col-picker
|
|
|
v-model="model.areaCodes"
|
|
|
:columns="area"
|
|
|
clearable
|
|
|
- placeholder="Please choose"
|
|
|
+ :placeholder="t('addressBook.operate.form.district.placeholder')"
|
|
|
value-key="name"
|
|
|
label-key="name"
|
|
|
:column-change="columnChange"
|
|
@@ -311,24 +312,24 @@ onLoad(async (options: any) => {
|
|
|
/>
|
|
|
</wd-cell>
|
|
|
|
|
|
- <wd-cell title="Floor/Unit No./Street" vertical required>
|
|
|
+ <wd-cell :title="t('addressBook.operate.form.street')" vertical required>
|
|
|
<wd-textarea
|
|
|
v-model="model.detail"
|
|
|
clearable
|
|
|
auto-height
|
|
|
- placeholder="Detailed address"
|
|
|
+ :placeholder="t('addressBook.operate.form.street.placeholder')"
|
|
|
/>
|
|
|
</wd-cell>
|
|
|
<wd-input
|
|
|
v-model="model.postCode"
|
|
|
- label="Postcode"
|
|
|
+ :label="t('addressBook.operate.form.postcode')"
|
|
|
label-width="240rpx"
|
|
|
custom-label-class="text-28rpx"
|
|
|
clearable
|
|
|
- placeholder="Your postcode"
|
|
|
+ :placeholder="t('addressBook.operate.form.postcode.placeholder')"
|
|
|
required
|
|
|
/>
|
|
|
- <wd-cell title="Default">
|
|
|
+ <wd-cell :title="t('addressBook.operate.form.default')">
|
|
|
<wd-switch v-model="model.isDefault" :active-value="1" :inactive-value="0" size="42rpx" />
|
|
|
</wd-cell>
|
|
|
</wd-cell-group>
|
|
@@ -337,7 +338,7 @@ onLoad(async (options: any) => {
|
|
|
<template #bottom>
|
|
|
<view class="bg-white/60 px-28rpx py-30rpx backdrop-blur-20">
|
|
|
<wd-button plain block @click="save">
|
|
|
- {{ isEditMode ? 'Update' : 'Save' }}
|
|
|
+ {{ isEditMode ? t('addressBook.operate.button.update') : t('addressBook.operate.button.save') }}
|
|
|
</wd-button>
|
|
|
</view>
|
|
|
</template>
|