fix: 增加京东E卡

This commit is contained in:
zhangds 2024-03-01 15:30:58 +08:00
parent ea7cbe8b11
commit d1d8db3669
1 changed files with 87 additions and 16 deletions

View File

@ -72,22 +72,45 @@
<div v-else class="ipt-acc" style="position: relative;z-index: 99;"> <div v-else class="ipt-acc" style="position: relative;z-index: 99;">
<h4 class="title" v-if="goodInfo.product_type===2&&goodInfo.card_show==2">{{goodInfo.product_name}}</h4> <h4 class="title" v-if="goodInfo.product_type===2&&goodInfo.card_show==2">{{goodInfo.product_name}}</h4>
<template v-if="goodInfo.product_type===1||goodInfo.product_type===2&&goodInfo.card_show==1"> <template v-if="goodInfo.product_type===1||goodInfo.product_type===2&&goodInfo.card_show==1">
<p v-if="acctype=='tel'"><span>账号:</span><input :type="acctype" <!-- 京东E卡 -->
onkeyup="this.value=this.value.replace(/\D/g,'')" :disabled="goodsDetail.available!=1" <template v-if="goodInfo.is_e_card">
onKeypress="return(/[\d]/.test(String.fromCharCode(event.keyCode)))" :maxlength="maxlen" v-model="account" <p>
:placeholder="placeholder" @focus="(e)=>focusFn(e)"></p> <span>账号:</span>
<p v-if="acctype=='tel'"><span>再次输入:</span> <input :type="acctype" <input :type="acctype" onkeyup="this.value=this.value.replace(/\D/g,'')"
onkeyup="this.value=this.value.replace(/\D/g,'')" :disabled="goodsDetail.available!=1" :disabled="goodsDetail.available!=1"
onKeypress="return(/[\d]/.test(String.fromCharCode(event.keyCode)))" :maxlength="maxlen" onKeypress="return(/[\d]/.test(String.fromCharCode(event.keyCode)))" :maxlength="11" v-model="account"
v-model="reaccount" placeholder="请再次输入" @focus="(e)=>focusFn(e)"></p> placeholder="请输入手机号" @focus="(e)=>focusFn(e)">
<p v-if="acctype!='tel'"><span>账号:</span> <input :type="acctype" :maxlength="maxlen" v-model="account" </p>
:disabled="goodsDetail.available!=1" :placeholder="placeholder" @focus="(e)=>focusFn(e)"></p> <p>
<p v-if="acctype!='tel'"><span>再次输入:</span><input :type="acctype" :maxlength="maxlen" v-model="reaccount" <span>验证码:</span>
:disabled="goodsDetail.available!=1" placeholder="请再次输入" @focus="(e)=>focusFn(e)"></p> <input class="queryCode" :type="acctype" onkeyup="this.value=this.value.replace(/\D/g,'')"
:disabled="goodsDetail.available!=1"
onKeypress="return(/[\d]/.test(String.fromCharCode(event.keyCode)))" :maxlength="6" v-model="jd_code"
placeholder="请输入验证码" @focus="(e)=>focusFn(e)">
<button :disabled="!computedAccount" class="query-code" @click="sendJDSms">
{{cunt!==60?cunt+'s':'获取验证码'}}
</button>
</p>
</template>
<!-- 非E卡 -->
<template v-else>
<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>
</template> </template>
</div> </div>
<div class="bottom" id="bottom" v-show="describe.type||detailUrl"> <div class="bottom" id="bottom" v-show="describe.type||detailUrl">
<img :src="detailUrl" v-show="detailUrl"> <img :src="detailUrl" v-show="detailUrl">
<img :src="describe.bg_image" v-show="describe.type==1&&describe.bg_image"> <img :src="describe.bg_image" v-show="describe.type==1&&describe.bg_image">
@ -100,7 +123,7 @@
<p>订单</p> <p>订单</p>
</div> </div>
<button class="exchange-btn" <button class="exchange-btn"
:style="{'background': (exchangeOpen||(goodInfo.product_type===2&&goodInfo.card_show==2))?bgcolor:'#D7D7D7','color':(exchangeOpen||(goodInfo.product_type===2&&goodInfo.card_show==2))?ftcolor:'#333'}" :style="{'background': computedExChange?bgcolor:'#D7D7D7','color':computedExChange?ftcolor:'#333'}"
@click="exchangeGoodsFn">立即兑换</button> @click="exchangeGoodsFn">立即兑换</button>
</div> </div>
</div> </div>
@ -169,6 +192,8 @@
popboxshow: false, popboxshow: false,
exchangeOpen: false, exchangeOpen: false,
suspension: false, suspension: false,
cunt: 60,
jd_code: '',
popboxtype: '', popboxtype: '',
describe: {}, describe: {},
detailUrl: '', detailUrl: '',
@ -244,7 +269,29 @@
return; return;
} }
}, },
openErrorDialog(tip) {
/* 获取京东E卡短信 */
sendJDSms () {
if (this.cunt === 60) {
req.axiosPost('/key/order/jdSendSms', { code_batch_id: this.goodsDetail.code_batch_id, mobile: this.account })
.then((res) => {
if (res.code == 200) {
this.openDialog('短信下发成功!');
const clr = setInterval(() => {
if (this.cunt <= 1) {
this.cunt = 60;
return clearInterval(clr);
}
this.cunt--;
}, 1000);
} else {
this.openErrorDialog(res.message);
}
});
}
},
openErrorDialog (tip) {
this.maskshow = true; this.maskshow = true;
this.popboxtype = '提示'; this.popboxtype = '提示';
this.tiptext = tip; this.tiptext = tip;
@ -297,6 +344,16 @@
return this.surexchangeBtn(); return this.surexchangeBtn();
} }
/* 京东E卡 */
if (this.goodInfo.is_e_card && this.goodInfo.product_type === 1) {
if (this.computedExChange) {
this.maskshow = true;
this.popboxshow = true;
this.popboxtype = '兑换';
}
return;
}
if (!this.account) { if (!this.account) {
this.openDialog('请输入兑换账号!'); this.openDialog('请输入兑换账号!');
return false; return false;
@ -367,7 +424,8 @@
"goods_id": this.goodInfo.goods_id, "goods_id": this.goodInfo.goods_id,
"account": this.account, "account": this.account,
"code_batch_id": this.goodInfo.code_batch_id, "code_batch_id": this.goodInfo.code_batch_id,
"token": localStorage.getItem('token') "token": localStorage.getItem('token'),
'jd_code': this.jd_code
}; };
self.popboxshow = false; self.popboxshow = false;
req.axiosPost('/key/usage', data).then(res => { req.axiosPost('/key/usage', data).then(res => {
@ -450,6 +508,19 @@
this.reaccount = ""; this.reaccount = "";
}, },
}, },
computed: {
/* 手机号验证 */
computedAccount () {
return /^[1][3,4,5,6,7,8,9][0-9]{9}$/.test(this.account);
},
/* 兑换按钮验证 */
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;
}
},
watch: { watch: {
account() { account() {
if ((this.account == this.reaccount) && this.account) { if ((this.account == this.reaccount) && this.account) {