- 新增地址类型定义,增强前端地址数据结构 - 新增地址编辑页面,支持地址智能识别和定位选点功能 - 地址编辑支持省市区选择及默认地址设置 - 新增地址列表页面,支持地址展示、删除、编辑和选择功能 - 实现售后申请页面,支持选择售后类型和退款原因 - 售后申请支持商品选择、退款金额计算和凭证上传 - 新增售后详情页面,支持售后状态展示及申请取消 - 优化页面加载和用户交互体验,增加错误提示和权限处理
83 lines
2.0 KiB
TypeScript
83 lines
2.0 KiB
TypeScript
import {useEffect, useState} from "react";
|
|
import Taro from '@tarojs/taro'
|
|
import { View } from '@tarojs/components'
|
|
import {Input, Button,Form} from '@nutui/nutui-react-taro'
|
|
|
|
const Setting = () => {
|
|
const [FormData, setFormData] = useState<any>(
|
|
{
|
|
domain: undefined
|
|
}
|
|
)
|
|
|
|
// 提交表单
|
|
const submitSucceed = (values: any) => {
|
|
if(values.domain){
|
|
Taro.setStorageSync('ServerUrl',values.domain)
|
|
setFormData({
|
|
domain: values.domain
|
|
})
|
|
Taro.showToast({
|
|
title: '保存成功',
|
|
icon: 'success'
|
|
});
|
|
setTimeout(() => {
|
|
Taro.navigateBack()
|
|
},500)
|
|
}
|
|
}
|
|
|
|
const submitFailed = (error: any) => {
|
|
// Taro.showToast({ title: error[0].message, icon: 'error' })
|
|
}
|
|
const reload = () => {
|
|
// setting 页面不是 tabBar 页面,无需调用 hideTabBar
|
|
if (Taro.getStorageSync('ServerUrl')) {
|
|
setFormData({
|
|
domain: Taro.getStorageSync('ServerUrl')
|
|
})
|
|
}
|
|
}
|
|
|
|
useEffect(() => {
|
|
reload()
|
|
}, [])
|
|
|
|
return (
|
|
<>
|
|
<Form
|
|
divider
|
|
initialValues={FormData}
|
|
labelPosition='left'
|
|
onFinish={(values) => submitSucceed(values)}
|
|
onFinishFailed={(errors) => submitFailed(errors)}
|
|
footer={
|
|
<View
|
|
style={{
|
|
display: 'flex',
|
|
justifyContent: 'center',
|
|
width: '100%'
|
|
}}
|
|
>
|
|
<Button nativeType='submit' block type='info' size='large'>
|
|
保存
|
|
</Button>
|
|
</View>
|
|
}
|
|
>
|
|
<View className='flex flex-col justify-center pt-3'>
|
|
<View className='text-sm py-1 px-4'>服务域名</View>
|
|
<Form.Item
|
|
name='domain'
|
|
initialValue={FormData.domain}
|
|
rules={[{message: '请输入服务域名'}]}
|
|
>
|
|
<Input placeholder='https://domain.com/api' type='text' style={{backgroundColor: '#f5f5f5', borderRadius: '8px', padding: '5px 10px'}} />
|
|
</Form.Item>
|
|
</View>
|
|
</Form>
|
|
</>
|
|
)
|
|
}
|
|
export default Setting
|