fix: 增加入口也,微信静默授权
This commit is contained in:
parent
5dfc5ed44d
commit
b08de98768
|
@ -10,6 +10,7 @@
|
|||
charset="utf-8"></script>
|
||||
<script type="text/javascript"
|
||||
src="https://lsxdemall.oss-cn-beijing.aliyuncs.com/common/axios.js?v=1367936144322"></script>
|
||||
<script src="https://lsxdemall.oss-cn-beijing.aliyuncs.com/MarketingSystem/js/libs.js"></script>
|
||||
<script src="https://lsxdemall.oss-cn-beijing.aliyuncs.com/siteqiexchange/js/swiper.min.js"></script>
|
||||
<link href="https://lsxdemall.oss-cn-beijing.aliyuncs.com/siteqiexchange/css/swiper.min.css" rel="stylesheet">
|
||||
<link rel="stylesheet" href="https://lsxdemall.oss-cn-beijing.aliyuncs.com/MarketingSystem/css/loading.css">
|
||||
|
@ -288,7 +289,7 @@
|
|||
<script>
|
||||
new Vue({
|
||||
el: '#homepage',
|
||||
data () {
|
||||
data() {
|
||||
return {
|
||||
swiperDataList: [], //轮播
|
||||
promtshow: false,
|
||||
|
@ -317,7 +318,12 @@
|
|||
modelPop
|
||||
},
|
||||
|
||||
created () {
|
||||
created() {
|
||||
let openid = getQueryString("openid");
|
||||
if (openid) {
|
||||
localStorage.setItem('openid', openid);
|
||||
}
|
||||
|
||||
this.getGoods();
|
||||
let productConfig = JSON.parse(localStorage.getItem('product_list'));
|
||||
document.title = localStorage.getItem('title');
|
||||
|
@ -328,24 +334,24 @@
|
|||
},
|
||||
|
||||
methods: {
|
||||
tabHandle (id) {
|
||||
tabHandle(id) {
|
||||
this.tabActive = id;
|
||||
},
|
||||
|
||||
closeTip () {
|
||||
closeTip() {
|
||||
this.suspension = false;
|
||||
},
|
||||
|
||||
susTipFn () {
|
||||
susTipFn() {
|
||||
this.suspension = true;
|
||||
},
|
||||
|
||||
onSelected (item) {
|
||||
onSelected(item) {
|
||||
this.exchangeCommity = item;
|
||||
this.gstatus = item.available;
|
||||
},
|
||||
|
||||
backHandler () {
|
||||
backHandler() {
|
||||
let backUrl = window.history.length;
|
||||
if (window.history.length) {
|
||||
history.go(-backUrl + 1);
|
||||
|
@ -353,7 +359,7 @@
|
|||
},
|
||||
|
||||
// 单条弹框
|
||||
openDialog () {
|
||||
openDialog() {
|
||||
this.promtshow = true;
|
||||
setTimeout(() => {
|
||||
this.promtshow = false;
|
||||
|
@ -362,7 +368,7 @@
|
|||
},
|
||||
|
||||
//根据token获取商品信息
|
||||
async getGoods () {
|
||||
async getGoods() {
|
||||
let self = this;
|
||||
let showType = localStorage.getItem('showType');
|
||||
this.showType = showType;
|
||||
|
@ -535,12 +541,12 @@
|
|||
}
|
||||
},
|
||||
/* 动态置灰 */
|
||||
dynamicAsh (item) {
|
||||
dynamicAsh(item) {
|
||||
return (item.stock && (item.stock < 0 || item.available != 1) && item.available != 2 && item.available != 22) ? 'changegray' : '';
|
||||
},
|
||||
|
||||
//选择商品点击兑换
|
||||
exchangeBtn (row = this.exchangeCommity) {
|
||||
exchangeBtn(row = this.exchangeCommity) {
|
||||
let gstatus = row.available;
|
||||
this.gstatus = gstatus;
|
||||
if (gstatus == 1 || gstatus == 22) {
|
||||
|
@ -562,7 +568,7 @@
|
|||
|
||||
|
||||
/* 弹框回调 */
|
||||
backFunctionPop () {
|
||||
backFunctionPop() {
|
||||
if (this.gstatus == 8) {
|
||||
window.history.go(0);
|
||||
}
|
||||
|
@ -575,18 +581,18 @@
|
|||
},
|
||||
|
||||
/* 判Tab长度 */
|
||||
calculateTabLength () {
|
||||
calculateTabLength() {
|
||||
return this.viewConfig.bottomBar.navlist.filter(item => item.iswitch === '1').length;
|
||||
},
|
||||
|
||||
/* 图片跳转 */
|
||||
autoImgHandle () {
|
||||
autoImgHandle() {
|
||||
if (this.viewConfig.picture.jumpType === '1') {
|
||||
window.location.href = this.viewConfig.picture.jumpUrl;
|
||||
}
|
||||
},
|
||||
//搜索
|
||||
searchFn () {
|
||||
searchFn() {
|
||||
window.location.href = './searchPage.html';
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
charset="utf-8"></script>
|
||||
<script type="text/javascript" src="https://lsxdemall.oss-cn-beijing.aliyuncs.com/common/axios.js?v=1367936144322">
|
||||
</script>
|
||||
<script src="https://lsxdemall.oss-cn-beijing.aliyuncs.com/MarketingSystem/js/libs.js"></script>
|
||||
<script src="https://lsxdemall.oss-cn-beijing.aliyuncs.com/siteqiexchange/js/swiper.min.js"></script>
|
||||
<link href="https://lsxdemall.oss-cn-beijing.aliyuncs.com/siteqiexchange/css/swiper.min.css" rel="stylesheet">
|
||||
<link rel="stylesheet" href="https://lsxdemall.oss-cn-beijing.aliyuncs.com/MarketingSystem/css/homepage2_0.css?v=3">
|
||||
|
@ -17,6 +18,7 @@
|
|||
<script src="https://lsxdemall.oss-cn-beijing.aliyuncs.com/MarketingSystem/js/loading.js"></script>
|
||||
<script src="https://lsxdemall.oss-cn-beijing.aliyuncs.com/MarketingSystem/js/api2_0.js"></script>
|
||||
<script src="https://lsxdemall.oss-cn-beijing.aliyuncs.com/common/tabs.js"></script>
|
||||
|
||||
</head>
|
||||
<style scoped>
|
||||
* {
|
||||
|
@ -235,7 +237,7 @@
|
|||
tabStaticComponent
|
||||
},
|
||||
created() {
|
||||
let openid = this.getQueryString("openid");
|
||||
let openid = getQueryString("openid");
|
||||
if (openid) {
|
||||
localStorage.setItem('openid', openid);
|
||||
}
|
||||
|
@ -251,12 +253,6 @@
|
|||
this.bannerUrl = productConfig.bannerUrl;
|
||||
},
|
||||
methods: {
|
||||
getQueryString(name) {
|
||||
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
|
||||
var r = window.location.search.substr(1).match(reg);
|
||||
if (r != null) return unescape(r[2]);
|
||||
return null;
|
||||
},
|
||||
closeTip() {
|
||||
this.suspension = false;
|
||||
},
|
||||
|
|
138
index.html
138
index.html
|
@ -110,12 +110,6 @@
|
|||
},
|
||||
|
||||
async created() {
|
||||
// 白名单不清除
|
||||
// let bmd_token = this.getQueryString('token');
|
||||
// if (!bmd_token) {
|
||||
// sessionStorage.clear();
|
||||
// localStorage.clear();
|
||||
// }
|
||||
|
||||
sessionStorage.clear();
|
||||
localStorage.clear();
|
||||
|
@ -129,10 +123,9 @@
|
|||
});
|
||||
let self = this;
|
||||
//获取链接携带的参数
|
||||
let linkId = this.getQueryString('id');
|
||||
let keyCode = this.getQueryString('key');
|
||||
let openid = this.getQueryString('openid');
|
||||
openid && localStorage.setItem('openid', openid);
|
||||
let linkId = getQueryString('id');
|
||||
let keyCode = getQueryString('key');
|
||||
|
||||
if (!linkId) {//地址栏无携带id
|
||||
let path = window.location.pathname;
|
||||
let parmas = path.split('/');
|
||||
|
@ -172,26 +165,15 @@
|
|||
req.axiosPost('/key/loginFromLink', data).then(res => {
|
||||
if (res.code == 200) {
|
||||
localStorage.setItem('key', keyCode);
|
||||
this.wxgzAuth(res.data.is_have_webview_voucher);
|
||||
localStorage.setItem('token', res.data.token);
|
||||
localStorage.setItem('haskey', keyCode);
|
||||
this.openDialog('正在加载商品...');
|
||||
localStorage.setItem('entryLink', window.location.href);//存储起始页链接
|
||||
sessionStorage.setItem("bm_auth", JSON.stringify(data)); // 存储包码数据
|
||||
|
||||
/** TODO: 判断是否是包码逻辑 **/
|
||||
if (res.data.settlement_data && res.data.settlement_data.settlement_type > 0) {
|
||||
self.goToPackKey({ token: res.data.token, settlement_data: res.data.settlement_data }, 1);
|
||||
} else {
|
||||
let clr = setTimeout(() => {
|
||||
if (this.pageType === 4 || this.pageType === 8) {
|
||||
window.location.replace('/coupon/couponCollection.html');
|
||||
} else {
|
||||
window.location.replace('/homepage.html');
|
||||
}
|
||||
clearTimeout(clr);
|
||||
}, 1000);
|
||||
}
|
||||
this.openDialog('正在加载商品...');
|
||||
|
||||
// 统一跳转函数
|
||||
this.gotoPage();
|
||||
} else {
|
||||
self.openErrorDialog(res.message);
|
||||
}
|
||||
|
@ -234,6 +216,57 @@
|
|||
},
|
||||
},
|
||||
methods: {
|
||||
// 统一跳转逻辑判断
|
||||
gotoPage(data, type) {
|
||||
console.log("gotoPage =>", data);
|
||||
|
||||
// 微信授权回调地址
|
||||
let wxauth_url = "https://openapi.1688sup.com/wechat/oauth";
|
||||
|
||||
// 第一步:判断是否是 微信静默授权 是 -> 拼接回调地址
|
||||
if (data.is_have_webview_voucher) {
|
||||
// 第二步: 判断是否是包码 是 -> 走包码回调地址
|
||||
if (data.settlement_data && data.settlement_data.settlement_type > 0) {
|
||||
// ***包码逻辑 打开结算 2
|
||||
if (!data.settlement_data.is_settlement && data.settlement_data.settlement_type === 2) {
|
||||
settlementFun(data.token, data.settlement_data.settlement_type);
|
||||
}
|
||||
wxauth_url = `${wxauth_url}?jump=${location.origin}/packkey/bm-index.html`;
|
||||
} else {
|
||||
// 不是包码
|
||||
if (this.pageType === 4 || this.pageType === 8) {
|
||||
wxauth_url = `${wxauth_url}?jump=${location.origin}/coupon/couponCollection.html`;
|
||||
} else {
|
||||
wxauth_url = `${wxauth_url}?jump=${location.origin}/homepage.html`;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// 第三步:不需要微信静默授权
|
||||
if (data.settlement_data && data.settlement_data.settlement_type > 0) {
|
||||
// ***包码逻辑 打开结算 2
|
||||
if (!data.settlement_data.is_settlement && data.settlement_data.settlement_type === 2) {
|
||||
settlementFun(data.token, data.settlement_data.settlement_type);
|
||||
}
|
||||
wxauth_url = '/packkey/bm-index.html';
|
||||
} else {
|
||||
// 不是包码
|
||||
if (this.pageType === 4 || this.pageType === 8) {
|
||||
wxauth_url = '/coupon/couponCollection.html';
|
||||
} else {
|
||||
wxauth_url = '/homepage.html';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 第四步:是否需要记录 当前页面
|
||||
setTimeout(() => {
|
||||
if (type) {
|
||||
window.location.replace(wxauth_url);
|
||||
} else {
|
||||
window.location.href = wxauth_url
|
||||
}
|
||||
}, 300)
|
||||
},
|
||||
// 判断是否是包码 跳转对应的包码页面 ****
|
||||
goToPackKey(data, type) {
|
||||
// 存储数据
|
||||
|
@ -256,26 +289,6 @@
|
|||
}, 300)
|
||||
},
|
||||
|
||||
// 静默授权
|
||||
wxgzAuth(is_have_webview_voucher, token) {
|
||||
console.log("token 1111111 =>", token);
|
||||
debugger
|
||||
/* 公众号打开 */
|
||||
if (is_have_webview_voucher && !this.openid) {
|
||||
const key = localStorage.getItem('key');
|
||||
const linkId = localStorage.getItem('linkId');
|
||||
if (token) {
|
||||
location.href = `https://openapi.1688sup.com/wechat/oauth?jump=${location.origin}/${linkId}/${token}`;
|
||||
return
|
||||
} else {
|
||||
location.href = `https://openapi.1688sup.com/wechat/oauth?jump=${location.origin}/${linkId}/${key}`;
|
||||
return
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
//获取白名单验证码
|
||||
getcode() {
|
||||
let self = this;
|
||||
|
@ -329,28 +342,11 @@
|
|||
}, 2000);
|
||||
|
||||
if (res.code == 200) {
|
||||
localStorage.setItem('key', self.key);
|
||||
this.wxgzAuth(res.data.is_have_webview_voucher);
|
||||
|
||||
localStorage.setItem('token', res.data.token);
|
||||
this.openDialog('正在加载商品...');
|
||||
localStorage.setItem('key', self.key);
|
||||
localStorage.setItem('token', res.data.token);
|
||||
localStorage.setItem('entryLink', window.location.href);//存储起始页链接
|
||||
|
||||
/** TODO: 判断是否是包码逻辑 **/
|
||||
if (res.data.settlement_data && res.data.settlement_data.settlement_type > 0) {
|
||||
setTimeout(() => {
|
||||
self.goToPackKey({ token: res.data.token, settlement_data: res.data.settlement_data });
|
||||
}, 1000);
|
||||
} else {
|
||||
setTimeout(() => {
|
||||
if (this.pageType === 4 || this.pageType === 8) {
|
||||
window.location.href = './coupon/couponCollection.html';
|
||||
} else {
|
||||
window.location.href = './homepage.html';
|
||||
}
|
||||
}, 1000);
|
||||
}
|
||||
|
||||
this.gotoPage(res.data);
|
||||
} else {
|
||||
self.openErrorDialog(res.message);
|
||||
}
|
||||
|
@ -402,12 +398,6 @@
|
|||
this.openDialog('正在加载商品...');
|
||||
localStorage.setItem('entryLink', window.location.href);//存储起始页链接
|
||||
sessionStorage.setItem("bm_auth", JSON.stringify(form_data_res.data.settlement_data));
|
||||
// 判断是否需要静默授权
|
||||
if (form_data_res.data.is_have_webview_voucher) {
|
||||
location.href = `https://openapi.1688sup.com/wechat/oauth?jump=${location.origin}/homepage.html`
|
||||
}
|
||||
|
||||
// this.wxgzAuth(res.data.is_have_webview_voucher, res.data.token);
|
||||
|
||||
/** TODO: 判断是否是包码逻辑 **/
|
||||
// if (form_data_res.data.settlement_data && form_data_res.data.settlement_data.settlement_type > 0) {
|
||||
|
@ -432,12 +422,6 @@
|
|||
}).catch(err => { });
|
||||
}
|
||||
},
|
||||
getQueryString(name) {
|
||||
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
|
||||
var r = window.location.search.substr(1).match(reg);
|
||||
if (r != null) return unescape(r[2]);
|
||||
return null;
|
||||
},
|
||||
// 单条弹框
|
||||
openDialog(tip) {
|
||||
this.promtshow = true;
|
||||
|
|
|
@ -169,7 +169,8 @@
|
|||
type: 0, // 1商品 2立减金 3红包 4组合商品 -> 兑换码类型
|
||||
channel: 1, // 1支付宝 2微信 3云闪付 -> 渠道平台
|
||||
receive_mode: 1, // 1官方领取 2账号领取 -> 领取方式
|
||||
goodsName: ""
|
||||
goodsName: "",
|
||||
|
||||
})
|
||||
|
||||
const openToast = (msg) => {
|
||||
|
@ -318,6 +319,11 @@
|
|||
}
|
||||
|
||||
onMounted(() => {
|
||||
let openid = getQueryString("openid");
|
||||
if (openid) {
|
||||
localStorage.setItem('openid', openid);
|
||||
}
|
||||
|
||||
// 打开成功结算3
|
||||
if (bm_obj_data && !bm_obj_data.settlement_data.is_settlement && bm_obj_data.settlement_data.settlement_type === 3) {
|
||||
settlementFun(bm_obj_data.token, bm_obj_data.settlement_data.settlement_type);
|
||||
|
|
|
@ -32,3 +32,11 @@ const locationReplace = (url) => {
|
|||
location.replace(url);
|
||||
}
|
||||
};
|
||||
|
||||
// 获取url参数
|
||||
const getQueryString = (name) => {
|
||||
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
|
||||
var r = window.location.search.substr(1).match(reg);
|
||||
if (r != null) return unescape(r[2]);
|
||||
return null;
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue