From 17a97a4f6a778bdfed9f09e1ad48c5aec6d51313 Mon Sep 17 00:00:00 2001 From: zhangguoping Date: Tue, 3 Sep 2024 14:49:52 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BA=A2=E5=8C=85=E5=AF=B9=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/templates/cmsCash/index.vue | 58 ++++++++++++++++++++---- src/views/templates/cmsVoucher/index.vue | 2 +- 2 files changed, 51 insertions(+), 9 deletions(-) diff --git a/src/views/templates/cmsCash/index.vue b/src/views/templates/cmsCash/index.vue index eaceb32..d5343bb 100644 --- a/src/views/templates/cmsCash/index.vue +++ b/src/views/templates/cmsCash/index.vue @@ -121,15 +121,57 @@ export default { } }, /* 立即领取 */ - receive() { - if (this.loading) return; - this.loading = true; - let data = { - key: localStorage.getItem("key"), - goods_id: this.goodsInfo.entity.goods_id, - code_batch_id: this.goodsInfo.code_batch_id, - token: localStorage.getItem("token"), + async receive() { + let self = this; + if (this.goods.err_code != 0) { + return showToast(this.goods.reason); + } + const params = { + id: [this.goodsID], + key: + localStorage.getItem("key") || + "rPBVzOCs0FN4P7jNMqHo5IVfb0oaAyigbfNBmCKnavs=", + account: "123", + name: "123", }; + const res = await EXCHANGE(params); + if (res.code === 200 && res.data.length) { + const data = res.data[0]; + if (data.code === 200) { + // window.location.href = data.path; + self.orderPolling(); + } else { + showToast(data.message); + } + // res.data.forEach(item => { + // if(item.id === self.goodsID && item.code != 0) { + // showToast(self.message) + // } + // }) + } else { + showToast(res.message); + } + }, + async orderPolling() { + const that = this; + const params = { + key: localStorage.getItem("key"), + id: [localStorage.getItem("id")], + }; + const res = await ORDER_QUERY(); + if (res && res.code === 200) { + if (res.data.status === 2) { + return await this.getData(); + } else { + setTimeout(() => { + that.orderPolling(); + }, 3000); + } + } else { + setTimeout(() => { + that.orderPolling(); + }, 3000); + } }, // 红包 结算 publicCollection(order_number: string) { diff --git a/src/views/templates/cmsVoucher/index.vue b/src/views/templates/cmsVoucher/index.vue index 414e72b..8fc7d7e 100644 --- a/src/views/templates/cmsVoucher/index.vue +++ b/src/views/templates/cmsVoucher/index.vue @@ -245,7 +245,7 @@ export default { const res = await EXCHANGE(params); if (res.code === 200 && res.data.length) { const data = res.data[0]; - if (data.code === 0) { + if (data.code === 200) { // window.location.href = data.path; self.orderPolling(); } else {