Browse Source

小程序联系我们功能实现

李志伟 3 years ago
parent
commit
9ef048a18d

+ 36
- 9
src/pages/MineUserAll/ContactMe/index.jsx View File

@@ -1,30 +1,57 @@
1
-
2 1
 import CustomNav from '@/components/CustomNav'
3
-// import { Button } from '@tarojs/components'
4 2
 import Taro from '@tarojs/taro'
5 3
 import withLayout from '@/layouts'
6
-
7
-import { Button, Text, Textarea } from '@tarojs/components'
4
+import { Button} from '@tarojs/components'
8 5
 import './style.less'
6
+import {saveFeedback} from '@/services/mine'
9 7
 
10 8
 
11 9
 export default withLayout((props) => {
12
-  const { router, person } = props
13
-
10
+  const { person } = props
11
+  const {personId}=person
14 12
   const back = () => {
15 13
     Taro.navigateBack()
16 14
   }
17
-
15
+  const submit=()=>{
16
+    var content=document.getElementById('content').value
17
+    if(content!=''){
18
+      saveFeedback({
19
+        personId,
20
+        content
21
+      }).then(()=>{
22
+        // 成功返回一个模态框提醒用户
23
+        wx.showModal({
24
+          title: '提示',
25
+          content: '反馈成功',
26
+          showCancel:false,
27
+          success (res) {
28
+            if (res.confirm) {
29
+              back()
30
+            }
31
+          }
32
+        })             
33
+      })
34
+    }
35
+    else{
36
+      wx.showToast({
37
+        title: '请重新输入',
38
+        icon: 'none',
39
+        duration: 2000
40
+      }) 
41
+    }
42
+  }
18 43
   return (
19 44
     <view className='box-content'>
20 45
       <CustomNav title='联系我们' />
46
+      <view style={{padding:'60rpx 30rpx'}}>
21 47
       <view class='section'>
22
-        <Textarea placeholder='请输入您的建议或意见!' confirm-type='done' />
48
+        <textarea placeholder='请输入您的建议或意见!' id='content' />
23 49
       </view>
24 50
       <view className='button-info'>
25
-        <Button className='button-box'>提交</Button>
51
+        <Button className='button-box' onClick={submit}>提交</Button>
26 52
         <Button className='button-box-Cancel' onClick={back} >取消</Button>
27 53
       </view>
54
+      </view>
28 55
     </view>
29 56
   )
30 57
 })

+ 14
- 21
src/pages/MineUserAll/ContactMe/style.less View File

@@ -1,38 +1,31 @@
1 1
 .box-content {
2 2
   .section {
3
-    width: 690px;
4 3
     height: 254px;
5
-    background: #ffffff;
6 4
     border: 1px solid #b5b5b5;
7 5
     box-shadow: 0px 4px 24px 0px rgba(0, 0, 0, 0.08);
8
-    padding: 0 20px 0 20px;
9
-    margin: auto;
6
+    padding: 30px;    
7
+    font-size: 24px;
10 8
     textarea {
11
-      padding-top: 20px;
12
-      width: 100%;
13
-      font-size: 24px;
14
-      font-weight: 400;
15
-      color: #666666;
9
+      height: 100%;
16 10
     }
17 11
   }
12
+  button{
13
+    font-size: 30px; 
14
+    border-radius: 12px;
15
+    line-height: 88px;
16
+  }
18 17
   .button-info {
18
+    width: calc(100% - 60px);
19
+    position: absolute;
20
+    bottom: 60px;
19 21
     .button-box {
20
-      margin-top: 20%;
21
-      width: 690px;
22
-      height: 88px;
23
-      line-height: 88px;
24
-
25
-      background: #274291;
26
-      border-radius: 12px;
22
+      background: #274291;     
23
+      color: #fff;
27 24
     }
28
-    .button-box-Cancel {
29
-      width: 690px;
30
-      height: 88px;
31
-      line-height: 88px;
25
+    .button-box-Cancel {      
32 26
       margin-top: 40px;
33 27
       color: #274291;
34 28
       border: 2px solid #274291;
35
-      border-radius: 12px;
36 29
     }
37 30
   }
38 31
 }

+ 9
- 2
src/services/mine.js View File

@@ -5,7 +5,7 @@ import request from '@/utils/request'
5 5
  * @param {*} data 
6 6
  * @returns 
7 7
  */
8
- export const saveEvaluation = (data) => request('/taEvaluation ', { method: 'post', data })
8
+ export const saveEvaluation = (data) => request('/taEvaluation', { method: 'post', data })
9 9
 
10 10
  /**
11 11
  * 查看评价详情
@@ -15,4 +15,11 @@ import request from '@/utils/request'
15 15
   export const getEvaluationDetail = (id) => request(`/taEvaluation/${id}`)
16 16
 
17 17
  //订单列表用哪个表    
18
-//收藏列表
18
+//收藏列表
19
+
20
+/**
21
+ * 联系我们
22
+ * @param {*} data 
23
+ * @returns 
24
+ */
25
+ export const saveFeedback = (data) => request('/taFeedback', { method: 'post', data })