<template>
	<view class="content">

		<!-- 列表 -->
		<view class="itemContent">
			<view v-for="(item,index) in itemData" :key="index">
				<view class="item">


					<!-- 第一行 -->
					<view class="firstView">
						<view class="left">
							<image :src='item.HeadUrl' v-if="item.HeadUrl" class="storeImg"></image>
							<image src="../../static/img/pic_def_ava.png" mode="" class="storeImg" v-else></image>
							<view class="nickName">{{item.Name?item.Name:'微信昵称'}}</view>
						</view>
						<!-- 时间截取 -->
						<view class="time">{{item.CreateTime.slice(0,item.CreateTime.length-8)}}</view>
					</view>

					<!-- 第2行 -->
					<view class="secondView">
						<view class="fen">总分</view>
						<!-- 星星 -->
						<uni-rate :value="item.Overallevaluation" :max="5" color="#EEEEEE" active-color="#EC0F0A"
							:size="13" :margin="2" :readonly="true" />

						<view class="count">服务态度{{item.ServiceEvaluation}}星</view>
						<view class="count">施工质量{{item.ConstructionEvaluation}}星</view>
						<view class="count">店面环境{{item.StoreEvaluation}}星</view>
					</view>



					<view class="contentMes">{{item.EContent}}</view>

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

							<image :src="itemImg.imageUrl" class="img" :class="{'img4R':(indexImg+1)%4==0&&indexImg!=0}"
								@click.stop="previewImage(itemImg.imageUrl,item.imgs)"></image>
						</view>
					</view>

					<!-- 商家回复 -->

					<view v-if="item.ReplyContent" class="writeBack">
						<view class="title">
							<view style="font-weight: bold;">商家回复</view>
							<view>{{item.ReplyTime.slice(0,item.ReplyTime.length-8)}}</view>
						</view>
						<view>{{item.ReplyContent}}</view>
					</view>

					<!-- <view class="bottom">
						<view class="btnBox" @click.stop="goOrder(item)">
							<image src="../../static/img/icon_ding.png" class="btnImg"></image>
							<view class="btn">查看订单</view>
						</view>

						<view class="btnBox" @click.stop="deleteItem(item, index)">
							<image src="../../static/img/icon_del.png" class="btnImg"></image>
							<view class="btn">删除</view>
						</view>

					</view> -->





				</view>


			</view>

		</view>

		<!-- 上拉 加载更多 -->
		<view class="noMore" v-if="noMoreShow">没有更多数据</view>
		<!-- 无数据空白页 -->
		<nodata v-if="itemData.length==0"></nodata>

	</view>
</template>

<script>
	import nodata from '../../components/nodata/nodata.vue'
	export default {
		components: {
			nodata,
		},
		data() {
			return {
				itemData: [],
				page: 1,
				noMoreShow: false,
				shopID: '',
			}
		},
		onLoad(opt) {
			// console.log('opt===',opt);
			this.shopID = opt.shopID;
		},
		onShow() {
			this.itemData = []
			this.page = 1
			this.getItemData()
		},
		methods: {
			goOrder(item) {
				uni.navigateTo({
					url: 'historyDetail?id=' + item.SheetID
				})
			},
			
			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 = 'openMiniEvaluate/deleteMyOpenEvaluate',
								params = {
									id: item.ID,

								}
							that.$http(url, params, 'POST').then(res => {
								uni.hideLoading();

								that.page = 1
								that.getItemData()

							})
						}

					}
				});

			},
			getItemData() {
				uni.showLoading({
					title: '加载中'
				})
				let url = 'openMiniEvaluate/listShopOpenEvaluatePage',
					params = {
						page: this.page,
						limit: 20,
						shopId: this.shopID,
					}
				this.$http(url, params, 'GET').then(res => {
					uni.hideLoading();
					var list = res.data.Items

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


					if (this.page == 1) {
						this.itemData = list
					} else {
						this.itemData = this.itemData.concat(list)
					}

					if (list.length < 10) {
						this.noMoreShow = false
					} else {
						this.noMoreShow = true
					}


				})
			},

		},

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

	}
</script>

<style scoped>
	.content {
		background: #f4f5f7;
		min-height: 100vh;
		padding-top: 20rpx;
		padding-bottom: 60rpx;
	}



	.item {
		border-radius: 10rpx;
		padding: 20rpx;
		background-color: #FFFFFF;

		margin: 0 24rpx 20rpx;

	}


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

	}

	.left {
		display: flex;
		align-items: center;
	}

	.storeImg {
		width: 56rpx;
		height: 56rpx;
		border-radius: 8rpx;
		margin-right: 10rpx;
	}

	.nickName {
		font-weight: 500;
		font-size: 26rpx;

		color: #333333;
	}

	.firstView {
		margin-bottom: 24rpx;
	}



	.time {
		font-size: 26rpx;
		color: #999999;
	}


	.fen {
		font-size: 22rpx;
		color: #999999;

	}

	.count {
		font-size: 22rpx;
		color: #999999;
		margin-right: 20rpx;
	}

	.thirdView {
		display: flex;
		justify-content: flex-start;
		padding-top: 10rpx;
		padding-bottom: 20rpx;
	}


	.contentMes {
		font-size: 26rpx;
		color: #333333;
		line-height: 37rpx;
		padding: 16rpx 0;
	}

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

	.img {
		width: 150rpx;
		height: 150rpx;
		margin-right: 20rpx;
		border-radius: 8rpx;
	}

	.img4R {

		margin-right: 0;
	}

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

		border-radius: 10rpx;
	}

	.title {
		display: flex;
		justify-content: space-between;
		margin-bottom: 10rpx;
	}

	.bottom {
		padding-top: 27rpx;
		padding-bottom: 7rpx;
		border-top: 1rpx solid #EEEEEE;
		display: flex;
		justify-content: flex-end;
		align-items: center;
	}

	.btnBox {
		display: flex;
		align-items: center;
		margin-left: 40rpx;
	}

	.btnImg {
		width: 24rpx;
		height: 24rpx;
	}

	.btn {
		color: #666666;
		font-size: 24rpx;
		margin-left: 5rpx;
	}

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