|
@@ -2,7 +2,7 @@ import { useState, useEffect } from 'react'
|
2
|
2
|
import Taro from '@tarojs/taro'
|
3
|
3
|
import { useSelector } from 'react-redux'
|
4
|
4
|
import withLayout from '@/layout'
|
5
|
|
-import { ScrollView, Input, Image } from '@tarojs/components'
|
|
5
|
+import { ScrollView, Input, Image, Block, Textarea } from '@tarojs/components'
|
6
|
6
|
import { getImgURL } from '@/utils/image'
|
7
|
7
|
import { fetch, uploadFiles } from '@/utils/request'
|
8
|
8
|
import { UPDATE_USER_INFO, ROLE_CODE } from '@/constants/user'
|
|
@@ -20,28 +20,35 @@ export default withLayout(() => {
|
20
|
20
|
const [UserRole, setUserRole] = useState(null) // 1-普通用户 2-经纪人 3-置业顾问 4-驻场管理
|
21
|
21
|
const [FormData, setFormData] = useState({
|
22
|
22
|
name: '',
|
23
|
|
- phone: ''
|
|
23
|
+ phone: '',
|
|
24
|
+ description: ''
|
24
|
25
|
})
|
25
|
26
|
|
26
|
27
|
useEffect(() => {
|
27
|
28
|
if (user?.userInfo?.person?.personId) {
|
28
|
29
|
const person = user.userInfo.person
|
29
|
|
- setUserRole(person.personType === ROLE_CODE.CUSTOMER || person.personType === ROLE_CODE.DRIFT ? 1 : person.personType === ROLE_CODE.CHANNEL_AGENT ? 2 : person.personType === ROLE_CODE.CONSULTANT ? 3 : 4)
|
|
30
|
+ setUserRole(person.personType === ROLE_CODE.CHANNEL_AGENT ? 2 : person.personType === ROLE_CODE.CONSULTANT ? 3 : person.personType === ROLE_CODE.MARKETING ? 4 : 1)
|
30
|
31
|
}
|
31
|
32
|
}, [user])
|
32
|
33
|
|
33
|
34
|
useEffect(() => {
|
34
|
35
|
setUserInfo(user?.userInfo?.person)
|
35
|
|
- setFormData({ name: user?.userInfo?.person.name, phone: user?.userInfo?.person.phone })
|
|
36
|
+ setFormData({ name: user?.userInfo?.person.name, phone: user?.userInfo?.person.phone, description: user?.userInfo?.person.description })
|
36
|
37
|
}, [user])
|
37
|
38
|
|
38
|
39
|
const Save = () => {
|
39
|
|
- fetch({ url: `${API_EDIT_AGENT}?name=${FormData.name}&phone=${FormData.phone}`, method: 'put' }).then(() => {
|
|
40
|
+ let params = ''
|
|
41
|
+ if(UserRole === 3) {
|
|
42
|
+ params = `name=${FormData.name}&phone=${FormData.phone}&description=${FormData.description}`
|
|
43
|
+ } else {
|
|
44
|
+ params = `name=${FormData.name}&phone=${FormData.phone}`
|
|
45
|
+ }
|
|
46
|
+ fetch({ url: `${API_EDIT_AGENT}?${params}`, method: 'put' }).then(() => {
|
40
|
47
|
Taro.showToast({
|
41
|
48
|
title: '修改成功',
|
42
|
49
|
icon: 'none'
|
43
|
50
|
})
|
44
|
|
- dispatch({ type: UPDATE_USER_INFO, payload: { name: FormData.name, phone: FormData.phone } })
|
|
51
|
+ dispatch({ type: UPDATE_USER_INFO, payload: { name: FormData.name, phone: FormData.phone, description: FormData.description } })
|
45
|
52
|
// login({ path: '', scene: '' })
|
46
|
53
|
})
|
47
|
54
|
}
|
|
@@ -53,7 +60,7 @@ export default withLayout(() => {
|
53
|
60
|
}
|
54
|
61
|
|
55
|
62
|
const ToUploadImg = () => {
|
56
|
|
- if(UserRole - 0 === 3) {
|
|
63
|
+ if (UserRole - 0 === 3) {
|
57
|
64
|
Taro.chooseImage({
|
58
|
65
|
count: 1,
|
59
|
66
|
success: function (res) {
|
|
@@ -102,6 +109,18 @@ export default withLayout(() => {
|
102
|
109
|
</view>
|
103
|
110
|
</view>
|
104
|
111
|
|
|
112
|
+ {
|
|
113
|
+ true &&
|
|
114
|
+ <Block>
|
|
115
|
+ <text>简介</text>
|
|
116
|
+ <view className='FormLine flex-h'>
|
|
117
|
+ <view className='flex-item'>
|
|
118
|
+ <Textarea auto-height placeholder='请输入简介' value={FormData.description} onInput={FormChange.bind(this, 'description')} />
|
|
119
|
+ </view>
|
|
120
|
+ </view>
|
|
121
|
+ </Block>
|
|
122
|
+ }
|
|
123
|
+
|
105
|
124
|
</view>
|
106
|
125
|
|
107
|
126
|
<view className='Btn'>
|