<template>
	<!-- 商品评价 -->
	<view class="evaluate">
		<!-- 顶部tab -->
		<!-- <view class="tabs">
			<view v-for="(item, index) in tabList" :key="index" class="tabs_list"  @tap="setTabs(item, index)"
			 :style="'color:' + (active == index ?colors :'') + ';font-weight:' + (active == index ?'bold' : '500')">
				{{item.name}}({{item.number}})
				<view class="active" :style="'background:' + colors" v-if="active == index"></view>
			</view>
		</view> -->
		<!-- 评价列表 -->
		<view class="my_evaluate" >
			<view class="evaluate_box">
				<view class="pingjia">
					 <view v-if="commits && commits.length > 0">
						<view class="pingjia_box" v-for="(row, indexs) in commits" :key="indexs">
								<view class="box_top">
									<image :src="row.headimg || headimg" mode="" class="head"></image>
									<view class="right">
										<p class="name">{{ row.username }}</p>
										<p class="p2">
											<text class="text1">{{ row.createTime }}</text>
											<text class="text2">{{ row.goodsName }}</text>
										</p>
										<p class="p3">
							
											<image src="/static/images/home/stars.png" v-for="i in +row.qualityScore" :key="i" mode="" ></image>
											<image src="/static/images/home/star-no.png" v-for="(s,h) in (5-row.qualityScore)" :key="h" mode="" ></image>
											</p>
									</view>
								</view>
									<view class="tag_box" v-if="row.tags">
										<view class="tags" v-for="(s,x) in row.tags" :key="x">{{s}}</view>
									</view>
								<view class="ping_neirong">{{ row.content }}</view>
								<fileList v-model="row.fileList" :show-colse-btn="false" :show-title="false"></fileList>
				
								<view class="huifu" v-if="row.reply && row.reply !== ''">商家回复：{{ row.reply }}</view>
							</view>
							<p class="onbottom">—— 到底了 ——</p>
						</view>
					</view> 
			</view>
		</view>
		<nodata v-if="commits.length == 0" :colors="colors"></nodata>
	</view>
</template>

<script>
	import { getCommits } from "@/api";
	import tabs from '../../commponent/public/tabs.vue'
	import { getFileList } from '@/utils/util.js'
	import fileList from '@/pages/commponent/public/fileList.vue'
	let app = getApp()

	export default {
		components: {
			tabs,
			fileList
		},
		data() {
			return {
				colors: '',
				tabList: [{
					name: '最新',
					number: 10,
					id: 0
				}, {
					name: '好评',
					number: 8,
					id: 1
				}, {
					name: '中评',
					number: 8,
					id: 2
				}, {
					name: '差评',
					number: 6,
					id: 3
				}, {
					name: '有图',
					number: 5,
					id: 4
				}],
				active: 0,
				
				headimg:'/static/images/face.jpg',
				goodsId: null,
				commits: []
			}
		},
		onReady() {},
		onLoad(options) {
			this.goodsId = options.id
			this.colors = app.globalData.newColor; //设置主题颜色
			this.getCommits(this.goodsId)
		
		},
		methods:{
			getCommits(goodsId) {
				if (!goodsId) {
					uni.navigateBack()
					return
				}
				let s = [
					  {		
						  "rule": "eq",
						  "type": "string",
						  "dictCode": "",
						  "val": goodsId,
						  "field": "goodId"
					  }
				]
						
				const params = {
					pageNo:1,
					pageSize: 5,
					superQueryParams: s,
					superQueryMatchType: 'and',
					"column": "createTime",
					order: "desc",
				}
				uni.showLoading({
					mask: true
				})
				params.superQueryParams = encodeURI(JSON.stringify(s))
				getCommits(params).then(res => {
					uni.hideLoading()
					const list = res.result.records.map(v => {
						v.fileList = getFileList(v.url)
						return v
					})
					this.commits = list
				})
			},
			setTabs(item,index){ //切换状态栏 模拟数据
				this.active = index
				// this.goodsEva = index == 0 ? this.temporary : []
			},
		
			
		}
	}
</script>

<style lang="scss" scoped>
	.tabs {
		height: 80upx;
		line-height: 80upx;
		display: flex;
		justify-content: flex-start;
		align-items: center;
		background-color: #fff;
		border-bottom: 1upx solid rgba($color: #eee, $alpha: 0.5);
		.tabs_list {
			flex: 1;
			text-align: center;
			font-size: 28upx;
			position: relative;
			color: #333;
		}
		.active {
			font-weight: bold;
			color: #DD4F42;
			width: 50upx;
			height: 4upx;
			border-radius: 20upx;
			background-color: #DD4F42;
			position: absolute;
			bottom: 0upx;
			left: 50%;
			transform: translateX(-50%);
			transition: all 0.3s;
		}
	}
	.my_evaluate{
		padding: 20upx 4%;
		.eva_title{
			height: 70upx;
			margin-top: 10upx;
			line-height: 70upx;
			font-size: 30upx;
			font-weight: bold;
			color: #202020;
			text{
				font-weight: normal;
			}
			.seeAll{
				float: right;
				font-size: 24upx;
				color: #999999;
				transform: translateY(6upx);
				&:active{
					opacity: 0.8;
				}
			}
		}
		.evaluate_box{
			.pingjia {
				background-color: #ffffff;
				overflow: hidden;
				.pingjia_box {
					overflow: hidden;
					margin-top: 20upx;
					padding-bottom: 20upx;
					overflow: hidden;
					border-bottom: 1upx solid #f2f2f2;
					&:last-child {
						border-bottom: none;
						padding-bottom: 10upx;
					}
					.box_top {
						display: flex;
						.head {
							height: 80upx;
							max-width: 80upx;
							min-width: 80upx;
							flex: 1;
							border-radius: 50%;
							float: left;
						}
						.right {
							flex: 1;
							margin-left: 20upx;
							position: relative;
							.name {
								font-size: 26upx;
								font-family: Source Han Sans CN;
								font-weight: 400;
								color: rgba(0, 0, 0, 1);
							}
							.p2 {
								margin-top: 20upx;
								font-size: 24upx;
								font-family: Source Han Sans CN;
								font-weight: 400;
								color: rgba(156, 156, 156, 1);
								.text2 {
									margin-left: 50upx;
								}
							}
							.p3 {
								height: 35upx;
								position: absolute;
								right: 0;
								width: 200upx;
								top: 8upx;
								image {
									width: 35upx;
									height: 35upx;
									float: left;
									margin-left: 5upx;
								}
							}
						}
					}
					.tag_box {
						margin-top: 20upx;
						overflow: hidden;
						.tags {
							font-size: 22upx;
							font-family: Source Han Sans CN;
							font-weight: 400;
							background-color: #FAEFF7;
							color: #FF546E;
							float: left;
							height: 50upx;
							line-height: 50upx;
							padding: 0 15upx;
							border-radius: 25upx;
							text-align: center;
							margin-right: 20upx;
						}
					}
					.ping_neirong {
						font-size: 28upx;
						margin-top: 20upx;
						font-family: Source Han Sans CN;
						font-weight: 500;
						color: rgba(0, 0, 0, 1);
						line-height: 50upx;
					}
					.huifu {
						padding: 20upx;
						background-color: #f3f3f3;
						border-radius: 10upx;
						font-size: 24upx;
						font-family: Source Han Sans CN;
						font-weight: 400;
						color: rgba(77, 77, 77, 1);
					}
				}
			}
		}
	}
	.onbottom{
		height: 80upx;
		line-height: 80upx;
		text-align: center;
		font-size: 24upx;
		color: #ccc;
	}

</style>
