修复已知问题
This commit is contained in:
@@ -5,6 +5,7 @@ import {ConfigProvider} from '@nutui/nutui-react-taro'
|
||||
import Taro, {getCurrentInstance} from '@tarojs/taro'
|
||||
import {getUserInfo, updateUserInfo} from "@/api/layout";
|
||||
import {TenantId} from "@/utils/config";
|
||||
import { TextArea } from '@nutui/nutui-react-taro'
|
||||
import './profile.scss'
|
||||
|
||||
const {router} = getCurrentInstance()
|
||||
@@ -12,7 +13,7 @@ import {
|
||||
Form,
|
||||
Button,
|
||||
Input,
|
||||
Radio
|
||||
Radio,
|
||||
} from '@nutui/nutui-react-taro'
|
||||
import {DictData} from "@/api/system/dict-data/model";
|
||||
import {pageDictData} from "@/api/system/dict-data";
|
||||
@@ -20,7 +21,6 @@ import {User} from "@/api/system/user/model";
|
||||
function Profile() {
|
||||
const formId = Number(router?.params.id)
|
||||
|
||||
const [form] = Form.useForm()
|
||||
const [sex, setSex] = useState<DictData[]>()
|
||||
const [FormData, setFormData] = useState<User>(
|
||||
{
|
||||
@@ -34,12 +34,7 @@ function Profile() {
|
||||
comments: undefined
|
||||
}
|
||||
)
|
||||
const [user, setUser] = useState<any>({
|
||||
nickname: '',
|
||||
avatar: undefined,
|
||||
username: '',
|
||||
mobile: ''
|
||||
})
|
||||
|
||||
const reload = () => {
|
||||
// 获取数据字典
|
||||
pageDictData({limit: 200}).then(res => {
|
||||
@@ -47,8 +42,8 @@ function Profile() {
|
||||
})
|
||||
// 获取用户信息
|
||||
getUserInfo().then((data) => {
|
||||
setUser(data)
|
||||
setFormData(data)
|
||||
// 更新表单数据
|
||||
setFormData(data);
|
||||
})
|
||||
}
|
||||
|
||||
@@ -60,7 +55,7 @@ function Profile() {
|
||||
Taro.showToast({title: `保存成功`, icon: 'success'})
|
||||
setTimeout(() => {
|
||||
return Taro.navigateBack()
|
||||
},1000)
|
||||
}, 1000)
|
||||
}).catch(() => {
|
||||
Taro.showToast({
|
||||
title: '保存失败',
|
||||
@@ -73,8 +68,8 @@ function Profile() {
|
||||
}
|
||||
|
||||
const uploadAvatar = ({detail}) => {
|
||||
setUser({
|
||||
...user,
|
||||
setFormData({
|
||||
...FormData,
|
||||
avatar: `${detail.avatarUrl}`,
|
||||
})
|
||||
Taro.uploadFile({
|
||||
@@ -89,7 +84,7 @@ function Profile() {
|
||||
const data = JSON.parse(res.data);
|
||||
if (data.code === 0) {
|
||||
updateUserInfo({
|
||||
userId: user.userId,
|
||||
userId: FormData?.userId,
|
||||
avatar: `${data.data.thumbnail}`
|
||||
}).then(() => {
|
||||
Taro.showToast({
|
||||
@@ -101,9 +96,18 @@ function Profile() {
|
||||
})
|
||||
}
|
||||
|
||||
// 获取微信昵称
|
||||
const getWxNickname = (nickname: string) => {
|
||||
// 更新表单数据
|
||||
setFormData({
|
||||
...FormData,
|
||||
nickname: nickname
|
||||
});
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
reload()
|
||||
}, [form]);
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<>
|
||||
@@ -112,13 +116,13 @@ function Profile() {
|
||||
<Cell title={'头像'} align={'center'} extra={
|
||||
<>
|
||||
<Button open-type="chooseAvatar" style={{height: '58px'}} onChooseAvatar={uploadAvatar}>
|
||||
<Avatar src={user.avatar} size="54"/>
|
||||
<Avatar src={FormData?.avatar} size="54"/>
|
||||
</Button>
|
||||
<ArrowRight color="#cccccc" className={'ml-1'} size={20}/>
|
||||
</>
|
||||
}
|
||||
/>
|
||||
<Cell title={'手机号码'} align={'center'} extra={user.mobile}/>
|
||||
<Cell title={'手机号码'} align={'center'} extra={FormData?.phone}/>
|
||||
</Cell.Group>
|
||||
<ConfigProvider>
|
||||
<Form
|
||||
@@ -145,17 +149,15 @@ function Profile() {
|
||||
label={'昵称'}
|
||||
name="nickname"
|
||||
initialValue={FormData.nickname}
|
||||
rules={[{message: '请输入昵称'}]}
|
||||
rules={[{message: '请获取微信昵称'}]}
|
||||
>
|
||||
<Input placeholder="请输入昵称" type="text"/>
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
label={'真实姓名'}
|
||||
name="realName"
|
||||
initialValue={FormData.realName}
|
||||
rules={[{message: '请输入真实姓名'}]}
|
||||
>
|
||||
<Input placeholder="请输入真实姓名或单位名称" type="text"/>
|
||||
<Input
|
||||
type="nickname"
|
||||
className="info-content__input"
|
||||
placeholder="请输入昵称"
|
||||
value={FormData?.nickname}
|
||||
onInput={(e) => getWxNickname(e.detail.value)}
|
||||
/>
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
label="性别"
|
||||
@@ -165,7 +167,7 @@ function Profile() {
|
||||
{message: '请选择性别'}
|
||||
]}
|
||||
>
|
||||
<Radio.Group defaultValue={FormData.sex} direction="horizontal">
|
||||
<Radio.Group value={FormData?.sex} direction="horizontal">
|
||||
{
|
||||
sex?.map((item, index) => (
|
||||
<Radio key={index} value={item.dictDataCode}>
|
||||
@@ -175,20 +177,17 @@ function Profile() {
|
||||
}
|
||||
</Radio.Group>
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
label={'联系地址'}
|
||||
name="address"
|
||||
initialValue={FormData.address}
|
||||
rules={[{message: '请输入联系地址'}]}
|
||||
>
|
||||
<Input placeholder="请输入联系地址" type="text"/>
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
label="备注信息"
|
||||
name="comments"
|
||||
initialValue={FormData.comments}
|
||||
rules={[{message: '备注信息'}]}
|
||||
>
|
||||
<TextArea
|
||||
placeholder={'个性签名'}
|
||||
value={FormData?.comments}
|
||||
onChange={(value) => setFormData({...FormData, comments: value})}
|
||||
/>
|
||||
<Input placeholder={'个性签名'} />
|
||||
</Form.Item>
|
||||
</Form>
|
||||
|
||||
Reference in New Issue
Block a user