瀏覽代碼

静态页面

1002884655 4 年之前
父節點
當前提交
22ddcdf4c5

+ 26
- 6
src/pages/WuYe/TianJiaBaoXiu/index.jsx 查看文件

11
   const [Title, setTitle] = useState('')
11
   const [Title, setTitle] = useState('')
12
   const [Desc, setDesc] = useState('')
12
   const [Desc, setDesc] = useState('')
13
   const [DataLock, setDataLock] = useState(false)
13
   const [DataLock, setDataLock] = useState(false)
14
-  const CurrnetBaoXiuType = Current.router.params.type
14
+  const [CurrnetBaoXiuType] = useState(Current.router.params.type)
15
+  const [PhotoUrl, setPhotoUrl] = useState(null)
15
 
16
 
16
   const TitleChange = (e) => {
17
   const TitleChange = (e) => {
17
     setTitle(e.detail.value)
18
     setTitle(e.detail.value)
42
         ticketTitle: Title,
43
         ticketTitle: Title,
43
         ticketContent: Desc,
44
         ticketContent: Desc,
44
         type: 2,
45
         type: 2,
45
-        repairType: CurrnetBaoXiuType - 0
46
+        repairType: [CurrnetBaoXiuType] - 0,
47
+        imageUrl: PhotoUrl
46
       }
48
       }
47
     }).then((res) => {
49
     }).then((res) => {
48
       Taro.showToast({ title: '报修提交成功', icon: 'none' })
50
       Taro.showToast({ title: '报修提交成功', icon: 'none' })
60
       sizeType: ['compressed'],
62
       sizeType: ['compressed'],
61
       sourceType: ['album', 'camera'],
63
       sourceType: ['album', 'camera'],
62
       success: (res) => {
64
       success: (res) => {
63
-        console.log(res)
65
+        const tempFilePaths = res.tempFilePaths
66
+        Taro.uploadFile({
67
+          url: apis.uploadImage.url,
68
+          filePath: tempFilePaths[0],
69
+          name: 'file',
70
+          formData: { user: 'upload' },
71
+          header: { 'x-action': 'miniapp', 'authorization': `Bearer ${Taro.getStorageSync('token')}` },
72
+          success: (res) => {
73
+            setPhotoUrl(JSON.parse(res.data).data)
74
+          }
75
+        })
64
       }
76
       }
65
     })
77
     })
66
   }
78
   }
67
 
79
 
80
+  const DeleteItem = () => {
81
+    setPhotoUrl(null)
82
+  }
83
+
68
   return (
84
   return (
69
     <view className='WuYeTianJiaBaoXiu'>
85
     <view className='WuYeTianJiaBaoXiu'>
70
       <view className='Form'>
86
       <view className='Form'>
78
             <text>添加图片</text>
94
             <text>添加图片</text>
79
           </view>
95
           </view>
80
         </view>
96
         </view>
81
-        <view className='PhotoItem'>
82
-          <text className='iconfont iconshanchu'></text>
83
-        </view>
97
+        {
98
+          PhotoUrl !== null &&
99
+          <view className='PhotoItem'>
100
+            <text className='iconfont iconshanchu' onClick={DeleteItem}></text>
101
+            <image mode='aspectFit' src={PhotoUrl}></image>
102
+          </view>
103
+        }
84
       </view>
104
       </view>
85
       <view className='Btn'>
105
       <view className='Btn'>
86
         <text onClick={Send}>确认发送</text>
106
         <text onClick={Send}>确认发送</text>

+ 1
- 1
src/pages/WuYe/TianJiaBaoXiu/index.less 查看文件

83
           z-index: 1;
83
           z-index: 1;
84
         }
84
         }
85
 
85
 
