未登录时不请求授权接口;移除详情页评价模块;

This commit is contained in:
yangjian 2025-03-10 16:23:04 +08:00
parent a683294a38
commit e762f98e4a
5 changed files with 17 additions and 458 deletions

View File

@ -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",
@ -93,7 +92,7 @@ Page({
},
/**
* 添加或者取消收藏商品
* 添加或者取消收藏商品
*/
addOrCannelCollection() {
wx.showLoading();
@ -148,93 +147,6 @@ 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",
method: "GET",
data: {
prodId: this.data.prodId,
shopId: this.data.shopId,
},
callBack: (res) => {
this.setData({
couponList: res
})
}
})
},
/**
* 根据skuList进行数据组装
@ -259,7 +171,7 @@ Page({
//找到和商品价格一样的那个SKU作为默认选中的SKU
var defaultSku = this.data.defaultSku;
var isDefault = false;
if (!defaultSku && skuList[i].price == this.data.price) {
if (!defaultSku && skuList[i].price == this.data.price) {
defaultSku = skuList[i];
isDefault = true;
this.setData({
@ -576,4 +488,4 @@ Page({
})
})

View File

@ -47,47 +47,6 @@
<view class="sku-con">{{selectedProp.length>0?selectedProp+'':selectedProp}}{{prodNum}}件</view>
<view class="more">...</view>
</view>
<!-- 评价 -->
<view class='cmt-wrap'>
<view class="cmt-tit" bindtap='showComment'>
<view class="cmt-t">
评价
<text class="cmt-good">好评{{prodCommData.positiveRating}}%</text>
</view>
<view class="cmt-count">
共{{prodCommData.number}}条
<text class="cmt-more"></text>
</view>
</view>
<view class="cmt-cont">
<view class="cmt-tag" bindtap='showComment'>
<text>全部({{prodCommData.number}})</text>
<text>好评({{prodCommData.praiseNumber}})</text>
<text>中评({{prodCommData.secondaryNumber}})</text>
<text>差评({{prodCommData.negativeNumber}})</text>
<text>有图({{prodCommData.picNumber}})</text>
</view>
<view class="cmt-items">
<view class="cmt-item" wx:for="{{littleCommPage}}" wx:key="prodCommId">
<view class="cmt-user">
<text class="date">{{item.recTime}}</text>
<view class="cmt-user-info">
<image class="user-img" src="{{item.pic}}"></image>
<view class="nickname">{{item.nickName}}</view>
<van-rate readonly value="{{ item.score }}" bind:change="onChange" color="#f44" />
</view>
</view>
<view class="cmt-cnt">{{item.content}}</view>
<scroll-view class="cmt-attr" scroll-x="true" wx:if="{{item.pics.length}}">
<image src="{{commPic}}" wx:for='{{item.pics}}' wx:for-item="commPic" wx:key='*this'></image>
</scroll-view>
</view>
</view>
<view class="cmt-more-v" wx:if="{{prodCommPage.records.length > 2}}">
<text bindtap='showComment'>查看全部评价</text>
</view>
</view>
</view>
<!-- 商品详情 -->
<view class="prod-detail">
<view>
@ -180,46 +139,5 @@
</view>
</view>
</view>
<!-- 评价弹窗 -->
<view class="cmt-popup" wx:if="{{commentShow}}">
<view class="cmt-tit">
<view class="cmt-t">
商品评价
<text class="cmt-good">好评度{{prodCommData.positiveRating}}%</text>
</view>
<text class="close" bindtap='closePopup'></text>
</view>
<view class="cmt-cont">
<view class="cmt-tag">
<text bindtap='getProdCommPage' data-evaluate="-1" class="{{evaluate==-1?'selected':''}}">全部({{prodCommData.number}})</text>
<text bindtap='getProdCommPage' data-evaluate="0" class="{{evaluate==0?'selected':''}}">好评({{prodCommData.praiseNumber}})</text>
<text bindtap='getProdCommPage' data-evaluate="1" class="{{evaluate==1?'selected':''}}">中评({{prodCommData.secondaryNumber}})</text>
<text bindtap='getProdCommPage' data-evaluate="2" class="{{evaluate==2?'selected':''}}">差评({{prodCommData.negativeNumber}})</text>
<text bindtap='getProdCommPage' data-evaluate="3" class="{{evaluate==3?'selected':''}}">有图({{prodCommData.picNumber}})</text>
</view>
<view class="cmt-items">
<view class="cmt-item" wx:for="{{prodCommPage.records}}" wx:key="prodCommId">
<view class="cmt-user">
<text class="date">{{item.recTime}}</text>
<view class="cmt-user-info">
<image class="user-img" src="{{item.pic}}"></image>
<view class="nickname">{{item.nickName}}</view>
<van-rate readonly value="{{ item.score }}" bind:change="onChange" color="#f44" />
</view>
</view>
<view class="cmt-cnt">{{item.content}}</view>
<scroll-view class="cmt-attr" scroll-x="true" wx:if="{{item.pics.length}}">
<image src="{{commPic}}" wx:for='{{item.pics}}' wx:for-item="commPic" wx:key='*this'></image>
</scroll-view>
<view class="cmt-reply" wx:if="{{item.replyContent}}">
<text class='reply-tit'>店铺回复:</text> {{item.replyContent}}
</view>
</view>
</view>
<view class="load-more" wx:if='{{prodCommPage.pages > prodCommPage.current}}'>
<text bindtap='getMoreCommPage'>点击加载更多</text>
</view>
</view>
</view>
</view>
<wxs module="wxs" src="../../wxs/number.wxs" />
<wxs module="wxs" src="../../wxs/number.wxs" />

View File

@ -149,6 +149,10 @@ function updateUserInfo() {
//获取购物车商品数量
function getCartCount() {
if (!wx.getStorageSync('token')) {
wx.removeTabBarBadge()
return
}
var params = {
url: "/p/shopCart/prodCount",
method: "GET",
@ -177,4 +181,4 @@ function getCartCount() {
exports.getToken = getToken;
exports.request = request;
exports.getCartCount = getCartCount;
exports.updateUserInfo = updateUserInfo;
exports.updateUserInfo = updateUserInfo;

View File

@ -1,7 +1,6 @@
.container {
background: #f4f4f4;
height: 100%;
padding-bottom: 150rpx;
height: calc(100vh - 88rpx);
}
swiper {
height: 750rpx;
@ -602,7 +601,6 @@ rich-text {
left: 0;
width: 100%;
display: flex;
flex-direction: row nowrap;
height: 98rpx;
z-index: 999;
box-shadow: 0 -1px 3px rgba(0, 0, 0, 0.05);

View File

@ -79,80 +79,6 @@
...
</view>
</view>
<!-- 评价 -->
<view class="cmt-wrap">
<view
class="cmt-tit"
@tap="showComment"
>
<view class="cmt-t">
评价
<text class="cmt-good">
好评{{ prodCommData.positiveRating }}%
</text>
</view>
<view class="cmt-count">
{{ prodCommData.number }}
<text class="cmt-more" />
</view>
</view>
<view class="cmt-cont">
<view
class="cmt-tag"
@tap="showComment"
>
<text>全部({{ prodCommData.number }})</text>
<text>好评({{ prodCommData.praiseNumber }})</text>
<text>中评({{ prodCommData.secondaryNumber }})</text>
<text>差评({{ prodCommData.negativeNumber }})</text>
<text>有图({{ prodCommData.picNumber }})</text>
</view>
<view class="cmt-items">
<view
v-for="(item, index) in littleCommPage"
:key="index"
class="cmt-item"
>
<view class="cmt-user">
<text class="date">
{{ item.recTime }}
</text>
<view class="cmt-user-info">
<image
class="user-img"
:src="item.pic"
/>
<view class="nickname">
{{ item.nickName }}
</view>
</view>
</view>
<view class="cmt-cnt">
{{ item.content }}
</view>
<scroll-view
v-if="item.pics.length"
class="cmt-attr"
scroll-x="true"
>
<image
v-for="(commPic, index2) in item.pics"
:key="index2"
:src="commPic"
/>
</scroll-view>
</view>
</view>
<view
v-if="prodCommPage.records.length > 2"
class="cmt-more-v"
>
<text @tap="showComment">
查看全部评价
</text>
</view>
</view>
</view>
<!-- 商品详情 -->
<view class="prod-detail">
<view>
@ -306,125 +232,6 @@
</view>
</view>
</view>
<!-- 评价弹窗 -->
<view
v-if="commentShow"
class="cmt-popup"
>
<view class="cmt-tit">
<view class="cmt-t">
商品评价
<text class="cmt-good">
好评度{{ prodCommData.positiveRating }}%
</text>
</view>
<text
class="close"
@tap="closePopup"
/>
</view>
<view class="cmt-cont">
<view class="cmt-tag">
<text
data-evaluate="-1"
:class="evaluate==-1?'selected':''"
@tap="getProdCommPage"
>
全部({{ prodCommData.number }})
</text>
<text
data-evaluate="0"
:class="evaluate==0?'selected':''"
@tap="getProdCommPage"
>
好评({{ prodCommData.praiseNumber }})
</text>
<text
data-evaluate="1"
:class="evaluate==1?'selected':''"
@tap="getProdCommPage"
>
中评({{ prodCommData.secondaryNumber }})
</text>
<text
data-evaluate="2"
:class="evaluate==2?'selected':''"
@tap="getProdCommPage"
>
差评({{ prodCommData.negativeNumber }})
</text>
<text
data-evaluate="3"
:class="evaluate==3?'selected':''"
@tap="getProdCommPage"
>
有图({{ prodCommData.picNumber }})
</text>
</view>
<view class="cmt-items">
<block v-if="prodCommPage.records.length">
<view
v-for="(item, index) in prodCommPage.records"
:key="index"
class="cmt-item"
>
<view class="cmt-user">
<text class="date">
{{ item.recTime }}
</text>
<view class="cmt-user-info">
<image
class="user-img"
:src="item.pic"
/>
<view class="nickname">
{{ item.nickName }}
</view>
</view>
</view>
<view class="cmt-cnt">
{{ item.content }}
</view>
<scroll-view
v-if="item.pics.length"
class="cmt-attr"
scroll-x="true"
>
<image
v-for="(commPic, index2) in item.pics"
:key="index2"
:src="commPic"
/>
</scroll-view>
<view
v-if="item.replyContent"
class="cmt-reply"
>
<text class="reply-tit">
店铺回复
</text>
{{ item.replyContent }}
</view>
</view>
</block>
<view
v-if="!prodCommPage.records.length"
class="empty"
>
暂无评价
</view>
</view>
<view
v-if="prodCommPage.pages > prodCommPage.current"
class="load-more"
>
<text @tap="getMoreCommPage">
点击加载更多
</text>
</view>
</view>
</view>
</view>
</template>
@ -443,10 +250,10 @@ let prodId = 0
* 生命周期函数--监听页面加载
*/
onLoad((options) => {
prodId = options.prodid//
getProdInfo() //
getProdCommData() //
getLittleProdComm() //
prodId = options.prodid
//
getProdInfo()
//
getCollection()
})
@ -549,86 +356,6 @@ const getProdInfo = () => {
})
}
const prodCommData = ref({})
const getProdCommData = () => {
http.request({
url: '/prodComm/prodCommData',
method: 'GET',
data: {
prodId
}
})
.then(({ data }) => {
prodCommData.value = data
})
}
const prodCommPage = ref({
current: 0,
pages: 0,
records: []
})
/**
* 获取部分评论
*/
const getLittleProdComm = () => {
if (prodCommPage.value.records.length) {
return
}
getProdCommPage()
}
const getMoreCommPage = () => {
getProdCommPage()
}
const littleCommPage = ref([])
const evaluate = ref(-1)
/**
* 获取分页获取评论
*/
const getProdCommPage = (e) => {
if (e) {
if (e.currentTarget.dataset.evaluate === evaluate.value) {
return
}
prodCommPage.value = {
current: 0,
pages: 0,
records: []
}
evaluate.value = e.currentTarget.dataset.evaluate
}
http.request({
url: '/prodComm/prodCommPageByProd',
method: 'GET',
data: {
prodId,
size: 10,
current: prodCommPage.value.current + 1,
evaluate: evaluate.value
}
})
.then(({ data }) => {
data.records.forEach(item => {
if (item.pics) {
item.pics = item.pics.split(',')
}
})
let records = prodCommPage.value.records
records = records.concat(data.records)
//
prodCommPage.value = {
current: data.current,
pages: data.pages,
records
}
if (!littleCommPage.value.length) {
littleCommPage.value = records.slice(0, 2)
}
})
}
let selectedPropObjList = null
const skuGroup = ref({})
const defaultSku = ref(null)