shopcomment.vue 4.9 KB
<template>
	<view class="container">
		<view class="goodcomment">


			<view class="goodcommentop flexone">
				<view class="topitem " :class="star_type==0?'topitemactive':''" @click="commenttype" :data-id="0">全部({{total}})</view>
				<view class="topitem" :class="star_type==1?'topitemactive':''" @click="commenttype" :data-id="1">好评({{total1}})</view>
				<view class="topitem" :class="star_type==2?'topitemactive':''" @click="commenttype" :data-id="2">中评({{total2}})</view>
				<view class="topitem" :class="star_type==3?'topitemactive':''" @click="commenttype" :data-id="3">差评({{total3}})</view>
			</view>
			<view class="nodata" v-if="commentlist.length==0">暂无评论</view>
			<view v-else>
				<view class="commentlist">
					<view class="jianintro photobox" bindtap="comdetail" v-for="(item,index) in commentlist" :key="index">
						<view class="comtop flextwo">
							<view class="comleft">
								<image :src="item.user.avatar"></image>
							</view>
							<view class="comright">
								<view class="comrtop">
									<view class="usertop flextwo">
										<view class="comrname">{{item.user.nickname}}</view>
										<view class="comdate">{{item.createtime}}</view>
									</view>
									<view class="star starone flexone">
										<view class="staritem">
											<image src="../../static/starredk.png" v-if="item.star>=1"></image>
											<image src="../../static/starred.png" v-else></image>
										</view>
										<view class="staritem">
											<image src="../../static/starredk.png" v-if="item.star>=2"></image>
											<image src="../../static/starred.png" v-else></image>
										</view>
										<view class="staritem">
											<image src="../../static/starredk.png" v-if="item.star>=3"></image>
											<image src="../../static/starred.png" v-else></image>
										</view>
										<view class="staritem">
											<image src="../../static/starredk.png" v-if="item.star>=4"></image>
											<image src="../../static/starred.png" v-else></image>
										</view>
										<view class="staritem">
											<image src="../../static/starredk.png" v-if="item.star>=5"></image>
											<image src="../../static/starred.png" v-else></image>
										</view>

									</view>

								</view>
							</view>
						</view>
						<view>
							<view class="commenttext">
								{{item.content}}
							</view>
							<view class="commentimg flexone" v-if="item.images.length!=0">
								<view class="commentimgitem" v-for="(itemk,indexk) in item.images" :key="indexk" @click="previewimg(index,indexk)">
									<image :src="itemk" mode=""></image>
								</view>
								
							</view>
						</view>
					</view>
				</view>

			</view>
		</view>
	</view>
</template>

<script>
	import app from "../../App.vue";
	export default {
		data() {
			return {
				commentlist: [],
				total: 0,
				total1: 0,
				total2: 0,
				total3: 0,
				store_id: '',
				star_type: 0,
				page: 1,
			}
		},
		onLoad(options) {
			this.store_id=options.store_id;
			this.getcommentlist()
		},
		methods: {
			// 评论切换
			commenttype(e) {
				this.star_type = e.currentTarget.dataset.id;
				this.page = 1;
				this.commentlist = [];
				this.getcommentlist()
			},

			// 获取评论列表
			getcommentlist() {
				let that = this;
				var url = 'goods_comments/store_goods_comments';
				var params = {

					store_id: that.store_id,
					star_type: that.star_type,
					page: that.page,
					pageNum: 10
				}
				console.log('33478478', params)
				app.post(url, params).then((res) => {
					console.log('获取评论列表', res);
					that.commentlist = that.commentlist.concat(res.data.data.list);
					that.total = res.data.data.total;
					that.total1 = res.data.data.total1;
					that.total2 = res.data.data.total2;
					that.total3 = res.data.data.total3;

				}).catch((err) => {
					console.log(err)

				})
			},
			// 预览图片
			previewimg(index, indexk) {
				let that = this;
				console.log(that.commentlist[index].images[indexk])
				uni.previewImage({
					current: that.commentlist[index].images[indexk],
					urls: that.commentlist[index].images,
					success: function(res) {},
					fail: function(res) {},
					complete: function(res) {},
				})

			},
		}

	}
</script>
<style>
	@import url('../../base/nearshop');
	@import url('../../base/homepage');

	.tapnavactive::after {
		bottom: -32rpx;
	}

	.goodetailbox {
		color: #3D454C;
		font-size: 24rpx;
		padding: 20rpx;
		box-sizing: border-box;
	}

	.huiyuanprice {
		margin-left: 28rpx
	}

	.tapnav {
		padding: 32rpx 126rpx;
		box-sizing: border-box;
	}

	.miaoduleft {
		width: 260rpx !important;

	}

	.miaotiao {
		position: relative;
	}

	.qiang {
		width: 200rpx;
		display: block;
		position: absolute;
		left: 0rpx;
		top: 0;
		text-align: left;
		padding-left: 10rpx;
		box-sizing: border-box;
	}

	.topitemactive {
		border: 1rpx solid #C29445;
		color: #C29445;
	}
</style>