From 09bbce1780078e154aca67a4f481e4d21264cda4 Mon Sep 17 00:00:00 2001 From: dengjie <209192278@qq.com> Date: Sun, 29 Jan 2023 14:15:43 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packageMy/myRelease/myRelease.vue | 3 +- .../detail/productsDetail/productsDetail.vue | 42 +++++++++++++------ service/request.js | 2 +- 3 files changed, 32 insertions(+), 15 deletions(-) diff --git a/packageMy/myRelease/myRelease.vue b/packageMy/myRelease/myRelease.vue index 47d172f..a38c731 100644 --- a/packageMy/myRelease/myRelease.vue +++ b/packageMy/myRelease/myRelease.vue @@ -89,6 +89,7 @@ }, onLoad() { this.getIdeasAndNeeds() + console.log(uni.getStorageSync('loginToken')); if (!uni.getStorageSync('loginToken') || uni.getStorageSync('loginToken').length === 0) { this.isLoad = false // uni.navigateTo({ @@ -102,7 +103,7 @@ //获取创意发布 getIdeasAndNeeds() { this.$apiServe.getIdeasAndNeeds(this.type).then(res => { - // console.log('获取创意发布&需求发布', res.data.data); + console.log('获取创意发布&需求发布', res.data.data); let data = res.data.data for (const item of data) { item.pub_time = dateFormatXwDetail(item.pub_time) diff --git a/pages/detail/productsDetail/productsDetail.vue b/pages/detail/productsDetail/productsDetail.vue index a43ee77..8979639 100644 --- a/pages/detail/productsDetail/productsDetail.vue +++ b/pages/detail/productsDetail/productsDetail.vue @@ -5,8 +5,8 @@ - + @@ -100,10 +100,13 @@ //获取详情信息 getProductDetail() { this.$apiServe.getProductDetail(this.id).then(res => { - // console.log('产品详情页', res.data) + console.log('产品详情页', res.data) if (res.data.data.thumb) { this.isThumb = true } + if (res.data.code == 0) { + this.$toast.warn('没有权限访问') + } if (res.data.data) { let detail = res.data.data detail.pub_time = dateFormatDetail(detail.pub_time) @@ -118,19 +121,32 @@ }, //收藏按钮 starTap() { - 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(_ => {}) + if (this.detailList.is_fav === 1) { + this.$toast.warn('已收藏') + } else if (this.detailList.is_fav === 0) { + 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() { - this.showHeart = !this.showHeart + // this.showHeart = !this.showHeart + this.$apiServe.thumb(this.id).then(res => { + console.log('点赞成功', res.data) + if (res.data.code == 1) { + this.showHeart = 1 + this.$toast.warn('点赞成功') + } else { + this.$toast.warn('点赞失败') + } + }).finally(_ => {}) }, reOnLoad() { if (!uni.getStorageSync('loginToken') || uni.getStorageSync('loginToken').length === 0) { diff --git a/service/request.js b/service/request.js index 6a7335d..199cefd 100644 --- a/service/request.js +++ b/service/request.js @@ -8,7 +8,7 @@ function isOutTime(res) { }) }, 1000) uni.removeStorageSync('userInfo') - uni.removeStorageSync('loginToken') + uni.removeStorageSync('token') } else { // uni.showToast(res.data.message); }