diff --git a/locale/en.json b/locale/en.json index 10cc0a54..4381ba4c 100644 --- a/locale/en.json +++ b/locale/en.json @@ -1579,6 +1579,7 @@ "3v6ulk": "After choosing for so long, do you really want to delete it?", "8q2yej": "Please slide the data you want to operate on first", "9g81jk": "Data does not exist", + "8tt78i": "Add to Favorites", "87rfg3": "Cancel collection", "346c25": "Collection successful", "21051p": "Collection failed", diff --git a/locale/zh.json b/locale/zh.json index 38001f09..b18a7cae 100644 --- a/locale/zh.json +++ b/locale/zh.json @@ -1571,6 +1571,7 @@ "3v6ulk": "挑了这么久,真的要删除吗?", "8q2yej": "请先滑动要操作的数据", "9g81jk": "数据不存在", + "8tt78i": "加入收藏", "87rfg3": "取消收藏", "346c25": "收藏成功", "21051p": "收藏失败", diff --git a/pages/user-favor/user-favor.vue b/pages/user-favor/user-favor.vue index f6de84f2..3420514f 100644 --- a/pages/user-favor/user-favor.vue +++ b/pages/user-favor/user-favor.vue @@ -267,11 +267,7 @@ } app.globalData.showToast(res.data.msg, 'success'); } else { - if (app.globalData.is_login_check(res.data)) { - app.globalData.showToast(res.data.msg); - } else { - app.globalData.showToast(self.$t('common.sub_error_retry_tips')); - } + app.globalData.showToast(res.data.msg); } }, fail: () => { diff --git a/pages/user-goods-browse/user-goods-browse.vue b/pages/user-goods-browse/user-goods-browse.vue index 78c4b517..b2070200 100644 --- a/pages/user-goods-browse/user-goods-browse.vue +++ b/pages/user-goods-browse/user-goods-browse.vue @@ -16,7 +16,7 @@ - + @@ -231,57 +231,88 @@ this.get_data_list(); }, - // 删除 - delete_event(e) { + // 列表数据事件 + item_event(e) { var self = this; wx.showActionSheet({ - itemList: [self.$t('common.del_record')], - success (res) { - // 参数 - var id = e.currentTarget.dataset.value; - var index = e.currentTarget.dataset.index; - // 加载loding - uni.showLoading({ - title: self.$t('common.processing_in_text') - }); - uni.request({ - url: app.globalData.get_request_url("delete", "usergoodsbrowse"), - method: 'POST', - data: { - ids: id - }, - dataType: 'json', - success: res => { - uni.hideLoading(); - if (res.data.code == 0) { - var temp_data_list = self.data_list; - temp_data_list.splice(index, 1); - self.setData({ - data_list: temp_data_list - }); - if (temp_data_list.length == 0) { - self.setData({ - data_list_loding_status: 0, - data_bottom_line_status: false - }); - } - app.globalData.showToast(res.data.msg, 'success'); - } else { - if (app.globalData.is_login_check(res.data)) { - app.globalData.showToast(res.data.msg); - } else { - app.globalData.showToast(self.$t('common.sub_error_retry_tips')); - } - } - }, - fail: () => { - uni.hideLoading(); - app.globalData.showToast(self.$t('common.internet_error_tips')); - } - }); + itemList: [self.$t('cart.cart.8tt78i'), self.$t('common.del_record')], + success (res) { + var id = e.currentTarget.dataset.value; + var index = e.currentTarget.dataset.index; + if(res.tapIndex == 0) { + self.goods_favor_handle(self, id, index); + } else { + self.goods_delete_handle(self, id, index); + } } }); }, + + // 删除处理 + goods_delete_handle(self, id, index, success_msg = null) { + uni.showLoading({ + title: self.$t('common.processing_in_text') + }); + uni.request({ + url: app.globalData.get_request_url("delete", "usergoodsbrowse"), + method: 'POST', + data: { + ids: id + }, + dataType: 'json', + success: res => { + uni.hideLoading(); + if (res.data.code == 0) { + var temp_data_list = self.data_list; + temp_data_list.splice(index, 1); + self.setData({ + data_list: temp_data_list + }); + if (temp_data_list.length == 0) { + self.setData({ + data_list_loding_status: 0, + data_bottom_line_status: false + }); + } + app.globalData.showToast(success_msg || res.data.msg, 'success'); + } else { + app.globalData.showToast(res.data.msg); + } + }, + fail: () => { + uni.hideLoading(); + app.globalData.showToast(self.$t('common.internet_error_tips')); + } + }); + }, + + // 收藏操作 + goods_favor_handle(self, id, index) { + uni.showLoading({ + title: self.$t('common.processing_in_text'), + }); + uni.request({ + url: app.globalData.get_request_url('favor', 'goods'), + method: 'POST', + data: { + id: self.data_list[index]['goods_id'], + is_mandatory_favor: 1 + }, + dataType: 'json', + success: (res) => { + uni.hideLoading(); + if (res.data.code == 0) { + self.goods_delete_handle(self, id, index, res.data.msg); + } else { + app.globalData.showToast(res.data.msg); + } + }, + fail: () => { + uni.hideLoading(); + app.globalData.showToast(self.$t('common.internet_error_tips')); + }, + }); + }, // 加入购物车 goods_cart_event(e) {