分佣:绑定 user

pull/1/MERGE
YunaiV 2023-09-09 21:06:25 +08:00
parent e9019e9d39
commit 15b7e3d94c
5 changed files with 31 additions and 40 deletions

View File

@ -81,7 +81,7 @@
let snsapiBase = 'snsapi_base'; let snsapiBase = 'snsapi_base';
let urlData = location.pathname + location.search; let urlData = location.pathname + location.search;
if (!that.$store.getters.isLogin && Auth.isWeixin()) { if (!that.$store.getters.isLogin && Auth.isWeixin()) {
const { code, state, scope } = option.query; const { code, } = option.query;
if (code && code != uni.getStorageSync('snsapiCode') if (code && code != uni.getStorageSync('snsapiCode')
&& location.pathname.indexOf('/pages/users/wechat_login/index') === -1) { && location.pathname.indexOf('/pages/users/wechat_login/index') === -1) {
// code // code
@ -89,8 +89,7 @@
let spread = that.globalData.spid ? that.globalData.spid : 0; let spread = that.globalData.spid ? that.globalData.spid : 0;
Auth.auth(code, that.$Cache.get('spread')) Auth.auth(code, that.$Cache.get('spread'))
.then(res => { .then(res => {
uni.setStorageSync('snRouter', decodeURIComponent(decodeURIComponent(option.query uni.setStorageSync('snRouter', decodeURIComponent(decodeURIComponent(option.query.back_url)));
.back_url)));
if (res.type === 'register') { if (res.type === 'register') {
this.$Cache.set('snsapiKey', res.key); this.$Cache.set('snsapiKey', res.key);
} }

View File

@ -5,6 +5,13 @@ export function getBrokerageUser() {
return request.get('app-api/trade/brokerage-user/get'); return request.get('app-api/trade/brokerage-user/get');
} }
// 获得个人分销信息
export function bindBrokerageUser(bindUserId) {
return request.put('app-api/trade/brokerage-user/bind', {
bindUserId
});
}
// 获得个人分销统计 // 获得个人分销统计
export function getBrokerageUserSummary() { export function getBrokerageUserSummary() {
return request.get('app-api/trade/brokerage-user/get-summary'); return request.get('app-api/trade/brokerage-user/get-summary');

View File

@ -17,19 +17,13 @@
<script> <script>
const app = getApp(); const app = getApp();
import sendVerifyCode from "@/mixins/SendVerifyCode"; import sendVerifyCode from "@/mixins/SendVerifyCode";
import Routine from '@/libs/routine';
import {mapGetters} from "vuex"; import {mapGetters} from "vuex";
import { import {
loginMobile,
registerVerify, registerVerify,
getCodeApi, getCodeApi,
getUserInfo, getUserInfo,
phoneSilenceAuth, phoneSilenceAuth,
phoneWxSilenceAuth
} from "@/api/user"; } from "@/api/user";
import {
bindingPhone
} from '@/api/api.js'
import { import {
getUserPhone, getUserPhone,
iosBinding iosBinding
@ -173,7 +167,6 @@
phoneSilenceAuth({ phoneSilenceAuth({
code: code, code: code,
spid: app.globalData.spid, spid: app.globalData.spid,
spread: app.globalData.code,
phone: this.account, phone: this.account,
captcha: this.codeNum captcha: this.codeNum
}).then(res => { }).then(res => {

View File

@ -119,10 +119,10 @@
// #ifdef MP // #ifdef MP
phoneSilenceAuth(code) { phoneSilenceAuth(code) {
let self = this let self = this
// TODO @
phoneSilenceAuth({ phoneSilenceAuth({
code: code, code: code,
spid: app.globalData.spid, spid: app.globalData.spid,
spread: app.globalData.code,
phone: this.account, phone: this.account,
captcha: this.codeNum captcha: this.codeNum
}).then(res => { }).then(res => {

View File

@ -57,12 +57,13 @@
</template> </template>
<script> <script>
import sendVerifyCode from "@/mixins/SendVerifyCode"; import sendVerifyCode from "@/mixins/SendVerifyCode";
import { loginMobile, registerVerify, getUserInfo } from "@/api/user"; import { loginMobile, registerVerify } 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";
export default { import * as BrokerageAPI from '@/api/trade/brokerage.js'
export default {
name: "Login", name: "Login",
mixins: [sendVerifyCode], mixins: [sendVerifyCode],
data: function() { data: function() {
@ -299,14 +300,13 @@
AuthApi.login({ AuthApi.login({
mobile: this.account, mobile: this.account,
password: this.password, password: this.password,
spread: this.$Cache.get("spread") // TODO
}).then(({ data }) => { }).then(({ data }) => {
// debugger
// TODO refreshToken // TODO refreshToken
this.$store.commit("LOGIN", { this.$store.commit("LOGIN", {
'token': data.accessToken 'token': data.accessToken
}); });
this.getUserInfo(data); this.getUserInfo(data);
this.bindBrokerUser();
}).catch(e => { }).catch(e => {
this.$util.Tips({ this.$util.Tips({
title: e title: e
@ -315,32 +315,24 @@
}, },
getUserInfo(data) { getUserInfo(data) {
this.$store.commit("SETUID", data.userId); this.$store.commit("SETUID", data.userId);
// TODO UserApi.getUserInfo().then(res => {
if (true) { this.$store.commit("UPDATE_USERINFO", res.data);
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) {
let backUrl = this.$Cache.get(BACK_URL) || "/pages/index/index"; backUrl = '/pages/index/index';
if (backUrl.indexOf('/pages/users/login/index') !== -1) { }
backUrl = '/pages/index/index'; uni.reLaunch({
} url: backUrl
uni.reLaunch({ });
url: backUrl })
}); },
}) bindBrokerUser() {
} else { const spread = this.$Cache.get("spread");
getUserInfo().then(res => { if (spread > 0) {
this.$store.commit("UPDATE_USERINFO", res.data); BrokerageAPI.bindBrokerageUser(spread)
let backUrl = this.$Cache.get(BACK_URL) || "/pages/index/index";
if (backUrl.indexOf('/pages/users/login/index') !== -1) {
backUrl = '/pages/index/index';
}
uni.reLaunch({
url: backUrl
});
})
} }
} }
} }
}; };
</script> </script>