Unverified Commit 7df32f31 authored by linlinjava's avatar linlinjava Committed by GitHub
Browse files

#311



* Add register function.

* Add register function.
Co-authored-by: default avatarLongbao Ye <yelongbao@126.com>
parent 38227877
...@@ -59,6 +59,13 @@ export function authProfile(data) { ...@@ -59,6 +59,13 @@ export function authProfile(data) {
}) })
} }
const AuthRegister='wx/auth/register'; //账号注册 const AuthRegister='wx/auth/register'; //账号注册
export function authRegister(data) {
return request({
url: AuthRegister,
method: 'post',
data
});
}
const AuthReset='wx/auth/reset'; //账号密码重置 const AuthReset='wx/auth/reset'; //账号密码重置
export function authReset(data) { export function authReset(data) {
return request({ return request({
......
...@@ -10,8 +10,9 @@ export default [ ...@@ -10,8 +10,9 @@ export default [
component: () => import('@/views/login/register-getCode') component: () => import('@/views/login/register-getCode')
}, },
{ {
path: '/login/registerSubmit', path: '/login/registerSubmit/:phone',
name: 'registerSubmit', name: 'registerSubmit',
props: true,
component: () => import('@/views/login/register-submit') component: () => import('@/views/login/register-submit')
}, },
{ {
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
<script> <script>
import field from '@/components/field/'; import field from '@/components/field/';
import fieldGroup from '@/components/field-group/'; import fieldGroup from '@/components/field-group/';
import { mobileReg } from '@/utils/validate';
export default { export default {
data() { data() {
...@@ -30,7 +31,21 @@ export default { ...@@ -30,7 +31,21 @@ export default {
methods: { methods: {
submitCode() { submitCode() {
this.$router.push({ name: 'registerSubmit' }); if(this.mobile === ''){
return
}
if(!mobileReg.test(this.mobile)){
this.mobile = ''
return
}
try {
this.$router.push({
name: 'registerSubmit',
params: { phone: this.mobile}
});
} catch (error) {
console.log(error.message);
}
} }
}, },
......
...@@ -5,11 +5,22 @@ ...@@ -5,11 +5,22 @@
<div>{{statusText}}</div> <div>{{statusText}}</div>
</div> </div>
<div class="status_text"><span class="red">3秒</span>后返回到登录页, 您也可以<router-link to="/login" class="red">点此登录</router-link></div> <div class="status_text">
<span class="red">
<countdown v-if="counting" :time="3000" @end="countDownEnd">
<template slot-scope="props">{{ +props.seconds || 3 }}</template>
</countdown>
</span>
后返回到登录页, 您也可以
<router-link to="/login" class="red">点此登录</router-link>
</div>
</div> </div>
</template> </template>
<script> <script>
import field from '@/components/field/';
import fieldGroup from '@/components/field-group/';
export default { export default {
name: 'payment-status', name: 'payment-status',
...@@ -19,10 +30,18 @@ export default { ...@@ -19,10 +30,18 @@ export default {
data() { data() {
return { return {
counting: true,
isSuccess: true isSuccess: true
}; };
}, },
methods:{
countDownEnd() {
this.counting = false;
window.location = '#/login/';
}
},
computed: { computed: {
statusText() { statusText() {
return this.isSuccess ? '注册成功' : '注册失败'; return this.isSuccess ? '注册成功' : '注册失败';
...@@ -37,6 +56,11 @@ export default { ...@@ -37,6 +56,11 @@ export default {
activated() { activated() {
this.isSuccess = this.status === 'success'; this.isSuccess = this.status === 'success';
},
components: {
[field.name]: field,
[fieldGroup.name]: fieldGroup
} }
}; };
</script> </script>
......
...@@ -2,12 +2,13 @@ ...@@ -2,12 +2,13 @@
<md-field-group class="register_submit"> <md-field-group class="register_submit">
<md-field v-model="code" icon="mobile" placeholder="请输入验证码"> <md-field v-model="code" icon="mobile" placeholder="请输入验证码">
<div slot="rightIcon" @click="getCode" class="getCode red"> <div slot="rightIcon" @click="getCode" class="getCode red">
<countdown v-if="counting" :time="60000" @end="countdownend"> <countdown v-if="counting" :time="60000" @end="countDownEnd">
<template slot-scope="props">{{ +props.seconds || 60 }}秒后获取</template> <template slot-scope="props">{{ +props.seconds || 60 }}秒后获取</template>
</countdown> </countdown>
<span v-else>获取验证码</span> <span v-else>获取验证码</span>
</div> </div>
</md-field> </md-field>
<md-field v-model="username" icon="username" placeholder="请输入用户名"/>
<md-field v-model="password" icon="lock" placeholder="请输入密码"/> <md-field v-model="password" icon="lock" placeholder="请输入密码"/>
<md-field v-model="repeatPassword" icon="lock" placeholder="请再次确认密码"/> <md-field v-model="repeatPassword" icon="lock" placeholder="请再次确认密码"/>
...@@ -20,29 +21,83 @@ ...@@ -20,29 +21,83 @@
<script> <script>
import field from '@/components/field/'; import field from '@/components/field/';
import fieldGroup from '@/components/field-group/'; import fieldGroup from '@/components/field-group/';
import { authRegisterCaptcha } from '@/api/api';
import { authRegister } from '@/api/api';
import {Toast} from "vant";
export default { export default {
props: {
phone: String
},
data() { data() {
return { return {
counting: true, counting: true,
code: '', code: '',
username: '',
password: '', password: '',
repeatPassword: '' repeatPassword: ''
}; };
}, },
mounted:function(){
this.getCode();
},
methods: { methods: {
registerSubmit() { registerSubmit() {
if(this.username === '' || this.code === ''){
return
}
if(this.password === '' || this.repeatPassword === ''){
return
}
if(this.password !== this.repeatPassword){
this.password = ''
this.repeatPassword = ''
return
}
let data = this.getRegisterData();
authRegister(data).then(res => {
this.$router.push({ this.$router.push({
name: 'registerStatus', name: 'registerStatus',
params: { status: 'success' } params: { status: 'success' }
}); });
}).catch (error => {
Toast.fail(error.data.errmsg);
if (error.data.errno == 705) {
window.location = '#/login/';
}
});
}, },
getCode() { getCode() {
this.counting = true; this.counting = true;
let data = {
mobile: this.phone
};
authRegisterCaptcha(data).then(res => {
this.counting = true;
}).catch(error => {
alert(error.data.errmsg);
this.counting = true;
});
},
getRegisterData() {
const password = this.password;
const code = this.code;
const repeatPassword = this.repeatPassword;
const mobile = this.phone;
const username = this.username;
return {
code: code,
username: username,
password: password,
repeatPassword: repeatPassword,
mobile: mobile
};
}, },
countdownend() {
countDownEnd() {
this.counting = false; this.counting = false;
} }
}, },
......
...@@ -325,7 +325,6 @@ public class WxAuthController { ...@@ -325,7 +325,6 @@ public class WxAuthController {
return ResponseUtil.ok(result); return ResponseUtil.ok(result);
} }
/** /**
* 请求验证码 * 请求验证码
* *
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment