Your Name преди 3 години
родител
ревизия
4e8f031ecb
променени са 5 файла, в които са добавени 125 реда и са изтрити 15 реда
  1. 12
    1
      src/components/Picker/index.jsx
  2. 1
    0
      src/constants/api.js
  3. 2
    2
      src/pages/index/activityDetail/index.jsx
  4. 1
    1
      src/pages/mine/addCustomer/index.jsx
  5. 109
    11
      src/pages/mine/sureVisit/index.jsx

+ 12
- 1
src/components/Picker/index.jsx Целия файл

@@ -3,13 +3,18 @@ import { Picker, View } from '@tarojs/components'
3 3
 import './style.scss'
4 4
 
5 5
 export default (props) => {
6
-  const { kv, value, onChange, dicts, placeholder, ...leftProps } = props
6
+  const { kv, value, onChange, dicts, placeholder, mode, ...leftProps } = props
7 7
   const [rangeKey, rangeVal] = kv || ['label', 'value']
8 8
 
9 9
   const [inx, setInx] = useState()
10 10
   const [text, setText] = useState()
11 11
 
12 12
   const handleChange = (e) => {
13
+    if (mode && mode !== 'selector') {
14
+      onChange(e.detail.value)
15
+      return
16
+    }
17
+
13 18
     const index = e.detail.value - 0
14 19
     const item = dicts[index]
15 20
     if (onChange) {
@@ -31,6 +36,12 @@ export default (props) => {
31 36
     }
32 37
   }, [dicts, rangeKey, rangeVal, value])
33 38
 
39
+  useEffect(() => {
40
+    if (mode && mode !== 'selector') {
41
+      setText(value)
42
+    }
43
+  }, [mode, value])
44
+
34 45
   return (
35 46
     <Picker
36 47
       className='g-picker'

+ 1
- 0
src/constants/api.js Целия файл

@@ -138,6 +138,7 @@ export const API_CHANNEL_REPORT = resolvePath('channel/report')
138 138
 export const API_MANAGE_CUSTOMER_LIST = resolvePath('marking/customers')
139 139
 export const API_TOBE_MANAGER = resolvePath('marketing')
140 140
 export const API_MY_BUILDINGIDS = resolvePath('building/mine')
141
+export const API_MARKETING_VISIT = resolvePath('marketing/visit')
141 142
 
142 143
 
143 144
 // report

+ 2
- 2
src/pages/index/activityDetail/index.jsx Целия файл

@@ -212,8 +212,8 @@ export default withLayout((props) => {
212 212
             <Button open-type='share' className='ShareBtn'>分享</Button>
213 213
           </view>
214 214
           <view>
215
-            <text className='iconfont icon-haibao'></text>
216
-            <text>海报</text>
215
+            <text className='iconfont icon-pengyouquan1'></text>
216
+            <text>朋友圈</text>
217 217
           </view>
218 218
         </view>
219 219
       </view>

+ 1
- 1
src/pages/mine/addCustomer/index.jsx Целия файл

@@ -96,7 +96,7 @@ export default withLayout((props) => {
96 96
       const t = setTimeout(() => {
97 97
         Taro.navigateBack({ delta: 1 })
98 98
         clearTimeout(t)
99
-      }, 2000)
99
+      }, 1500)
100 100
     }).catch((err) => {
101 101
       console.error(err)
102 102
       setLoading(false)

+ 109
- 11
src/pages/mine/sureVisit/index.jsx Целия файл

@@ -1,44 +1,141 @@
1 1
 import React, { useState, useEffect } from 'react'
2
+import Taro from '@tarojs/taro'
2 3
 import withLayout from '@/layout'
3
-import './index.scss'
4
-import { ScrollView, Input } from '@tarojs/components'
4
+import { ScrollView, Input, Image } from '@tarojs/components'
5
+import Picker from '@/components/Picker'
6
+import { getChannelCustomerDetail } from '@/services/person'
7
+import { getCardList } from '@/services/card'
8
+import { uploadFiles, fetch } from '@/utils/request'
9
+import { API_MARKETING_VISIT } from '@/constants/api'
5 10
 import '@/assets/css/iconfont.css'
11
+import './index.scss'
6 12
 
7 13
 export default withLayout((props) => {
14
+  const { id } = props
15
+
16
+  const [loading, setLoading] = useState(false)
17
+  const [channelCustomer, setChannelCustomer] = useState({})
18
+  const [consultantList, setConsultantList] = useState([])
19
+  const [consultant, setConsultant] = useState()
20
+  const [visitDate, setVisitDate] = useState()
21
+  const [imageUrl, setImageUrl] = useState()
22
+  const [remark, setRemark] = useState()
23
+
24
+  const openAlbum = (e) => {
25
+    e.stopPropagation()
26
+
27
+    Taro.chooseImage({
28
+      count: 1,
29
+      sizeType: ['original', 'compressed'],  //可选择原图或压缩后的图片
30
+      sourceType: ['album', 'camera'], //可选择性开放访问相册、相机
31
+      success: res => {
32
+        Taro.showLoading({
33
+          title: '加载中',
34
+        })
35
+        uploadFiles(res.tempFilePaths).then(data => {
36
+          setImageUrl(data[0])
37
+          Taro.hideLoading()
38
+        }).catch(() => {
39
+          Taro.hideLoading()
40
+        })
41
+      },
42
+      complete: () => {
43
+        Taro.hideLoading()
44
+      }
45
+    })
46
+  }
47
+
48
+  const handleSubmit = () => {
49
+    const payload = {
50
+      id,
51
+      type: 'report',
52
+      realtyConsultant: consultant,
53
+      customerVisit: {
54
+        buildingId: channelCustomer.buildingId,
55
+        name: channelCustomer.name,
56
+        recommendPerson: channelCustomer.recommendPerson,
57
+        realtyConsultant: consultant,
58
+        imageUrl,
59
+        visitDate: `${visitDate}T12.00.00.000Z`,  // 随便造了一个时刻
60
+        remark,
61
+        channelId: channelCustomer.channelId,
62
+      }
63
+    }
64
+
65
+    setLoading(true)
66
+    fetch({ url: API_MARKETING_VISIT, payload, method: 'PUT' }).then((res) => {
67
+      setLoading(false)
68
+      Taro.showToast({
69
+        url: '操作成功',
70
+        icon: 'none'
71
+      })
72
+      const t = setTimeout(() => {
73
+        Taro.navigateBack({ delta: 1 })
74
+        clearTimeout(t)
75
+      }, 1500)
76
+    }).catch((e) => {
77
+      setLoading(false)
78
+    })
79
+  }
80
+
81
+  useEffect(() => {
82
+    if (id) {
83
+      getChannelCustomerDetail(id).then((res) => {
84
+        setChannelCustomer(res || {})
85
+
86
+        setConsultant(res?.realtyConsultant)
87
+
88
+        if (res?.buildingId) {
89
+          getCardList({
90
+            pageNumber: 1,
91
+            pageSize: 50,
92
+            buildingId: res.buildingId,
93
+          }).then((x) => {
94
+            const { records } = x || {}
95
+            setConsultantList(records || [])
96
+          })
97
+        }
98
+      })
99
+    }
100
+  }, [id])
8 101
 
9 102
   // const [PageProps] = useState(props)
10 103
 
11 104
   return (
12 105
     <view className='Page sureVisit'>
13 106
 
14
-      <ScrollView scroll-y={true} refresher-enabled={false} refresher-background='#fff'>
107
+      <ScrollView scrollY>
15 108
         <view className='PageContent'>
16 109
 
17 110
           <text>客户姓名</text>
18 111
           <view className='FormLine flex-h'>
19 112
             <view className='flex-item'>
20
-              <Input placeholder='请输入姓名'></Input>
113
+              <text>{channelCustomer.name}</text>
114
+              {/* <Input placeholder='请输入姓名' value={channelCustomer.name}></Input> */}
21 115
             </view>
22 116
           </view>
23 117
 
24 118
           <text>归属渠道</text>
25 119
           <view className='FormLine flex-h'>
26 120
             <view className='flex-item'>
27
-              <Input placeholder='请输入渠道'></Input>
121
+              <text>{channelCustomer.channelName}</text>
122
+              {/* <Input placeholder='请输入渠道' value={channelCustomer.channelName}></Input> */}
28 123
             </view>
29 124
           </view>
30 125
 
31 126
           <text>内场接待</text>
32 127
           <view className='FormLine flex-h'>
33 128
             <view className='flex-item'>
34
-              <Input placeholder='请输入内场接待'></Input>
129
+              {/* <Input placeholder='请输入内场接待'></Input> */}
130
+              <Picker kv={['name', 'id']} value={consultant} placeholder='请输入内场接待' dicts={consultantList} onChange={setConsultant} />
35 131
             </view>
36 132
           </view>
37 133
 
38 134
           <text>到访时间</text>
39 135
           <view className='FormLine flex-h'>
40 136
             <view className='flex-item'>
41
-              <text>请选择</text>
137
+              {/* <text>请选择</text> */}
138
+              <Picker mode='date' value={visitDate} onChange={setVisitDate} />
42 139
             </view>
43 140
             <text className='iconfont icon-jiantoudown'></text>
44 141
           </view>
@@ -46,21 +143,22 @@ export default withLayout((props) => {
46 143
           <text>到访照片</text>
47 144
           <view className='FormLine flex-h'>
48 145
             <view className='flex-item'>
49
-              <view className='UploadImg'>
146
+              {/* <view className='UploadImg'>
50 147
                 <text className='iconfont icon-xiangji centerLabel'></text>
51
-              </view>
148
+              </view> */}
149
+              <Image src={imageUrl} className='UploadImg' onClick={openAlbum} mode="aspectFill"></Image>
52 150
             </view>
53 151
           </view>
54 152
 
55 153
           <text>备注</text>
56 154
           <view className='FormLine flex-h'>
57 155
             <view className='flex-item'>
58
-              <Input placeholder='补充说明(选填)'></Input>
156
+              <textarea placeholder='补充说明(选填)' value={remark} onInput={(e) => setRemark(e.detail.value)} ></textarea>
59 157
             </view>
60 158
           </view>
61 159
 
62 160
           <view className='Btn'>
63
-            <text>提交</text>
161
+            <button loading={loading} onClick={handleSubmit}>提交</button>
64 162
           </view>
65 163
 
66 164
         </view>