mobileclient/packkey/redPackets.html

336 lines
15 KiB
HTML
Raw Normal View History

2024-02-25 13:51:00 +08:00
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport"
content="width=device-width, height=device-height, initial-scale=1.0, maximum-scale=1.0, user-scalable=0,viewport-fit=cover" />
<title>现金红包领取</title>
<script src="https://lsxdemall.oss-cn-beijing.aliyuncs.com/common/vue.min.js?v=1367936144322" type="text/javascript"
charset="utf-8"></script>
<script type="text/javascript" src="https://lsxdemall.oss-cn-beijing.aliyuncs.com/common/axios.js?v=1367936144322">
</script>
2024-04-11 03:05:05 +08:00
<script src="https://lsxdemall.oss-cn-beijing.aliyuncs.com/MarketingSystem/js/api2_0.js?v=1000"></script>
2024-04-22 10:24:59 +08:00
<link rel="stylesheet" href="../homepage2_0.css" />
2024-02-25 13:51:00 +08:00
<script src="https://lsxdemall.oss-cn-beijing.aliyuncs.com/common/modelPop.js"></script>
2024-03-25 21:53:04 +08:00
<script src="https://lsxdemall.oss-cn-beijing.aliyuncs.com/MarketingSystem/js/libs.js?v=sdfhksdfklwrwer"></script>
2024-02-25 13:51:00 +08:00
<style>
* {
margin: 0 auto;
padding: 0;
font-family: HYQiHei;
}
html {
font-size: 26.66666667vw;
}
body {
-webkit-text-size-adjust: 100% !important;
text-size-adjust: 100% !important;
-moz-text-size-adjust: 100% !important;
font-size: .14rem;
}
</style>
</head>
<body>
<div id='redPacketsViews'>
<img @click="backGoodsFn" v-if="backAble" class="backIcon"
src="https://lsxdemall.oss-cn-beijing.aliyuncs.com/MarketingSystem/img/backprepageBtn.png" alt="">
<div class="prompt" :class="promptShow?'proactive':''">
复制成功,请到浏览器打开
</div>
<!-- 弹出提示 -->
<model-pop :show.sync="popShow" :title="popTitle" :status="popStatus" :text="popText" :bottom_text="popBt"
@backFunction="copyFn"></model-pop>
<!-- 单条弹出框 -->
<div class="box">
<div class='top'>
<p class="title">{{goodsInfo.entity.batch_goods_name}}</p>
<p class='effect_date'>
<span>红包有效期截止 {{goodsInfo.entity.end_time}}</span>
</p>
<p class='money'>
<span class='tag' :style="{fontSize:this.fonts().b}"></span>
<span
:style="{fontSize:this.fonts().a}">{{goodsInfo.entity.cash_amount_type==='1'?parseFloat(goodsInfo.entity.denomination)
:`${parseFloat(goodsInfo.entity.min_denomination)}~${parseFloat(goodsInfo.entity.max_denomination)}`}}</span>
</p>
<p class='type'>
<span>{{goodsInfo.entity.cash_amount_type==='1'?'固额红包':'随机红包'}}</span>
</p>
2024-04-22 17:30:11 +08:00
<div class="bt" v-if="goodsInfo.available==9">
{{buttonTextFun(goodsInfo.type,'received')}}
</div>
2024-04-22 17:48:14 +08:00
<p class="bt" @click="receive" v-else>
2024-04-22 10:24:59 +08:00
{{buttonTextFun(goodsInfo.type,'receive')}}
2024-02-25 13:51:00 +08:00
</p>
</div>
<div class="instruction-box">
<div class="instruction-header"></div>
<div class='instruction'>
<div class='instruction-1'>
<p class='center'>
<img class='notice'
src='https://lsxdemall.oss-cn-beijing.aliyuncs.com/MarketingSystem/img/redPacktes/common_title_notice.png'
alt='' />
</p>
<div v-if="goodsInfo.entity.receive_type === 1" class="available_time">
<h3 class="instruction-text">领取时间</h3>
<ul class="timeList">
<li v-for="item in sortWeeks(goodsInfo.entity.receive_rule.week)" :key='item'>
{{item}}
<p v-for="(item1,index) in goodsInfo.entity.receive_rule.time" key={index} style='
text-align: center ; margin-top: 5px'>
{{item1[0]}}~{{item1[1]}}
</p>
</li>
</ul>
</div>
<div v-if="goodsInfo.entity.receive_type === 2" class="available_time">
<h3 class="instruction-text">领取时间</h3>
<ul class="timeList">
<li v-for="item in goodsInfo.entity.receive_irregular" :key='item.date'>
{{item.date}}
<p v-for="item1 in item.time" style='margin-top:5px' :key='item1[1]'>
{{item1[0]}}~{{item1[1]}}
</p>
</li>
</ul>
</div>
<div v-if="goodsInfo.entity.receive_type === 3" class="available_time">
<h3 class="instruction-text">领取时间</h3>
<ul class="timeList">
<li v-for="item in goodsInfo.entity.receive_day" :key='item'>{{item.join(" ~ ")}}</li>
</ul>
</div>
<div>
<h3 class="instruction-text">使用规则</h3>
<p class='scroll' v-html="goodsInfo.entity.instruction"></p>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
<script>
const bm_obj_data = sessionStorage.getItem("bm_auth") ? JSON.parse(sessionStorage.getItem("bm_auth")) : null;
2024-02-25 13:51:00 +08:00
new Vue({
el: "#redPacketsViews",
2024-05-13 11:17:01 +08:00
data() {
2024-02-25 13:51:00 +08:00
return {
promptShow: false,
popShow: false,
popTitle: '温馨提示',
popText: '请点击下方[复制]按钮,复制链接到浏览器打开!',
popStatus: 1, /*1 成功 2提示 3失败 */
popBt: '点击复制',
copyLink: '',
goodsInfo: JSON.parse(sessionStorage.getItem('goodsInfo')),
backAble: sessionStorage.getItem('goodsCount') > 1,
2024-05-13 11:17:01 +08:00
loading: false,
openid: ""
2024-02-25 13:51:00 +08:00
};
},
components: {
modelPop
},
2024-05-13 11:17:01 +08:00
created() {
let openid = getQueryString("openid");
if (openid) {
this.openid = openid;
2024-05-15 11:38:10 +08:00
this.getGoodsStatus();
2024-05-13 11:17:01 +08:00
}
},
mounted() {
2024-02-25 13:51:00 +08:00
document.title = localStorage.getItem('title');
},
methods: {
2024-05-15 11:37:41 +08:00
// 获取最新的商品状态
getGoodsStatus() {
if (this.goodsInfo.entity.goods_id) {
let params = {
token: localStorage.getItem("token")
}
req.axiosGet(`/key/order/orderCashInfoByGoodsId/${this.goodsInfo.entity.goods_id}`, params).then(res => {
if (res.code === 200) {
if (res.data.receive_status === 1 || res.data.receive_status === 2) {
this.goodsInfo.available = 9;
localStorage.setItem('goodsInfo', JSON.stringify(this.goodsInfo));
}
2024-05-15 11:42:02 +08:00
} else {
if (res.code == 403) {
if (this.backAble) {
2024-05-15 11:44:38 +08:00
this.tip(res.message, 2, '关闭');
2024-05-15 11:42:02 +08:00
setTimeout(() => {
window.location.href = localStorage.getItem('entryLink');
}, 3000);
} else {
2024-05-15 11:44:38 +08:00
this.tip(res.message, 2, '关闭');
2024-05-15 11:42:02 +08:00
}
} else {
2024-05-15 11:44:38 +08:00
this.tip(res.message, 2, '关闭');
2024-05-15 11:42:02 +08:00
}
2024-05-15 11:37:41 +08:00
}
})
}
},
2024-02-25 13:51:00 +08:00
/* 立即领取 */
2024-05-13 11:17:01 +08:00
receive() {
2024-02-25 13:51:00 +08:00
if (this.loading) return;
this.loading = true;
let data = {
key: localStorage.getItem("key"),
goods_id: this.goodsInfo.entity.goods_id,
code_batch_id: this.goodsInfo.code_batch_id,
token: localStorage.getItem("token"),
};
req.axiosPost("/key/usage", data)
.then(({ code, data, message }) => {
this.loading = false;
if (code == 200) {
2024-03-03 15:11:47 +08:00
// 领取结算 4
if (bm_obj_data && !bm_obj_data.settlement_data.is_settlement && bm_obj_data.settlement_data.settlement_type === 4) {
settlementFun(bm_obj_data.token, bm_obj_data.settlement_data.settlement_type);
}
2024-03-07 21:47:17 +08:00
setTimeout(() => {
this.judgeEnvironment(data.order_number, data.redirect_url);
2024-03-18 16:31:59 +08:00
}, 300);
2024-02-25 13:51:00 +08:00
} else {
if (code == 403) {
if (this.backAble) {
this.tip(message, 2, '关闭');
setTimeout(() => {
window.location.href = localStorage.getItem('entryLink');
}, 3000);
} else {
this.tip(message, 2, '关闭');
}
} else {
this.tip(message, 2, '关闭');
}
}
})
.catch((err) => { this.loading = false; });
},
2024-05-13 11:17:01 +08:00
// 红包 结算
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) {
// 领取成功结算 5
if (bm_obj_data && !bm_obj_data.settlement_data.is_settlement && bm_obj_data.settlement_data.settlement_type === 5) {
settlementFun(bm_obj_data.token, bm_obj_data.settlement_data.settlement_type);
}
this.goodsInfo.available = 9;
2024-05-13 11:17:01 +08:00
this.tip("领取成功", 2, '关闭');
localStorage.setItem('goodsInfo', JSON.stringify(this.goodsInfo));
2024-05-13 11:17:01 +08:00
} else {
this.tip(res.message, 2, '关闭');
}
})
.catch((err) => { this.loading = false; });
},
2024-02-25 13:51:00 +08:00
/* 根据环境进行下一步操作 1 支付宝 2 微信 */
2024-05-13 11:17:01 +08:00
judgeEnvironment(order_number, weiXinUrl) {
2024-02-25 13:51:00 +08:00
let ua = window.navigator.userAgent.toLowerCase();
2024-05-13 11:17:01 +08:00
/* 支付宝:判断如果是微信/安卓百度浏览器 则复制链接 */
2024-02-25 13:51:00 +08:00
if (this.goodsInfo.entity.channel === 1) {
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) {
this.copyLink = aliPaysUrl;
this.tip('请点击下方[复制]按钮,复制链接到浏览器打开!', 1, '点击复制');
} else {
location.replace(aliPaysUrl);
}
2024-05-13 11:17:01 +08:00
return
2024-02-25 13:51:00 +08:00
}
2024-05-13 11:17:01 +08:00
/* 微信 */
2024-02-25 13:51:00 +08:00
if (this.goodsInfo.entity.channel === 2) {
2024-05-13 11:17:01 +08:00
// 第一步:是否是微信环境 -> 公众号授权
if (this.openid && ua.indexOf('micromessenger') !== -1) {
this.publicCollection(order_number);
2024-02-25 13:51:00 +08:00
} else {
2024-05-13 11:17:01 +08:00
// 第二步:其它环境 微信小程序
window.location.replace(weiXinUrl);
2024-02-25 13:51:00 +08:00
}
2024-05-13 11:17:01 +08:00
return
2024-02-25 13:51:00 +08:00
}
},
/* 复制文本 */
2024-05-13 11:17:01 +08:00
copyFn() {
2024-02-25 13:51:00 +08:00
if (this.popBt === '关闭') {
return this.popShow = false;
}
var textArea = document.createElement("textarea");
textArea.value = this.copyLink;
document.body.appendChild(textArea);
textArea.select();
document.execCommand("copy");
this.promptShow = true;
this.popShow = false;
setTimeout(() => {
this.promptShow = false;
}, 3000);
document.body.removeChild(textArea);
clearTimeout;
},
/* 触发提示 */
2024-05-13 11:17:01 +08:00
tip(text, status, bt) {
2024-02-25 13:51:00 +08:00
this.popText = text;
this.popStatus = status; /*1 成功 2提示 3失败 */
this.popBt = bt;
this.popShow = true;
},
/* 返回 */
2024-05-13 11:17:01 +08:00
backGoodsFn() {
2024-02-25 13:51:00 +08:00
if (this.backAble) {
2024-02-28 09:55:23 +08:00
locationReplace('./homepage.html');
2024-02-25 13:51:00 +08:00
} else {
history.go(-2);
}
},
/* 动态font */
2024-05-13 11:17:01 +08:00
fonts() {
2024-02-25 13:51:00 +08:00
const { cash_amount_type, min_denomination, max_denomination } = this.goodsInfo.entity;
const defaultCss = { b: '0.2rem', a: '0.32rem' };
if (cash_amount_type === '2') {
const count = String(parseFloat(min_denomination)).length + String(parseFloat(max_denomination)).length + 1;
if (count > 6) {
return {
a: 0.32 - ((count - 6) / 100 * 1.5) + 'rem',
b: 0.2 - ((count - 6) / 100) + 'rem'
};
} else {
return defaultCss;
}
} else {
return defaultCss;
}
}
},
})
</script>
</html>