feat:商品评论接口调试

This commit is contained in:
黄泽群
2026-07-09 14:11:16 +08:00
committed by charles
parent 1aeb515cc5
commit dc0af03dd6
9 changed files with 835 additions and 429 deletions
+23 -19
View File
@@ -21,7 +21,7 @@
<view class="user-left">
<image
class="avatar"
:src="item.avatar || defaultAvatar"
:src="item.userImage"
mode="aspectFill"
></image>
<text class="username">{{ item.userName }}</text>
@@ -29,10 +29,10 @@
<view class="user-right">
<view class="stars">
<text
v-for="s in 5"
v-for="s in item.rating"
:key="s"
class="star-icon"
:style="{ color: s <= item.score ? '#7934F6' : '#e5e5e5' }"
:style="{ color: s <= item.rating ? '#7934F6' : '#e5e5e5' }"
>★</text
>
</view>
@@ -48,6 +48,8 @@
</template>
<script>
import { getGoodsReviewsList } from "@/api/product.js";
export default {
name: "Evaluation",
props: {
@@ -56,30 +58,32 @@ export default {
type: Object,
default: () => ({}),
},
evalId: {
type: Number,
default: 0,
},
},
data() {
return {
// 默认头像,网络图片或本地图片路径均可
defaultAvatar: "https://img.yzcdn.cn/vant/cat.jpeg",
totalCount: "99+",
list: [
{
avatar: "",
userName: "张***三",
score: 5, // 星级评分,满分5
content:
"商品质量非常不错,和描述的一模一样,做工精细没有多余线头,穿着很舒服,下次还会来购买的!强烈推荐给大家!",
images: [
"https://img.yzcdn.cn/vant/apple-1.jpg",
"https://img.yzcdn.cn/vant/apple-2.jpg",
],
createTime: "2026-06-15",
spec: "颜色: 经典黑; 尺码: XL",
},
],
list: [],
};
},
mounted() {
this.getGoodsReviewsList();
},
methods: {
async getGoodsReviewsList() {
const params = {
goodsId: this.evalId,
};
const resp = await getGoodsReviewsList(params);
if (resp && resp.bizcode === 100) {
this.list = (resp.data.entitys || []).slice(0, 2);
this.totalCount = resp.data.totalCount || "0";
}
},
// 点击查看全部评价
goMore() {
// 触发父组件的事件,或者直接在这里写路由跳转