mobileclient/coupon/details.html

669 lines
30 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!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/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/details.css">
<script src="https://lsxdemall.oss-cn-beijing.aliyuncs.com/MarketingSystem/js/api2_0.js"></script>
<link rel="stylesheet" href="https://lsxdemall.oss-cn-beijing.aliyuncs.com/common/payPop.css">
<script src="https://lsxdemall.oss-cn-beijing.aliyuncs.com/common/payPop.js"></script>
<script src="https://lsxdemall.oss-cn-beijing.aliyuncs.com/common/modelPop.js"></script>
<script src="https://cdn.bootcdn.net/ajax/libs/vConsole/3.4.1/vconsole.min.js"></script>
</head>
<body>
<div id="exchangePage">
<!-- 时提框 -->
<model-pop :show.sync="popShow" :title="popTitle" :status="popStatus" :text="popText" :bottom_text="bottomText"
@backFunction="backFunctionPop"></model-pop>
<div v-if="!suspension" class="content">
<!-- 返回模块-->
<img @click="backHandler" class="back" v-if="backAble"
src="https://lsxdemall.oss-cn-beijing.aliyuncs.com/MarketingSystem/img/backprepageBtn.png" alt="">
<!-- 优惠券权益商品 -->
<div v-if="goodsDetail.type===1">
<div class="about-good">
<img :src="goodsShow[0]" alt="" v-if="goodsShow.length<=1">
<div class="swiper-container" v-else>
<div class="swiper-wrapper">
<div class="swiper-slide" v-for="(item,i) in goodsShow" :key="i">
<img :src="item" alt="">
</div>
</div>
<div class="swiper-pagination"></div>
</div>
</div>
<div class="ipt-acc" style="position: relative;z-index: 999;" @click="bindAvailable">
<div class="title">
<p>
<span class="sign"></span>{{goodsDetail.origin_price}}
</p>
<p class="text">{{goodInfo.product_name}}</p>
</div>
<template v-if="goodInfo.product_type===1">
<p v-if="acctype=='tel'"><span>账号:</span><input :type="acctype"
onkeyup="this.value=this.value.replace(/\D/g,'')" :disabled="goodsDetail.available!=1"
onKeypress="return(/[\d]/.test(String.fromCharCode(event.keyCode)))" :maxlength="maxlen"
v-model="account" :placeholder="placeholder" @focus="(e)=>focusFn(e)"></p>
<p v-if="acctype=='tel'"><span>再次输入:</span> <input :type="acctype"
onkeyup="this.value=this.value.replace(/\D/g,'')" :disabled="goodsDetail.available!=1"
onKeypress="return(/[\d]/.test(String.fromCharCode(event.keyCode)))" :maxlength="maxlen"
v-model="reAccount" placeholder="请再次输入" @focus="(e)=>focusFn(e)"></p>
<p v-if="acctype!='tel'"><span>账号:</span> <input :type="acctype" :maxlength="maxlen"
v-model="account" :disabled="goodsDetail.available!=1" :placeholder="placeholder"
@focus="(e)=>focusFn(e)"></p>
<p v-if="acctype!='tel'"><span>再次输入:</span><input :type="acctype" :maxlength="maxlen"
v-model="reAccount" :disabled="goodsDetail.available!=1" placeholder="请再次输入"
@focus="(e)=>focusFn(e)"></p>
</template>
</div>
<div class="bottom" id="bottom" :style="{borderWidth:(describe.type||detailUrl)?'0.05rem':'0'}"
v-show="describe.type||detailUrl">
<img :src="detailUrl" v-show="detailUrl">
<img :src="describe.bg_image" v-show="describe.type==1&&describe.bg_image">
<div v-html="describe.content" class="goodsTip" v-show="describe.type==3&&describe.content"></div>
</div>
</div>
<!-- 优惠券立减金 -->
<div class="reduce" v-if="goodsDetail.type===2">
<div class="couponShow">
<div class="coupon-left">
<p class="coupon_money">
<span></span>{{goodInfo.reduce_amount}}
</p>
<p class="full_money">满{{goodInfo.denomination}}可用</p>
</div>
<div class="coupon-right">
<p class="title">{{goodInfo.batch_goods_name}}</p>
<p style="font-size: 0.11rem">
{{goodInfo.card_type|cardType}}可用
</p>
<p class="validity">
有效期:{{receive_time.effect_time.start_time}}至{{receive_time.effect_time.end_time}}
</p>
<p class="validity" v-if="receive_time.use_time.type=='received'">
领取后{{receive_time.use_time.effect_date_type==0?'立即':'次日凌晨'}}生效,有效期
{{receive_time.use_time.effect_day}}天
</p>
<p class="validity" v-if="receive_time.use_time.type=='fiexd'">
可用时间:{{receive_time.use_time.fiexd_time.start_time}}-{{receive_time.use_time.fiexd_time.end_time}}
</p>
</div>
</div>
<div class="coupon_explain">
<h1>- 兑换说明 -</h1>
<div class="content">
<h3 v-if="receive_time.use_time.type=='week'||receive_time.use_time.type=='irregular'">可用时间</h3>
<ul v-if="receive_time.use_time.type=='week'" class="weekTime">
<li v-for="(item,index) in receive_time.use_time.week" :key="index">
<p>{{item}}</p>
<div>
<p v-for="(item2,index2) in receive_time.use_time.time" :key="index2">
{{item2[0]}}~{{item2[1]}}
</p>
</div>
</li>
</ul>
<ul v-if="receive_time.use_time.type=='irregular'">
<li v-for="(item,index) in receive_time.use_time.day" :key="index">
<p>{{item[0]}}至{{item[1]}}</p>
<div>
<p v-for="(item2,index2) in receive_time.use_time.time" :key="index2">
{{item2[0]}}~{{item2[1]}}
</p>
</div>
</li>
</ul>
</div>
<div class="content">
<h3>使用须知</h3>
<p>
1、在{{goodInfo.channel==1?'支付宝H5':'微信APP内打开链接'}},点击【一键领取】完成领取{{goodInfo.channel==1?'支付宝':'微信'}}立减金<br />
2、{{goodInfo.channel==1?'支付宝':'微信'}}立减金一旦领取不可撤销、不可转让。注意不要将兑换券泄露给他人
</p>
</div>
<div class="content">
<h3>使用规则</h3>
<p v-html="goodsDetail.instruction"></p>
</div>
</div>
</div>
<!-- 支付模块-->
<div class="exchange-btn-fr">
<div class="pay_left">
<div class="order" v-if="!backAble">
<img src="https://lsxdemall.oss-cn-beijing.aliyuncs.com/MarketingSystem/img/toOrder.png" alt=""
@click="toOrder">
<p>订单</p>
</div>
<div class="title">
<p>
<span class="sign"></span>{{goodsDetail.coupon_price}}
</p>
<p class="text" v-if="goodsDetail.origin_price-goodsDetail.coupon_price!==0">共省&nbsp;¥
{{(goodsDetail.origin_price-goodsDetail.coupon_price).toFixed(2)}}</p>
</div>
</div>
<template v-if="goodsDetail.type===1">
<button class="exchange-btn" v-if="goodInfo.product_type===1"
:style="{'background': exchangeOpen?bgcolor:'#D7D7D7','color':exchangeOpen?ftColor:'#333'}"
@click="exchangeGoodsFn">立即支付</button>
<button v-else class="exchange-btn" v-else :style="{'background': bgcolor,'color':ftColor}"
@click="exchangeGoodsFn">立即支付</button>
</template>
<button class="exchange-btn" v-else :style="{'background': bgcolor,'color':ftColor}"
@click="exchangeGoodsFn">立即支付</button>
</div>
</div>
<!-- 单条弹出框 -->
<div class="prompt" :class="promtshow?'proactive':''">
{{this.promttip}}
</div>
<!-- 悬浮提示 -->
<div v-if="suspension" class="suspensionDom">
<img @click="suspension = false"
src="https://lsxdemall.oss-cn-beijing.aliyuncs.com/MarketingSystem/img/backprepageBtn.png" alt="">
<h4>活动规则</h4>
<div v-html="describe.content">
</div>
</div>
<img class="susTip" @click="suspension = true"
v-if="describe.type==='2'&&describe.content&&!suspension&&goodsDetail.type===1"
src="https://lsxdemall.oss-cn-beijing.aliyuncs.com/MarketingSystem/img/acticeTextTip.png" alt="">
<!-- 弹出框 -->
<!-- 支付弹窗 -->
<pay-pop :show.sync="show" :active="payType" @payFunction="payFunction" :money="goodsDetail.coupon_price" />
</div>
</body>
<script>
var vConsole = new VConsole();
let goodsCount = null, goodsDetail = null;
new Vue({
el: '#exchangePage',
data () {
return {
account: '',
reAccount: '',
maxlen: 11,
acctype: 'tel',
promttip: '',
promtshow: false,
productType: 0,
placeholder: '',
exchangeOpen: false,
suspension: false,
describe: {},
detailUrl: '',
goodInfo: '',
bgcolor: '',
ftColor: '',
goodsDetail: {},//商品详情
backAble: true,
goodsShow: [
'https://lsxd-yunshanfu.oss-cn-hangzhou.aliyuncs.com/common_image/20220120/9bedd7af6a8a570be8f2858564f9ec6d.png'
],
show: false, /* 控制支付弹窗 */
payType: 1, /* 支付方式 */
/* 提示框状态 */
popShow: false,
popTitle: '',
popText: '',
popStatus: 1, /*1 成功 2提示 3失败 */
bottomText: '', /* 复制按钮 */
href: '',/* 支付地址 */
receive_time: {},
orderNumber:'',
isLogin: false,/* 是否跳登录页 */
}
},
filters: {
cardType (val) {
return val.map((item) => {
return item == 1 ? "借记卡" : "信用卡" + " ";
}).join(" ");
},
},
watch: {
account (va) {
va && this.watchAccount()
},
reAccount (va) {
va && this.watchAccount()
},
productType: {
immediate: true,
handler (newVal) {
this.maxlen = 50;
this.acctype = "text";
switch (Number(newVal)) {
case 0:
this.placeholder = "请输入昵称";
break;
case 1:
this.acctype = "tel";
this.placeholder = "请输入手机号";
this.maxlen = 11;
break;
case 2:
this.placeholder = "请输入邮箱";
break;
case 3:
this.placeholder = "请输入手机号或邮箱";
break;
case 4:
this.placeholder = "请输入QQ号";
this.acctype = "tel";
this.maxlen = 10;
break;
case 5:
this.placeholder = "请输入手机号或QQ号";
this.maxlen = 11;
this.acctype = "tel";
break;
case 6:
this.placeholder = "请输入邮箱或QQ号";
break;
case 7:
this.placeholder = "请输入手机号/邮箱/QQ号";
break;
case 8:
this.placeholder = "请输入微信号";
this.maxlen = 20;
break;
case 9:
this.placeholder = "请输入手机号或微信";
this.maxlen = 20;
break;
case 10:
this.placeholder = "请输入邮箱或微信号";
break;
case 11:
this.placeholder = "请输入手机号/邮箱/微信号";
break;
case 12:
this.placeholder = "请输入QQ号或微信号";
this.maxlen = 20;
break;
case 13:
this.placeholder = "请输入手机号/QQ号/微信号";
this.maxlen = 20;
break;
case 14:
this.placeholder = "请输入邮箱/QQ号/微信号";
break;
default:
this.placeholder = "请输入手机号/邮箱/QQ号/微信号";
break;
}
}
}
},
components: {
modelPop,
payPop
},
created () {
/* 配置信息 */
document.title = localStorage.getItem('title');
let detailsConfig = JSON.parse(localStorage.getItem('product_detail'));
goodsCount = localStorage.getItem('goodsCount');
this.backAble = goodsCount > 1;//多个商品才有返回
this.bgcolor = detailsConfig.button_color;
this.ftColor = detailsConfig.font_color;
this.describe = detailsConfig.describe;
//商品详情
const goodsId = JSON.parse(localStorage.getItem('goodsInfo')).entity.goods_id;
this.getDetails(goodsId)
},
methods: {
bindAvailable () {
if (goodsDetail.available != 1) {
this.openErrorDialog(product_status(goodsDetail.available, goodsDetail));
return
}
},
/* 请求详情 */
getDetails (goods_id) {
const token = localStorage.getItem('token')
return new Promise((resolve, reject) => {
req.axiosPost(`/key/product_detail/${goods_id}`, { token }).then(({ code, data, message }) => {
if (code == 200) {
this.goodsDetail = data
goodsDetail = data
this.goodInfo = data.entity;
let goods_desc = data.entity.describe_url;
this.goodsShow = goods_desc && goods_desc.length > 0 ? goods_desc : [data.show_url];
this.detailUrl = data.entity.detail_url ? data.entity.detail_url : '';
this.productType = data.entity.account_type;
this.receive_time = data.entity.time_limit;
this.$nextTick(function () {
var swiper = new Swiper('.swiper-container', {
loop: true, // 循环模式选项
autoplay: 3000, //可选选项,自动滑动
pagination: '.swiper-pagination',
})
})
} else {
this.openErrorDialog(message);
if (code == 403) {
this.delayedOut(3)
this.isLogin = true
}
}
}).catch(err => {
});
});
},
/* 跳转订单 */
toOrder () {
window.location.replace('./myOrder.html');
},
openErrorDialog (tip, bottomText) {
this.popTitle = '温馨提示'
this.popText = tip
this.popStatus = 2
this.popShow = true
this.bottomText = bottomText
},
backHandler () {
if (goodsCount > 1) {
window.location.replace('./couponCollection.html');
} else {
history.go(-2);
}
},
// 单条弹框
openDialog (tip) {
this.promtshow = true;
this.promttip = tip
setTimeout(() => {
this.promtshow = false;
this.promttip = '';
}, 3000)
},
/* 弹窗回调 */
backFunctionPop (type) {
if (this.bottomText === '点击复制' && type) {
var aux = document.createElement("input");
aux.setAttribute("value", this.href);
document.body.appendChild(aux);
aux.select();
document.execCommand("copy");
document.body.removeChild(aux);
this.openDialog('复制成功')
}
if (this.isLogin) {
this.delayedOut()
}
},
/* 延时自动退出 */
delayedOut (time = 1) {
let entryLink = localStorage.getItem('entryLink');
setTimeout(() => {
window.location.replace(entryLink);
}, time * 1000);
},
//兑换商品
exchangeGoodsFn () {
if (this.goodsDetail.type === 1 && this.goodInfo.product_type === 1) { /* 兑换码 */
if (goodsDetail.available != 1) {
this.openErrorDialog(product_status(goodsDetail.available, goodsDetail));
return
}
if (!this.account) {
this.openDialog('请输入兑换账号!');
return false;
} else {
let nameReg = /\w{4}/.test(this.account);
let phoneReg = /^[1][3,4,5,6,7,8,9][0-9]{9}$/.test(this.account);
let qqReg = /^[1-9][0-9]{4,9}$/.test(this.account);
let emailsReg = /^[A-Za-z0-9\u4e00-\u9fa5\.]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/.test(this.account);
let weiXinReg = /^[a-zA-Z][a-zA-Z\d_-]{5,19}$/.test(this.account);
let regFlag = true;
switch (Number(this.productType)) {
case 0:
this.placeholder = "请输入昵称";
regFlag = nameReg
break;
case 1:
regFlag = phoneReg
break;
case 2:
regFlag = emailsReg
break;
case 3:
regFlag = phoneReg || emailsReg
break;
case 4:
regFlag = qqReg
break;
case 5:
regFlag = phoneReg || qqReg
break;
case 6:
regFlag = emailsReg || qqReg
break;
case 7:
regFlag = phoneReg || emailsReg || qqReg
break;
case 8:
regFlag = weiXinReg
break;
case 9:
regFlag = phoneReg || weiXinReg
break;
case 10:
regFlag = emailsReg || weiXinReg
break;
case 11:
regFlag = phoneReg || emailsReg || weiXinReg
break;
case 12:
regFlag = qqReg || weiXinReg
break;
case 13:
regFlag = phoneReg || qqReg || weiXinReg
break;
case 14:
regFlag = emailsReg || qqReg || weiXinReg
break;
default:
regFlag = phoneReg || emailsReg || qqReg || weiXinReg
break;
}
if (!regFlag) {
this.openDialog("充值账号格式不正确!");
return false;
}
}
if (this.reAccount == "") {
this.openDialog("请再次输入账号!");
return false;
}
if (this.account != this.reAccount) {
this.reAccount == ""
this.openDialog("两次输入的账号必须一致!");
return false;
}
}
this.show = true
},
focusFn (a) {
let ele = document.querySelector('.ipt-acc');
setTimeout(function () {
ele.scrollIntoView(false);
document.body.scrollTop = ele.scrollHeight;
document.documentElement.scrollTop = ele.scrollHeight;
}, 400);
},
/* 去支付 */
async payFunction ({ payType, isSupport }) {
this.payType = payType
this.show = false
let orderInfo = await this.createdOrder(payType);
if (orderInfo.pay_status == 2 || [1, 2].includes(orderInfo.channel)) {//pay_status 2已支付 channel 1 支付宝 2微信
let orderNumber = orderInfo.pay_status == 2 ? orderInfo.order_number : orderInfo.original_order_number;
window.location.replace('/paysuccess.html?order_number=' + orderNumber + '&token=' + localStorage.getItem('token'));
} else {
this.createdPay(orderInfo.order_number);
}
},
//创建优惠券订单
createdOrder (payType) {
let self = this;
let data = {
"token": localStorage.getItem('token'),
"key": localStorage.getItem('key'),
"code_batch_id": this.goodsDetail.coupon && this.goodsDetail.coupon.code_batch_id || this.goodsDetail.code_batch_id,
"goods_id": this.goodInfo.goods_id,
"account": this.account || '888888', /* 卡密时默认账号 */
"pay_type": payType == 2 ? 1 : 5,
"pay_amount": this.goodsDetail.coupon_price
}
return new Promise((resolve, reject) => {
req.axiosPost('/key/createCouponOrder', data).then(res => {
if (res.code == 200) {
resolve(res.data);
} else {
this.openErrorDialog(res.message);
if (res.code == 403) {
this.delayedOut(3)
this.isLogin = true
}
}
}).catch(err => {
});
});
},
//优惠券订单支付
createdPay (orderNumber) {
console.log(582,orderNumber);
this.orderNumber=orderNumber;
let open_id = localStorage.getItem('code_weixin')
console.log(582,open_id);
let data={
token: localStorage.getItem('token'),
}
if(open_id){
data.open_id=encodeURIComponent(open_id);
}
req.axiosGet('/key/coupon/createPay/' + orderNumber, data).then(res => {
if (res.code == 200) {
this.payWayRun(res.data);
} else {
this.openErrorDialog(res.message);
}
}).catch(err => { });
},
//根据环境去执行
payWayRun (result) {
if (this.payType == 1) {// 1微信支付 2 支付宝支付
if (isWx()) {
//进行微信支付
this.gotoWeiXinPay(result)
} else {
console.log(604,result);
if (result) {
window.location.href = result;
}
}
}
if (this.payType == 2) {// 1微信支付 2 支付宝支付
if (isWx()) {
this.href = result;
} else {
window.location.href = result;
}
}
},
//解决WeixinJSBridge is not defined 报错的方法
gotoWeiXinPay(payInfo) {
if (typeof WeixinJSBridge == "undefined") {
if (document.addEventListener) {
document.addEventListener('WeixinJSBridgeReady', this.onBridgeReady(payInfo), false);
} else if (document.attachEvent) {
document.attachEvent('WeixinJSBridgeReady', this.onBridgeReady(payInfo));
document.attachEvent('onWeixinJSBridgeReady', this.onBridgeReady(payInfo));
}
} else {
this.onBridgeReady(payInfo);
}
},
onBridgeReady(data) {
let self=this;
WeixinJSBridge.invoke(
'getBrandWCPayRequest', {
"appId": data.appId, //公众号名称,由商户传入
"timeStamp": data.timeStamp, //时间戳自1970年以来的秒数
"nonceStr": data.nonceStr, //随机串
"package": data.package,
"signType": data.signType, //微信签名方式:
"paySign": data.paySign //微信签名
},
function (res) {
if (res.err_msg == "get_brand_wcpay_request:ok") {
window.location.replace('/paysuccess.html?order_number=' + self.orderNumber + '&token=' + localStorage.getItem('token'));
//支付成功后跳转的页面
} else if (res.err_msg == "get_brand_wcpay_request:cancel") {
} else if (res.err_msg == "get_brand_wcpay_request:fail") {
WeixinJSBridge.call('closeWindow');
} //使用以上方式判断前端返回
}
);
},
/* 监听账号 */
watchAccount () {
if (this.account === this.reAccount) {
this.exchangeOpen = true;
} else {
this.exchangeOpen = false;
}
}
},
})
</script>
</html>