From 0bd831fe350d8a24f737400589c8a6741bf844c3 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Sun, 10 Sep 2023 18:37:22 +0800 Subject: [PATCH] =?UTF-8?q?=E7=99=BB=E5=BD=95=EF=BC=9A=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E7=99=BB=E5=BD=95=E5=AE=8C=E5=90=8E=EF=BC=8C=E4=B8=8D=E4=BC=9A?= =?UTF-8?q?=E8=BF=9B=E8=A1=8C=E8=B7=B3=E8=BD=AC=EF=BC=8C=E5=9C=A8=E5=BE=AE?= =?UTF-8?q?=E4=BF=A1=E5=B0=8F=E7=A8=8B=E5=BA=8F=E7=9A=84=E6=83=85=E5=86=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/users/login/index.vue | 50 +++++++++++++++++++++++++++++++++++-- 1 file changed, 48 insertions(+), 2 deletions(-) diff --git a/pages/users/login/index.vue b/pages/users/login/index.vue index 18940f71..de103252 100644 --- a/pages/users/login/index.vue +++ b/pages/users/login/index.vue @@ -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); + } }); }) },