登录:修复登录完后,不会进行跳转,在微信小程序的情况

pull/1/MERGE
YunaiV 2023-09-10 18:37:22 +08:00
parent 54c6e483a4
commit 0bd831fe35
1 changed files with 48 additions and 2 deletions

View File

@ -62,6 +62,7 @@
import { appAuth, appleLogin } from "@/api/public";
const BACK_URL = "login_back_url";
import * as BrokerageAPI from '@/api/trade/brokerage.js'
import Routine from '@/libs/routine.js';
export default {
name: "Login",
mixins: [sendVerifyCode],
@ -243,9 +244,25 @@
title: '请输入正确的验证码'
});
}
// 1.
let socialType = undefined;
let socialCode = undefined;
let socialState = undefined;
// 1.1
// #ifdef MP
socialType = 34;
socialCode = await Routine.getCode();
socialState = 'default'
// #endif
// 2.
AuthApi.smsLogin({
mobile: this.account,
code: this.captcha,
socialType: socialType,
socialCode: socialCode,
socialState: socialState
}).then(res => {
// TODO refreshToken
let data = res.data;
@ -301,9 +318,25 @@
title: '请填写密码'
});
}
// 1.
let socialType = undefined;
let socialCode = undefined;
let socialState = undefined;
// 1.1
// #ifdef MP
socialType = 34;
socialCode = await Routine.getCode();
socialState = 'default'
// #endif
// 2.
AuthApi.login({
mobile: this.account,
password: this.password,
socialType: socialType,
socialCode: socialCode,
socialState: socialState
}).then(({ data }) => {
// TODO refreshToken
this.$store.commit("LOGIN", {
@ -319,15 +352,28 @@
},
getUserInfo(data) {
this.$store.commit("SETUID", data.userId);
this.$store.commit("OPENID", data.openid);
UserApi.getUserInfo().then(res => {
this.$store.commit("UPDATE_USERINFO", res.data);
//
let backUrl = this.$Cache.get(BACK_URL) || "/pages/index/index";
if (backUrl.indexOf('/pages/users/login/index') !== -1) {
if (backUrl.indexOf('/') !== 0) {
backUrl = '/' + backUrl;
}
if (backUrl.indexOf('/pages/users/login/index') === 0) {
backUrl = '/pages/index/index';
}
uni.reLaunch({
url: backUrl
url: backUrl,
success:function (res) {
console.log("success",res);
},
fail:function (res) {
console.log("fail",res);
},
complete:function (res) {
console.log("complete",res);
}
});
})
},