update @关闭自动授权,红包/立减金 公众号授权区分

This commit is contained in:
huangzhen 2024-11-06 11:50:03 +08:00
parent dc44e4aa75
commit c0b7029a29
7 changed files with 66 additions and 48 deletions

View File

@ -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',
};

View File

@ -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 {

View File

@ -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 = '';

View File

@ -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();

View File

@ -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();
}

View File

@ -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 || '活动异常';

View File

@ -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();
}