feat: 增加红包

This commit is contained in:
zhangds 2024-05-11 15:35:57 +08:00
parent 5d94239d51
commit 9ce76d9597
2 changed files with 56 additions and 17 deletions

View File

@ -622,7 +622,13 @@
} else if (entity.channel === 1 && entity.receive_mode === 2) { } else if (entity.channel === 1 && entity.receive_mode === 2) {
window.location.replace("./zfb-redPackets.html"); window.location.replace("./zfb-redPackets.html");
} else { } else {
window.location.replace("./redPackets.html"); // 判断 在那个环境打开 如果是微信 获取openid
if (navigator.userAgent.toLowerCase().indexOf('micromessenger') !== -1) {
let auth_url = `https://openapi.1688sup.com/wechat/oauth?payment_subject=bale&jump=${location.origin}/redPackets.html`
window.location.replace(auth_url);
} else {
window.location.replace("./redPackets.html");
}
} }
} }
}, },

View File

@ -11,8 +11,9 @@
<script type="text/javascript" src="https://lsxdemall.oss-cn-beijing.aliyuncs.com/common/axios.js?v=1367936144322"> <script type="text/javascript" src="https://lsxdemall.oss-cn-beijing.aliyuncs.com/common/axios.js?v=1367936144322">
</script> </script>
<script src="https://lsxdemall.oss-cn-beijing.aliyuncs.com/MarketingSystem/js/api2_0.js?v=1000"></script> <script src="https://lsxdemall.oss-cn-beijing.aliyuncs.com/MarketingSystem/js/api2_0.js?v=1000"></script>
<link rel="stylesheet" href="./homepage2_0.css" />
<script src="https://lsxdemall.oss-cn-beijing.aliyuncs.com/common/modelPop.js"></script> <script src="https://lsxdemall.oss-cn-beijing.aliyuncs.com/common/modelPop.js"></script>
<script src="https://lsxdemall.oss-cn-beijing.aliyuncs.com/MarketingSystem/js/libs.js?v=sdfhksdfklwrwer"></script>
<style> <style>
* { * {
margin: 0 auto; margin: 0 auto;
@ -31,6 +32,7 @@
font-size: .14rem; font-size: .14rem;
} }
</style> </style>
<link rel="stylesheet" href="./homepage2_0.css" />
</head> </head>
<body> <body>
@ -120,7 +122,7 @@
<script> <script>
new Vue({ new Vue({
el: "#redPacketsViews", el: "#redPacketsViews",
data () { data() {
return { return {
promptShow: false, promptShow: false,
popShow: false, popShow: false,
@ -131,20 +133,26 @@
copyLink: '', copyLink: '',
goodsInfo: JSON.parse(sessionStorage.getItem('goodsInfo')), goodsInfo: JSON.parse(sessionStorage.getItem('goodsInfo')),
backAble: sessionStorage.getItem('goodsCount') > 1, backAble: sessionStorage.getItem('goodsCount') > 1,
loading: false loading: false,
openid: ""
}; };
}, },
components: { components: {
modelPop modelPop
}, },
created() {
mounted () { let openid = getQueryString("openid");
if (openid) {
this.openid = openid;
}
},
mounted() {
document.title = localStorage.getItem('title'); document.title = localStorage.getItem('title');
}, },
methods: { methods: {
/* 立即领取 */ /* 立即领取 */
receive () { receive() {
if (this.loading) return; if (this.loading) return;
this.loading = true; this.loading = true;
let data = { let data = {
@ -176,11 +184,32 @@
}) })
.catch((err) => { this.loading = false; }); .catch((err) => { this.loading = false; });
}, },
// 红包 结算
publicCollection(order_number) {
let params = {
order_number,
open_id: this.openId,
subject: "bale"
};
req.axiosPost("/wechat/cash/receive", params)
.then((res) => {
this.loading = false;
if (res.code == 200) {
this.tip("领取成功", 2, '关闭');
this.goodInfo.available = 9;
localStorage.setItem('goodInfo', JSON.stringify(this.goodInfo));
} else {
this.tip(res.message, 2, '关闭');
}
})
.catch((err) => { this.loading = false; });
},
/* 根据环境进行下一步操作 1 支付宝 2 微信 */ /* 根据环境进行下一步操作 1 支付宝 2 微信 */
judgeEnvironment (order_number, weiXinUrl) { judgeEnvironment(order_number, weiXinUrl) {
let ua = window.navigator.userAgent.toLowerCase(); let ua = window.navigator.userAgent.toLowerCase();
/* 判断如果是微信/安卓百度浏览器 则复制链接 */
/* 支付宝:判断如果是微信/安卓百度浏览器 则复制链接 */
if (this.goodsInfo.entity.channel === 1) { if (this.goodsInfo.entity.channel === 1) {
const aliPaysUrl = `alipays://platformapi/startapp?appId=2021004100663111&page=pages/index/index?order_number=${encodeURIComponent(window.btoa(order_number))}`; const aliPaysUrl = `alipays://platformapi/startapp?appId=2021004100663111&page=pages/index/index?order_number=${encodeURIComponent(window.btoa(order_number))}`;
if (isWx() || (ua.indexOf("android") > -1 && ua.indexOf("baiduboxapp") > -1) || ua.indexOf("windows") > -1) { if (isWx() || (ua.indexOf("android") > -1 && ua.indexOf("baiduboxapp") > -1) || ua.indexOf("windows") > -1) {
@ -189,19 +218,23 @@
} else { } else {
location.replace(aliPaysUrl); location.replace(aliPaysUrl);
} }
return
} }
/* 微信 */
if (this.goodsInfo.entity.channel === 2) { if (this.goodsInfo.entity.channel === 2) {
if (ua.indexOf("windows") > -1) { // 第一步:是否是微信环境 -> 公众号授权
this.copyLink = weiXinUrl; if (this.openId && ua.indexOf('micromessenger') !== -1) {
this.tip('请点击下方[复制]按钮,复制链接到浏览器打开!', 1, '点击复制'); this.publicCollection(order_number);
} else { } else {
location.replace(weiXinUrl); // 第二步:其它环境 微信小程序
window.location.replace(weiXinUrl);
} }
return
} }
}, },
/* 复制文本 */ /* 复制文本 */
copyFn () { copyFn() {
if (this.popBt === '关闭') { if (this.popBt === '关闭') {
return this.popShow = false; return this.popShow = false;
} }
@ -220,7 +253,7 @@
}, },
/* 触发提示 */ /* 触发提示 */
tip (text, status, bt) { tip(text, status, bt) {
this.popText = text; this.popText = text;
this.popStatus = status; /*1 成功 2提示 3失败 */ this.popStatus = status; /*1 成功 2提示 3失败 */
this.popBt = bt; this.popBt = bt;
@ -228,7 +261,7 @@
}, },
/* 返回 */ /* 返回 */
backGoodsFn () { backGoodsFn() {
if (this.backAble) { if (this.backAble) {
window.location.replace('./homepage.html'); window.location.replace('./homepage.html');
} else { } else {
@ -237,7 +270,7 @@
}, },
/* 动态font */ /* 动态font */
fonts () { fonts() {
const { cash_amount_type, min_denomination, max_denomination } = this.goodsInfo.entity; const { cash_amount_type, min_denomination, max_denomination } = this.goodsInfo.entity;
const defaultCss = { b: '0.2rem', a: '0.32rem' }; const defaultCss = { b: '0.2rem', a: '0.32rem' };
if (cash_amount_type === '2') { if (cash_amount_type === '2') {