mobileclient/redPackets.html

259 lines
11 KiB
HTML

<!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>
<script src="https://lsxdemall.oss-cn-beijing.aliyuncs.com/MarketingSystem/js/api2_0.js?v=1000"></script>
<link rel="stylesheet" href="https://lsxdemall.oss-cn-beijing.aliyuncs.com/MarketingSystem/css/homepage2_0.css" />
<script src="https://lsxdemall.oss-cn-beijing.aliyuncs.com/common/modelPop.js"></script>
<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>
<p class="bt" @click="receive">
<img src='https://lsxdemall.oss-cn-beijing.aliyuncs.com/MarketingSystem/img/redPacktes/common_btn_receive.png'
alt='' />
</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>
new Vue({
el: "#redPacketsViews",
data() {
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,
loading: false
};
},
components: {
modelPop
},
mounted() {
document.title = localStorage.getItem('title');
},
methods: {
/* 立即领取 */
receive() {
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) {
this.judgeEnvironment(data.order_number, data.redirect_url);
} 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; });
},
/* 根据环境进行下一步操作 1 支付宝 2 微信 */
judgeEnvironment(order_number, weiXinUrl) {
let ua = window.navigator.userAgent.toLowerCase();
/* 判断如果是微信/安卓百度浏览器 则复制链接 */
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);
}
}
if (this.goodsInfo.entity.channel === 2) {
if (ua.indexOf("windows") > -1) {
this.copyLink = weiXinUrl;
this.tip('请点击下方[复制]按钮,复制链接到浏览器打开!', 1, '点击复制');
} else {
location.replace(weiXinUrl);
}
}
},
/* 复制文本 */
copyFn() {
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;
},
/* 触发提示 */
tip(text, status, bt) {
this.popText = text;
this.popStatus = status; /*1 成功 2提示 3失败 */
this.popBt = bt;
this.popShow = true;
},
/* 返回 */
backGoodsFn() {
if (this.backAble) {
window.location.replace('./homepage.html');
} else {
history.go(-2);
}
},
/* 动态font */
fonts() {
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>