2024-12-18 15:46:27 +08:00
|
|
|
|
<script setup>
|
|
|
|
|
// 商品评价列表
|
|
|
|
|
import {
|
|
|
|
|
ref,
|
|
|
|
|
reactive,
|
|
|
|
|
nextTick,
|
|
|
|
|
getCurrentInstance,
|
|
|
|
|
} from 'vue'
|
|
|
|
|
import {
|
|
|
|
|
onLoad,
|
|
|
|
|
onReady,
|
2025-02-12 09:05:14 +08:00
|
|
|
|
onPullDownRefresh,
|
|
|
|
|
onReachBottom
|
2024-12-18 15:46:27 +08:00
|
|
|
|
} from '@dcloudio/uni-app'
|
|
|
|
|
import {
|
|
|
|
|
useStore
|
|
|
|
|
} from 'vuex'
|
|
|
|
|
//
|
|
|
|
|
import util from '@/common/js/util.js'
|
2025-02-12 09:05:14 +08:00
|
|
|
|
// 接口地址
|
|
|
|
|
import api from '@/api/index.js'
|
2024-12-18 15:46:27 +08:00
|
|
|
|
const {
|
|
|
|
|
proxy
|
|
|
|
|
} = getCurrentInstance()
|
|
|
|
|
const {
|
|
|
|
|
userinfo
|
|
|
|
|
} = useStore().state
|
2025-02-12 09:05:14 +08:00
|
|
|
|
//
|
2024-12-18 15:46:27 +08:00
|
|
|
|
const typeList = ref([{
|
|
|
|
|
text: '全部',
|
2025-02-12 09:05:14 +08:00
|
|
|
|
param: {},
|
2024-12-18 15:46:27 +08:00
|
|
|
|
}, {
|
|
|
|
|
text: '最新',
|
2025-02-12 09:05:14 +08:00
|
|
|
|
param: {
|
|
|
|
|
isNew: 1,
|
|
|
|
|
},
|
2024-12-18 15:46:27 +08:00
|
|
|
|
}, {
|
2025-02-12 09:05:14 +08:00
|
|
|
|
text: '有图',
|
|
|
|
|
param: {
|
|
|
|
|
isImage: 1,
|
|
|
|
|
},
|
2024-12-18 15:46:27 +08:00
|
|
|
|
}])
|
|
|
|
|
// 当前选中
|
|
|
|
|
const typeIndex = ref(0)
|
2025-02-12 09:05:14 +08:00
|
|
|
|
// id
|
|
|
|
|
const id = ref('')
|
|
|
|
|
// 评论列表
|
|
|
|
|
const comment = reactive({
|
|
|
|
|
pageNum: 1,
|
|
|
|
|
pageSize: 5,
|
|
|
|
|
list: [],
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
onLoad((option) => {
|
|
|
|
|
if (option.id) id.value = option.id
|
|
|
|
|
|
|
|
|
|
// 获取商品评论
|
|
|
|
|
getProComment()
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
onPullDownRefresh(() => {
|
|
|
|
|
refreshList()
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
onReachBottom(() => {
|
|
|
|
|
getMoreList()
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
// 重载
|
|
|
|
|
function refreshList() {
|
|
|
|
|
comment.pageNum = 1
|
|
|
|
|
getProComment()
|
|
|
|
|
}
|
2024-12-18 15:46:27 +08:00
|
|
|
|
|
2025-02-12 09:05:14 +08:00
|
|
|
|
// 获取更多
|
|
|
|
|
function getMoreList() {
|
|
|
|
|
if (comment.total <= comment.list.length) return
|
|
|
|
|
comment.pageNum++
|
|
|
|
|
getProComment()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 获取商品评论
|
|
|
|
|
function getProComment() {
|
|
|
|
|
api.shop.getProComment({
|
|
|
|
|
query: {
|
|
|
|
|
// 产品id
|
|
|
|
|
productId: id.value,
|
|
|
|
|
pageNum: comment.pageNum,
|
|
|
|
|
pageSize: comment.pageSize,
|
|
|
|
|
...typeList.value[typeIndex.value].param,
|
|
|
|
|
}
|
|
|
|
|
}).then(rs => {
|
|
|
|
|
if (rs.code == 200) {
|
|
|
|
|
// 页码
|
|
|
|
|
if (comment.pageNum == 1) comment.list.length = 0
|
|
|
|
|
// 列表
|
|
|
|
|
comment.list.push(...rs.rows.map(item => {
|
|
|
|
|
if(item.imageUrls) item.imageUrls = item.imageUrls.split(',')
|
|
|
|
|
return item
|
|
|
|
|
}))
|
|
|
|
|
// 总数
|
|
|
|
|
comment.total = rs.total
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
util.alert({
|
|
|
|
|
content: rs.msg,
|
|
|
|
|
showCancel: false,
|
|
|
|
|
})
|
|
|
|
|
}).finally(() => {
|
|
|
|
|
uni.stopPullDownRefresh()
|
|
|
|
|
})
|
|
|
|
|
}
|
2024-12-18 15:46:27 +08:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 当前评论状态
|
|
|
|
|
* @param {Object} index
|
|
|
|
|
*/
|
|
|
|
|
function handleTypeIndex(index) {
|
|
|
|
|
if (typeIndex.value === index) return
|
|
|
|
|
typeIndex.value = index
|
2025-02-12 09:05:14 +08:00
|
|
|
|
// 重载列表
|
|
|
|
|
refreshList()
|
2024-12-18 15:46:27 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 打开弹窗
|
|
|
|
|
function open() {
|
|
|
|
|
proxy.$refs.popup.open();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 预览图片
|
|
|
|
|
function preview(urls, current) {
|
|
|
|
|
uni.previewImage({
|
|
|
|
|
urls,
|
|
|
|
|
current,
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<template>
|
|
|
|
|
<view class="app">
|
|
|
|
|
<view class="typeList df ptb20 pl20 bfff f30">
|
|
|
|
|
<view class="item df fdr aic mr20 ptb5 plr20 br4" :class="{'active': index === typeIndex}"
|
|
|
|
|
v-for="(item, index) in typeList" :key="index" @click="handleTypeIndex(index)">
|
|
|
|
|
<!-- <image class="icon mr10 wh30" v-if="item.icon" :src="item.icon" /> -->
|
|
|
|
|
<text class="">{{ item.text }}</text>
|
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
|
|
|
|
|
<view class="listBox f28">
|
2025-02-12 09:05:14 +08:00
|
|
|
|
<view class="nomore mtb30" v-if="!comment.list[0]">暂无评论~</view>
|
2024-12-18 15:46:27 +08:00
|
|
|
|
|
2025-02-12 09:05:14 +08:00
|
|
|
|
<view class="list df fdc mlr30" v-for="(item, index) in comment.list" :key="index">
|
2024-12-18 15:46:27 +08:00
|
|
|
|
<!-- 评论的用户 -->
|
2025-02-12 09:05:14 +08:00
|
|
|
|
<view class="userinfo rows mtb20 ">
|
|
|
|
|
<image class="wh80 cir" :src="item.avatar" mode="aspectFill" />
|
|
|
|
|
<view class="name f1 mlr20 c333 f34">{{ item.nickname }}</view>
|
|
|
|
|
<!-- <uni-icons type="more-filled" color="#999" /> -->
|
2024-12-18 15:46:27 +08:00
|
|
|
|
</view>
|
|
|
|
|
|
2025-02-12 09:05:14 +08:00
|
|
|
|
<view class="content ml30 plr20 bfff br20">
|
2024-12-18 15:46:27 +08:00
|
|
|
|
<!-- 款式日期 -->
|
|
|
|
|
<view class="rows mtb20 c999">
|
2025-02-12 09:05:14 +08:00
|
|
|
|
<view class="">款式:{{ item.sku }}</view>
|
|
|
|
|
<view class="">{{ item.commentTime }}</view>
|
2024-12-18 15:46:27 +08:00
|
|
|
|
</view>
|
|
|
|
|
|
|
|
|
|
<!-- 评论内容 -->
|
|
|
|
|
<view class="content mtb20 f30">{{item.content}}</view>
|
|
|
|
|
|
|
|
|
|
<!-- 图片 -->
|
2025-02-12 09:05:14 +08:00
|
|
|
|
<view class="images mtb20" v-if="item.imageUrls">
|
|
|
|
|
<view class="item pr" @click="preview(item.imageUrls,secIndex)"
|
|
|
|
|
v-for="(image, secIndex) in item.imageUrls" :key="secIndex">
|
2024-12-18 15:46:27 +08:00
|
|
|
|
<image class="img pa br10" :src="image" mode="aspectFill" />
|
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
|
|
|
|
|
<!-- 菜单 -->
|
2025-02-12 09:05:14 +08:00
|
|
|
|
<view class="fn df jcr aic mtb20 c999" v-if="0">
|
2024-12-18 15:46:27 +08:00
|
|
|
|
<!-- 点赞 -->
|
|
|
|
|
<view class="ec-item df aic mr20">
|
|
|
|
|
<uni-icons type="hand-up-filled" color="#FF0000" v-if="item.isLike == 1" />
|
|
|
|
|
<uni-icons type="hand-up" color="#999" v-else />
|
|
|
|
|
<view class="ml10">0</view>
|
|
|
|
|
</view>
|
|
|
|
|
|
|
|
|
|
<!-- 留言数 -->
|
|
|
|
|
<view class="ec-item df aic mr20">
|
|
|
|
|
<uni-icons type="chat" color="#999" />
|
|
|
|
|
<view class="ml10">{{item.child.length}}</view>
|
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
|
|
|
|
|
<!-- 子评论 -->
|
|
|
|
|
<view class="child oh mtb20 plr20 br10">
|
|
|
|
|
<view class="msg mtb10" v-for="(secItem,secIndex) in item.child" :key="secIndex">
|
|
|
|
|
<text class="c666">{{secItem.nickname}}:</text>
|
|
|
|
|
<text class="c333 ml5">{{secItem.content}}</text>
|
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
|
2025-02-12 09:05:14 +08:00
|
|
|
|
<view class="nomore mtb30" v-if="comment.list[0]">暂无更多评论~</view>
|
2024-12-18 15:46:27 +08:00
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<style lang="scss">
|
|
|
|
|
.typeList {
|
|
|
|
|
.item {
|
|
|
|
|
color: #666;
|
|
|
|
|
background-color: #FFF6EB;
|
|
|
|
|
transition: .3s;
|
|
|
|
|
|
|
|
|
|
&.active {
|
|
|
|
|
color: #fff;
|
|
|
|
|
background-color: #FF9B27;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 图片
|
|
|
|
|
.images {
|
|
|
|
|
display: grid;
|
|
|
|
|
grid-template-columns: repeat(3, 1fr);
|
|
|
|
|
grid-gap: 10rpx;
|
|
|
|
|
|
|
|
|
|
.item {
|
|
|
|
|
padding-bottom: 100%;
|
|
|
|
|
|
|
|
|
|
.img {
|
|
|
|
|
width: 100%;
|
|
|
|
|
height: 100%;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 子评论
|
|
|
|
|
.child {
|
|
|
|
|
background-color: #F4F4F4;
|
|
|
|
|
}
|
|
|
|
|
</style>
|