mobileclient/combining.html

803 lines
39 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" />
<title>组合立减金</title>
<link rel="stylesheet" href="./combining.css">
<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/vue.min.js?v=20210302151401"
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"></script>
<script src="https://lsxdemall.oss-cn-beijing.aliyuncs.com/MarketingSystem/js/libs.js?v=sdfhksdfklwrwer"></script>
</head>
<body>
<div id="app">
<div v-if="goods">
<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':''">
{{prompt_text}}
</div>
<div class="mask" @touchmove.prevent @mousewheel.prevent v-show="message">
<div class="model">
<p class="m-title">温馨提示</p>
<p class="m-msg">{{message}}</p>
<button class="m-but" @click="copyFn" v-if="copyLink">复制</button>
<button class="m-but" @click="message = ''" v-else>知道了</button>
</div>
</div>
<div class="content" :style="{background: dynamicStyle.bg}">
<img class="banner" :src="dynamicStyle.banner" alt="">
<div class="countdown" v-if="this.outTime.length>0">
<p :style="{color:dynamicStyle.times_color}">{{this.outTime[0]}}</p>
<p :style="{color:dynamicStyle.times_color}">{{this.outTime[1]}}</p>
<p :style="{color:dynamicStyle.times_color}">{{this.outTime[2]}}</p>
</div>
<div class="box">
<div class="box-cotent">
<div class="goods-box"
:style="{backgroundImage:`url(${dynamicStyle.goods_bg})`,paddingTop:goods.group_info.channel==1?'0.28rem':goods.group_info.channel==2?'0.16rem':'0.2rem'}">
<p class="title" :style="{color:dynamicStyle.title_color}">{{goods.title}}</p>
<ul class="g-b-u"
:style="{marginLeft:goods.group_info.channel==1?'0.12rem':'0.14rem',marginTop:goods.group_info.channel==2?'0.12rem':'0.28rem'}">
<li :style="{backgroundImage:`url(${item.voucher.status === 5 ? dynamicStyle.goods_a: item.voucher.status === 3 ? dynamicStyle.goods_c: dynamicStyle.goods_b})`}"
v-for="item in goods.product">
<p class="g-b-u-t">{{ item.voucher.status === 3 ? '领取成功' : '立减金'}}</p>
<p class="money">
<span></span>
{{item.voucher.reduce_amount}}
</p>
<p class="reduce">满{{item.voucher.denomination}}可用</p>
<p class="g-b-but" v-if="item.voucher.status === 1">
待领取({{item.voucher.num}}/{{item.voucher.send_num}})</p>
<p class="g-b-but" v-if="item.voucher.status === 2">
发放中({{item.voucher.num}}/{{item.voucher.send_num}})</p>
<p class="g-b-but" style="background-color: #FFE2A5;"
v-if="item.voucher.status === 3">
待使用({{item.voucher.num}}/{{item.voucher.send_num}})</p>
<p class="g-b-but" v-if="item.voucher.status === 5" style="font-size: 0.1rem;">
领取失败({{item.voucher.num}}/{{item.voucher.send_num}})</p>
</li>
</ul>
<p class="notis" :style="{color:dynamicStyle.notis_color}" v-show="goods.product.length>3">
滑动查看更多
</p>
</div>
<p class="g_b_title"
v-if="goods.send_status !== 2 && (goods.group_info.channel==3||goods.group_info.channel==1&&goods.group_info.receive_mode==2)">
<img src="https://lsxdemall.oss-cn-beijing.aliyuncs.com/MarketingSystem/img/combining/ysf_title_icon.png"
alt="">
{{goods.group_info.channel==1?'支付宝账号':'云闪付账号'}}
<img src="https://lsxdemall.oss-cn-beijing.aliyuncs.com/MarketingSystem/img/combining/ysf_title_icon.png"
alt="">
</p>
<template
v-if="goods.send_status !== 2 && (goods.group_info.channel==3||goods.group_info.channel==1&&goods.group_info.receive_mode==2)">
<input type="text" maxlength="50"
:placeholder="goods.group_info.channel==3?'请输入手机号':'请输入账号'" v-model="form.confirm">
<input type="text" maxlength="50"
:placeholder="goods.group_info.channel==3?'请再次输入手机号':'请再次输入账号'"
v-model="form.receive_account">
</template>
<!-- 普通状态 -->
<img class="but"
:style="{marginTop:goods.group_info.channel==2||goods.group_info.channel==1&&goods.group_info.receive_mode==1&&'0.12rem'}"
src="https://lsxdemall.oss-cn-beijing.aliyuncs.com/MarketingSystem/img/combining/ysf_but.png"
alt="" @click="submit"
v-show="goods.send_status === 5 || goods.send_status === 3 || goods.send_status === 4">
<!-- 发放中。。。 -->
<div class="ff-btn" v-show="goods.send_status === 1">
<div class="ff-text">发放中,请等待<span class="ani_dot">...</span></div>
</div>
<p class="time" v-if="goods.group_info.time_limit.timer_show!=2"
:style="{marginTop: 0,color:dynamicStyle.time_color}">
生效时间:{{goods.group_info.time_limit.effect_time.start_time}}
~
{{goods.group_info.time_limit.effect_time.end_time}}</p>
<p class="time" :style="{marginTop: '0.05rem',color:dynamicStyle.time_color}"
v-if="goods.group_info.time_limit.receive_time.start_time">
领取时间:{{goods.group_info.time_limit.receive_time.start_time}} ~
{{goods.group_info.time_limit.receive_time.end_time}}</p>
</div>
<div class="box-footer">
<img class="b-f-img" :src="dynamicStyle.footer_top" alt="">
<div class="b-f-b" :style="{backgroundImage:`url(${dynamicStyle.footer_middle})`}">
<div class="b-f-i" v-html="goods.group_info.instruction"
:style="{color:dynamicStyle.footer_color}" v-if="goods.group_info.instructionType==1">
</div>
<img v-else :src="goods.group_info.group_image" alt="" class="group_image">
</div>
<img class="b-f-img" :style="{filter:goods.receive_status==1?'grayscale(0)':'grayscale(0.6)'}"
:src="dynamicStyle.footer_bottom" alt="">
</div>
</div>
</div>
<!-- 弹窗 -->
<div class="tip-pop mask" v-show="popMsg">
<div class="tip-main" style="top: 10%;">
<div class="tip-pop-head">
<img src="https://lsxdemall.oss-cn-beijing.aliyuncs.com/MarketingSystem/img/combining/zh-dd.png"
class="tip-pop-dd" />
</div>
<p class="tip-title">温馨提示</p>
<p class="tip-card-status" v-show="goods.send_status === 2">全部领取成功</p>
<p class="tip-card-status" v-show="goods.send_status === 3" style="color: #FD2323;">全部领取失败</p>
<p class="tip-card-status" v-show="goods.send_status === 4">领取成功{{ isOKLength }}条,<span
style="color: #FD2323;font-size: 0.16rem;">失败{{ isErrLength }}条</span></p>
<p class="tip-card-text" v-show="goods.send_status === 2">
请前往支付宝APP-我的卡包查询使用
</p>
<p class="tip-card-text" style="padding: 0 0.2rem;" v-show="goods.send_status === 3">
{{ goods.err_msg[0] }}
</p>
<p class="tip-card-text" v-show="goods.send_status === 4">
请根据界面错误原因进行调整后再重试
</p>
<div v-if="errListShow"
style="padding: 0 0.2rem;overflow-y: scroll;max-height: 2rem;text-align: left;">
<p class="err-list-p" v-for="(item,index) in goods.err_msg">错误{{Number(index) + 1}}: {{ item }}
</p>
</div>
<button class="tip-btn" v-show="goods.send_status === 2 || goods.send_status === 3"
@click="() => popMsg = false">我知道了</button>
<button class="tip-btn" v-show="goods.send_status === 4" @click="() => {
errListShow = !errListShow
if(errListShow === false){
popMsg = false;
}
}">{{
errListShow ? '我知道了' : '查看失败原因' }}</button>
</div>
</div>
</div>
<!-- 弹出提示 -->
<div class="popboxshow" v-if="popboxshow" :class="popboxshow?'active':''">
<div class="tip">
<p>{{tiptext}}</p>
<span @click="knowFn">知道了</span>
</div>
</div>
</div>
</body>
<script>
// 详情数据
const mock_data = {
"title": "asdas12",
"begin_time": "2024-04-04 10:18:48",
"end_time": "2024-04-09 23:59:59",
"group_info": {
"type": "2",
"channel": "1",
"quantity": "10",
"is_webview": "0",
"time_limit": {
"timer_show": "1",
"effect_time": {
"end_time": "2024-04-09 23:59:59",
"start_time": "2024-04-04 10:18:48"
},
"receive_time": {
"end_time": "",
"start_time": ""
}
},
"group_cover": "",
"group_image": "",
"instruction": "<p>1、立减金自领取之日起7天有效请在有效期内使用\n<br\/>2、支付宝立减金自领取后每个立减金一次性使用不兑换、不找零到期后自动失效逾期未使用不再补发。使用支付宝支付进行付款(大于立减金面额0.01元以上)即可自动抵扣\n<br\/>3、多张立减金可在单笔支付宝支付订单中一起使用但当用户的立减金超过8张时系统会选取其中一部分使用不保证在一张订单中全部使用\n<br\/>4、使用立减金的支付宝支付订单如发生全额退款且立减金仍在有效期内立减金将自动退还给用户如立减金已过期则不退还给用户;如发生部分退款,用户支付金额将按比例原路退还,立减金将不退还给用户<\/p>",
"receive_mode": "2",
"instructionType": "1"
},
"send_status": 4, // 1发放中2全部成功 3全部失败4部分失败5待领取
"err_msg": ["用户支付宝未实名认证,请进入支付宝实名认证或换个账号重试", "云闪付未实名认证", "xxxxx", "asdqweqw", "用户支付宝未实名认证,请进入支付宝实名认证或换个账号重试", "云闪付未实名认证", "xxxxx", "asdqweqw"],
"product": [
{
"id": 65799,
"type": 2,
"voucher": {
"id": 1802,
"goods_id": 65799,
"channel_activity_id": "aaaa1",
"denomination": "2.00",
"reduce_amount": "1.00",
"send_num": 1,
"used_num": 0,
"num": 1,
"status": 5 // 1待领取2发放中3待使用, 5领取失败
}
},
{
"id": 657991,
"type": 2,
"voucher": {
"id": 18021,
"goods_id": 657991,
"channel_activity_id": "aaaa1",
"denomination": "2.00",
"reduce_amount": "1.00",
"send_num": 1,
"used_num": 0,
"num": 1,
"status": 5 // 1待领取2发放中3待使用4已使用5领取失败
}
},
{
"id": 657991,
"type": 2,
"voucher": {
"id": 18021,
"goods_id": 657991,
"channel_activity_id": "aaaa1",
"denomination": "2.00",
"reduce_amount": "1.00",
"send_num": 1,
"used_num": 0,
"num": 1,
"status": 3 // 1待领取2发放中3待使用4已使用5领取失败
}
}, {
"id": 657991,
"type": 2,
"voucher": {
"id": 18021,
"goods_id": 657991,
"channel_activity_id": "aaaa1",
"denomination": "2.00",
"reduce_amount": "1.00",
"send_num": 1,
"used_num": 0,
"num": 1,
"status": 2 // 1待领取2发放中3待使用4已使用5领取失败
}
}, {
"id": 657991,
"type": 2,
"voucher": {
"id": 18021,
"goods_id": 657991,
"channel_activity_id": "aaaa1",
"denomination": "2.00",
"reduce_amount": "1.00",
"send_num": 1,
"used_num": 0,
"num": 1,
"status": 1 // 1待领取2发放中3待使用4已使用5领取失败
}
}
],
"send_num": 1,
"settlement_data": {
"is_settlement": true,
"settlement_type": 1
}
}
const phoneReg = /^[1][3,4,5,6,7,8,9][0-9]{9}$/;
const emailReg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
new Vue({
el: "#app",
data() {
return {
goods: '',
backAble: (~~sessionStorage.getItem('goodsCount')) > 1,
token: localStorage.getItem('token'),
key: localStorage.getItem('key'),
promptShow: false,
popShow: false,
is: false,
cls: null,
prompt_text: '',
receive_time: '',
message: '',
loading: false,
openId: localStorage.getItem('openid'),
copyLink: '',
outTime: [],
form: {
confirm: null,
receive_account: null
},
errListShow: false,
popMsg: false,
popboxshow: false,
maskshow: false,
tiptext: "",
cont: 0,
timeGet: null,
isOKLength: 0,
isErrLength: 0
};
},
mounted() {
document.title = localStorage.getItem('title');
this.code_batch_id = JSON.parse(sessionStorage.getItem('goodsInfo')).entity.code_batch_id;
this.getProductDetail();
/* 倒计时 */
const key_expiration_time = sessionStorage.getItem('key_expiration_time');
if (key_expiration_time != 0) {
const cls = setInterval(() => {
const time = pageOutTime(key_expiration_time);
if (time) {
this.outTime = time;
} else {
this.outTime = ['00', '00', '00'];
clearInterval(cls);
}
}, 1000);
} else {
this.outTime = [];
}
},
computed: {
dynamicStyle() {
switch (Number(this.goods.group_info.channel)) {
case 1:
return {
bg: '#4989f5',
title_color: '#fff',
banner: 'https://lsxdemall.oss-cn-beijing.aliyuncs.com/MarketingSystem/img/combining/zfb_common_img_banner.png',
goods_bg: 'https://lsxdemall.oss-cn-beijing.aliyuncs.com/MarketingSystem/img/combining/zfb_redenvelope_img.png',
footer_top: 'https://lsxdemall.oss-cn-beijing.aliyuncs.com/MarketingSystem/img/combining/zfb_common_img_top.png',
footer_middle: 'https://lsxdemall.oss-cn-beijing.aliyuncs.com/MarketingSystem/img/combining/zfb_common_img_middle.png',
footer_bottom: 'https://lsxdemall.oss-cn-beijing.aliyuncs.com/MarketingSystem/img/combining/zfb_common_img_d.png',
footer_color: '#4989F5',
notis_color: '#FF486D',
times_color: '#1b7bff',
goods_a: 'https://lsxdemall.oss-cn-beijing.aliyuncs.com/MarketingSystem/img/combining/zfb_redenvelope_tobeused.png',
goods_b: 'https://lsxdemall.oss-cn-beijing.aliyuncs.com/MarketingSystem/img/combining/zfb_redenvelope_overdue.png',
goods_c: 'https://lsxdemall.oss-cn-beijing.aliyuncs.com/MarketingSystem/img/combining/zh-box.png',
};
case 2:
return {
bg: '#cee5be',
title_color: '#239700',
banner: 'https://lsxdemall.oss-cn-beijing.aliyuncs.com/MarketingSystem/img/combining/wx_common_img_banner.png',
goods_bg: 'https://lsxdemall.oss-cn-beijing.aliyuncs.com/MarketingSystem/img/combining/wx_redenvelope_img.png',
footer_top: 'https://lsxdemall.oss-cn-beijing.aliyuncs.com/MarketingSystem/img/combining/wx_common_img_top.png',
footer_middle: 'https://lsxdemall.oss-cn-beijing.aliyuncs.com/MarketingSystem/img/combining/wx_common_img_middle.png',
footer_bottom: 'https://lsxdemall.oss-cn-beijing.aliyuncs.com/MarketingSystem/img/combining/wx_common_img_d.png',
footer_color: '#5eb145',
time_color: '#5eb145',
times_color: '#5eb145',
notis_color: '#239700',
goods_a: 'https://lsxdemall.oss-cn-beijing.aliyuncs.com/MarketingSystem/img/combining/zfb_redenvelope_tobeused.png',
goods_b: 'https://lsxdemall.oss-cn-beijing.aliyuncs.com/MarketingSystem/img/combining/zfb_redenvelope_overdue.png',
goods_c: 'https://lsxdemall.oss-cn-beijing.aliyuncs.com/MarketingSystem/img/combining/zh-box.png',
};
case 3:
return {
bg: '#ff4830',
title_color: '#FF3024',
banner: 'https://lsxdemall.oss-cn-beijing.aliyuncs.com/MarketingSystem/img/combining/ysf_common_img_banner.png',
goods_bg: 'https://lsxdemall.oss-cn-beijing.aliyuncs.com/MarketingSystem/img/combining/ysf_redenvelope_img.png',
footer_top: 'https://lsxdemall.oss-cn-beijing.aliyuncs.com/MarketingSystem/img/combining/ysf_common_img_top.png',
footer_middle: 'https://lsxdemall.oss-cn-beijing.aliyuncs.com/MarketingSystem/img/combining/ysf_common_img_middle.png',
footer_bottom: 'https://lsxdemall.oss-cn-beijing.aliyuncs.com/MarketingSystem/img/combining/ysf_common_img_d.png',
footer_color: '#FF4901',
times_color: '#ed703f',
notis_color: '#FFD3D8',
goods_a: 'https://lsxdemall.oss-cn-beijing.aliyuncs.com/MarketingSystem/img/combining/ysf_redenvelope_tobeused.png',
goods_b: 'https://lsxdemall.oss-cn-beijing.aliyuncs.com/MarketingSystem/img/combining/ysf_redenvelope_overdue.png',
goods_c: 'https://lsxdemall.oss-cn-beijing.aliyuncs.com/MarketingSystem/img/combining/zh-box.png',
};
default:
return {};
}
},
},
methods: {
// 错误弹出框关闭
knowFn() {
this.popboxshow = false;
this.maskshow = false;
},
// 错误弹窗
openErrorDialog(tip) {
this.maskshow = true;
this.tiptext = tip;
this.popboxshow = true;
},
// 计算 send_status
// 计算 num
formatNum() {
},
// 计算 send_num
formatSendNum() {
},
// 转状态
formatStatus(status) {
// status 2发放中3待使用4已使用5领取失败
// 6发放中 1待使用 2已使用 9领取失败
switch (status) {
case 6:
return 2
case 1:
return 3
case 2:
return 3
case 9:
return 5
default:
return 1;
}
},
// 轮循
groupProductVoucherDetail() {
let self = this;
req.axiosGet('/key/group/groupProductVoucherDetail', {
token: this.token,
code_batch_id: this.code_batch_id
}).then(res => {
console.log("res =>", res);
if (res.code === 200) {
// send_status 1发放中2全部成功 3全部失败4部分失败 5未领取
// status 1待领取2发放中3待使用4已使用5领取失败
// 第一步:格式化数据
// 1.优先排出,发放中 和 全部领取失败 状态
let all_err = [];
let product_all = [];
res.data.product.forEach(item => {
let el = self.goods.product.find(items => items.id === item.id);
if (el) {
item.order_voucher.forEach(row => {
if (row.receive_error !== "") {
all_err.push(row.receive_error); // 存储错误
}
let obj = {
id: item.id,
type: item.type,
voucher: {
denomination: el.voucher.denomination,
reduce_amount: el.voucher.reduce_amount,
status: self.formatStatus(row.status),
num: self.formatStatus(row.status) === 3 ? 0 : 1,
send_num: 1
}
}
product_all.push(obj)
})
}
})
// 第二步:更新商品数据
self.goods.product = product_all;
// 第三步:需要确认 最终状态即 send_status 状态
// status 1待领取2发放中3待使用4已使用5领取失败
// send_status 1发放中2全部成功 3全部失败4部分失败 5未领取
let ffLength = product_all.filter(item => item.voucher.status === 2); // 发放中
// 只要有一个 发放中 -> send_status 1 发放中
if (ffLength.length > 0) {
self.goods.send_status = 1;
return;
}
let errLength = product_all.filter(item => item.voucher.status === 5);// 全部失败
// 领取失败失败数,大于等于全部数量 -> send_status 3 全部失败
if (errLength.length > 0 && product_all.length === errLength.length) {
self.goods.send_status = 3;
// 错误去重
self.goods.err_msg = [...new Set(all_err)];
self.popMsg = true;
clearInterval(self.timeGet);
self.timeGet = null;
return
} else if (errLength.length > 0 && product_all.length > errLength.length) {
// 领取失败数,小于全部数量 -> send_status 4 部分失败
// 错误去重
self.goods.err_msg = [...new Set(all_err)];
self.isOKLength = product_all.length - errLength.length;
self.isErrLength = errLength.length;
self.goods.send_status = 4;
self.popMsg = true;
clearInterval(self.timeGet);
self.timeGet = null;
return
}
// 3待使用4已使用 数量等于或者大于 最终长度 全部成功
let allOkLength = product_all.filter(item => item.voucher.status === 4 || item.voucher.status === 3);
if (allOkLength.length > 0 && allOkLength.length === product_all.length) {
self.goods.send_status = 2;
self.popMsg = true;
clearInterval(self.timeGet);
self.timeGet = null;
return
}
} else {
clearInterval(self.timeGet);
self.timeGet = null;
}
})
},
//获取商品详情
getProductDetail() {
let self = this;
req.axiosGet('/key/group/groupProductDetail', {
token: this.token,
code_batch_id: this.code_batch_id
}).then(res => {
if (res.code == 200) {
this.goods = res.data;
// send_status 1发放中2全部成功 3全部失败4部分失败 5未领取
this.popMsg = res.data.send_status === 2 || res.data.send_status === 3 || res.data.send_status === 4 ? true : false;
// 部分失败
if (res.data.send_status === 4) {
let all_product_length = res.data.product.length;
let is_err_length = res.data.product.filter(item => item.voucher.status === 5).length;
self.isOKLength = all_product_length - is_err_length;
self.isErrLength = is_err_length;
}
// 发放中 轮循
if (res.data.send_status === 1) {
self.timeGet = setInterval(() => {
// 安全值
if (self.cont > 10) {
clearInterval(self.timeGet);
self.timeGet = null;
}
self.groupProductVoucherDetail();
self.cont++;
}, 5000)
}
} else {
this.openErrorDialog(res.message)
}
}).catch();
},
/* ******************************************** 官方领取 ******************************************** */
/* 直接领取 */
directSubmit() {
/* 公众号打开 */
if (this.goods.group_info.channel == 2 && this.goods.group_info.is_webview == 1 && !this.openId) {
const linkId = localStorage.getItem('linkId');
location.href = `https://openapi.1688sup.com/wechat/oauth?jump=${location.origin}/${linkId}/${this.key}`;
return;
}
const data = {
key: this.key,
token: this.token,
code_batch_id: this.code_batch_id,
receive_mode: 1
};
req.axiosPost("/key/couponGroupUsage", data)
.then((res) => {
if (res.code == 200) {
if (this.goods.group_info.channel == 1 && this.goods.group_info.receive_mode == 1) {
/* 支付宝官方领取 */
this.toLinkAlipay();
} else if (this.goods.group_info.channel == 2) {
if (this.goods.group_info.is_webview == 1) {
/* 公众号 */
this.publicCollection();
} else {
/* 小程序 */
window.location.replace(res.data.redirect_url);
this.getProductDetail();
}
}
} else {
this.axiosErrorFun(res.code, res.message);
}
})
.catch((err) => { this.loading = false; });
},
/* 公众号领取 */
publicCollection() {
let params = {
token: this.token,
code_batch_id: this.code_batch_id,
channel_user_id: this.openId,
is_webview: 1
};
req.axiosPost("/voucher/groupVoucherGrant", params)
.then((res) => {
if (res.code == 200) {
this.message = '领取成功';
this.getProductDetail();
} else {
this.axiosErrorFun(res.code, res.message);
}
})
.catch((err) => { this.loading = false; });
},
/* 支付宝官方领取H5跳转 */
toLinkAlipay() {
let self = this;
let banklink = encodeURIComponent(
window.location.origin +
`/packkey/combiningAlipay.html?codeBatchId=${this.code_batch_id}&token=${this.token}`
);
let link = "http://openapi.1688sup.com/alipay/oauth?jump=" + banklink;
let ua = navigator.userAgent.toLowerCase(); //判断用户打开链接环境
if (isWx() ||
(ua.indexOf("android") > -1 &&
ua.indexOf("baiduboxapp") > -1) ||
ua.indexOf("windows") > -1) {
//复制链接地址,提醒去浏览器打开
this.message = '请点击下方[复制]按钮,复制链接到浏览器打开!';
this.copyLink = link;
} else {
//唤起支付宝
window.location.replace(link);
}
},
/* ******************************************** 账号领取 ******************************************** */
/* 立即领取 */
submit() {
if (this.goods.group_info.channel == 3 || this.goods.group_info.channel == 1 && this.goods.group_info.receive_mode == 2) {
const { confirm, receive_account } = this.form;
if (this.loading) return;
if (confirm !== receive_account) return this.tips('两次输入账号不一致');
/* 云闪付校验手机号 支付宝校验手机号/邮箱号 */
if ((phoneReg.test(receive_account) && this.goods.group_info.channel == 3 || this.goods.group_info.channel == 1 && (emailReg.test(receive_account) || phoneReg.test(receive_account)))) {
this.finalSubmit();
} else {
this.tips('请输入正确的账号');
}
} else {
this.directSubmit();
}
},
// 提交函数
submitOne(data) {
/* 领取立减金 */
req.axiosPost("/key/couponGroupUsage", data)
.then(({ code, message }) => {
if (code == 200) {
this.getProductDetail();
} else {
this.axiosErrorFun(code, message);
}
})
.catch((err) => { this.loading = false; });
},
// 重试函数
resetSubmit(data) {
/* 领取立减金 */
req.axiosPost("/voucher/groupVoucherRetry", data)
.then(({ code, message }) => {
if (code == 200) {
this.getProductDetail();
} else {
this.axiosErrorFun(code, message);
}
})
.catch((err) => { this.loading = false; });
},
/* 验证后 最终提交 */
finalSubmit() {
this.loading = true;
const self = this;
let data = {
key: this.key,
code_batch_id: this.code_batch_id,
token: localStorage.getItem("token"),
account: this.form.receive_account,
receive_mode: 2
};
setTimeout(() => {
this.loading = false;
}, 2000)
if (this.goods.send_status === 3 || this.goods.send_status === 4) {
this.resetSubmit(data); // 重试
} else {
this.submitOne(data); // 普通提交
}
},
/* 返回 */
backGoodsFn() {
if (this.backAble) {
window.location.replace('./homepage.html');
} else {
history.go(-2);
}
},
/* 接口异常处理 */
axiosErrorFun(code, message) {
this.loading = false;
if (code == 403) {
if (this.backAble) {
this.message = message;
setTimeout(() => {
window.location.href = localStorage.getItem('entryLink');
}, 3000);
} else {
this.message = message;
}
} else {
this.message = message;
}
},
//复制文本
copyFn() {
var textArea = document.createElement("textarea");
textArea.value = this.copyLink;
document.body.appendChild(textArea);
textArea.select();
document.execCommand("copy");
this.tips("复制成功,请到浏览器打开");
document.body.removeChild(textArea);
this.copyshow = false;
this.maskshow = false;
this.copyLink = null;
this.message = '';
},
/* 触发提示 */
tips(text) {
this.cls && clearTimeout(this.cls);
this.prompt_text = text;
this.promptShow = true;
this.cls = setTimeout(() => {
this.promptShow = false;
}, 3000);
},
}
})
</script>
</html>