浏览代码

change in basic service, now showing alert of possible failures

jason.lu 6 年之前
父节点
当前提交
56bd94b477
共有 1 个文件被更改,包括 312 次插入312 次删除
  1. 312 312
      sourcecode/h5app/vue/src/views/SecurityVerify.vue

+ 312 - 312
sourcecode/h5app/vue/src/views/SecurityVerify.vue

@@ -1,313 +1,313 @@
-<template>
-    <div>
-        <nav-bar path="index" title="身份验证"/>
-        <div class='card'>
-            <h3><strong>个人资料</strong></h3>
-            <van-cell-group :border="false">
-                <van-field
-                        v-model="phone"
-                        required
-                        clearable
-                        label="手机号"
-                        placeholder="请输入手机号"
-                        :error="phoneError"
-                        @click="phoneError=false"
-                />
-                <!--<van-field-->
-                <!--v-model="sms"-->
-                <!--center-->
-                <!--clearable-->
-                <!--label="短信验证码"-->
-                <!--placeholder="请输入短信验证码"-->
-                <!--required-->
-                <!--disabled-->
-                <!--&gt;-->
-                <!--<van-button slot="button" size="small" type="primary">发送验证码</van-button>-->
-                <!--</van-field>-->
-
-                <van-field
-                        v-model="username"
-                        required
-                        clearable
-                        label="昵称"
-                        placeholder="请输入昵称"
-                        maxlength="12"
-                        :error="usernameError"
-                        @click="usernameError=false"
-                />
-                <van-field
-                        v-model="wechat"
-                        required
-                        clearable
-                        label="微信号"
-                        placeholder="请输入微信号"
-                        maxlength="20"
-                        :error="wechatError"
-                        @click="wechatError=false"
-                />
-            </van-cell-group>
-
-            <p>性别</p>
-            <van-radio-group v-model="radio">
-                <van-radio name="1" checked-color="#fd6740" style="float: left; margin-right: 20px">男</van-radio>
-                <van-radio name="2" checked-color="#fd6740">女</van-radio>
-            </van-radio-group>
-
-            <p>宿舍区</p>
-            <van-button size="large" @click="show = true">{{dormitory}}</van-button>
-            <van-actionsheet
-                    v-model="show"
-                    :actions="actions"
-                    cancel-text="取消"
-                    @select="onSelect"
-            />
-        </div>
-
-        <div class="card" style="margin-bottom: 10px">
-            <p>上传校卡照片</p>
-            <div style="margin-bottom: 10px">
-                <add-photo @onRead="onRead"/>
-            </div>
-            <p>活动仅允许深大学生参与,请上传正面校卡照片审核~</p>
-        </div>
-
-        <van-button
-                class="submit_button"
-                type="primary"
-                @click="next"
-                :loading="loading"
-        >下一步
-        </van-button>
-    </div>
-</template>
-
-<script>
-    import {BasicFunction} from "../connector/basic-service";
-    import NavBar from '../components/navBar';
-    import {
-        Uploader, Icon,
-        CellGroup, Field,
-        RadioGroup, Radio,
-        Picker,
-        Button,
-        Actionsheet,
-        Toast
-    } from 'vant';
-    import AddPhoto from "../components/addPhoto";
-    export default {
-        name: "SecurityVerify",
-        components: {
-            AddPhoto,
-            NavBar,
-            [Uploader.name]: Uploader, [Icon.name]: Icon,
-            [CellGroup.name]: CellGroup, [Field.name]: Field,
-            [RadioGroup.name]: RadioGroup, [Radio.name]: Radio,
-            [Picker.name]: Picker,
-            [Button.name]: Button,
-            [Actionsheet.name]: Actionsheet
-        },
-        data() {
-            return {
-                phone: '',
-                phoneError: false,
-                sms: '',
-                username: '',
-                usernameError: false,
-                wechat: '',
-                wechatError: false,
-                radio: '1',
-                show: false,
-                dormitory: '点击选择宿舍区',
-                dorId: -1,
-                actions: [
-                    {id: 0, name: '斋区'},
-                    {id: 1, name: '西南'},
-                    {id: 2, name: '南区'},
-                    {id: 3, name: '桂庙'},
-                    {id: 4, name: '西丽'},
-                ],
-                photo: null,
-                loading: false
-            };
-        },
-        methods: {
-            next() {
-                this.loading = true;
-                // 检查输入
-                if (this.phone.length !== 11) {
-                    Toast.fail("请输入11位手机号");
-                    this.phoneError = true;
-                    this.loading = false;
-                    return;
-                } else if (this.username.length < 1) {
-                    this.usernameError = true;
-                    this.loading = false;
-                    return;
-                } else if (this.wechat.length < 6) {
-                    this.wechatError = true;
-                    Toast.fail('请输入正确格式的微信号');
-                    this.loading = false;
-                    return;
-                } else if (this.dorId === -1) {
-                    Toast.fail('请选择宿舍区');
-                    this.loading = false;
-                    return;
-                } else if (this.photo === null) {
-                    Toast.fail('请上传校卡正面照片');
-                    this.loading = false;
-                    return;
-                }
-
-                let that = this;
-                // console.log('------- photo -------');
-                // console.log(this.photo);
-                let formData = new FormData();
-                formData.append('file', this.photo);
-                BasicFunction.get_data("http://gift.fogice.com/server/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;
-                    }
-                    if (res.ret === '10000') {
-                        let imgURL = res.model; // TODO: 把imgurl也加入用户信息
-                        let userId = localStorage.getItem('frontend-userid');
-                        // console.log('----- User Identity -----');
-                        BasicFunction.get_data("smartIdentity/list?userId=" + userId, function (res) {
-                            if (res.ret === '10000') {
-                                let useridentity = res.model.list[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);
-                                            if (res.ret === '10000') {
-                                                let user = res.model.list[0];
-                                                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.ret === '10000') {
-                                                        Toast.success("注册成功");
-                                                        that.$router.push('presentRegister');
-                                                    } else {
-                                                        Toast.fail('注册失败');
-                                                        that.loading = false;
-                                                    }
-                                                }, [user]);
-                                            } else {
-                                                Toast.fail('获取用户信息失败');
-                                                that.loading = false;
-                                            }
-                                        }, {});
-                                    } else {
-                                        Toast.fail("注册失败,请检查网络");
-                                        that.loading = false;
-                                    }
-                                }, [useridentity]);
-                            } else {
-                                Toast.fail('获取信息失败');
-                            }
-                        }, {});
-                    } else {
-                        Toast.fail('上传图片失败,请检查网络');
-                        that.loading = false;
-                    }
-                }, formData);
-            },
-            onSelect(item) {
-                // 点击选项时默认不会关闭菜单,可以手动关闭
-                this.show = false;
-                this.dormitory = item.name;
-                this.dorId = item.id;
-            },
-            onRead(e) {
-                this.photo = e;
-            }
-        },
-        created: function () {
-            let userid = localStorage.getItem('frontend-userid');
-            let that = this;
-            BasicFunction.get_data('smartUsers/list?uid=' + userid, function (res) {
-                // console.log('----- User Info ----- ' + userid);
-                // console.log(res);
-                if (res.ret === '10000') {
-                    if (res.model.list[0].phone.length !== 0) that.$router.push('presentRegister');
-                }
-            }, {});
-        }
-    }
-
-    // 判断是否有emoji
-    function isEmojiCharacter(substring) {
-        for (var i = 0; i < substring.length; i++) {
-            var hs = substring.charCodeAt(i);
-            if (0xd800 <= hs && hs <= 0xdbff) {
-                if (substring.length > 1) {
-                    var ls = substring.charCodeAt(i + 1);
-                    var uc = ((hs - 0xd800) * 0x400) + (ls - 0xdc00) + 0x10000;
-                    if (0x1d000 <= uc && uc <= 0x1f77f) {
-                        return true;
-                    }
-                }
-            } else if (substring.length > 1) {
-                var ls = substring.charCodeAt(i + 1);
-                if (ls == 0x20e3) {
-                    return true;
-                }
-            } else {
-                if (0x2100 <= hs && hs <= 0x27ff) {
-                    return true;
-                } else if (0x2B05 <= hs && hs <= 0x2b07) {
-                    return true;
-                } else if (0x2934 <= hs && hs <= 0x2935) {
-                    return true;
-                } else if (0x3297 <= hs && hs <= 0x3299) {
-                    return true;
-                } else if (hs == 0xa9 || hs == 0xae || hs == 0x303d || hs == 0x3030
-                    || hs == 0x2b55 || hs == 0x2b1c || hs == 0x2b1b
-                    || hs == 0x2b50) {
-                    return true;
-                }
-            }
-        }
-    }
-</script>
-
-<style scoped>
-    p, h3 {
-        color: #fd6740;
-    }
-    h3 {
-        padding: 5px;
-        border-bottom: solid 1px #e4e4e4;
-    }
-    .card {
-        background-color: white;
-        margin: 20px 20px;
-        border: solid 1px #e4e4e4;
-        padding: 15px;
-        text-align: left;
-    }
-
-    .submit_button {
-        margin-bottom: 10px;
-        margin-left: auto;
-        margin-right: auto;
-        background-color: #fd6740;
-        border-color: #fd6740;
-        width: 85%;
-    }
+<template>
+    <div>
+        <nav-bar path="index" title="身份验证"/>
+        <div class='card'>
+            <h3><strong>个人资料</strong></h3>
+            <van-cell-group :border="false">
+                <van-field
+                        v-model="phone"
+                        required
+                        clearable
+                        label="手机号"
+                        placeholder="请输入手机号"
+                        :error="phoneError"
+                        @click="phoneError=false"
+                />
+                <!--<van-field-->
+                <!--v-model="sms"-->
+                <!--center-->
+                <!--clearable-->
+                <!--label="短信验证码"-->
+                <!--placeholder="请输入短信验证码"-->
+                <!--required-->
+                <!--disabled-->
+                <!--&gt;-->
+                <!--<van-button slot="button" size="small" type="primary">发送验证码</van-button>-->
+                <!--</van-field>-->
+
+                <van-field
+                        v-model="username"
+                        required
+                        clearable
+                        label="昵称"
+                        placeholder="请输入昵称"
+                        maxlength="12"
+                        :error="usernameError"
+                        @click="usernameError=false"
+                />
+                <van-field
+                        v-model="wechat"
+                        required
+                        clearable
+                        label="微信号"
+                        placeholder="请输入微信号"
+                        maxlength="20"
+                        :error="wechatError"
+                        @click="wechatError=false"
+                />
+            </van-cell-group>
+
+            <p>性别</p>
+            <van-radio-group v-model="radio">
+                <van-radio name="1" checked-color="#fd6740" style="float: left; margin-right: 20px">男</van-radio>
+                <van-radio name="2" checked-color="#fd6740">女</van-radio>
+            </van-radio-group>
+
+            <p>宿舍区</p>
+            <van-button size="large" @click="show = true">{{dormitory}}</van-button>
+            <van-actionsheet
+                    v-model="show"
+                    :actions="actions"
+                    cancel-text="取消"
+                    @select="onSelect"
+            />
+        </div>
+
+        <div class="card" style="margin-bottom: 10px">
+            <p>上传校卡照片</p>
+            <div style="margin-bottom: 10px">
+                <add-photo @onRead="onRead"/>
+            </div>
+            <p>活动仅允许深大学生参与,请上传正面校卡照片审核~</p>
+        </div>
+
+        <van-button
+                class="submit_button"
+                type="primary"
+                @click="next"
+                :loading="loading"
+        >下一步
+        </van-button>
+    </div>
+</template>
+
+<script>
+    import {BasicFunction} from "../connector/basic-service";
+    import NavBar from '../components/navBar';
+    import {
+        Uploader, Icon,
+        CellGroup, Field,
+        RadioGroup, Radio,
+        Picker,
+        Button,
+        Actionsheet,
+        Toast
+    } from 'vant';
+    import AddPhoto from "../components/addPhoto";
+    export default {
+        name: "SecurityVerify",
+        components: {
+            AddPhoto,
+            NavBar,
+            [Uploader.name]: Uploader, [Icon.name]: Icon,
+            [CellGroup.name]: CellGroup, [Field.name]: Field,
+            [RadioGroup.name]: RadioGroup, [Radio.name]: Radio,
+            [Picker.name]: Picker,
+            [Button.name]: Button,
+            [Actionsheet.name]: Actionsheet
+        },
+        data() {
+            return {
+                phone: '',
+                phoneError: false,
+                sms: '',
+                username: '',
+                usernameError: false,
+                wechat: '',
+                wechatError: false,
+                radio: '1',
+                show: false,
+                dormitory: '点击选择宿舍区',
+                dorId: -1,
+                actions: [
+                    {id: 0, name: '斋区'},
+                    {id: 1, name: '西南'},
+                    {id: 2, name: '南区'},
+                    {id: 3, name: '桂庙'},
+                    {id: 4, name: '西丽'},
+                ],
+                photo: null,
+                loading: false
+            };
+        },
+        methods: {
+            next() {
+                this.loading = true;
+                // 检查输入
+                if (this.phone.length !== 11) {
+                    Toast.fail("请输入11位手机号");
+                    this.phoneError = true;
+                    this.loading = false;
+                    return;
+                } else if (this.username.length < 1) {
+                    this.usernameError = true;
+                    this.loading = false;
+                    return;
+                } else if (this.wechat.length < 6) {
+                    this.wechatError = true;
+                    Toast.fail('请输入正确格式的微信号');
+                    this.loading = false;
+                    return;
+                } else if (this.dorId === -1) {
+                    Toast.fail('请选择宿舍区');
+                    this.loading = false;
+                    return;
+                } else if (this.photo === null) {
+                    Toast.fail('请上传校卡正面照片');
+                    this.loading = false;
+                    return;
+                }
+
+                let that = this;
+                // console.log('------- photo -------');
+                // console.log(this.photo);
+                let formData = new FormData();
+                formData.append('file', this.photo);
+                BasicFunction.get_data("http://gift.fogice.com/server/fileserver/upload?sign=abcdefg", function (res) {
+                    // console.log('----- upload photo result -----');
+                    // console.log(res);
+                    if (res == undefined || res.model === undefined || res.model.length === 0) {
+                        Toast.fail('上传失败,请重试');
+                        return;
+                    }
+                    if (res.ret === '10000') {
+                        let imgURL = res.model; // TODO: 把imgurl也加入用户信息
+                        let userId = localStorage.getItem('frontend-userid');
+                        // console.log('----- User Identity -----');
+                        BasicFunction.get_data("smartIdentity/list?userId=" + userId, function (res) {
+                            if (res.ret === '10000') {
+                                let useridentity = res.model.list[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);
+                                            if (res.ret === '10000') {
+                                                let user = res.model.list[0];
+                                                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.ret === '10000') {
+                                                        Toast.success("注册成功");
+                                                        that.$router.push('presentRegister');
+                                                    } else {
+                                                        Toast.fail('注册失败');
+                                                        that.loading = false;
+                                                    }
+                                                }, [user]);
+                                            } else {
+                                                Toast.fail('获取用户信息失败');
+                                                that.loading = false;
+                                            }
+                                        }, {});
+                                    } else {
+                                        Toast.fail("注册失败,请检查网络");
+                                        that.loading = false;
+                                    }
+                                }, [useridentity]);
+                            } else {
+                                Toast.fail('获取信息失败');
+                            }
+                        }, {});
+                    } else {
+                        Toast.fail('上传图片失败,请检查网络');
+                        that.loading = false;
+                    }
+                }, formData);
+            },
+            onSelect(item) {
+                // 点击选项时默认不会关闭菜单,可以手动关闭
+                this.show = false;
+                this.dormitory = item.name;
+                this.dorId = item.id;
+            },
+            onRead(e) {
+                this.photo = e;
+            }
+        },
+        created: function () {
+            let userid = localStorage.getItem('frontend-userid');
+            let that = this;
+            BasicFunction.get_data('smartUsers/list?uid=' + userid, function (res) {
+                // console.log('----- User Info ----- ' + userid);
+                // console.log(res);
+                if (res.ret === '10000') {
+                    if (res.model.list[0].phone.length !== 0) that.$router.push('presentRegister');
+                }
+            }, {});
+        }
+    }
+
+    // 判断是否有emoji
+    function isEmojiCharacter(substring) {
+        for (var i = 0; i < substring.length; i++) {
+            var hs = substring.charCodeAt(i);
+            if (0xd800 <= hs && hs <= 0xdbff) {
+                if (substring.length > 1) {
+                    var ls = substring.charCodeAt(i + 1);
+                    var uc = ((hs - 0xd800) * 0x400) + (ls - 0xdc00) + 0x10000;
+                    if (0x1d000 <= uc && uc <= 0x1f77f) {
+                        return true;
+                    }
+                }
+            } else if (substring.length > 1) {
+                var ls = substring.charCodeAt(i + 1);
+                if (ls == 0x20e3) {
+                    return true;
+                }
+            } else {
+                if (0x2100 <= hs && hs <= 0x27ff) {
+                    return true;
+                } else if (0x2B05 <= hs && hs <= 0x2b07) {
+                    return true;
+                } else if (0x2934 <= hs && hs <= 0x2935) {
+                    return true;
+                } else if (0x3297 <= hs && hs <= 0x3299) {
+                    return true;
+                } else if (hs == 0xa9 || hs == 0xae || hs == 0x303d || hs == 0x3030
+                    || hs == 0x2b55 || hs == 0x2b1c || hs == 0x2b1b
+                    || hs == 0x2b50) {
+                    return true;
+                }
+            }
+        }
+    }
+</script>
+
+<style scoped>
+    p, h3 {
+        color: #fd6740;
+    }
+    h3 {
+        padding: 5px;
+        border-bottom: solid 1px #e4e4e4;
+    }
+    .card {
+        background-color: white;
+        margin: 20px 20px;
+        border: solid 1px #e4e4e4;
+        padding: 15px;
+        text-align: left;
+    }
+
+    .submit_button {
+        margin-bottom: 10px;
+        margin-left: auto;
+        margin-right: auto;
+        background-color: #fd6740;
+        border-color: #fd6740;
+        width: 85%;
+    }
 </style>