fix: 修改 卡密兑换商品

This commit is contained in:
zhangds 2024-04-03 15:43:55 +08:00
parent 8b7c4b5783
commit d90f947c3b
2 changed files with 42 additions and 30 deletions

View File

@ -156,7 +156,7 @@
let goodsCount = null, goodsDetail = null; let goodsCount = null, goodsDetail = null;
new Vue({ new Vue({
el: '#exchangePage', el: '#exchangePage',
data () { data() {
return { return {
account: '', account: '',
reaccount: '', reaccount: '',
@ -189,7 +189,7 @@
] ]
}; };
}, },
created () { created() {
document.title = localStorage.getItem('title'); document.title = localStorage.getItem('title');
let detailsConfig = JSON.parse(localStorage.getItem('product_detail')); let detailsConfig = JSON.parse(localStorage.getItem('product_detail'));
goodsCount = sessionStorage.getItem('goodsCount'); goodsCount = sessionStorage.getItem('goodsCount');
@ -227,7 +227,7 @@
}); });
}, },
methods: { methods: {
bindAvailable () { bindAvailable() {
if (goodsDetail.available != 1) { if (goodsDetail.available != 1) {
this.openErrorDialog(product_status(goodsDetail.available, goodsDetail)); this.openErrorDialog(product_status(goodsDetail.available, goodsDetail));
return; return;
@ -235,7 +235,7 @@
}, },
/* 获取京东E卡短信 */ /* 获取京东E卡短信 */
sendJDSms () { sendJDSms() {
if (this.cunt === 60) { if (this.cunt === 60) {
req.axiosPost('/key/order/jdSendSms', { code_batch_id: this.goodsDetail.code_batch_id, mobile: this.account }) req.axiosPost('/key/order/jdSendSms', { code_batch_id: this.goodsDetail.code_batch_id, mobile: this.account })
.then((res) => { .then((res) => {
@ -255,27 +255,27 @@
} }
}, },
openErrorDialog (tip) { openErrorDialog(tip) {
this.maskshow = true; this.maskshow = true;
this.popboxtype = '提示'; this.popboxtype = '提示';
this.tiptext = tip; this.tiptext = tip;
this.popboxshow = true; this.popboxshow = true;
}, },
backgoodsFn () { backgoodsFn() {
if (goodsCount > 1) { if (goodsCount > 1) {
window.location.replace('./homepage.html'); window.location.replace('./homepage.html');
} else { } else {
history.go(-2); history.go(-2);
} }
}, },
closeTip () { closeTip() {
this.suspension = false; this.suspension = false;
}, },
susTipFn () { susTipFn() {
this.suspension = true; this.suspension = true;
}, },
// 单条弹框 // 单条弹框
openDialog (tip) { openDialog(tip) {
this.promtshow = true; this.promtshow = true;
this.promttip = tip; this.promttip = tip;
const clr = setTimeout(() => { const clr = setTimeout(() => {
@ -286,21 +286,27 @@
}, },
//刷新页面 //刷新页面
successchangeBtnFn () { successchangeBtnFn() {
window.location.replace(document.referrer); window.location.replace(document.referrer);
}, },
//兑换商品 //兑换商品
exchangeGoodsFn () { exchangeGoodsFn() {
if (goodsDetail.available != 1) { if (goodsDetail.available != 1) {
return this.openErrorDialog(product_status(goodsDetail.available, goodsDetail)); return this.openErrorDialog(product_status(goodsDetail.available, goodsDetail));
} }
/* 卡密商品直接兑换 */ /* 卡密商品直接兑换 */
if (this.goodInfo.product_type === 2 && this.goodInfo.card_show == 2 && this.backAble) { if (this.goodInfo.product_type === 2 && this.goodInfo.card_show == 2) {
this.maskshow = true; /* 当只有一个卡密商品、为线上查看卡密且只能兑换一次时执行 */
this.popboxshow = true; if (!this.backAble && this.goodsDetail.restrict == 1) {
this.popboxtype = '兑换'; return this.surexchangeBtn();
return; } else {
this.maskshow = true;
this.popboxshow = true;
this.popboxtype = '兑换';
return;
}
} }
/* 当只有一个卡密商品、为线上查看卡密且只能兑换一次时执行 */ /* 当只有一个卡密商品、为线上查看卡密且只能兑换一次时执行 */
@ -380,7 +386,7 @@
this.popboxtype = '兑换'; this.popboxtype = '兑换';
}, },
//确定兑换 //确定兑换
surexchangeBtn () { surexchangeBtn() {
this.maskshow = false; this.maskshow = false;
let self = this; let self = this;
let data = { let data = {
@ -434,14 +440,14 @@
}); });
}, },
//关闭弹出框,仅关闭弹框 //关闭弹出框,仅关闭弹框
successchangeBtn () { successchangeBtn() {
this.maskshow = false; this.maskshow = false;
this.popboxshow = false; this.popboxshow = false;
this.account = ""; this.account = "";
this.reaccount = ""; this.reaccount = "";
this.jd_code = ''; this.jd_code = '';
}, },
focusFn (a) { focusFn(a) {
let ele = document.querySelector('.ipt-acc'); let ele = document.querySelector('.ipt-acc');
setTimeout(function () { setTimeout(function () {
ele.scrollIntoView(false); ele.scrollIntoView(false);
@ -450,7 +456,7 @@
}, 400); }, 400);
}, },
//关闭,关闭弹框 //关闭,关闭弹框
closeBtn () { closeBtn() {
this.popboxshow = false; this.popboxshow = false;
this.maskshow = false; this.maskshow = false;
this.account = ""; this.account = "";
@ -461,25 +467,25 @@
computed: { computed: {
/* 手机号验证 */ /* 手机号验证 */
computedAccount () { computedAccount() {
return /^[1][3,4,5,6,7,8,9][0-9]{9}$/.test(this.account); return /^[1][3,4,5,6,7,8,9][0-9]{9}$/.test(this.account);
}, },
/* 兑换按钮验证 */ /* 兑换按钮验证 */
computedExChange () { computedExChange() {
return this.exchangeOpen || (this.goodInfo.product_type === 2 && this.goodInfo.card_show == 2) || this.goodInfo.is_e_card && this.computedAccount && this.jd_code.length === 6; return this.exchangeOpen || (this.goodInfo.product_type === 2 && this.goodInfo.card_show == 2) || this.goodInfo.is_e_card && this.computedAccount && this.jd_code.length === 6;
} }
}, },
watch: { watch: {
account () { account() {
if ((this.account == this.reaccount) && this.account) { if ((this.account == this.reaccount) && this.account) {
this.exchangeOpen = true; this.exchangeOpen = true;
} else { } else {
this.exchangeOpen = false; this.exchangeOpen = false;
} }
}, },
reaccount () { reaccount() {
if ((this.account == this.reaccount) && this.account) { if ((this.account == this.reaccount) && this.account) {
this.exchangeOpen = true; this.exchangeOpen = true;
} else { } else {
@ -488,7 +494,7 @@
}, },
productType: { productType: {
immediate: true, immediate: true,
handler (newVal) { handler(newVal) {
this.maxlen = 50; this.maxlen = 50;
this.acctype = "text"; this.acctype = "text";
if (newVal == 0) { if (newVal == 0) {

View File

@ -343,12 +343,18 @@
if (goodsDetail.available != 1) { if (goodsDetail.available != 1) {
return this.openErrorDialog(product_status(goodsDetail.available, goodsDetail)); return this.openErrorDialog(product_status(goodsDetail.available, goodsDetail));
} }
/* 卡密商品直接兑换 */ /* 卡密商品直接兑换 */
if (this.goodInfo.product_type === 2 && this.goodInfo.card_show == 2 && this.backAble) { if (this.goodInfo.product_type === 2 && this.goodInfo.card_show == 2) {
this.maskshow = true; /* 当只有一个卡密商品、为线上查看卡密且只能兑换一次时执行 */
this.popboxshow = true; if (!this.backAble && this.goodsDetail.restrict == 1) {
this.popboxtype = '兑换'; return this.surexchangeBtn();
return; } else {
this.maskshow = true;
this.popboxshow = true;
this.popboxtype = '兑换';
return;
}
} }
/* 当只有一个卡密商品、为线上查看卡密且只能兑换一次时执行 */ /* 当只有一个卡密商品、为线上查看卡密且只能兑换一次时执行 */