diff --git a/pages/goods-detail/goods-detail.vue b/pages/goods-detail/goods-detail.vue index dcd369d4..4d40ee26 100644 --- a/pages/goods-detail/goods-detail.vue +++ b/pages/goods-detail/goods-detail.vue @@ -222,7 +222,7 @@ {{ item.desc || item.name }} - {{ item.status_operable_name }} + {{ item.status_operable_name }} @@ -529,7 +529,7 @@ - + @@ -743,8 +743,6 @@ plugins_seckill_is_valid: false, // 优惠劵插件 plugins_coupon_data: null, - temp_coupon_receive_index: null, - temp_coupon_receive_value: null, popup_coupon_status: false, // 购买记录插件 plugins_salerecords_data: null, @@ -1345,55 +1343,69 @@ }); }, - // 优惠劵领取事件 - coupon_receive_event(index, value) { - // 参数处理 - if ((index || null) == null && (value || null) == null) { - var index = this.temp_coupon_receive_index; - var value = this.temp_coupon_receive_value; - } else { - this.setData({ - temp_coupon_receive_index: index, - temp_coupon_receive_value: value, - }); + // 优惠券组件领取事件 + coupon_receive_back_event() { + if (!app.globalData.is_single_page_check()) { + return false; } - // 登录校验 - var user = app.globalData.get_user_info(this, 'coupon_receive_event'); + let user = app.globalData.get_user_info(this, 'coupon_receive_back_event'); if (user != false) { - var temp_list = this.plugins_coupon_data.data; - uni.showLoading({ - title: this.$t('common.processing_in_text'), - }); - uni.request({ - url: app.globalData.get_request_url('receive', 'coupon', 'coupon'), - method: 'POST', - data: { - coupon_id: value, - }, - dataType: 'json', - success: (res) => { - uni.hideLoading(); - if (res.data.code == 0) { - app.globalData.showToast(res.data.msg, 'success'); - temp_list[index] = res.data.data.coupon; - this.setData({ - 'plugins_coupon_data.data': 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')); - }, - }); + let res = uni.getStorageSync('cache_plugins_coupon_receive_key') || null; + if(res != null) { + this.coupon_receive_handle(res); + } } }, + // 优惠劵领取事件 + coupon_receive_event(e) { + if (!app.globalData.is_single_page_check()) { + return false; + } + // 登录校验 + let user = app.globalData.get_user_info(this, 'coupon_receive_event', e); + if (user != false) { + this.coupon_receive_handle(e.currentTarget.dataset); + } + }, + + // 优惠券领取处理 + coupon_receive_handle(params) { + let index = params.index; + let value = params.value; + let temp_list = this.plugins_coupon_data.data; + uni.showLoading({ + title: this.$t('common.processing_in_text'), + }); + uni.request({ + url: app.globalData.get_request_url('receive', 'coupon', 'coupon'), + method: 'POST', + data: { + coupon_id: value, + }, + dataType: 'json', + success: (res) => { + uni.hideLoading(); + if (res.data.code == 0) { + app.globalData.showToast(res.data.msg, 'success'); + temp_list[index] = res.data.data.coupon; + this.setData({ + 'plugins_coupon_data.data': temp_list, + }); + } else { + if (app.globalData.is_login_check(res.data, this, 'coupon_receive_handle', params)) { + app.globalData.showToast(res.data.msg); + } + } + }, + fail: () => { + uni.hideLoading(); + app.globalData.showToast(this.$t('common.internet_error_tips')); + }, + }); + }, + // 购买记录提示处理 plugins_salerecords_tips_handle() { // 销毁之前的任务 diff --git a/pages/plugins/coupon/components/coupon-card/coupon-card.vue b/pages/plugins/coupon/components/coupon-card/coupon-card.vue index 3f869190..b47283d2 100644 --- a/pages/plugins/coupon/components/coupon-card/coupon-card.vue +++ b/pages/plugins/coupon/components/coupon-card/coupon-card.vue @@ -27,7 +27,7 @@ - {{ propStatusOperableName || this.$t('coupon-card.coupon-card.m9316y') }} + {{ propStatusOperableName || this.$t('coupon-card.coupon-card.m9316y') }} {{ propStatusOperableName || this.$t('coupon-card.coupon-card.m9316y') }} {{ propStatusOperableName || this.$t('coupon-card.coupon-card.m9316y') }} @@ -41,7 +41,7 @@ - {{$t('coupon-card.coupon-card.j318xx')}} + {{$t('coupon-card.coupon-card.j318xx')}} @@ -136,13 +136,19 @@ // 符号 currency_symbol: app.globalData.currency_symbol(), // 首页地址 - home_page_url: tabbar_pages[0], + home_page_url: tabbar_pages[0], + // 缓存key + cache_key: 'cache_plugins_coupon_receive_key', }; }, methods: { // 领取 - receive(e) { - this.$emit('call-back', this.propIndex, this.propData.id); + receive_event(e) { + uni.setStorageSync(this.cache_key, { + index: this.propIndex, + value: this.propData.id + }); + this.$emit('call-back'); }, // url事件 diff --git a/pages/plugins/coupon/detail/detail.vue b/pages/plugins/coupon/detail/detail.vue index 2dd6b073..ff0de4dd 100644 --- a/pages/plugins/coupon/detail/detail.vue +++ b/pages/plugins/coupon/detail/detail.vue @@ -5,7 +5,7 @@ - + @@ -144,55 +144,51 @@ }); }, // 优惠劵领取事件 - coupon_receive_event(index, value) { - if (!app.globalData.is_single_page_check()) { - return false; - } - // 参数处理 - if ((index || null) == null && (value || null) == null) { - var index = this.temp_coupon_receive_index; - var value = this.temp_coupon_receive_value; - } else { - this.setData({ - temp_coupon_receive_index: index, - temp_coupon_receive_value: value, - }); - } - // 登录校验 - var user = app.globalData.get_user_info(this, 'coupon_receive_event'); - if (user != false) { - var data = this.data; - if (data['status_type'] == 0) { - uni.showLoading({ - title: this.$t('common.processing_in_text'), - }); - uni.request({ - url: app.globalData.get_request_url('receive', 'coupon', 'coupon'), - method: 'POST', - data: { - coupon_id: value, - }, - dataType: 'json', - success: (res) => { - uni.hideLoading(); - if (res.data.code == 0) { - app.globalData.showToast(res.data.msg, 'success'); - data = res.data.data.coupon; - this.setData({ - data_list: data, - }); - } else { - if (app.globalData.is_login_check(res.data, this, 'coupon_receive_event')) { - app.globalData.showToast(res.data.msg); + coupon_receive_back_event() { + if (!app.globalData.is_single_page_check()) { + return false; + } + // 缓存 + let res = uni.getStorageSync('cache_plugins_coupon_receive_key') || null; + if(res != null) { + // 登录校验 + let user = app.globalData.get_user_info(this, 'coupon_receive_back_event'); + if (user != false) { + let index = res.index; + let value = res.value; + let data = this.data; + if (data['status_type'] == 0) { + uni.showLoading({ + title: this.$t('common.processing_in_text'), + }); + uni.request({ + url: app.globalData.get_request_url('receive', 'coupon', 'coupon'), + method: 'POST', + data: { + coupon_id: value, + }, + dataType: 'json', + success: (res) => { + uni.hideLoading(); + if (res.data.code == 0) { + app.globalData.showToast(res.data.msg, 'success'); + data = res.data.data.coupon; + this.setData({ + data_list: data, + }); + } else { + if (app.globalData.is_login_check(res.data, this, 'coupon_receive_back_event')) { + app.globalData.showToast(res.data.msg); + } } - } - }, - fail: () => { - uni.hideLoading(); - app.globalData.showToast(this.$t('common.internet_error_tips')); - }, - }); - } + }, + fail: () => { + uni.hideLoading(); + app.globalData.showToast(this.$t('common.internet_error_tips')); + }, + }); + } + } } }, diff --git a/pages/plugins/coupon/index/index.vue b/pages/plugins/coupon/index/index.vue index 39ecf5a7..746387ca 100644 --- a/pages/plugins/coupon/index/index.vue +++ b/pages/plugins/coupon/index/index.vue @@ -11,7 +11,7 @@ - + @@ -163,55 +163,51 @@ }); }, // 优惠劵领取事件 - coupon_receive_event(index, value) { - if (!app.globalData.is_single_page_check()) { - return false; - } - // 参数处理 - if ((index || null) == null && (value || null) == null) { - var index = this.temp_coupon_receive_index; - var value = this.temp_coupon_receive_value; - } else { - this.setData({ - temp_coupon_receive_index: index, - temp_coupon_receive_value: value, - }); - } - // 登录校验 - var user = app.globalData.get_user_info(this, 'coupon_receive_event'); - if (user != false) { - var temp_list = this.data_list; - if (temp_list[index]['status_type'] == 0) { - uni.showLoading({ - title: this.$t('common.processing_in_text'), - }); - uni.request({ - url: app.globalData.get_request_url('receive', 'coupon', 'coupon'), - method: 'POST', - data: { - coupon_id: value, - }, - dataType: 'json', - success: (res) => { - uni.hideLoading(); - if (res.data.code == 0) { - app.globalData.showToast(res.data.msg, 'success'); - 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); + coupon_receive_back_event() { + if (!app.globalData.is_single_page_check()) { + return false; + } + // 缓存 + let res = uni.getStorageSync('cache_plugins_coupon_receive_key') || null; + if(res != null) { + // 登录校验 + let user = app.globalData.get_user_info(this, 'coupon_receive_back_event'); + if (user != false) { + let index = res.index; + let value = res.value; + let temp_list = this.data_list; + if (temp_list[index]['status_type'] == 0) { + uni.showLoading({ + title: this.$t('common.processing_in_text'), + }); + uni.request({ + url: app.globalData.get_request_url('receive', 'coupon', 'coupon'), + method: 'POST', + data: { + coupon_id: value, + }, + dataType: 'json', + success: (res) => { + uni.hideLoading(); + if (res.data.code == 0) { + app.globalData.showToast(res.data.msg, 'success'); + 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_back_event')) { + app.globalData.showToast(res.data.msg); + } } - } - }, - fail: () => { - uni.hideLoading(); - app.globalData.showToast(this.$t('common.internet_error_tips')); - }, - }); - } + }, + fail: () => { + uni.hideLoading(); + app.globalData.showToast(this.$t('common.internet_error_tips')); + }, + }); + } + } } }, diff --git a/pages/plugins/coupon/shop/shop.vue b/pages/plugins/coupon/shop/shop.vue index f9fb1010..caec3645 100644 --- a/pages/plugins/coupon/shop/shop.vue +++ b/pages/plugins/coupon/shop/shop.vue @@ -5,7 +5,7 @@ - + @@ -162,54 +162,50 @@ }, // 优惠劵领取事件 - coupon_receive_event(index, value) { - if (!app.globalData.is_single_page_check()) { - return false; - } - // 参数处理 - if ((index || null) == null && (value || null) == null) { - var index = this.temp_coupon_receive_index; - var value = this.temp_coupon_receive_value; - } else { - this.setData({ - temp_coupon_receive_index: index, - temp_coupon_receive_value: value, - }); - } - // 登录校验 - var user = app.globalData.get_user_info(this, 'coupon_receive_event'); - if (user != false) { - var temp_list = this.data_list; - if (temp_list[index]['status_type'] == 0) { - uni.showLoading({ - title: this.$t('common.processing_in_text'), - }); - uni.request({ - url: app.globalData.get_request_url('receive', 'coupon', 'coupon'), - method: 'POST', - data: { - coupon_id: value, - }, - dataType: 'json', - success: (res) => { - uni.hideLoading(); - if (res.data.code == 0) { - app.globalData.showToast(res.data.msg, 'success'); - 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); + coupon_receive_back_event() { + if (!app.globalData.is_single_page_check()) { + return false; + } + // 缓存 + let res = uni.getStorageSync('cache_plugins_coupon_receive_key') || null; + if(res != null) { + // 登录校验 + let user = app.globalData.get_user_info(this, 'coupon_receive_back_event'); + if (user != false) { + let index = res.index; + let value = res.value; + let temp_list = this.data_list; + if (temp_list[index]['status_type'] == 0) { + uni.showLoading({ + title: this.$t('common.processing_in_text'), + }); + uni.request({ + url: app.globalData.get_request_url('receive', 'coupon', 'coupon'), + method: 'POST', + data: { + coupon_id: value, + }, + dataType: 'json', + success: (res) => { + uni.hideLoading(); + if (res.data.code == 0) { + app.globalData.showToast(res.data.msg, 'success'); + 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_back_event')) { + app.globalData.showToast(res.data.msg); + } } - } - }, - fail: () => { - uni.hideLoading(); - app.globalData.showToast(this.$t('common.internet_error_tips')); - }, - }); + }, + fail: () => { + uni.hideLoading(); + app.globalData.showToast(this.$t('common.internet_error_tips')); + }, + }); + } } } },