李志伟 3 年前
父节点
当前提交
5403f0ab5f
共有 2 个文件被更改,包括 12 次插入7 次删除
  1. 2
    2
      src/components/MyButton/index.jsx
  2. 10
    5
      src/pages/feedback/index.jsx

+ 2
- 2
src/components/MyButton/index.jsx 查看文件

2
 import './style.less'
2
 import './style.less'
3
 
3
 
4
 export default (props) => {
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 查看文件

13
   const { person } = useModel('person')
13
   const { person } = useModel('person')
14
   const [value, setValue] = useState()
14
   const [value, setValue] = useState()
15
   const [show, setShow] = useState(true)
15
   const [show, setShow] = useState(true)
16
+  const [loading, setLoading] = useState(false)
16
   const onChange = (e) => {
17
   const onChange = (e) => {
17
     if (e.detail.value) {
18
     if (e.detail.value) {
18
       setValue(e.detail.value)
19
       setValue(e.detail.value)
27
         icon: 'none',
28
         icon: 'none',
28
       })
29
       })
29
     } else {
30
     } else {
30
-      console.log(value)
31
+      setLoading(true)
31
       addFeedback({ ...person, content: value }).then((res) => {
32
       addFeedback({ ...person, content: value }).then((res) => {
32
         Taro.showToast({
33
         Taro.showToast({
33
           title: '反馈已收到!',
34
           title: '反馈已收到!',
34
-          icon: 'success',
35
-          duration: 2000
35
+          icon: 'success'
36
         })
36
         })
37
         setTimeout(() => {
37
         setTimeout(() => {
38
           Taro.navigateBack({
38
           Taro.navigateBack({
39
             delta: 1
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
 
70
 
66
         </View>
71
         </View>
67
         <View className='bottomBtn'>
72
         <View className='bottomBtn'>
68
-          <MyButton value='提交' onClick={handleSumbit} />
73
+          <MyButton value='提交' loading={loading} onClick={handleSumbit} />
69
         </View>
74
         </View>
70
       </View>
75
       </View>
71
     </View>
76
     </View>