清除定时器

This commit is contained in:
zhouxinyu1029 2024-04-12 21:41:50 +08:00
parent db279e7a13
commit 9d2318d68f
3 changed files with 78 additions and 60 deletions

View File

@ -214,7 +214,7 @@
const emailReg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
new Vue({
el: "#app",
data () {
data() {
return {
goods: '',
backAble: (~~sessionStorage.getItem('goodsCount')) > 1,
@ -249,7 +249,7 @@
};
},
mounted () {
mounted() {
document.title = localStorage.getItem('title');
this.code_batch_id = JSON.parse(sessionStorage.getItem('goodsInfo')).entity.code_batch_id;
this.getProductDetail();
@ -272,7 +272,7 @@
},
computed: {
dynamicStyle () {
dynamicStyle() {
switch (Number(this.goods.group_info.channel)) {
case 1:
return {
@ -326,7 +326,7 @@
methods: {
//获取商品详情
getProductDetail () {
getProductDetail() {
const self = this;
req.axiosGet('/key/group/v2/groupProductDetail', {
token: self.token,
@ -341,6 +341,10 @@
// send_status 1发放中2全部成功 3全部失败4部分失败 5未领取
self.popMsg = self.goods.send_status === 2 || self.goods.send_status === 3 || self.goods.send_status === 4 ? true : false;
if (self.goods.send_status === 2 || self.goods.send_status === 3) {
clearInterval(self.timeGet);
self.timeGet = null;
}
// 部分失败
if (self.goods.send_status === 4) {
let all_product_voucher = [];
@ -351,6 +355,8 @@
let is_err_length = all_product_voucher.filter(item => item.status === 9).length;
self.isOKLength = all_product_voucher.length - is_err_length;
self.isErrLength = is_err_length;
clearInterval(self.timeGet);
self.timeGet = null;
}
// 1.发放中 轮循
@ -391,7 +397,7 @@
}).catch();
},
// 轮循
groupProductVoucherDetail () {
groupProductVoucherDetail() {
let self = this;
req.axiosPost('/key/group/groupProductVoucherDetail', {
token: this.token,
@ -507,7 +513,7 @@
/* ******************************************** 官方领取 ******************************************** */
/* 直接领取 */
directSubmit () {
directSubmit() {
const self = this;
self.loading = true;
setTimeout(() => {
@ -558,7 +564,7 @@
},
/* 公众号领取 */
publicCollection () {
publicCollection() {
let params = {
token: this.token,
code_batch_id: this.code_batch_id,
@ -588,7 +594,7 @@
},
/* 支付宝官方领取H5跳转 */
toLinkAlipay () {
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);
@ -621,7 +627,7 @@
/* ******************************************** 账号领取 ******************************************** */
/* 立即领取 */
submit () {
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;
@ -638,7 +644,7 @@
},
// 提交函数
submitOne (data) {
submitOne(data) {
/* 领取立减金 */
req.axiosPost("/key/couponGroupUsage", data)
.then(({ code, message }) => {
@ -656,7 +662,7 @@
},
// 重试函数
resetSubmit (data) {
resetSubmit(data) {
/* 领取立减金 */
req.axiosPost("/voucher/groupVoucherRetry", data)
.then(({ code, message }) => {
@ -670,7 +676,7 @@
},
/* 验证后 最终提交 */
finalSubmit () {
finalSubmit() {
const self = this;
self.loading = true;
setTimeout(() => {
@ -697,7 +703,7 @@
},
/* 返回 */
backGoodsFn () {
backGoodsFn() {
if (this.backAble) {
window.location.replace('./homepage.html');
} else {
@ -706,7 +712,7 @@
},
/* 接口异常处理 */
axiosErrorFun (code, message) {
axiosErrorFun(code, message) {
this.loading = false;
if (code == 403) {
if (this.backAble) {
@ -723,7 +729,7 @@
},
//复制文本
copyFn () {
copyFn() {
var textArea = document.createElement("textarea");
textArea.value = this.copyLink;
document.body.appendChild(textArea);
@ -738,7 +744,7 @@
},
/* 触发提示 */
tips (text) {
tips(text) {
this.cls && clearTimeout(this.cls);
this.prompt_text = text;
this.promptShow = true;
@ -747,18 +753,18 @@
}, 3000);
},
// 错误弹出框关闭
knowFn () {
knowFn() {
this.popboxshow = false;
this.maskshow = false;
},
// 错误弹窗
openErrorDialog (tip) {
openErrorDialog(tip) {
this.maskshow = true;
this.tiptext = tip;
this.popboxshow = true;
},
// 6发放中 1待使用 9领取失败 20待领取 轮循+详情
formatStatusText (status) {
formatStatusText(status) {
switch (status) {
case 6:
return "发放中";
@ -775,7 +781,7 @@
}
},
// 计算 num
computeNum (data) {
computeNum(data) {
const self = this;
let new_product = data.map(item => {
let result = item.voucher.reduce((acc, curr) => {

View File

@ -214,7 +214,7 @@
const emailReg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
new Vue({
el: "#app",
data () {
data() {
return {
goods: '',
backAble: (~~sessionStorage.getItem('goodsCount')) > 1,
@ -249,7 +249,7 @@
};
},
mounted () {
mounted() {
document.title = localStorage.getItem('title');
this.code_batch_id = JSON.parse(sessionStorage.getItem('goodsInfo')).entity.code_batch_id;
this.getProductDetail();
@ -272,7 +272,7 @@
},
computed: {
dynamicStyle () {
dynamicStyle() {
switch (Number(this.goods.group_info.channel)) {
case 1:
return {
@ -326,7 +326,7 @@
methods: {
//获取商品详情
getProductDetail () {
getProductDetail() {
const self = this;
req.axiosGet('/key/group/v2/groupProductDetail', {
token: self.token,
@ -341,6 +341,10 @@
// send_status 1发放中2全部成功 3全部失败4部分失败 5未领取
self.popMsg = self.goods.send_status === 2 || self.goods.send_status === 3 || self.goods.send_status === 4 ? true : false;
if (self.goods.send_status === 2 || self.goods.send_status === 3) {
clearInterval(self.timeGet);
self.timeGet = null;
}
// 部分失败
if (self.goods.send_status === 4) {
let all_product_voucher = [];
@ -351,6 +355,8 @@
let is_err_length = all_product_voucher.filter(item => item.status === 9).length;
self.isOKLength = all_product_voucher.length - is_err_length;
self.isErrLength = is_err_length;
clearInterval(self.timeGet);
self.timeGet = null;
}
// 1.发放中 轮循
@ -391,7 +397,7 @@
}).catch();
},
// 轮循
groupProductVoucherDetail () {
groupProductVoucherDetail() {
let self = this;
req.axiosPost('/key/group/groupProductVoucherDetail', {
token: this.token,
@ -507,7 +513,7 @@
/* ******************************************** 官方领取 ******************************************** */
/* 直接领取 */
directSubmit () {
directSubmit() {
const self = this;
self.loading = true;
setTimeout(() => {
@ -557,7 +563,7 @@
},
/* 公众号领取 */
publicCollection () {
publicCollection() {
let params = {
token: this.token,
code_batch_id: this.code_batch_id,
@ -587,7 +593,7 @@
},
/* 支付宝官方领取H5跳转 */
toLinkAlipay () {
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);
@ -620,7 +626,7 @@
/* ******************************************** 账号领取 ******************************************** */
/* 立即领取 */
submit () {
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;
@ -637,7 +643,7 @@
},
// 提交函数
submitOne (data) {
submitOne(data) {
/* 领取立减金 */
req.axiosPost("/key/couponGroupUsage", data)
.then(({ code, message }) => {
@ -655,7 +661,7 @@
},
// 重试函数
resetSubmit (data) {
resetSubmit(data) {
/* 领取立减金 */
req.axiosPost("/voucher/groupVoucherRetry", data)
.then(({ code, message }) => {
@ -669,7 +675,7 @@
},
/* 验证后 最终提交 */
finalSubmit () {
finalSubmit() {
const self = this;
self.loading = true;
setTimeout(() => {
@ -696,7 +702,7 @@
},
/* 返回 */
backGoodsFn () {
backGoodsFn() {
if (this.backAble) {
window.location.replace('./homepage.html');
} else {
@ -705,7 +711,7 @@
},
/* 接口异常处理 */
axiosErrorFun (code, message) {
axiosErrorFun(code, message) {
this.loading = false;
if (code == 403) {
if (this.backAble) {
@ -722,7 +728,7 @@
},
//复制文本
copyFn () {
copyFn() {
var textArea = document.createElement("textarea");
textArea.value = this.copyLink;
document.body.appendChild(textArea);
@ -737,7 +743,7 @@
},
/* 触发提示 */
tips (text) {
tips(text) {
this.cls && clearTimeout(this.cls);
this.prompt_text = text;
this.promptShow = true;
@ -746,18 +752,18 @@
}, 3000);
},
// 错误弹出框关闭
knowFn () {
knowFn() {
this.popboxshow = false;
this.maskshow = false;
},
// 错误弹窗
openErrorDialog (tip) {
openErrorDialog(tip) {
this.maskshow = true;
this.tiptext = tip;
this.popboxshow = true;
},
// 6发放中 1待使用 9领取失败 20待领取 轮循+详情
formatStatusText (status) {
formatStatusText(status) {
switch (status) {
case 6:
return "发放中";
@ -774,7 +780,7 @@
}
},
// 计算 num
computeNum (data) {
computeNum(data) {
const self = this;
let new_product = data.map(item => {
let result = item.voucher.reduce((acc, curr) => {

View File

@ -213,7 +213,7 @@
const emailReg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
new Vue({
el: "#app",
data () {
data() {
return {
goods: '',
backAble: (~~sessionStorage.getItem('goodsCount')) > 1,
@ -248,7 +248,7 @@
};
},
mounted () {
mounted() {
document.title = localStorage.getItem('title');
this.code_batch_id = JSON.parse(sessionStorage.getItem('goodsInfo')).entity.code_batch_id;
this.getProductDetail();
@ -271,7 +271,7 @@
},
computed: {
dynamicStyle () {
dynamicStyle() {
switch (Number(this.goods.group_info.channel)) {
case 1:
return {
@ -325,7 +325,7 @@
methods: {
//获取商品详情
getProductDetail () {
getProductDetail() {
const self = this;
req.axiosGet('/key/group/v2/groupProductDetail', {
token: self.token,
@ -340,6 +340,10 @@
// send_status 1发放中2全部成功 3全部失败4部分失败 5未领取
self.popMsg = self.goods.send_status === 2 || self.goods.send_status === 3 || self.goods.send_status === 4 ? true : false;
if (self.goods.send_status === 2 || self.goods.send_status === 3) {
clearInterval(self.timeGet);
self.timeGet = null;
}
// 部分失败
if (self.goods.send_status === 4) {
let all_product_voucher = [];
@ -350,6 +354,8 @@
let is_err_length = all_product_voucher.filter(item => item.status === 9).length;
self.isOKLength = all_product_voucher.length - is_err_length;
self.isErrLength = is_err_length;
clearInterval(self.timeGet);
self.timeGet = null;
}
// 1.发放中 轮循
@ -378,7 +384,7 @@
}).catch();
},
// 轮循
groupProductVoucherDetail () {
groupProductVoucherDetail() {
let self = this;
req.axiosPost('/key/group/groupProductVoucherDetail', {
token: this.token,
@ -494,7 +500,7 @@
/* ******************************************** 官方领取 ******************************************** */
/* 直接领取 */
directSubmit () {
directSubmit() {
const self = this;
self.loading = true;
setTimeout(() => {
@ -540,7 +546,7 @@
},
/* 公众号领取 */
publicCollection () {
publicCollection() {
let params = {
token: this.token,
code_batch_id: this.code_batch_id,
@ -560,7 +566,7 @@
},
/* 支付宝官方领取H5跳转 */
toLinkAlipay () {
toLinkAlipay() {
let self = this;
let banklink = encodeURIComponent(
window.location.origin +
@ -583,7 +589,7 @@
/* ******************************************** 账号领取 ******************************************** */
/* 立即领取 */
submit () {
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;
@ -600,7 +606,7 @@
},
// 提交函数
submitOne (data) {
submitOne(data) {
/* 领取立减金 */
req.axiosPost("/key/couponGroupUsage", data)
.then(({ code, message }) => {
@ -614,7 +620,7 @@
},
// 重试函数
resetSubmit (data) {
resetSubmit(data) {
/* 领取立减金 */
req.axiosPost("/voucher/groupVoucherRetry", data)
.then(({ code, message }) => {
@ -628,7 +634,7 @@
},
/* 验证后 最终提交 */
finalSubmit () {
finalSubmit() {
const self = this;
self.loading = true;
setTimeout(() => {
@ -655,7 +661,7 @@
},
/* 返回 */
backGoodsFn () {
backGoodsFn() {
if (this.backAble) {
window.location.replace('./homepage.html');
} else {
@ -664,7 +670,7 @@
},
/* 接口异常处理 */
axiosErrorFun (code, message) {
axiosErrorFun(code, message) {
this.loading = false;
if (code == 403) {
if (this.backAble) {
@ -681,7 +687,7 @@
},
//复制文本
copyFn () {
copyFn() {
var textArea = document.createElement("textarea");
textArea.value = this.copyLink;
document.body.appendChild(textArea);
@ -696,7 +702,7 @@
},
/* 触发提示 */
tips (text) {
tips(text) {
this.cls && clearTimeout(this.cls);
this.prompt_text = text;
this.promptShow = true;
@ -705,18 +711,18 @@
}, 3000);
},
// 错误弹出框关闭
knowFn () {
knowFn() {
this.popboxshow = false;
this.maskshow = false;
},
// 错误弹窗
openErrorDialog (tip) {
openErrorDialog(tip) {
this.maskshow = true;
this.tiptext = tip;
this.popboxshow = true;
},
// 6发放中 1待使用 9领取失败 20待领取 轮循+详情
formatStatusText (status) {
formatStatusText(status) {
switch (status) {
case 6:
return "发放中";
@ -733,7 +739,7 @@
}
},
// 计算 num
computeNum (data) {
computeNum(data) {
const self = this;
let new_product = data.map(item => {
let result = item.voucher.reduce((acc, curr) => {