update @关闭自动授权,红包/立减金 公众号授权区分
This commit is contained in:
parent
dc44e4aa75
commit
c0b7029a29
|
@ -46,9 +46,10 @@ export const { accountTypeMap } = {
|
|||
/**
|
||||
* 支付宝/微信 授权地址/环境判断
|
||||
*/
|
||||
export const { isWx, wxAuthUrl, zfbAuthUrl, zfbAuthMiniUrl } = {
|
||||
export const { isWx, wxAuthUrlHB, wxAuthUrlLJJ, zfbAuthUrl, zfbAuthMiniUrl } = {
|
||||
isWx: navigator.userAgent.toLowerCase().indexOf('micromessenger') !== -1,
|
||||
wxAuthUrl: 'https://utils.85938.cn/utils/v1/wechat/oauth/bale',
|
||||
wxAuthUrlHB: 'https://openapi.1688sup.com/wechat/oauth?payment_subject=bale', // 红包
|
||||
wxAuthUrlLJJ: 'https://openapi.1688sup.com/wechat/oauth', // 立减金
|
||||
zfbAuthUrl: 'https://openapi.1688sup.com/alipay/oauth',
|
||||
zfbAuthMiniUrl: 'alipays://platformapi/startapp?appId=2021004100663111',
|
||||
};
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { copyFn } from "@/utils/methods";
|
||||
import { isWx, wxAuthUrl, zfbAuthUrl, zfbAuthMiniUrl } from "@/utils/datas";
|
||||
import { isWx, wxAuthUrlHB, wxAuthUrlLJJ, zfbAuthUrl, zfbAuthMiniUrl } from "@/utils/datas";
|
||||
import { GET_WXSCHEMA } from "@/router/api";
|
||||
|
||||
/**
|
||||
|
@ -15,17 +15,24 @@ export async function channelJudge (channel: number, mode: number, judgeData?: a
|
|||
if (id) { // 单品
|
||||
url = url + `&id=${id}`;
|
||||
}
|
||||
|
||||
if (group_id) { // 组合商品
|
||||
url = url + `&group_id=${group_id}&ids=${JSON.stringify(ids)}`;
|
||||
url = url + `&group_id=${group_id}&ids=${JSON.stringify(ids)}&goodType=${type}`;
|
||||
}
|
||||
const openid = localStorage.getItem('openid');
|
||||
if (openid) {
|
||||
url = url + `&openid=${openid}`;
|
||||
// 组合商品 存在 红包/立减金 支付宝/微信 切换兑换(复制链接)的情况
|
||||
const openidHB = localStorage.getItem('openidHB');
|
||||
const openidLJJ = localStorage.getItem('openidLJJ');
|
||||
if (openidHB) {
|
||||
url = url + `&openidHB=${openidHB}`;
|
||||
}
|
||||
if (openidLJJ) {
|
||||
url = url + `&openidLJJ=${openidLJJ}`;
|
||||
}
|
||||
const alipayuserid = localStorage.getItem('alipayuserid');
|
||||
if (alipayuserid) {
|
||||
url = url + `&alipayuserid=${alipayuserid}`;
|
||||
}
|
||||
|
||||
const backLink = encodeURIComponent(url);
|
||||
if (channel === 1 && mode === 1) { // 支付宝-官方领取 区分商品类型:1 红包 支付宝小程序;3 立减金 支付宝授权
|
||||
const ua = navigator.userAgent.toLowerCase();
|
||||
|
@ -80,9 +87,11 @@ export async function channelJudge (channel: number, mode: number, judgeData?: a
|
|||
showToast(res?.message || '请求失败')
|
||||
}
|
||||
} else {
|
||||
if (!localStorage.getItem('openid')) {
|
||||
// 微信进入未获取到 openid
|
||||
location.replace(`${wxAuthUrl}?jump=${backLink}`);
|
||||
if (!localStorage.getItem('openidHB') && [1].includes(type)) { // 红包
|
||||
location.replace(`${wxAuthUrlHB}&jump=${backLink}`);
|
||||
}
|
||||
if (!localStorage.getItem('openidLJJ') && [3].includes(type)) { // 立减金
|
||||
location.replace(`${wxAuthUrlLJJ}?jump=${backLink}`);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
<script lang="ts">
|
||||
import { LOGIN } from "@/router/api";
|
||||
import { wxAuthUrl } from "@/utils/datas";
|
||||
// import { wxAuthUrl } from "@/utils/datas"; // 后续开放自动授权需要区分红包/立减金
|
||||
import { getQueryParams } from "@/utils/methods";
|
||||
import env from "@/utils/request/env";
|
||||
|
||||
|
@ -17,8 +17,8 @@ export default {
|
|||
key: this.$route.query.key || localStorage.getItem("key") || '',
|
||||
loginBack: this.$route.query.loginBack,
|
||||
// jumpPath: this.$route.query.jumpPath,
|
||||
openid: getQueryParams('openid') || localStorage.getItem("openid") || '', // 微信授权id
|
||||
isAutoEmpower: true,
|
||||
// openid: getQueryParams('openid') || '', // 微信授权id
|
||||
isAutoEmpower: false, // 红包/立减金 授权公众号不一样 入口暂时关闭自动授权
|
||||
loadingText: '加载中',
|
||||
dialogType: '',
|
||||
dialogText: '',
|
||||
|
@ -33,7 +33,7 @@ export default {
|
|||
sessionStorage.clear();
|
||||
localStorage.clear();
|
||||
this.key && localStorage.setItem("key", this.key);
|
||||
this.openid && localStorage.setItem("openid", this.openid);
|
||||
// this.openid && localStorage.setItem("openid", this.openid);
|
||||
}
|
||||
this.preLogic();
|
||||
},
|
||||
|
@ -46,15 +46,15 @@ export default {
|
|||
// sessionStorage.setItem("jumpPath", this.jumpPath || ''); // 复制链接-直接跳转详情页(暂时不用)
|
||||
|
||||
// 微信环境 自动授权
|
||||
if (this.isAutoEmpower && !this.openid && navigator.userAgent.toLowerCase().indexOf('micromessenger') !== -1) {
|
||||
const backLink = encodeURIComponent(`${location.origin}${env.BASE_DIRECTORY}cmsList`);
|
||||
const url = `${wxAuthUrl}?jump=${backLink}`;
|
||||
return location.replace(url);
|
||||
} else if (this.loginBack) {
|
||||
return location.replace(this.loginBack);
|
||||
} else {
|
||||
return this.$router.replace({ path: '/cmsList' });
|
||||
}
|
||||
// if (this.isAutoEmpower && !this.openid && navigator.userAgent.toLowerCase().indexOf('micromessenger') !== -1) {
|
||||
// const backLink = encodeURIComponent(`${location.origin}${env.BASE_DIRECTORY}cmsList`);
|
||||
// const url = `${wxAuthUrl}?jump=${backLink}`;
|
||||
// return location.replace(url);
|
||||
// } else if (this.loginBack) {
|
||||
// return location.replace(this.loginBack);
|
||||
// } else {
|
||||
// return this.$router.replace({ path: '/cmsList' });
|
||||
// }
|
||||
}
|
||||
}
|
||||
this.loginBack = '';
|
||||
|
|
|
@ -140,8 +140,9 @@ export default {
|
|||
data() {
|
||||
return {
|
||||
key: this.$route.query.key || localStorage.getItem("key"),
|
||||
openid: getQueryParams('openid') || localStorage.getItem("openid"), // 微信授权id
|
||||
alipayuserid: this.$route.query.alipayuserid || localStorage.getItem("alipayuserid"), // 支付宝授权id
|
||||
openid: getQueryParams('openid') || '', // 微信授权id
|
||||
goodType: '', // 微信授权区分 红包/立减,授权回调地址需要商品类型
|
||||
alipayuserid: this.$route.query.alipayuserid || '', // 支付宝授权id
|
||||
groupId: Number(this.$route.query.group_id),
|
||||
ids: JSON.parse(this.$route.query.ids || '[]'),
|
||||
detailType: 0, // 路由 replace 详情 type
|
||||
|
@ -254,6 +255,9 @@ export default {
|
|||
},
|
||||
async created() {
|
||||
document.title = '组合商品';
|
||||
this.openid && this.goodType === 1 && localStorage.setItem("openidHB", this.openid);
|
||||
this.openid && this.goodType === 3 && localStorage.setItem("openidLJJ", this.openid);
|
||||
this.alipayuserid && localStorage.setItem("alipayuserid", this.alipayuserid);
|
||||
if (this.$route.query.key && this.$route.query.token && this.groupId && !sessionStorage.getItem('autoReceive')) { // 回调/复制 打开
|
||||
urlToLocal();
|
||||
sessionStorage.setItem('autoReceive', 'is');
|
||||
|
@ -503,7 +507,7 @@ export default {
|
|||
}
|
||||
|
||||
// 直充(非 卡密-平台下发) + 红包/立减金(支付-账号领取/云闪付) 输入判断
|
||||
let obj = this.selectedPro[0], account = '';
|
||||
let obj = this.selectedPro[0], account: any = '';
|
||||
if (this.getModalPlaceholder) {
|
||||
if (type !== 'submit') {
|
||||
return this.inputModalShow = true;
|
||||
|
@ -539,10 +543,10 @@ export default {
|
|||
// 红包/立减金(支付-官方领取/微信) 授权判断
|
||||
if (obj.goods.type === 1) { // 红包
|
||||
if (obj.cash.channel === 1 && obj.cash.receive_mode === 1) { // 支付宝-官方领取
|
||||
account = this.alipayuserid;
|
||||
account = localStorage.getItem("alipayuserid");
|
||||
}
|
||||
if (obj.cash.channel === 2) { // 微信
|
||||
account = this.openid;
|
||||
account = localStorage.getItem("openidHB");
|
||||
}
|
||||
if (!account) { // 存在打开 支付宝/微信 webview 返回 不刷新页面的情况
|
||||
this.visibilityFunc();
|
||||
|
@ -550,10 +554,10 @@ export default {
|
|||
if (!account) return channelJudge(obj.cash.channel, obj.cash.receive_mode, { group_id: this.groupId, ids: ids, type: 1 });
|
||||
} else if (obj.goods.type === 3) {
|
||||
if (obj.info.channel === 1 && obj.info.receive_mode === 1) { // 支付宝-官方领取
|
||||
account = this.alipayuserid;
|
||||
account = localStorage.getItem("alipayuserid");
|
||||
}
|
||||
if (obj.info.channel === 2) { // 微信
|
||||
account = this.openid;
|
||||
account = localStorage.getItem("openidLJJ");
|
||||
}
|
||||
if (!account) { // 存在打开 支付宝/微信 webview 返回 不刷新页面的情况
|
||||
this.visibilityFunc();
|
||||
|
|
|
@ -119,8 +119,8 @@ export default {
|
|||
data() {
|
||||
return {
|
||||
key: this.$route.query.key || localStorage.getItem("key"),
|
||||
openid: getQueryParams('openid') || localStorage.getItem("openid"), // 微信授权id
|
||||
alipayuserid: this.$route.query.alipayuserid || localStorage.getItem("alipayuserid"), // 支付宝授权id
|
||||
openid: getQueryParams('openid') || '', // 微信授权id
|
||||
alipayuserid: this.$route.query.alipayuserid || '', // 支付宝授权id
|
||||
goodId: Number(this.$route.query.id),
|
||||
goods: {}, // 商品基本信息
|
||||
cash: {}, // 红包信息
|
||||
|
@ -150,6 +150,8 @@ export default {
|
|||
};
|
||||
},
|
||||
created() {
|
||||
this.openid && localStorage.setItem("openidHB", this.openid);
|
||||
this.alipayuserid && localStorage.setItem("alipayuserid", this.alipayuserid);
|
||||
if (this.$route.query.key && this.$route.query.token && this.goodId && !sessionStorage.getItem('autoReceive')) { // 回调/复制 打开
|
||||
urlToLocal();
|
||||
sessionStorage.setItem('autoReceive', 'is');
|
||||
|
@ -267,7 +269,7 @@ export default {
|
|||
this.pollStatus = true;
|
||||
return that.pollTime = setTimeout(() => { that.orderPolling() }, pollTimeNum);
|
||||
}
|
||||
let account = '';
|
||||
let account: any = '';
|
||||
if (this.needInput) { // 支付宝-账号领取 + 云闪付
|
||||
if (!this.inputVal) {
|
||||
return showToast('请输入账号');
|
||||
|
@ -291,13 +293,13 @@ export default {
|
|||
account = this.inputVal;
|
||||
}
|
||||
if (this.cash.channel === 1 && this.cash.receive_mode === 1) { // 支付宝-官方领取
|
||||
account = this.alipayuserid;
|
||||
account = localStorage.getItem("alipayuserid");
|
||||
if (!account) { // 存在打开 支付宝/微信 webview 返回 不刷新页面的情况
|
||||
this.visibilityFunc();
|
||||
}
|
||||
}
|
||||
if (this.cash.channel === 2) { // 微信
|
||||
account = this.openid;
|
||||
account = localStorage.getItem("openidHB");
|
||||
if (!account) { // 存在打开 支付宝/微信 webview 返回 不刷新页面的情况
|
||||
this.visibilityFunc();
|
||||
}
|
||||
|
|
|
@ -162,10 +162,10 @@ export default {
|
|||
},
|
||||
created() {
|
||||
if (this.$props.comType === 1) {
|
||||
const openid = getQueryParams('openid');
|
||||
if (openid) {
|
||||
localStorage.setItem('openid', openid || '');
|
||||
}
|
||||
// const openid = getQueryParams('openid');
|
||||
// if (openid) {
|
||||
// localStorage.setItem('openid', openid || '');
|
||||
// }
|
||||
// 处理公共数据
|
||||
this.btnMap.set(14003, '立即兑换');
|
||||
this.btnHighLight = [ ...this.btnHighLight, 14003, 14004 ];
|
||||
|
@ -216,10 +216,10 @@ export default {
|
|||
if (changeData.length === 1) {
|
||||
return this.jumpDetail(changeData[0], 'auto')
|
||||
}
|
||||
if (this.jumpPath) {
|
||||
// sessionStorage.removeItem('jumpPath')
|
||||
// return this.$router.push(this.jumpPath);
|
||||
}
|
||||
// if (this.jumpPath) {
|
||||
// sessionStorage.removeItem('jumpPath')
|
||||
// return this.$router.push(this.jumpPath);
|
||||
// }
|
||||
if (!this.dialogType && startsWith(String(errCode), this.interceptCode)) {
|
||||
this.dialogType = 'error';
|
||||
this.dialogText = reson || '活动异常';
|
||||
|
|
|
@ -96,8 +96,8 @@ export default {
|
|||
data() {
|
||||
return {
|
||||
key: this.$route.query.key || localStorage.getItem("key"),
|
||||
openid: getQueryParams('openid') || localStorage.getItem("openid"), // 微信授权id
|
||||
alipayuserid: this.$route.query.alipayuserid || localStorage.getItem("alipayuserid"), // 支付宝授权id
|
||||
openid: getQueryParams('openid') || '', // 微信授权id
|
||||
alipayuserid: this.$route.query.alipayuserid || '', // 支付宝授权id
|
||||
goodId: Number(this.$route.query.id),
|
||||
goods: {}, // 商品基本信息
|
||||
info: {}, // 立减金信息
|
||||
|
@ -121,6 +121,8 @@ export default {
|
|||
};
|
||||
},
|
||||
created() {
|
||||
this.openid && localStorage.setItem("openidLJJ", this.openid);
|
||||
this.alipayuserid && localStorage.setItem("alipayuserid", this.alipayuserid);
|
||||
if (this.$route.query.key && this.$route.query.token && this.goodId && !sessionStorage.getItem('autoReceive')) { // 回调/复制 打开
|
||||
urlToLocal();
|
||||
sessionStorage.setItem('autoReceive', 'is');
|
||||
|
@ -215,15 +217,15 @@ export default {
|
|||
this.pollStatus = true;
|
||||
return this.pollTime = setTimeout(() => { that.orderPolling() }, pollTimeNum);
|
||||
}
|
||||
let account = '';
|
||||
let account: any = '';
|
||||
if (this.info.channel === 1 && this.info.receive_mode === 1) { // 支付宝-官方领取
|
||||
account = this.alipayuserid;
|
||||
account = localStorage.getItem("alipayuserid");
|
||||
if (!account) { // 存在打开 支付宝/微信 webview 返回 不刷新页面的情况
|
||||
this.visibilityFunc();
|
||||
}
|
||||
}
|
||||
if (this.info.channel === 2) { // 微信
|
||||
account = this.openid;
|
||||
account = localStorage.getItem("openidLJJ");
|
||||
if (!account) { // 存在打开 支付宝/微信 webview 返回 不刷新页面的情况
|
||||
this.visibilityFunc();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue