fix: 更新

This commit is contained in:
zhangds 2024-04-05 20:29:59 +08:00
parent 1877f24c1c
commit 2734e96adf
3 changed files with 82 additions and 103 deletions

View File

@ -142,8 +142,8 @@
<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">领取成功6条,<span
style="color: #FD2323;font-size: 0.16rem;">失败6</span></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-我的卡包查询使用
@ -297,7 +297,6 @@
}
}
const bm_obj_data = sessionStorage.getItem("bm_auth") ? JSON.parse(sessionStorage.getItem("bm_auth")) : null;
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({
@ -329,7 +328,9 @@
maskshow: false,
tiptext: "",
cont: 0,
timeGet: null
timeGet: null,
isOKLength: 0,
isErrLength: 0
};
},
@ -468,13 +469,13 @@
// 第一步:格式化数据
// 1.优先排出,发放中 和 全部领取失败 状态
let all_err = [];
let product_all = [];
res.data.product.forEach(item => {
let el = self.goods.product.find(items => items.id === item.id);
console.log("elelele =>", el)
if (el) {
item.order_voucher.forEach(row => {
console.log("row 2=>", row)
all_err.push(row.receive_error); // 存储错误
let obj = {
id: item.id,
type: item.type,
@ -489,54 +490,59 @@
product_all.push(obj)
})
}
console.log("item 1=>", item)
})
console.log("格式化数据前 =>", this.goods.product);
console.log("格式化数据 =>", product_all);
// 第二步:更新商品数据
this.goods.product = product_all;
console.log("最终数据 =>", this.goods.product);
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.status === 2); // 发放中
let ffLength = product_all.filter(item => item.voucher.status === 2); // 发放中
// 只要有一个 发放中 -> send_status 1 发放中
if (ffLength.length > 0) {
this.goods.send_status = 1;
self.goods.send_status = 1;
return;
}
let errLength = product_all.filter(item => item.status === 5);// 全部失败
let errLength = product_all.filter(item => item.voucher.status === 5);// 全部失败
// 领取失败失败数,大于等于全部数量 -> send_status 3 全部失败
if (errLength.length > 0 && product_all.length === errLength.length) {
this.goods.send_status = 3;
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 3 全部失败
this.goods.send_status = 4;
// 领取失败数,小于全部数量 -> 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.status === 4 || item.status === 3);
let allOkLength = product_all.filter(item => item.voucher.status === 4 || item.voucher.status === 3);
if (allOkLength.length > 0 && allOkLength.length === product_all.length) {
this.goods.send_status = 2;
self.goods.send_status = 2;
self.popMsg = true;
clearInterval(self.timeGet);
self.timeGet = null;
return
}
} else {
clearInterval(this.timeGet);
this.timeGet = null;
clearInterval(self.timeGet);
self.timeGet = null;
}
})
},
@ -557,7 +563,7 @@
if (res.data.send_status === 1) {
self.timeGet = setInterval(() => {
// 安全值
if (self.cont > 2) {
if (self.cont > 10) {
clearInterval(self.timeGet);
self.timeGet = null;
}
@ -566,17 +572,6 @@
}, 5000)
}
// 代码暂时这样
if (res.data.group_info.channel == 1 && res.data.group_info.receive_mode == 1) {
} else if (res.data.group_info.channel == 2) {
} else {
// 领取成功结算 5
if (bm_obj_data && !bm_obj_data.settlement_data.is_settlement && bm_obj_data.settlement_data.settlement_type === 5) {
settlementFun(bm_obj_data.token, bm_obj_data.settlement_data.settlement_type);
}
}
} else {
this.openErrorDialog(res.message)
}
@ -603,10 +598,6 @@
req.axiosPost("/key/couponGroupUsage", data)
.then((res) => {
if (res.code == 200) {
// 领取结算 4
if (bm_obj_data && !bm_obj_data.settlement_data.is_settlement && bm_obj_data.settlement_data.settlement_type === 4) {
settlementFun(bm_obj_data.token, bm_obj_data.settlement_data.settlement_type);
}
if (this.goods.group_info.channel == 1 && this.goods.group_info.receive_mode == 1) {
/* 支付宝官方领取 */
this.toLinkAlipay();
@ -638,15 +629,6 @@
req.axiosPost("/voucher/groupVoucherGrant", params)
.then((res) => {
if (res.code == 200) {
// 领取成功结算 5
if (bm_obj_data && !bm_obj_data.settlement_data.is_settlement && bm_obj_data.settlement_data.settlement_type === 5) {
settlementFun(bm_obj_data.token, bm_obj_data.settlement_data.settlement_type);
}
// 使用结算 6
if (bm_obj_data && !bm_obj_data.settlement_data.is_settlement && bm_obj_data.settlement_data.settlement_type === 6) {
settlementFun(bm_obj_data.token, bm_obj_data.settlement_data.settlement_type);
}
this.message = '领取成功';
this.getProductDetail();
@ -660,15 +642,6 @@
/* 支付宝官方领取H5跳转 */
toLinkAlipay() {
// 领取成功结算 5
if (bm_obj_data && !bm_obj_data.settlement_data.is_settlement && bm_obj_data.settlement_data.settlement_type === 5) {
settlementFun(bm_obj_data.token, bm_obj_data.settlement_data.settlement_type);
}
// 使用结算 6
if (bm_obj_data && !bm_obj_data.settlement_data.is_settlement && bm_obj_data.settlement_data.settlement_type === 6) {
settlementFun(bm_obj_data.token, bm_obj_data.settlement_data.settlement_type);
}
let self = this;
let banklink = encodeURIComponent(
@ -720,21 +693,18 @@
account: this.form.receive_account,
receive_mode: 2
};
// 重试
if (this.goods.send_status === 3 || this.goods.send_status === 4) {
data.retry = 1;
}
setTimeout(() => {
this.loading = false;
}, 2000)
/* 领取立减金 */
req.axiosPost("/key/couponGroupUsage", data)
.then(({ code, message }) => {
if (code == 200) {
// 使用结算 6
if (bm_obj_data && !bm_obj_data.settlement_data.is_settlement && bm_obj_data.settlement_data.settlement_type === 6) {
settlementFun(bm_obj_data.token, bm_obj_data.settlement_data.settlement_type);
}
setTimeout(() => {
this.loading = false;
this.message = '领取成功';
this.getProductDetail();
}, 300);
this.getProductDetail();
} else {
this.axiosErrorFun(code, message);

View File

@ -122,8 +122,8 @@
});
let self = this;
//获取链接携带的参数
// let linkId = getQueryString('id');
let linkId = "2253"
let linkId = getQueryString('id');
// let linkId = "2253"
let keyCode = getQueryString('key');
if (!linkId) {//地址栏无携带id

View File

@ -142,8 +142,8 @@
<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">领取成功6条,<span
style="color: #FD2323;font-size: 0.16rem;">失败6</span></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-我的卡包查询使用
@ -329,7 +329,9 @@
maskshow: false,
tiptext: "",
cont: 0,
timeGet: null
timeGet: null,
isOKLength: 0,
isErrLength: 0
};
},
@ -468,13 +470,13 @@
// 第一步:格式化数据
// 1.优先排出,发放中 和 全部领取失败 状态
let all_err = [];
let product_all = [];
res.data.product.forEach(item => {
let el = self.goods.product.find(items => items.id === item.id);
console.log("elelele =>", el)
if (el) {
item.order_voucher.forEach(row => {
console.log("row 2=>", row)
all_err.push(row.receive_error); // 存储错误
let obj = {
id: item.id,
type: item.type,
@ -489,54 +491,59 @@
product_all.push(obj)
})
}
console.log("item 1=>", item)
})
console.log("格式化数据前 =>", this.goods.product);
console.log("格式化数据 =>", product_all);
// 第二步:更新商品数据
this.goods.product = product_all;
console.log("最终数据 =>", this.goods.product);
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.status === 2); // 发放中
let ffLength = product_all.filter(item => item.voucher.status === 2); // 发放中
// 只要有一个 发放中 -> send_status 1 发放中
if (ffLength.length > 0) {
this.goods.send_status = 1;
self.goods.send_status = 1;
return;
}
let errLength = product_all.filter(item => item.status === 5);// 全部失败
let errLength = product_all.filter(item => item.voucher.status === 5);// 全部失败
// 领取失败失败数,大于等于全部数量 -> send_status 3 全部失败
if (errLength.length > 0 && product_all.length === errLength.length) {
this.goods.send_status = 3;
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 3 全部失败
this.goods.send_status = 4;
// 领取失败数,小于全部数量 -> 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.status === 4 || item.status === 3);
let allOkLength = product_all.filter(item => item.voucher.status === 4 || item.voucher.status === 3);
if (allOkLength.length > 0 && allOkLength.length === product_all.length) {
this.goods.send_status = 2;
self.goods.send_status = 2;
self.popMsg = true;
clearInterval(self.timeGet);
self.timeGet = null;
return
}
} else {
clearInterval(this.timeGet);
this.timeGet = null;
clearInterval(self.timeGet);
self.timeGet = null;
}
})
},
@ -557,7 +564,7 @@
if (res.data.send_status === 1) {
self.timeGet = setInterval(() => {
// 安全值
if (self.cont > 2) {
if (self.cont > 10) {
clearInterval(self.timeGet);
self.timeGet = null;
}
@ -720,7 +727,13 @@
account: this.form.receive_account,
receive_mode: 2
};
// 重试
if (this.goods.send_status === 3 || this.goods.send_status === 4) {
data.retry = 1;
}
setTimeout(() => {
this.loading = false;
}, 2000)
/* 领取立减金 */
req.axiosPost("/key/couponGroupUsage", data)
.then(({ code, message }) => {
@ -729,12 +742,8 @@
if (bm_obj_data && !bm_obj_data.settlement_data.is_settlement && bm_obj_data.settlement_data.settlement_type === 6) {
settlementFun(bm_obj_data.token, bm_obj_data.settlement_data.settlement_type);
}
setTimeout(() => {
this.loading = false;
this.message = '领取成功';
this.getProductDetail();
}, 300);
this.getProductDetail();
} else {
this.axiosErrorFun(code, message);