diff --git a/xw-pages/order.html b/xw-pages/order.html
index 44b090b..9301cbe 100644
--- a/xw-pages/order.html
+++ b/xw-pages/order.html
@@ -106,7 +106,8 @@
scrollTop: 0,
startY: 0,
loadShowHeight: 0,
- loadFlag: false
+ loadFlag: false,
+ openId: localStorage.getItem('openid'),
};
},
@@ -194,6 +195,27 @@
});
},
+ /* 公众号领取 */
+ publicCollection(order_number) {
+ let params = {
+ order_number,
+ channel: 2,
+ channel_user_id: this.openId,
+ is_webview: 1
+ };
+ req.axiosPost("/voucher/grant", params)
+ .then((res) => {
+ this.loading = false;
+ if (res.code == 200) {
+ this.openErrorDialog('领取成功');
+ this.goodInfo.available = 9;
+ sessionStorage.setItem('goodInfo', JSON.stringify(this.goodInfo));
+ } else {
+ this.openErrorDialog(res.message);
+ }
+ })
+ .catch((err) => { this.loading = false; });
+ },
/* 领取跳转逻辑 */
toApp(item, data) {
let ua = navigator.userAgent.toLowerCase(); //判断用户打开链接环境
@@ -208,139 +230,17 @@
show: true
});
}
- if (item.channel == 1) {
- if (item.goods.entity.receive_mode === 2) {
- item.goods.available = 1;
- /* H5 领取 */
- sessionStorage.setItem(
- "goodsInfo",
- JSON.stringify(item.goods)
- );
- location.href = "/zfb-reduce.html";
- } else {
- let bankLink = '';
- if (item.is_group == 2) {
- bankLink = encodeURIComponent(
- window.location.origin +
- "/alipay.html?orderNumber=" +
- data.order_number
- );
- } else {
- bankLink = encodeURIComponent(
- window.location.origin +
- `/combiningAlipay.html?codeBatchId=${item.goods.code_batch_id}&token=${token}`
- );
- }
- let link =
- "http://openapi.1688sup.com/alipay/oauth?jump=" + bankLink;
- let ua = navigator.userAgent.toLowerCase(); //判断用户打开链接环境
- if (
- ua.indexOf("micromessenger") > -1 ||
- ua.indexOf("baiduboxapp") > -1 ||
- ua.indexOf("firefox") > -1
- ) {
- //在微信内置环境、百度app打开,不能唤起支付宝
- this.href = link;
- this.popFunction({
- title: "温馨提示",
- text: `请复制链接,在其他浏览器打开`,
- status: 2,
- b_text: "点击复制",
- show: true
- });
- } else {
- //唤起支付宝
- window.location.replace(link);
- }
- }
- }
-
- if (item.channel == 2) {
- if (ua.indexOf("windows") > -1) {
- this.href = data.redirect_url;
- this.popFunction({
- title: "温馨提示",
- text: `请复制链接,在其他浏览器打开`,
- status: 2,
- b_text: "点击复制",
- show: true
- });
- } else {
- location.replace(data.redirect_url);
- }
- }
- if (item.channel == 3) {
- item.goods.available = 1;
- /* H5 领取 */
- sessionStorage.setItem(
- "goodsInfo",
- JSON.stringify(item.goods)
- );
- location.href = "/ysf-reduce.html";
+ // 第一步:是否是微信环境 -> 公众号授权
+ if (ua.match(/MicroMessenger/i) === "micromessenger") {
+ this.publicCollection(data.order_number);
+ } else {
+ // 第二步:其它环境 微信小程序
+ this.loading = false;
+ window.location.replace(res.data.redirect_url);
}
}
- /* 红包领取 */
- if (item.type === 3) {
- if (item.channel === 1) {
- if (item.goods.entity.receive_mode === 2) {
- item.goods.available = 1;
- /* H5 领取 */
- sessionStorage.setItem(
- "goodsInfo",
- JSON.stringify(item.goods)
- );
- location.href = "/zfb-redPackets.html";
- } else {
- const aliPaysUrl = `alipays://platformapi/startapp?appId=2021004100663111&page=pages/index/index?order_number=${encodeURIComponent(
- window.btoa(data.order_number)
- )}`;
- if (
- isWx() ||
- (ua.indexOf("android") > -1 &&
- ua.indexOf("baiduboxapp") > -1) ||
- ua.indexOf("windows") > -1
- ) {
- this.href = aliPaysUrl;
- this.popFunction({
- title: "温馨提示",
- text: `请复制链接,在其他浏览器打开`,
- status: 2,
- b_text: "点击复制",
- show: true
- });
- } else {
- location.replace(aliPaysUrl);
- }
- }
- }
-
- if (item.channel === 2) {
- if (ua.indexOf("windows") > -1) {
- this.href = data.redirect_url;
- this.popFunction({
- title: "温馨提示",
- text: `请复制链接,在其他浏览器打开`,
- status: 2,
- b_text: "点击复制",
- show: true
- });
- } else {
- location.replace(data.redirect_url);
- }
- }
-
- if (item.channel == 3) {
- item.goods.available = 1;
- /* H5 领取 */
- sessionStorage.setItem(
- "goodsInfo",
- JSON.stringify(item.goods)
- );
- location.href = "/ysf.html";
- }
- }
},
/* 弹窗回调 */
diff --git a/xw-pages/reduce.html b/xw-pages/reduce.html
index af408d6..a33008e 100644
--- a/xw-pages/reduce.html
+++ b/xw-pages/reduce.html
@@ -254,8 +254,9 @@
if (res.code == 200) {
sessionStorage.setItem("lastid", self.goodInfo.product_id);
this.orderId = res.data.order_number;
+ const ua = navigator.userAgent.toLowerCase();
// 第一步:是否是微信环境 -> 公众号授权
- if (wx.match(/MicroMessenger/i) === "micromessenger") {
+ if (ua.match(/MicroMessenger/i) === "micromessenger") {
this.publicCollection(res.data.order_number);
} else {
// 第二步:其它环境 微信小程序
@@ -299,7 +300,6 @@
}
})
.catch((err) => { this.loading = false; });
- ;
},
//错误弹出框关闭
knowFn() {