登录:接入验证码登录
parent
b71fed3782
commit
3c7db828db
|
|
@ -30,3 +30,10 @@ export function login(data) {
|
||||||
noAuth: true // TODO 芋艿:后续要做调整
|
noAuth: true // TODO 芋艿:后续要做调整
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 使用手机 + 验证码登录
|
||||||
|
export function smsLogin(data) {
|
||||||
|
return request.post('app-api/member/auth/sms-login', data, {
|
||||||
|
noAuth: true // TODO 芋艿:后续要做调整
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -57,12 +57,13 @@
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
import sendVerifyCode from "@/mixins/SendVerifyCode";
|
import sendVerifyCode from "@/mixins/SendVerifyCode";
|
||||||
import { loginMobile, registerVerify } from "@/api/user";
|
import { loginMobile } from "@/api/user";
|
||||||
import * as AuthApi from "@/api/member/auth";
|
import * as AuthApi from "@/api/member/auth";
|
||||||
import * as UserApi from "@/api/member/user";
|
import * as UserApi from "@/api/member/user";
|
||||||
import { appAuth, appleLogin } from "@/api/public";
|
import { appAuth, appleLogin } from "@/api/public";
|
||||||
const BACK_URL = "login_back_url";
|
const BACK_URL = "login_back_url";
|
||||||
import * as BrokerageAPI from '@/api/trade/brokerage.js'
|
import * as BrokerageAPI from '@/api/trade/brokerage.js'
|
||||||
|
import {smsLogin} from "../../../api/member/auth";
|
||||||
export default {
|
export default {
|
||||||
name: "Login",
|
name: "Login",
|
||||||
mixins: [sendVerifyCode],
|
mixins: [sendVerifyCode],
|
||||||
|
|
@ -224,56 +225,61 @@
|
||||||
* 手机 + 验证码登录
|
* 手机 + 验证码登录
|
||||||
*/
|
*/
|
||||||
async loginMobile() {
|
async loginMobile() {
|
||||||
let that = this;
|
|
||||||
if (!this.account) {
|
if (!this.account) {
|
||||||
return that.$util.Tips({
|
return this.$util.Tips({
|
||||||
title: '请填写手机号码'
|
title: '请填写手机号码'
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (!/^1(3|4|5|7|8|9|6)\d{9}$/i.test(that.account)) return that.$util.Tips({
|
if (!/^1(3|4|5|7|8|9|6)\d{9}$/i.test(this.account)) {
|
||||||
title: '请输入正确的手机号码'
|
return this.$util.Tips({
|
||||||
});
|
title: '请输入正确的手机号码'
|
||||||
if (!that.captcha) return that.$util.Tips({
|
});
|
||||||
title: '请填写验证码'
|
}
|
||||||
});
|
if (!this.captcha) {
|
||||||
if (!/^[\w\d]+$/i.test(that.captcha)) return that.$util.Tips({
|
return this.$util.Tips({
|
||||||
title: '请输入正确的验证码'
|
title: '请填写验证码'
|
||||||
});
|
});
|
||||||
loginMobile({
|
}
|
||||||
phone: that.account,
|
if (!/^[\w\d]+$/i.test(this.captcha)) {
|
||||||
captcha: that.captcha,
|
return this.$util.Tips({
|
||||||
spread_spid: that.$Cache.get("spread")
|
title: '请输入正确的验证码'
|
||||||
})
|
});
|
||||||
.then(res => {
|
}
|
||||||
let data = res.data;
|
AuthApi.smsLogin({
|
||||||
let newTime = Math.round(new Date() / 1000);
|
mobile: this.account,
|
||||||
this.$store.commit("LOGIN", {
|
code: this.captcha,
|
||||||
'token': res.data.token
|
}).then(res => {
|
||||||
});
|
// TODO 芋艿:refreshToken 机制
|
||||||
that.getUserInfo(data);
|
let data = res.data;
|
||||||
})
|
this.$store.commit("LOGIN", {
|
||||||
.catch(res => {
|
'token': res.data.accessToken
|
||||||
that.$util.Tips({
|
});
|
||||||
title: res
|
this.getUserInfo(data);
|
||||||
});
|
this.bindBrokerUser();
|
||||||
});
|
}).catch(res => {
|
||||||
|
this.$util.Tips({
|
||||||
|
title: res
|
||||||
|
});
|
||||||
|
});
|
||||||
},
|
},
|
||||||
async code() {
|
async code() {
|
||||||
let that = this;
|
if (!this.account) {
|
||||||
if (!that.account) return that.$util.Tips({
|
return this.$util.Tips({
|
||||||
title: '请填写手机号码'
|
title: '请填写手机号码'
|
||||||
});
|
});
|
||||||
if (!/^1(3|4|5|7|8|9|6)\d{9}$/i.test(that.account)) return that.$util.Tips({
|
}
|
||||||
title: '请输入正确的手机号码'
|
if (!/^1(3|4|5|7|8|9|6)\d{9}$/i.test(this.account)) {
|
||||||
});
|
return this.$util.Tips({
|
||||||
if (that.formItem == 2) that.type = "register";
|
title: '请输入正确的手机号码'
|
||||||
await registerVerify(that.account)
|
});
|
||||||
|
}
|
||||||
|
await AuthApi.sendSmsCode(this.account, 1)
|
||||||
.then(res => {
|
.then(res => {
|
||||||
that.$util.Tips({title:res.message});
|
this.$util.Tips({title:res.message});
|
||||||
that.sendCode();
|
this.sendCode();
|
||||||
})
|
})
|
||||||
.catch(err => {
|
.catch(err => {
|
||||||
return that.$util.Tips({
|
return this.$util.Tips({
|
||||||
title: err
|
title: err
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue