<template>
	<view class="content">

		<!-- 列表 -->
		<view class="itemContent">
			
				<view class="item">

					<view class="leftView">
						<image :src='detail.PhotoPath' v-if="detail.PhotoPath" class="storeImg"></image>
						<image src="../../static/img/pic_def_ava.png"  mode="" class="storeImg" v-else></image>
					</view>

					<view class="rightView">
						<!-- 第一行 -->
						<view class="firstView">
							<view class="shopName">{{detail.Evaluator}}</view>
							
						</view>

						<!-- 第2行 -->
						<view class="secondView">
							<!-- 星星 -->
							<uni-rate :value="detail.Overallevaluation" :max="5" color="#EEEEEE" active-color="#FF4F00"
								:size="16" :margin="4" :readonly="true" />
								
								<view class="secondRightView">
									<view class="time">{{detail.CreateTime.slice(0,detail.CreateTime.length-8)}}</view>
									<image src="../../static/img/icon_del.png" class="deleteBtn"
										@click="deleteItem(detail, index)"></image>
								</view>
						</view>
						
						<view class="thirdView">
							<view class="count">服务态度：{{detail.Serviceevaluation}}</view>
							<view class="count">施工质量：{{detail.Constructionevaluation}}</view>
							<view class="count">店面环境：{{detail.Storeevaluation}}</view>
						</view>
						
						<view class="contentMes">{{detail.EContent}}</view>

						<!-- 照片 -->
						<view class="imgBg">
							<view v-for="(itemImg,indexImg) in detail.imgs" :key="indexImg">

								<image :src="itemImg.imageUrl" class="img"
									@click="previewImage(itemImg.imageUrl,detail.imgs)"></image>
							</view>
						</view>

						<!-- 商家回复 -->

						<view class="writeBack" v-if="detail.ReplyContent">商家回复：{{detail.ReplyContent}}</view>
					</view>



				</view>
			</view>
	

	

	</view>
</template>

<script>
	import nodata from '../../components/nodata/nodata.vue'
	export default {
		components: {
			nodata,
		},
		data() {
			return {
				itemData: [],
				page: 1,
				noMoreShow: false,
				imgArr: [],
				sheetId:'',
				detail:"",
			}
		},
		onLoad(opt) {
			this.sheetId=opt.id
			this.getItemData()
		},
		methods: {
			previewImage(img, arrDic) {
				var arr = [];

				arrDic.forEach(item => {
					arr.push(item.imageUrl)
				})

				// 预览图片
				uni.previewImage({
					urls: arr,
					current: img,
					longPressActions: {
						itemList: ['发送给朋友', '保存图片', '收藏'],
						success: function(data) {
							console.log('选中了第' + (data.tapIndex + 1) + '个按钮,第' + (data.index + 1) + '张图片');
						},
						fail: function(err) {
							console.log(err.errMsg);
						}
					}
				});
			},
			deleteItem(item, index) {
				var that=this;
				uni.showModal({
				    title: '提示',
				    content: '确定删除该条评价吗?',
				    success: function (res) {
						 if (res.confirm) {
							 that.itemData.splice(index, 1);
							 uni.showLoading({
							 	title: '删除中'
							 })
							 
							 let url = 'worldKeepCar/keepCarMy/deleteMyTMEvaluate',
							 	params = {
							 		id: item.ID,
							 
							 	}
							 that.$http(url, params, 'POST').then(res => {
							 	uni.hideLoading();
							 
							 	that.page = 1
							 	uni.navigateBack({
							 		delta:1
							 	})
							 
							 })
						 }
				       
				    }
				});
				
			},
			getItemData() {
				uni.showLoading({
					title: '加载中'
				})
				let url = 'worldKeepCar/keepCarMy/queryTMEvaluateDetail',
					params = {
						sheetId:this.sheetId

					}
				this.$http(url, params, 'GET').then(res => {
					uni.hideLoading();
					this.detail = res.data

					// 处理 undefined和null转为空白字符串
					/* list.forEach((item, index) => {
						for (const key in item) {
							item[key] = this.$praseStrEmpty(item[key])
						}
					}) */


				


				})
			},

		},

		// 下拉刷新 上拉加载更多
		onPullDownRefresh() {
			this.page = 1
			this.getItemData()
			setTimeout(function() {
				uni.stopPullDownRefresh();
			}, 1000);
		},
		onReachBottom() {
			this.page++;
			this.getItemData()
		},

	}
</script>

<style scoped>
	.content {
		background: #FFFFFF;
		min-height: 100vh;

	}



	.item {
		display: flex;
		justify-content: flex-start;
		padding: 0 24rpx;
		background-color: #FFFFFF;

	}

	.leftView {
		width: 117rpx;
		padding-right: 20rpx;
	}

	.storeImg {
		width: 72rpx;
		height: 72rpx;
		border-radius: 8rpx;
		margin-top: 30rpx;
	}

	.rightView {
		border-bottom: 1rpx #EEEEEE solid;
		width: 100vw;
	}

	.firstView,
	.secondView {
		display: flex;
		justify-content: space-between;
		align-items: center;

	}

	.firstView {
		padding-top: 30rpx;
	}

	.secondView {
		padding-top: 12rpx;
		padding-bottom: 20rpx;
	}

	.shopName {
		/* padding-top: 30rpx;
		padding-bottom: 10rpx; */
		font-size: 26rpx;
		font-weight: bold;
		color: #333333;
	}

	.secondRightView{
		display: flex;
	}
	.time {
		font-size: 26rpx;
		color: #999999;
		margin-right: 20rpx;
	}

	.deleteBtn {
		width: 36rpx;
		height: 36rpx;
	}
	.thirdView{
		display: flex;
		justify-content: flex-start;
		padding-top: 10rpx;
		padding-bottom: 20rpx;
	}
	.count{
		font-size: 24rpx;
		color: #999999;
		margin-right: 20rpx;
	}
	.contentMes {
		font-size: 26rpx;
		color: #666666;
		line-height: 37rpx;
		/* padding-top: 20rpx; */

	}

	.imgBg {
		display: flex;
		justify-content: flex-start;
		padding: 30rpx 0rpx;
		flex-wrap: wrap;
	}

	.img {
		width: 140rpx;
		height: 140rpx;
		margin-right: 5rpx;
		border-radius: 8rpx;
	}

	.writeBack {
		font-size: 26rpx;
		color: #666666;
		line-height: 37rpx;
		padding: 20rpx;
		background-color: #F4F5F7;
		
		padding-bottom: 20rpx;
	}

	.noMore {
		text-align: center;
		line-height: 50rpx;
		color: #999999;
		font-size: 28rpx;
	}
</style>
