| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357 |
- <template>
- <view class="home-reviews" :style="[bgRadius]" v-if="replyList.length > 0">
- <common-wrapper :config="configData">
- <view class="reviews-box">
- <!-- Header -->
- <view class="header acea-row row-between-wrapper">
- <view class="left acea-row row-middle">
- <text class="title" :style="{ color: titleColor }">{{
- $t("评价")
- }}</text>
- <text
- class="count"
- :style="{ color: countColor }"
- v-if="checkList.includes(0)"
- >({{ totalCount }})</text
- >
- </view>
- <navigator
- class="right acea-row row-middle"
- v-if="checkList.includes(1)"
- :url="
- productId
- ? '/pages/goods/goods_comment_list/index?product_id=' +
- productId
- : ''
- "
- hover-class="none"
- >
- <text class="rate" :style="{ color: rateColor }"
- >{{ replyChance }}% </text
- >{{ $t("好评率") }}
- <text class="iconfont icon-jiantou"></text>
- </navigator>
- </view>
- <!-- List -->
- <view class="list" v-if="!isSlide">
- <view class="item" v-for="(item, index) in showList" :key="index">
- <view class="user-info acea-row row-middle">
- <image
- :src="item.avatar"
- class="avatar"
- mode="aspectFill"
- ></image>
- <view class="info">
- <view class="name line1">{{ item.nickname }}</view>
- <view class="stars acea-row">
- <text
- class="iconfont icon-pingjia"
- v-for="i in 5"
- :key="i"
- :style="{ color: i <= item.star ? starColor : '#eee' }"
- ></text>
- </view>
- </view>
- </view>
- <view class="content line2">{{ item.comment }}</view>
- <view class="images acea-row" v-if="item.pics && item.pics.length">
- <view
- class="img-box"
- v-for="(img, imgIndex) in item.pics.slice(0, 3)"
- :key="imgIndex"
- >
- <image :src="img" class="img" mode="aspectFill"></image>
- <view class="more" v-if="imgIndex === 2 && item.pics.length > 3"
- >+{{ item.pics.length - 3 }}</view
- >
- </view>
- </view>
- </view>
- </view>
- <!-- Slide List -->
- <scroll-view scroll-x="true" class="slide-wrapper" v-else>
- <view
- class="slide-item"
- v-for="(item, index) in showList"
- :key="index"
- >
- <view class="user-info acea-row row-middle">
- <image
- :src="item.avatar"
- class="avatar"
- mode="aspectFill"
- ></image>
- <view class="info">
- <view class="name line1">{{ item.nickname }}</view>
- <view class="stars acea-row">
- <text
- class="iconfont icon-pingjia"
- v-for="i in 5"
- :key="i"
- :style="{ color: i <= item.star ? starColor : '#eee' }"
- ></text>
- </view>
- </view>
- </view>
- <view class="content line2">{{ item.comment }}</view>
- <view class="images acea-row" v-if="item.pics && item.pics.length">
- <view
- class="img-box"
- v-for="(img, imgIndex) in item.pics.slice(0, 3)"
- :key="imgIndex"
- >
- <image :src="img" class="img" mode="aspectFill"></image>
- <view class="more" v-if="imgIndex === 2 && item.pics.length > 3"
- >+{{ item.pics.length - 3 }}</view
- >
- </view>
- </view>
- </view>
- </scroll-view>
- </view>
- </common-wrapper>
- </view>
- </template>
- <script>
- import commonWrapper from "./commonWrapper.vue";
- import { getReplyList } from "@/api/store.js";
- export default {
- components: { commonWrapper },
- name: "homeReviews",
- props: {
- dataConfig: {
- type: Object,
- default: () => ({}),
- },
- productId: {
- type: [Number, String],
- default: 0,
- },
- reply: {
- type: Array,
- default: () => [],
- },
- replyCount: {
- type: [Number, String],
- default: 0,
- },
- replyChance: {
- type: [Number, String],
- default: 0,
- },
- },
- data() {
- return {
- replyList: [],
- };
- },
- watch: {
- productId: {
- handler(nVal) {
- if (nVal) {
- this.getReplyListFun();
- }
- },
- immediate: true,
- },
- dataConfig: {
- handler(nVal) {
- if (nVal && this.productId) {
- this.getReplyListFun();
- }
- },
- deep: true,
- },
- },
- computed: {
- configData() {
- return this.dataConfig;
- },
- bgRadius() {
- if (!this.dataConfig.fillet) return {};
- let borderRadius = `${this.dataConfig.fillet.val * 2}rpx`;
- if (this.dataConfig.fillet.type) {
- borderRadius = `${this.dataConfig.fillet.valList[0].val * 2}rpx ${
- this.dataConfig.fillet.valList[1].val * 2
- }rpx ${this.dataConfig.fillet.valList[3].val * 2}rpx ${
- this.dataConfig.fillet.valList[2].val * 2
- }rpx`;
- }
- return {
- borderRadius: borderRadius,
- overflow: "hidden",
- };
- },
- checkList() {
- return this.dataConfig.checkBoxConfig
- ? this.dataConfig.checkBoxConfig.type
- : [];
- },
- isSlide() {
- return this.dataConfig.layoutConfig
- ? this.dataConfig.layoutConfig.tabVal === 1
- : false;
- },
- showList() {
- return this.replyList;
- },
- titleColor() {
- return this.dataConfig.titleColor && this.dataConfig.titleColor.color[0]
- ? this.dataConfig.titleColor.color[0].item
- : "#333333";
- },
- countColor() {
- return this.dataConfig.countColor && this.dataConfig.countColor.color[0]
- ? this.dataConfig.countColor.color[0].item
- : "#999999";
- },
- rateColor() {
- if (
- this.dataConfig.toneConfig &&
- this.dataConfig.toneConfig.tabVal === 1
- ) {
- return this.dataConfig.rateColor && this.dataConfig.rateColor.color[0]
- ? this.dataConfig.rateColor.color[0].item
- : "#E93323";
- }
- return "var(--view-theme)";
- },
- starColor() {
- if (
- this.dataConfig.toneConfig &&
- this.dataConfig.toneConfig.tabVal === 1
- ) {
- return this.dataConfig.starColor && this.dataConfig.starColor.color[0]
- ? this.dataConfig.starColor.color[0].item
- : "#E93323";
- }
- return "var(--view-theme)";
- },
- totalCount() {
- return this.replyCount || "0";
- },
- },
- methods: {
- getReplyListFun() {
- let limit = this.dataConfig.numConfig ? this.dataConfig.numConfig.val : 2;
- getReplyList(this.productId, {
- page: 1,
- limit: limit,
- type: 0,
- }).then((res) => {
- this.replyList = res.data || [];
- });
- },
- },
- };
- </script>
- <style lang="scss" scoped>
- .header {
- margin-bottom: 24rpx;
- .title {
- font-size: 30rpx;
- font-weight: 600;
- }
- .icon-jiantou {
- color: #999;
- }
- .count {
- font-size: 24rpx;
- margin-left: 10rpx;
- }
- .right {
- font-size: 24rpx;
- }
- .iconfont {
- font-size: 24rpx;
- margin-left: 4rpx;
- }
- }
- .list {
- .item {
- background-color: #f9f9f9;
- border-radius: 12rpx;
- padding: 20rpx;
- margin-bottom: 20rpx;
- }
- }
- .slide-wrapper {
- white-space: nowrap;
- width: 100%;
- .slide-item {
- display: inline-block;
- background-color: #f9f9f9;
- border-radius: 12rpx;
- padding: 20rpx;
- margin-right: 20rpx;
- width: 600rpx;
- vertical-align: top;
- &:last-child {
- margin-right: 0;
- }
- }
- }
- .user-info {
- margin-bottom: 16rpx;
- .avatar {
- width: 64rpx;
- height: 64rpx;
- border-radius: 50%;
- }
- .info {
- margin-left: 16rpx;
- .name {
- font-size: 26rpx;
- color: #333;
- line-height: 36rpx;
- margin-bottom: 4rpx;
- max-width: 300rpx;
- }
- .stars {
- .iconfont {
- font-size: 20rpx;
- margin-right: 4rpx;
- }
- }
- }
- }
- .content {
- font-size: 26rpx;
- color: #333;
- line-height: 40rpx;
- margin-bottom: 16rpx;
- white-space: normal;
- }
- .images {
- .img-box {
- position: relative;
- margin-right: 12rpx;
- width: 120rpx;
- height: 120rpx;
- border-radius: 8rpx;
- overflow: hidden;
- .img {
- width: 100%;
- height: 100%;
- }
- .more {
- position: absolute;
- top: 0;
- left: 0;
- width: 100%;
- height: 100%;
- background-color: rgba(0, 0, 0, 0.4);
- display: flex;
- align-items: center;
- justify-content: center;
- color: #fff;
- font-size: 28rpx;
- }
- }
- }
- </style>
|