<template>
	<view class="wrap">
		<view class="top">
			<view>
				<text>发起日期:</text>
				<text>{{firstData.createTime}}</text>
			</view>
			
			<view>
				<text>联系方式:</text>
				<text>{{firstData.phone||'-'}}</text>
			</view>
		</view>
		
		<view class="middle">
			<view class="middle-title">处理记录</view>
			<view class="step">
				<view class="step-list" v-for="(item,index) in detailList" :key="index">
					<view class="list-left">
						<view class="circle">
							<text v-if="index!=0"></text>
						</view>
						<view class="line" v-if="index!=detailList.length-1"></view>
					</view>
					
					<view class="list-right">
						<view class="right-title">
							<text>{{item.title}}</text>
							<text>{{item.time}}</text>
						</view>
						<view class="right-content">
							{{item.text}}
						</view>
						<view class="right-img">
							<image v-for="(item2,a) in item.imgList" :key="a" :src="item2.imgUrl" @click="previewImg(item2.imgUrl)"></image>
						</view>
					</view>
				</view>
			</view>
		</view>
		
		<!-- 图片预览弹窗 -->
		<view class="img-pop" v-if="showPop" @click="showPop=false">
			<image :src='chooseImgUrl' mode="widthFix"></image>
		</view>
	</view>
	
</template>

<script>
export default{
  data(){
    return {
      showPop:false,//控制预览图片显示隐藏
      batchId:'',//批次id
      detailList:[],//详情数据
      firstData:'',//第一条数据
      chooseImgUrl:'',//预览图片地址
    }
  },
  onLoad(option){
    this.batchId=option.batchId
    this.initDetail()
  },
  methods:{
    //---预览图片
    previewImg(imgUrl){
      this.showPop=true
      this.chooseImgUrl=imgUrl
    },
    //---详情加载
    initDetail(){
		  let data={
		    batchId:this.batchId//批次Id
		  }
		  this.$request('comment/userComment/loadInfo',data).then((res)=>{
			  if(res.code=='00'){
		      let list=res.data||[]
		      if(list.length>0){
		        this.firstData=list[0]
		        list.forEach(item=>{
		          //游客发起数据
		          let imgList1=[]
		          let imgList2=[]
		          item.commentImgList.forEach(item2=>{
		            if(item2.imgCommentType==0){
		              //游客发送的图片
		              imgList1.push(item2)
		            }
		            if(item2.imgCommentType==1){
		      			  //商家发送的图片
		      			  imgList2.push(item2)
		            }
		          })
		          this.detailList.push({
		            title:'您发起建议',
		            text:item.commentText||'',
		            time:item.createTime,
		            imgList:imgList1
		          })
		          //商家回复数据
		          if(item.handleType===0){
                //商家电话回复
		            this.detailList.push({
                  title:'商家回复',
                  text:item.commentReply||'客服已进行电话回复',
                  time:item.updateTime,
                  imgList:imgList2
                })
		          }
		          if(item.handleType===1||item.handleType===2){
		            //商家文字回复，或者电话+文字回复
		            this.detailList.push({
		              title:'商家回复',
		              text:item.commentReply||'',
		              time:item.updateTime,
		              imgList:imgList2
		            })
		          }
		        })
		        this.detailList.reverse()
		      }
			  }else{
			    uni.showToast({
			      title: res.message,
			      icon: 'none'
			    })
			  }
		  })
    }
  }
}
</script>

<style scoped lang="scss">
.top{
	padding: 32rpx 40rpx;
	background: #ffffff;
}
.top view:not(:first-child){
	margin-top: 16rpx;
}
.top view text:first-child{
	color: #999999;
	margin-right: 20rpx;
}
.middle{
	margin-top: 20rpx;
	background: #ffffff;
	padding: 30rpx 30rpx 150rpx 30rpx;
}
.middle-title{
	font-size: 32rpx;
	font-weight: 600;
}
.step{
	margin-top: 40rpx;
}
.step-list{
	display: flex;
}
.list-left{
	margin-right:16rpx;
	flex-shrink: 0;
	display: flex;
	flex-direction: column;
	padding-top: 6rpx;
}
.circle{
	width: 24rpx;
	height: 24rpx;
	border-radius: 50%;
	background: #FE6600;
	position: relative;
	text{
		width: 16rpx;
		height: 16rpx;
		border-radius: 50%;
		background: #ffffff;
		position: absolute;
		top: 4rpx;
		left: 4rpx;
	}
}
.line{
	width: 4rpx;
	flex: 1;
	background: #FFEDD6;
	position: relative;
	left: 10rpx;
}
.list-right{
	flex: 1;
	padding-bottom: 40rpx;
}
.right-title{
	text:first-child{
		font-size: 32rpx;
		font-weight: 600;
		margin-right: 20rpx;
	}
	text:last-child{
		color: #999999;
	}
}
.right-content{
	margin-top: 10rpx;
	font-size: 24rpx;
}
.right-img{
	margin-top: 16rpx;
	image{
		width: 120rpx;
		height: 120rpx;
		margin-right: 20rpx;
	}
}
.img-pop{
	position:fixed;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	background: #000000;
	display: flex;
	align-items: center;
	justify-content: center;
	z-index: 9999;
	image{
		width: 100%;
	}
}
</style>