李志伟 3 anos atrás
pai
commit
d681a533ee

+ 22
- 11
src/pages/feedback/index.jsx Ver arquivo

@@ -5,30 +5,41 @@ import withLayout from '@/layouts'
5 5
 import CustomNav from "@/components/CustomNav"
6 6
 import MyButton from "@/components/MyButton"
7 7
 import editImg from '@/assets/user/edit.png'
8
+import { addFeedback } from "@/services/feedback"
8 9
 import './style.less'
10
+import { useModel } from "@/store"
9 11
 
10 12
 export default withLayout((props) => {
13
+  const { person } = useModel('person')
11 14
   const [value, setValue] = useState()
12 15
   const [show, setShow] = useState(true)
13
-  const onChange=(e)=>{
16
+  const onChange = (e) => {
14 17
     if (e.detail.value) {
15 18
       setValue(e.detail.value)
16
-    }else{
19
+    } else {
17 20
       setShow(true)
18 21
     }
19 22
   }
20
-  const handleSumbit = () => { 
23
+  const handleSumbit = () => {
21 24
     if (show) {
22 25
       Taro.showToast({
23 26
         title: '请输入您的建议',
24 27
         icon: 'none',
25 28
       })
26
-    } else{
27
-      Taro.showToast({
28
-        title: '已反馈',
29
-        icon: 'none',
29
+    } else {
30
+      console.log(value)
31
+      addFeedback({ ...person, content: value }).then((res) => {
32
+        Taro.showToast({
33
+          title: '反馈已收到!',
34
+          icon: 'success',
35
+          duration: 2000
36
+        })
37
+        setTimeout(() => {
38
+          Taro.navigateBack({
39
+            delta: 1
40
+          })
41
+        }, 1500)
30 42
       })
31
-      Taro.navigateBack({delta:1})
32 43
     }
33 44
   }
34 45
   return (
@@ -40,12 +51,12 @@ export default withLayout((props) => {
40 51
         <View className='content'>
41 52
           <Textarea
42 53
             value={value}
43
-            onFocus={()=>setShow(false)}
44
-            onBlur={onChange}
54
+            onFocus={() => setShow(false)}
55
+            onInput={onChange}
45 56
             className='value'
46 57
           />
47 58
           {
48
-            show && 
59
+            show &&
49 60
             <View className='defaultValue'>
50 61
               <Image src={editImg} className='edit' />
51 62
               请留下您宝贵的意见和建议!

+ 1
- 1
src/pages/index/components/order/index.jsx Ver arquivo

@@ -60,7 +60,7 @@ export default () => {
60 60
           <View className='head'>
61 61
             <Image className='headIcon' src={orderImg} />
62 62
             <Text className='title'>订单列表</Text>
63
-            <Text className='more' onClick={handleMore}>更多>></Text>
63
+            <Text className='more' onClick={handleMore}>更多{">"}{">"}</Text>
64 64
           </View>
65 65
 
66 66
           <MyCard order />

+ 8
- 0
src/services/feedback.js Ver arquivo

@@ -0,0 +1,8 @@
1
+import request from '@/utils/request'
2
+
3
+/**
4
+ * 反馈意见
5
+ * @param {*} data 
6
+ * @returns 
7
+ */
8
+ export const addFeedback = (data) => request('/feedback', { method: 'post', data })