|
|
@@ -3,7 +3,7 @@
|
|
|
<div class="content" v-if="!flag">
|
|
|
<el-form v-if="!phoneLogin" :model="form" ref="form" :rules="rules" label-width="0">
|
|
|
<el-form-item
|
|
|
- prop="username"
|
|
|
+ prop="phone"
|
|
|
:rules="{
|
|
|
pattern: /^1[3-9]\d{9}$/,
|
|
|
message: '请输入正确的手机号',
|
|
|
@@ -11,7 +11,7 @@
|
|
|
}"
|
|
|
>
|
|
|
<span class="el-icon-mobile-phone"></span>
|
|
|
- <el-input style="width: 300px" v-model="form.username" placeholder="请输入手机号"></el-input>
|
|
|
+ <el-input style="width: 300px" v-model="form.phone" placeholder="请输入手机号"></el-input>
|
|
|
</el-form-item>
|
|
|
<div @keyup.enter="Login">
|
|
|
<el-form-item prop="password" :rules="{ required: true, message: '请输入', trigger: 'blur' }">
|
|
|
@@ -56,7 +56,7 @@
|
|
|
<el-link type="danger" v-if="!phoneLogin" @click="passwordFn">忘记密码?</el-link>
|
|
|
</div>
|
|
|
<div class="sub-btn">
|
|
|
- <div v-if="!phoneLogin" class="btn1">登录</div>
|
|
|
+ <div v-if="!phoneLogin" @click="Login2" class="btn1">登录</div>
|
|
|
<div class="btn1" v-else @click="loginPhone">登录</div>
|
|
|
<el-button style="background: #f2f3f5; color: #292c33" type="info" class="btn-block" @click="Register"
|
|
|
>还没有账号?立即注册</el-button
|
|
|
@@ -100,11 +100,11 @@
|
|
|
placeholder="请输入8-16位密码,建议数字、大小写字母组合"
|
|
|
></el-input>
|
|
|
</el-form-item>
|
|
|
- <el-form-item prop="pass">
|
|
|
+ <el-form-item prop="password2">
|
|
|
<span class="el-icon-unlock"></span>
|
|
|
<el-input
|
|
|
style="width: 300px"
|
|
|
- v-model="form.pass"
|
|
|
+ v-model="form.password2"
|
|
|
type="password"
|
|
|
autocomplete="off"
|
|
|
placeholder="请再次输入密码"
|
|
|
@@ -141,7 +141,9 @@
|
|
|
</el-dialog>
|
|
|
</template>
|
|
|
<script>
|
|
|
+import phone from '../mixins/phone';
|
|
|
export default {
|
|
|
+ mixins: [phone],
|
|
|
props: {
|
|
|
dialogVisible: {
|
|
|
type: Boolean,
|
|
|
@@ -153,9 +155,25 @@ export default {
|
|
|
show: false,
|
|
|
phoneLogin: false,
|
|
|
flag: false,
|
|
|
- rules: {},
|
|
|
+ rules: {
|
|
|
+ password: [{ min: 8, max: 16, message: '密码长度在 8 到 16 个字符', trigger: 'blur' }],
|
|
|
+ password2: [
|
|
|
+ {
|
|
|
+ validator: (rule, value, callback) => {
|
|
|
+ if (value !== this.form.password) {
|
|
|
+ callback(new Error('两次密码输入不一致'));
|
|
|
+ } else {
|
|
|
+ callback();
|
|
|
+ }
|
|
|
+ },
|
|
|
+ trigger: 'blur'
|
|
|
+ },
|
|
|
+ { required: true, message: '请再次输入密码', trigger: 'blur' }
|
|
|
+ ]
|
|
|
+ },
|
|
|
form: {},
|
|
|
time: 0,
|
|
|
+ // isSend: false,
|
|
|
checked: false
|
|
|
};
|
|
|
},
|
|
|
@@ -167,11 +185,101 @@ export default {
|
|
|
passwordFn() {
|
|
|
this.flag = true;
|
|
|
this.flag1 = false;
|
|
|
+ this.form.phone = '';
|
|
|
+ this.form.password = '';
|
|
|
+ this.form.password2 = '';
|
|
|
+ },
|
|
|
+ doRegister() {
|
|
|
+ this.$http;
|
|
|
+ this.verifyMsg(this.form.phone, this.form.code)
|
|
|
+ .then(() => {
|
|
|
+ return this.$http.post(
|
|
|
+ '/auth/phoneRegister?phone=' +
|
|
|
+ this.form.phone +
|
|
|
+ '&password=' +
|
|
|
+ this.form.password +
|
|
|
+ '&code=' +
|
|
|
+ this.form.code
|
|
|
+ );
|
|
|
+ })
|
|
|
+ .then(res => {
|
|
|
+ console.log(res);
|
|
|
+ localStorage.setItem('nineToken', res);
|
|
|
+ return this.$store.dispatch('getUserInfo');
|
|
|
+ })
|
|
|
+ .then(() => {
|
|
|
+ this.$message.warning('注册成功');
|
|
|
+ this.flag = false;
|
|
|
+ // this.form = '';
|
|
|
+ // setTimeout(() => {
|
|
|
+ // this.$router.back();
|
|
|
+ // }, 1500);
|
|
|
+ })
|
|
|
+ .catch(e => {
|
|
|
+ if (e) {
|
|
|
+ this.$message.error(e.error);
|
|
|
+ }
|
|
|
+ });
|
|
|
},
|
|
|
- loginPhone() {},
|
|
|
- doRegister() {},
|
|
|
send() {
|
|
|
- this.sendCode();
|
|
|
+ this.sendMsg(this.form.phone);
|
|
|
+ },
|
|
|
+ Login2() {
|
|
|
+ this.loading = true;
|
|
|
+ this.$http
|
|
|
+ .post('/auth/login', {
|
|
|
+ phone: this.form.phone,
|
|
|
+ password: this.form.password
|
|
|
+ })
|
|
|
+ .then(res => {
|
|
|
+ localStorage.setItem('webToken', res);
|
|
|
+ this.$message.warning('登录成功');
|
|
|
+ // this.$store.commit('loginTypeFn', true);
|
|
|
+ return this.$store.dispatch('getUserInfo');
|
|
|
+ })
|
|
|
+ // .then(() => {
|
|
|
+ // this.$router.replace('/');
|
|
|
+ // })
|
|
|
+ .catch(e => {
|
|
|
+ this.loading = false;
|
|
|
+ this.$message.error(e.error);
|
|
|
+ });
|
|
|
+ },
|
|
|
+ loginPhone() {
|
|
|
+ // return this.$http
|
|
|
+ // .post('/auth/phoneLogin', {
|
|
|
+ // phone: this.form.phone,
|
|
|
+ // code: this.form.code
|
|
|
+ // })
|
|
|
+ // .catch(e => {
|
|
|
+ // if (e) {
|
|
|
+ // this.$message.error(e.error);
|
|
|
+ // }
|
|
|
+ // return Promise.reject();
|
|
|
+ // })
|
|
|
+ // .then(res => {
|
|
|
+ // localStorage.setItem('nineToken', res);
|
|
|
+ // return this.$store.dispatch('getUserInfo');
|
|
|
+ // });
|
|
|
+ // this.$toast.loading({
|
|
|
+ // message: '加载中...',
|
|
|
+ // forbidClick: true
|
|
|
+ // });
|
|
|
+ this.verifyMsg(this.form.phone, this.form.code)
|
|
|
+ .then(() => {
|
|
|
+ return this.$http.post('/user/bindPhone?phone=' + this.form.phone);
|
|
|
+ })
|
|
|
+ .then(() => {
|
|
|
+ this.$toast.success('修改成功');
|
|
|
+ // setTimeout(() => {
|
|
|
+ // this.$router.back();
|
|
|
+ // }, 1500);
|
|
|
+ })
|
|
|
+ .catch(e => {
|
|
|
+ if (e) {
|
|
|
+ this.$toast(e.error);
|
|
|
+ }
|
|
|
+ });
|
|
|
},
|
|
|
closeDialog() {
|
|
|
this.$emit('close');
|