提交 3451c249 编写于 作者: guofeng.chen's avatar guofeng.chen

修改微信授权

上级 14aeb84b
......@@ -12,6 +12,7 @@ const user = {
token: localStorage.getItem('token') || '',
info: {}, // 用户信息
wxInfo, // 微信信息,openid等
wxCode: '', // 微信code
},
mutations: {
SET_TOKEN: (state, payload) => {
......@@ -23,6 +24,9 @@ const user = {
SET_WX_INFO: (state, payload) => {
state.wxInfo = payload;
},
SET_WX_CODE: (state, payload) => {
state.wxCode = payload;
},
},
actions: {
// 外部登陆返回设置token
......@@ -77,6 +81,7 @@ const user = {
},
getWxUserInfo({ state, commit }, code) {
commit('SET_WX_CODE', code);
const type = 15;
let url = process.env.BUILD_ENV === 'dev' ? `https://sc.yunqueyi.com/wechats/users/info/${type}/${code}` : getBaseUrl(`wechats/users/info/${type}/${code}`);
fetch({
......
......@@ -108,6 +108,9 @@ export default {
wxInfo() {
return this.$store.state.user.wxInfo;
},
wxCode() {
return this.$store.state.user.wxCode;
},
tabLeft() {
const num = this.curtTabIdx + 0.25 + 15 / 115;
return this.tabW * num;
......@@ -123,6 +126,15 @@ export default {
if (token && !info.id) {
this.$store.dispatch('getUserInfo');
}
// 微信内先去授权
if (isWechat && !this.wxInfo.openid) {
if (location.search.indexOf('code') >= 0 || this.wxCode) {
// 避免code中转页再次授权
return;
}
wxOauth();
return;
}
// 数量加减
this.curtGoodsNum = this.goodsNum;
this.countTotalPrice = debounce(this.getTotalPrice, 500);
......@@ -263,12 +275,6 @@ export default {
this.goLogin();
return;
}
// 微信内先去授权
if (isWechat && !this.wxInfo.openid) {
this.$toast('微信授权中');
wxOauth();
return;
}
// 避免多次支付
if (this.showLoading) {
return;
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册