Browse Source

图形验证码

panhui 4 năm trước cách đây
mục cha
commit
8cbb5e6863

+ 47 - 4
src/main/nine-space/src/views/account/Register.vue

@@ -24,6 +24,21 @@
                 </template>
             </van-field>
 
+            <van-field
+                name="图形验证码"
+                placeholder="请输入图形验证码"
+                v-model="form.captcha"
+                :maxlength="6"
+                :rules="[{ required: true, message: '请输入图形验证码' }]"
+            >
+                <template #left-icon>
+                    <img :src="require('@assets/svgs/login_icon_code.svg')" class="icon" />
+                </template>
+                <template #button>
+                    <van-image @click="getCode" :src="codeImg" width="68" height="32" fit="contain" />
+                </template>
+            </van-field>
+
             <van-field
                 type="digit"
                 name="验证码"
@@ -135,15 +150,43 @@ export default {
                 password: '',
                 password2: '',
                 code: '',
-                inviteCode: this.$store.state.inviteCode || ''
+                inviteCode: this.$store.state.inviteCode || '',
+                captchaKey: '',
+                captcha: ''
             },
+            codeImg: '',
             checked: false
         };
     },
+    mounted() {
+        this.getCode();
+    },
     methods: {
+        getCode() {
+            this.$http.get('/captcha/get').then(res => {
+                this.form.captchaKey = res.key;
+                this.codeImg = res.image;
+            });
+        },
         sendPhone() {
-            this.$refs.form.validate('手机号码').then(() => {
-                this.sendMsg(this.form.phone);
+            this.$refs.form.validate(['手机号码', '图形验证码']).then(() => {
+                // this.sendMsg(this.form.phone);
+                this.$http
+                    .get('/sms/sendCaptchaVerify', {
+                        phone: this.form.phone,
+                        captchaKey: this.form.captchaKey,
+                        captcha: this.form.captcha
+                    })
+                    .then(res => {
+                        this.isSend = true;
+                        this.setTime(60);
+                        this.msgCode = res;
+                        this.$toast.success('发送成功');
+                    })
+                    .catch(e => {
+                        this.$toast(e.error);
+                        this.setTime(0);
+                    });
             });
         },
         submit() {
@@ -164,7 +207,7 @@ export default {
                 .then(() => {
                     this.$toast.success('注册成功');
                     setTimeout(() => {
-                        this.$router.back();
+                        this.$router.push('/home');
                     }, 1500);
                 })
                 .catch(e => {

+ 4 - 1
src/main/nine-space/src/views/product/List.vue

@@ -83,6 +83,7 @@ export default {
                 }
             ],
             url: '/collection/all',
+            salable: false,
             title: ''
         };
     },
@@ -98,6 +99,7 @@ export default {
 
         if (this.$route.query.source) {
             this.source = this.$route.query.source;
+            this.salable = true;
         }
 
         if (this.$route.query.minterId) {
@@ -120,7 +122,8 @@ export default {
                     source: this.source,
                     onShelf: true,
                     del: false,
-                    minterId: this.minterId
+                    minterId: this.minterId,
+                    salable: this.salable || ''
                 },
                 sort: this.sortOptions[this.title] || this.sort
             };

+ 4 - 2
src/main/nine-space/src/views/product/Search.vue

@@ -89,9 +89,11 @@ export default {
                     type: this.type,
                     source: this.source,
                     minterId: this.minterId,
-                    del: false
+                    del: false,
+                    salable: true
                 },
-                search: this.search
+                search: this.search,
+                sort: 'price,asc'
             };
         }
     }