From ac956c4896a2d1bdb43859edaf3fbecfefec27e8 Mon Sep 17 00:00:00 2001 From: yangjian Date: Mon, 10 Mar 2025 15:43:43 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9C=AA=E7=99=BB=E5=BD=95=E6=97=B6=E4=B8=8D?= =?UTF-8?q?=E8=AF=B7=E6=B1=82=E6=8E=88=E6=9D=83=E6=8E=A5=E5=8F=A3=EF=BC=9B?= =?UTF-8?q?=20=E7=A7=BB=E9=99=A4=E8=AF=A6=E6=83=85=E9=A1=B5=E8=AF=84?= =?UTF-8?q?=E4=BB=B7=E6=A8=A1=E5=9D=97=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/prod/prod.js | 80 +++--------------------------------------- pages/prod/prod.wxml | 82 -------------------------------------------- utils/http.js | 4 +++ 3 files changed, 8 insertions(+), 158 deletions(-) diff --git a/pages/prod/prod.js b/pages/prod/prod.js index c3dfb79..f12c31a 100644 --- a/pages/prod/prod.js +++ b/pages/prod/prod.js @@ -63,10 +63,6 @@ Page({ // 加载商品信息 this.getProdInfo(); - // 加载评论数据 - this.getProdCommData(); - // 加载评论项 - this.getLittleProdComm(); // 查看用户是否关注 this.getCollection(); }, @@ -75,6 +71,9 @@ Page({ * 获取是否关注信息 */ getCollection() { + if (!wx.getStorageSync('token')) { + return + } wx.showLoading(); var params = { url: "/p/user/collection/isCollection", @@ -148,78 +147,7 @@ Page({ }; http.request(params); }, - getProdCommData() { - http.request({ - url: "/prodComm/prodCommData", - method: "GET", - data: { - prodId: this.data.prodId, - }, - callBack: (res) => { - this.setData({ - prodCommData: res - }) - } - }) - }, - // 获取部分评论 - getLittleProdComm() { - if (this.data.prodCommPage.records.length) { - return; - } - this.getProdCommPage(); - }, - getMoreCommPage(e) { - this.getProdCommPage(); - }, - // 获取分页获取评论 - getProdCommPage(e) { - if (e) { - if (e.currentTarget.dataset.evaluate === this.data.evaluate) { - return; - } - this.setData({ - prodCommPage: { - current: 0, - pages: 0, - records: [] - }, - evaluate: e.currentTarget.dataset.evaluate - }) - } - http.request({ - url: "/prodComm/prodCommPageByProd", - method: "GET", - data: { - prodId: this.data.prodId, - size: 10, - current: this.data.prodCommPage.current + 1, - evaluate: this.data.evaluate - }, - callBack: (res) => { - res.records.forEach(item => { - if (item.pics) { - item.pics = item.pics.split(',') - } - }) - let records = this.data.prodCommPage.records - records = records.concat(res.records) - this.setData({ - prodCommPage: { - current: res.current, - pages: res.pages, - records: records - } - }) - // 如果商品详情中没有评论的数据,截取两条到商品详情页商品详情 - if (!this.data.littleCommPage.length) { - this.setData({ - littleCommPage: records.slice(0, 2) - }) - } - } - }) - }, + getCouponList() { http.request({ url: "/coupon/listByProdId", diff --git a/pages/prod/prod.wxml b/pages/prod/prod.wxml index d81a484..8707977 100644 --- a/pages/prod/prod.wxml +++ b/pages/prod/prod.wxml @@ -47,47 +47,6 @@ {{selectedProp.length>0?selectedProp+',':selectedProp}}{{prodNum}}件 ... - - - - - 评价 - 好评{{prodCommData.positiveRating}}% - - - 共{{prodCommData.number}}条 - - - - - - 全部({{prodCommData.number}}) - 好评({{prodCommData.praiseNumber}}) - 中评({{prodCommData.secondaryNumber}}) - 差评({{prodCommData.negativeNumber}}) - 有图({{prodCommData.picNumber}}) - - - - - {{item.recTime}} - - - {{item.content}} - - - - - - - 查看全部评价 - - - @@ -180,46 +139,5 @@ - - - - - 商品评价 - 好评度{{prodCommData.positiveRating}}% - - - - - - 全部({{prodCommData.number}}) - 好评({{prodCommData.praiseNumber}}) - 中评({{prodCommData.secondaryNumber}}) - 差评({{prodCommData.negativeNumber}}) - 有图({{prodCommData.picNumber}}) - - - - - {{item.recTime}} - - - {{item.content}} - - - - - 店铺回复: {{item.replyContent}} - - - - - 点击加载更多 - - - \ No newline at end of file diff --git a/utils/http.js b/utils/http.js index 211d6f0..0cabbda 100644 --- a/utils/http.js +++ b/utils/http.js @@ -149,6 +149,10 @@ function updateUserInfo() { //获取购物车商品数量 function getCartCount() { + if (!wx.getStorageSync('token')) { + wx.removeTabBarBadge() + return + } var params = { url: "/p/shopCart/prodCount", method: "GET",