李志伟 3 years ago
parent
commit
5403f0ab5f
2 changed files with 12 additions and 7 deletions
  1. 2
    2
      src/components/MyButton/index.jsx
  2. 10
    5
      src/pages/feedback/index.jsx

+ 2
- 2
src/components/MyButton/index.jsx View File

@@ -2,6 +2,6 @@ import { View,Button } from "@tarojs/components"
2 2
 import './style.less'
3 3
 
4 4
 export default (props) => {
5
-  const { value, onClick } = props
6
-  return <Button className='myBtn' onClick={onClick}>{value}</Button>
5
+  const { value,loading, onClick } = props
6
+  return <Button className='myBtn' disabled={loading} onClick={onClick}>{value}</Button>
7 7
 }

+ 10
- 5
src/pages/feedback/index.jsx View File

@@ -13,6 +13,7 @@ export default withLayout((props) => {
13 13
   const { person } = useModel('person')
14 14
   const [value, setValue] = useState()
15 15
   const [show, setShow] = useState(true)
16
+  const [loading, setLoading] = useState(false)
16 17
   const onChange = (e) => {
17 18
     if (e.detail.value) {
18 19
       setValue(e.detail.value)
@@ -27,18 +28,22 @@ export default withLayout((props) => {
27 28
         icon: 'none',
28 29
       })
29 30
     } else {
30
-      console.log(value)
31
+      setLoading(true)
31 32
       addFeedback({ ...person, content: value }).then((res) => {
32 33
         Taro.showToast({
33 34
           title: '反馈已收到!',
34
-          icon: 'success',
35
-          duration: 2000
35
+          icon: 'success'
36 36
         })
37 37
         setTimeout(() => {
38 38
           Taro.navigateBack({
39 39
             delta: 1
40 40
           })
41
-        }, 1500)
41
+        }, 1000)
42
+      }).catch(err => {
43
+        Taro.showToast({
44
+          title: '网络异常, 请刷新小程序重试',
45
+          icon: 'none',
46
+        })
42 47
       })
43 48
     }
44 49
   }
@@ -65,7 +70,7 @@ export default withLayout((props) => {
65 70
 
66 71
         </View>
67 72
         <View className='bottomBtn'>
68
-          <MyButton value='提交' onClick={handleSumbit} />
73
+          <MyButton value='提交' loading={loading} onClick={handleSumbit} />
69 74
         </View>
70 75
       </View>
71 76
     </View>