jason.lu 6 gadi atpakaļ
vecāks
revīzija
464897b82a

+ 83 - 74
sourcecode/h5app/vue/src/views/SecurityVerify.vue

@@ -127,15 +127,19 @@
                     {id: 4, name: '西丽'},
                 ],
                 photo: null,
-                loading: false
+                loading: false,
+                userDo : {},
+                identityDo : {},
+                identityUpload : false,
+                userUpload : false
             };
         },
         methods: {
             next() {
                 Toast.loading({
                     mask: true,
-                    message: '图片上传较慢,请耐心等待...',
-                    duration: 1000
+                    message: '此过程大约需要15s,你的校卡正在拼命上传,请耐心等待...',
+                    duration: 20000
                 });
                 this.loading = true;
                 // 检查输入
@@ -177,80 +181,14 @@
                 let that = this;
                 // console.log('------- photo -------');
                 // console.log(this.photo);
+                this.updateInfo(null);
                 let formData = new FormData();
                 formData.append('file', this.photo);
                 BasicFunction.get_data("fileserver/upload?sign=abcdefg", function (res) {
-                    // console.log('----- upload photo result -----');
-                    // console.log(res);
-                    // if (res.model === undefined || res.model.length === 0) {
-                    //     Toast.fail('上传失败,请重试');
-                    //     return;
-                    // }
                     try {
                         let imgURL = res.model;
                         if (res.ret === '10000') {
-                            let userId = localStorage.getItem('frontend-userid');
-                            // console.log('----- User Identity -----');
-                            BasicFunction.get_data("smartIdentity/list?userId=" + userId, function (res) {
-                                try {
-                                    let useridentity = res.model.list[0];
-                                    if (res.ret === '10000' && res.model !== undefined && res.model.list !== undefined && res.model.list.length > 0) {
-                                        useridentity.userWxAccount = that.wechat;
-                                        useridentity.dormDistrict = that.dorId;
-                                        useridentity.userSex = parseInt(that.radio);
-                                        useridentity.userSchoolCardPic = imgURL;
-                                        useridentity.userReviewStatus = 100;
-                                        useridentity.reviewerNote = "未审核";
-                                        useridentity.reviewerNoteToUser = "未审核";
-                                        BasicFunction.get_data("smartIdentity/updateBatch", function (response) {
-                                            // console.log(useridentity);
-                                            // console.log(response);
-                                            if (response.ret === "10000") {
-                                                // console.log('----- User Info -----');
-                                                BasicFunction.get_data('smartUsers/list?uid=' + userId, function (res) {
-                                                    // console.log(res);
-                                                    try {
-                                                        let user = res.model.list[0];
-                                                        if (res.ret === '10000' && res.model !== undefined && res.model.list !== undefined) {
-                                                            user.name = that.username;
-                                                            user.phone = that.phone;
-                                                            // console.log('----- Update User Info -----');
-                                                            // console.log(user);
-                                                            BasicFunction.get_data('smartUsers/updateBatch', function (res) {
-                                                                // console.log(res);
-                                                                if (res !== undefined && res.ret === '10000') {
-                                                                    Toast.success("注册成功");
-                                                                    that.$router.push('presentRegister');
-                                                                } else {
-                                                                    Toast.fail('注册失败');
-                                                                    that.loading = false;
-                                                                }
-                                                            }, [user]);
-                                                        } else {
-                                                            Toast.fail('获取用户信息失败');
-                                                            that.loading = false;
-                                                        }
-                                                    } catch (e) {
-                                                        console.warn(e);
-                                                        Toast.fail('获取用户信息失败');
-                                                        that.loading = false;
-                                                    }
-                                                }, {});
-                                            } else {
-                                                Toast.fail("注册失败,请检查网络");
-                                                that.loading = false;
-                                            }
-                                        }, [useridentity]);
-                                    } else {
-                                        Toast.fail('获取信息失败');
-                                        that.loading = false;
-                                    }
-                                } catch (e) {
-                                    console.warn(e);
-                                    Toast.fail('获取信息失败');
-                                    that.loading = false;
-                                }
-                            }, {});
+                            that.updateInfo(imgURL);
                         } else {
                             Toast.fail('上传图片失败,请检查网络');
                             that.loading = false;
@@ -262,6 +200,60 @@
                     }
                 }, formData);
             },
+            updateInfo(image){
+                let userId = localStorage.getItem('frontend-userid');
+                let that = this;
+                let useridentity = that.identityDo;
+                useridentity.userWxAccount = that.wechat;
+                useridentity.dormDistrict = that.dorId;
+                useridentity.userSex = parseInt(that.radio);
+                if(image != null){
+                    useridentity.userSchoolCardPic = image;
+                }
+                let beforeImage = image;
+                useridentity.userSchoolCardPic = image;
+                useridentity.userReviewStatus = 100;
+                useridentity.reviewerNote = "等待审核";
+                useridentity.reviewerNoteToUser = "等待审核";
+                BasicFunction.get_data("smartIdentity/updateBatch", function (response) {
+                    // console.log(useridentity);
+                    // console.log(response);
+                    if (response.ret === "10000") {
+                        // console.log('----- User Info -----');
+                        if(beforeImage != null) {
+                            that.identityUpload = true;
+                            if (that.userUpload == true) {
+                                Toast.success("注册成功");
+                                that.$router.push('presentRegister');
+                                return;
+                            }
+                        }
+                    } else {
+                        Toast.fail("注册失败,请检查网络");
+                        that.loading = false;
+                    }
+                }, [useridentity]);
+
+                let user = that.userDo;
+                user.name = that.username;
+                user.phone = that.phone;
+                // console.log('----- Update User Info -----');
+                // console.log(user);
+                BasicFunction.get_data('smartUsers/updateBatch', function (res) {
+                    // console.log(res);
+                    if (res !== undefined && res.ret === '10000') {
+                        that.userUpload = true;
+                        if(that.identityUpload == true && beforeImage != null) {
+                            Toast.success("注册成功");
+                            that.$router.push('presentRegister');
+                            return;
+                        }
+                    } else {
+                        Toast.fail('注册失败,请稍后再试');
+                        that.loading = false;
+                    }
+                }, [user]);
+            },
             onSelect(item) {
                 // 点击选项时默认不会关闭菜单,可以手动关闭
                 this.show = false;
@@ -280,17 +272,34 @@
                 return;
             }
             BasicFunction.get_data('smartUsers/list?uid=' + userid, function (res) {
-                // console.log('----- User Info ----- ' + userid);
-                // console.log(res);
                 if (res.ret === '10000') {
                     if(res.model === undefined || res.model == null || res.model.list == undefined || res.model.list.length <= 0){
-                        this.$router.push('login');
+                        localStorage.removeItem('frontend-userid');
+                        that.$router.push('login');
                         return;
                     }
                     if (res.model.list[0].phone != null && res.model.list[0].phone.length !== 0) {
                         that.$router.push('presentRegister');
                         return;
                     }
+                    that.userDo = res.model.list[0];
+                }
+            }, {});
+            BasicFunction.get_data("smartIdentity/list?userId=" + userId, function (res) {
+                try {
+                    if (res.ret === '10000' && res.model !== undefined && res.model.list !== undefined && res.model.list.length > 0) {
+                        that.identityDo = res.model.list[0];
+                    } else {
+                        localStorage.removeItem('frontend-userid');
+                        that.loading = false;
+                        that.$router.push('login');
+                    }
+                } catch (e) {
+                    console.warn(e);
+                    Toast.fail('获取信息缓慢,请检查网络或等一会再试吧!');
+                    localStorage.removeItem('frontend-userid');
+                    that.loading = false;
+                    that.$router.push('login');
                 }
             }, {});
         }

+ 3 - 2
sourcecode/h5app/vue/src/views/index.vue

@@ -210,8 +210,8 @@
                 //     return;
                 // }
                 try {
-                    let identity = res.model.list[0];
-                    if (res.ret === '10000') {
+                    if (res.ret === '10000' && res.model != undefined && res.model.list != undefined && res.model.list.length > 0) {
+                        let identity = res.model.list[0];
                         that.userStatus = identity.userReviewStatus;
                         BasicFunction.get_data("smartGoods/list?isDel=0&ownerId=" + userid, function (response) {
                             // console.log("------ Data Rcvd in Index --------");
@@ -245,6 +245,7 @@
                         }, {});
                     } else {
                         Toast.fail('获取信息失败');
+                        localStorage.removeItem('frontend-userid')
                     }
                 } catch (e) {
                     console.warn(e);