- 将获取 STS Token 的接口地址由 paopao-api 改为 guilixu-api - 更新图片上传接口地址为新的 guilixu-api 域名 - 修改用户推广页面中邀请码链接和二维码接口的域名 - 更改注册页微信登录接口请求的域名为 guilixu-api
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
|