diff --git a/components/productsBtn/productsBtn.vue b/components/productsBtn/productsBtn.vue index e5b011a..7f2c414 100644 --- a/components/productsBtn/productsBtn.vue +++ b/components/productsBtn/productsBtn.vue @@ -31,7 +31,7 @@ - + @@ -77,6 +77,7 @@ methods: { //获取历史记录 getHistoryOrCollection() { + console.log(uni.getStorageSync('token')); this.$apiServe.getHistoryOrCollection(this.type).then(res => { let data = res.data.data for (const item of data) { @@ -85,7 +86,7 @@ item.tags = this.tagsArray[0] item.create_time = dateFormatHistory(item.create_time) } - // console.log('获取历史记录', data); + console.log('获取历史记录', data); this.productList = data }).finally(_ => { @@ -96,21 +97,41 @@ var that = this uni.showModal({ title: '提示', - content: '你确定要删除吗', + content: '你确定要移除吗', success: function(res) { if (res.confirm) { that.$apiServe.deleteHistoryOrCollection(item.id).then(res => { if (res.data.code == 1) { - that.$toast.warn('删除成功') + that.$toast.warn('移除成功') } that.getHistoryOrCollection() }).finally(_ => {}) } else if (res.cancel) { - that.$toast.warn('取消删除') + that.$toast.warn('取消移除') } } }) - } + }, + //取消收藏按钮 + cancelCollect(item) { + var that = this + uni.showModal({ + title: '提示', + content: '你确定要取消收藏吗', + success: function(res) { + if (res.confirm) { + that.$apiServe.deleteHistoryOrCollection(item.id).then(res => { + if (res.data.code == 1) { + that.$toast.warn('取消收藏成功') + } + that.getHistoryOrCollection() + }).finally(_ => {}) + } else if (res.cancel) { + that.$toast.warn('取消操作') + } + } + }) + }, } } diff --git a/pages/detail/productsDetail/productsDetail.vue b/pages/detail/productsDetail/productsDetail.vue index e2836f4..a0d47bc 100644 --- a/pages/detail/productsDetail/productsDetail.vue +++ b/pages/detail/productsDetail/productsDetail.vue @@ -5,10 +5,10 @@ - - @@ -100,6 +100,7 @@ methods: { //获取详情信息 getProductDetail() { + console.log(this.id); this.$apiServe.getProductDetail(this.id).then(res => { console.log('产品详情页', res.data) if (res.data.data.thumb) { @@ -119,16 +120,15 @@ }, //收藏按钮 starTap() { - this.detailList.type = !this.detailList.type - // this.$apiServe.collect(this.id).then(res => { - // console.log('收藏成功', res.data) - // if (res.data.code == 1) { - // this.detailList.type = 1 - // this.$toast.warn('收藏成功') - // } else { - // this.$toast.warn('收藏失败') - // } - // }).finally(_ => {}) + this.$apiServe.collect(this.id).then(res => { + console.log('收藏成功', res.data) + if (res.data.code == 1) { + this.detailList.is_fav = 1 + this.$toast.warn('收藏成功') + } else { + this.$toast.warn('收藏失败') + } + }).finally(_ => {}) }, //点赞按钮 heartTap() { diff --git a/service/request.js b/service/request.js index 79f89a4..e1eb7c7 100644 --- a/service/request.js +++ b/service/request.js @@ -326,6 +326,13 @@ const apiService = { resolve(service.get(url)) }) }, + //修改个人信息 + getUser() { + const url = `/center/userinfo` + return new Promise((resolve, reject) => { + resolve(service.get(url)) + }) + }, // 获取首页分类Tag getTags(data) { const url = `/home/tags`