86
-        >text {
86
+        >text.iconfont {
87
           display: inline-block;
87
           display: inline-block;
88
           position: absolute;
88
           position: absolute;
89
           z-index: 2;
89
           z-index: 2;

+ 37
- 5
src/pages/WuYe/XiuGaiBaoXiu/index.jsx 查看文件

13
   const [DataLock, setDataLock] = useState(false)
13
   const [DataLock, setDataLock] = useState(false)
14
   const [DetailInfo, setDetailInfo] = useState(null)
14
   const [DetailInfo, setDetailInfo] = useState(null)
15
   const [CurrnetId] = useState(Current.router.params.id)
15
   const [CurrnetId] = useState(Current.router.params.id)
16
+  const [PhotoUrl, setPhotoUrl] = useState(null)
16
 
17
 
17
   useEffect(() => {
18
   useEffect(() => {
18
     Init()
19
     Init()
21
   const Init = () => {
22
   const Init = () => {
22
     request({ ...apis.getGongDanDetail, args: { orgId: user.orgId }, params: { ticketId: CurrnetId } }).then((res) => {
23
     request({ ...apis.getGongDanDetail, args: { orgId: user.orgId }, params: { ticketId: CurrnetId } }).then((res) => {
23
       setDetailInfo(res)
24
       setDetailInfo(res)
25
+      setPhotoUrl(res.tdImagesList !== null && res.tdImagesList.length > 0 ? res.tdImagesList[0] : null)
24
     })
26
     })
25
   }
27
   }
26
 
28
 
53
       data: {
55
       data: {
54
         ticketTitle: DetailInfo.ticketTitle,
56
         ticketTitle: DetailInfo.ticketTitle,
55
         ticketContent: DetailInfo.ticketContent,
57
         ticketContent: DetailInfo.ticketContent,
56
-        type: 2
58
+        type: 2,
59
+        imageUrl: PhotoUrl
57
       }
60
       }
58
     }).then((res) => {
61
     }).then((res) => {
59
       Taro.showToast({ title: '报修修改成功', icon: 'none' })
62
       Taro.showToast({ title: '报修修改成功', icon: 'none' })
65
     })
68
     })
66
   }
69
   }
67
 
70
 
71
+  const AddImg = () => { // 添加图片
72
+    Taro.chooseImage({
73
+      count: 1,
74
+      sizeType: ['compressed'],
75
+      sourceType: ['album', 'camera'],
76
+      success: (res) => {
77
+        const tempFilePaths = res.tempFilePaths
78
+        Taro.uploadFile({
79
+          url: apis.uploadImage.url,
80
+          filePath: tempFilePaths[0],
81
+          name: 'file',
82
+          formData: { user: 'upload' },
83
+          header: { 'x-action': 'miniapp', 'authorization': `Bearer ${Taro.getStorageSync('token')}` },
84
+          success: (res) => {
85
+            setPhotoUrl(JSON.parse(res.data).data)
86
+          }
87
+        })
88
+      }
89
+    })
90
+  }
91
+
92
+  const DeleteItem = () => {
93
+    setPhotoUrl(null)
94
+  }
95
+
68
   return (
96
   return (
69
     <view className='WuYeXiuGaiBaoXiu'>
97
     <view className='WuYeXiuGaiBaoXiu'>
70
       <view className='Form'>
98
       <view className='Form'>
72
         <Textarea placeholder='描述问题详情,以便我们更好的相处' onInput={DescChange} value={DetailInfo === null ? null : DetailInfo.ticketContent}></Textarea>
100
         <Textarea placeholder='描述问题详情,以便我们更好的相处' onInput={DescChange} value={DetailInfo === null ? null : DetailInfo.ticketContent}></Textarea>
73
       </view>
101
       </view>
74
       <view className='Photo'>
102
       <view className='Photo'>
75
-        <view className='Add'>
103
+        <view className='Add' onClick={AddImg}>
76
           <view className='centerLabel'>
104
           <view className='centerLabel'>
77
             <text className='iconfont iconxiangji'></text>
105
             <text className='iconfont iconxiangji'></text>
78
             <text>添加图片</text>
106
             <text>添加图片</text>
79
           </view>
107
           </view>
80
         </view>
108
         </view>
81
-        <view className='PhotoItem'>
82
-          <text className='iconfont iconshanchu'></text>
83
-        </view>
109
+        {
110
+          PhotoUrl !== null &&
111
+          <view className='PhotoItem'>
112
+            <text className='iconfont iconshanchu' onClick={DeleteItem}></text>
113
+            <image mode='aspectFit' src={PhotoUrl}></image>
114
+          </view>
115
+        }
84
       </view>
116
       </view>
85
       <view className='Btn'>
117
       <view className='Btn'>
86
         <text onClick={Send}>确认修改</text>
118
         <text onClick={Send}>确认修改</text>

+ 4
- 0
src/utils/api.js 查看文件

1
 const prefix = `${HOST}/api/wx`
1
 const prefix = `${HOST}/api/wx`
2
 
2
 
3
 const $api = {
3
 const $api = {
4
+  uploadImage: { // 上传图片
5
+    method: 'post',
6
+    url: `${prefix}/image`
7
+  },
4
   getMessageList: { // 获取小区通知
8
   getMessageList: { // 获取小区通知
5
     method: 'get',
9
     method: 'get',
6
     url: `${prefix}/message/:orgId/news`
10
     url: `${prefix}/message/:orgId/news`