Forráskód Böngészése

面谈功能提交增加loading

dev01 3 hete%!(EXTRA string=óta)
szülő
commit
a9d3296de7
1 módosított fájl, 17 hozzáadás és 5 törlés
  1. 17 5
      src/pages/interview/myUser.jsx

+ 17 - 5
src/pages/interview/myUser.jsx

@@ -93,7 +93,9 @@ class CustomerProfile extends Component {
       checkCompShow: false,
       checkCompList: [],
 
-      currAddress: []
+      currAddress: [],
+
+      loading: false,
     };
     this.queryByUidAll = this.queryByUidAll.bind(this);
     this.update = this.update.bind(this);
@@ -486,7 +488,7 @@ class CustomerProfile extends Component {
     return { flag, message };
   }
 
-  onSaveAllData(callback) {
+  onSaveAllData(succCallback, errorCallback) {
     const { dtails } = this.state;
 
     let params = {
@@ -574,19 +576,29 @@ class CustomerProfile extends Component {
       return;
     }
 
+    this.setState({ loading: true })
     updateUser(params).then((v) => {
+      this.setState({ loading: false });
       if (v.error.length === 0) {
         Taro.showToast({
           title: "修改成功",
         });
 
-        callback && callback(v.data);
+        succCallback && succCallback(v.data);
       } else {
+        errorCallback && errorCallback();
         Taro.showToast({
           title: v.error[0].message,
           icon: "none",
         });
       }
+    }).catch(() => {
+      this.setState({ loading: false });
+      Taro.showToast({
+        title: "提交失败!",
+        icon: "none",
+      });
+      errorCallback && errorCallback();
     })
   }
 
@@ -1383,7 +1395,7 @@ class CustomerProfile extends Component {
                       ) : null}
                       <View style={{ display: 'flex', marginTop: '24rpx' }}>
                         <AtButton type="secondary" circle onClick={this.handlePrevClick.bind(this)}>上一页</AtButton>
-                        <AtButton type="primary" circle onClick={this.handleNextClick.bind(this)}>下一页</AtButton>
+                        <AtButton type="primary" circle loading={this.state.loading} onClick={this.handleNextClick.bind(this)}>下一页</AtButton>
                       </View>
                     </View>
                     :
@@ -1916,7 +1928,7 @@ class CustomerProfile extends Component {
 
                         <View style={{ display: 'flex', marginTop: '24rpx' }}>
                           <AtButton type="secondary" circle onClick={this.handlePrevClick.bind(this)}>上一页</AtButton>
-                          <AtButton type="primary" circle onClick={this.handleNextClick.bind(this)}>下一页</AtButton>
+                          <AtButton type="primary" circle loading={this.state.loading} onClick={this.handleNextClick.bind(this)}>下一页</AtButton>
                         </View>
                       {/* </View> */}
                     </View>