diff --git a/App.vue b/App.vue index 486d688e..a02dd09d 100644 --- a/App.vue +++ b/App.vue @@ -82,7 +82,6 @@ let urlData = location.pathname + location.search; if (!that.$store.getters.isLogin && Auth.isWeixin()) { const { code, state } = option.query; - debugger if (code && code !== uni.getStorageSync('snsapiCode') && location.pathname.indexOf('/pages/users/wechat_login/index') === -1) { // 存储静默授权code diff --git a/components/login_mobile/index.vue b/components/login_mobile/index.vue index dacda330..99aaaaae 100644 --- a/components/login_mobile/index.vue +++ b/components/login_mobile/index.vue @@ -20,7 +20,7 @@ import {mapGetters} from "vuex"; import * as AuthApi from "@/api/member/auth"; import * as UserApi from "@/api/member/user"; - import { getUserInfo, } from "@/api/user"; + import * as BrokerageAPI from '@/api/trade/brokerage.js' import { iosBinding } from '@/api/public'; const BACK_URL = "login_back_url"; export default { @@ -97,7 +97,6 @@ }, // 登录 loginBtn() { - let that = this if (!this.account) { return this.$util.Tips({ title: '请填写手机号码' @@ -122,20 +121,20 @@ if (!this.userInfo.phone && this.isLogin) { // TODO 芋艿:不晓得它要搞啥哈??? iosBinding({ - captcha: that.codeNum, - phone: that.account + captcha: this.codeNum, + phone: this.account }).then(res => { - that.$util.Tips({ + this.$util.Tips({ title: '绑定手机号成功', icon: 'success' }, { tab: 3 }) - that.isApp = 1; - that.getUserInfo(); + this.isApp = 1; + this.getUserInfo(); }).catch(error => { uni.hideLoading() - that.$util.Tips({ + this.$util.Tips({ title: error }) }) @@ -143,20 +142,20 @@ AuthApi.smsLogin({ mobile: this.account, code: this.codeNum, - socialType: 31, // TODO 芋艿:先写死,不确定会不会有其它社交方式; + socialType: 31, socialCode: this.socialCode, socialState: this.socialState }).then(res => { // TODO 芋艿:refreshToken 机制 let data = res.data; - that.$store.commit('LOGIN', { - token: data.accessToken - }); - that.$store.commit("SETUID", res.data.uid); - that.getUserInfo(); + this.$store.commit("LOGIN", { + 'token': res.data.accessToken + }); + this.getUserInfo(data); + this.bindBrokerUser(); }).catch(error => { uni.hideLoading() - that.$util.Tips({ + this.$util.Tips({ title: error }) }) @@ -165,25 +164,33 @@ /** * 获取个人用户信息 */ - getUserInfo: function() { - let that = this; - getUserInfo().then(res => { + getUserInfo: function(data) { + this.$store.commit("SETUID", data.userId); + this.$store.commit("OPENID", data.openid); + UserApi.getUserInfo().then(res => { uni.hideLoading(); - that.$store.commit("UPDATE_USERINFO", res.data); - // #ifdef MP - that.$util.Tips({ + this.$store.commit("UPDATE_USERINFO", res.data); + // 调回登录前页面 + // #ifdef MP + this.$util.Tips({ title: '登录成功', icon: 'success' }, { tab: 3 }) - that.close() + this.close() // #endif // #ifdef H5 - that.$emit('wechatPhone', true) + this.$emit('wechatPhone', true) // #endif }); }, + bindBrokerUser() { + const spread = this.$Cache.get("spread"); + if (spread > 0) { + BrokerageAPI.bindBrokerageUser(spread) + } + } } } diff --git a/libs/login.js b/libs/login.js index ec0a43fb..8d102d18 100644 --- a/libs/login.js +++ b/libs/login.js @@ -34,20 +34,16 @@ export function _toLogin(push, pathLogin) { if (isWeixin()) { let urlData = location.pathname + location.search if (!Cache.has('snsapiKey')) { - // TODO 芋艿:先临时禁用掉,改成普通登录页 - // auth.oAuth('snsapi_base', urlData); - uni.navigateTo({ - url: '/pages/users/login/index' - }) + auth.oAuth('snsapi_base', urlData); } else { - if (['/pages/user/index'].indexOf(login_back_url) == -1) { + if (['/pages/user/index'].indexOf(login_back_url) === -1) { uni.navigateTo({ url: '/pages/users/wechat_login/index' }) } } } else { - if (['/pages/user/index'].indexOf(login_back_url) == -1) { + if (['/pages/user/index'].indexOf(login_back_url) === -1) { uni.navigateTo({ url: '/pages/users/login/index' }) @@ -55,11 +51,10 @@ export function _toLogin(push, pathLogin) { } // #endif - if (['pages/user/index','/pages/user/index'].indexOf(login_back_url) == -1) { + if (['pages/user/index','/pages/user/index'].indexOf(login_back_url) === -1) { // #ifdef MP - // TODO 芋艿:先临时禁用掉,改成普通登录页 uni.navigateTo({ - url: '/pages/users/login/index' + url: '/pages/users/wechat_login/index' }) // #endif } diff --git a/libs/wechat.js b/libs/wechat.js index c1c81863..10dd7165 100644 --- a/libs/wechat.js +++ b/libs/wechat.js @@ -156,7 +156,7 @@ class AuthWechat { return; } const { code } = parseQuery(); - if (!code || code == uni.getStorageSync('snsapiCode')){ + if (!code || code === uni.getStorageSync('snsapiCode')){ return this.toAuth(snsapiBase,url); } else{ if(Cache.has('snsapiKey')) diff --git a/pages/users/login/index.vue b/pages/users/login/index.vue index 739a06f2..5d04a686 100644 --- a/pages/users/login/index.vue +++ b/pages/users/login/index.vue @@ -398,16 +398,7 @@ backUrl = '/pages/index/index'; } uni.reLaunch({ - url: backUrl, - success:function (res) { - console.log("success",res); - }, - fail:function (res) { - console.log("fail",res); - }, - complete:function (res) { - console.log("complete",res); - } + url: backUrl }); }) }, diff --git a/pages/users/wechat_login/index.vue b/pages/users/wechat_login/index.vue index 28d1b27f..564a4f5a 100644 --- a/pages/users/wechat_login/index.vue +++ b/pages/users/wechat_login/index.vue @@ -39,13 +39,13 @@