From 0645649733d97546cc43e871d3ff39c8842be06b Mon Sep 17 00:00:00 2001 From: sws <1141121512@qq.com> Date: Thu, 12 Sep 2024 18:51:39 +0800 Subject: [PATCH] =?UTF-8?q?1.diy---=E4=BC=98=E6=83=A0=E5=88=B8=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E8=81=94=E8=B0=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/diy/coupon.vue | 86 +++++++++++++++++++++++-- pages/plugins/coupon/shop/shop.vue | 100 +++++++++++------------------ 2 files changed, 118 insertions(+), 68 deletions(-) diff --git a/components/diy/coupon.vue b/components/diy/coupon.vue index ecad6261..71bb8bd0 100644 --- a/components/diy/coupon.vue +++ b/components/diy/coupon.vue @@ -14,7 +14,7 @@ - 立即领取 + {{ item.status_operable_name }} @@ -30,7 +30,7 @@ {{ item.name }} {{ item.desc }} - 立即领取 + {{ item.status_operable_name }} @@ -53,8 +53,8 @@
- - 立即领取 + + {{ item.status_operable_name }} @@ -85,7 +85,11 @@ {{ content_title }} {{ content_desc }} - 领取全部 + + {{ data_list.filter((item) => item.status_type == 0).length > 0 ? '立即领取' : '不可领取' }} + + +
@@ -183,6 +187,8 @@ url_2: '', url_3: '', }, + // 首页地址 + home_page_url: app.globalData.data.tabbar_pages[0], }; }, mounted() { @@ -229,6 +235,72 @@ style_container: common_styles_computer(new_style.common_style), }); }, + // 领取优惠券 + receive_event(e) { + const coupon_status_type = e.currentTarget.dataset.type; + const coupon_index = e.currentTarget.dataset.index; + const coupon_id = e.currentTarget.dataset.id; + switch (coupon_status_type) { + case 0: + // 登录校验 + var user = app.globalData.get_user_info(this, 'coupon_receive_event'); + if (user != false) { + var temp_list = this.data_list; + if (temp_list[coupon_index]['is_operable'] != 0) { + uni.showLoading({ + title: this.$t('common.processing_in_text'), + }); + this.coupon_api(coupon_id, coupon_index); + } + } + break; + case 3: + app.globalData.url_event(e); + break; + } + }, + // 全部领取 + receive_all_event() { + const filter_data_list = this.data_list.map((item) => { + if (item.is_operable != 0 && item.status_type == 0) { + return item.id; + } + }); + this.coupon_api(filter_data_list.join(',')); + }, + // 优惠劵领取事件 + coupon_api(val, index) { + uni.request({ + url: app.globalData.get_request_url('receive', 'coupon', 'coupon'), + method: 'POST', + data: { + coupon_id: val, + }, + dataType: 'json', + success: (res) => { + uni.hideLoading(); + if (res.data.code == 0) { + app.globalData.showToast(res.data.msg, 'success'); + if (index) { + temp_list = res.data.data.coupon || []; + } else { + temp_list[index] = res.data.data.coupon || {}; + } + this.setData({ + data_list: temp_list, + }); + } else { + if (app.globalData.is_login_check(res.data, this, 'coupon_receive_event')) { + app.globalData.showToast(res.data.msg); + } + } + }, + fail: () => { + uni.hideLoading(); + app.globalData.showToast(this.$t('common.internet_error_tips')); + }, + }); + }, }, }; @@ -746,6 +818,10 @@ } } } + // 已领取 + .btn-already { + color: #e3ca90 !important; + } .hide-scrollbar { overflow: auto; &::-webkit-scrollbar { diff --git a/pages/plugins/coupon/shop/shop.vue b/pages/plugins/coupon/shop/shop.vue index 8a4618f0..99ca6d95 100644 --- a/pages/plugins/coupon/shop/shop.vue +++ b/pages/plugins/coupon/shop/shop.vue @@ -2,24 +2,24 @@ - + - - - + + + - + - + - + @@ -27,7 +27,7 @@ -