<template>
    <view style="padding-bottom: 120rpx;" v-if="pageShow">
        <!-- 使用标题栏 -->
        <status-nav :statusBackw="true" :statusTitle="true" :title-val="'商品评价'" :tabcolor="'#ffffff'"></status-nav>
        <view class="bacb padding-x20" :style="{marginTop:(statusHNH+10)+'px'}" style="background-color: #F5F5F5;">
            <!-- 列表 -->
            <evaluateList :eval-arr="evalArr" :isEval="true"></evaluateList>
        </view>
        <!-- 客服 -->
        <bottomkf :detail="proDetail" @diaoq="proDetailEv" :sku_img="sku_img"></bottomkf>
    </view>
</template>

<script>
    import bottomkf from '@/components/bottomkf.vue';
    import evaluateList from '@/components/evaluateList.vue';
    export default {
        components:{
            bottomkf,
            evaluateList
        },
        data() {
            return {
                evalArr:[],
				page:1,
				size:50,
				only_image:0,
				proDetail:'',
				sku_img:'',
				statusHNH:uni.getStorageSync('statusHNH'),
				pageShow:false
            }
        },
		onUnload() {
			uni.removeStorageSync('plOrder')
		},
		onLoad(options) {
			this.checkAllEvaluate(options.id)
			this.proDetail = uni.getStorageSync('plOrder')
		},
		onShow() {
			this.$toolAll.tools.guoq()
		},
        methods: {
			proDetailEv(){
				this.sku_img = this.$http + this.proDetail.sku_list[0].main_image
			},
            checkAllEvaluate(id){//查看所有评论列表事件
				let allEvaluateObj = {
					spu_id:id,
					page:this.page,
					size:this.size,
					only_image:this.only_image
				}
				this.$requst.post('product/spu/comment-list',allEvaluateObj).then(res=>{
					// console.log('所有评论信息：',res);
					if(res.code==0){
						this.pageShow = true
						if(res.data.list.length!=0){
							res.data.list.forEach(item=>{
								let imgArr = []
								item.images.forEach(itemimg=>{
									let imgObj = {
										src:this.$http + itemimg
									}
									imgArr.push(imgObj)
								})
								let newname = this.$toolAll.tools.hideName(item.account.nickname)//隐藏姓名中间几位
								let haveH = item.account.headimgurl.slice(0,4)
								if(haveH!='http') {
									haveH = this.$http
								} else haveH = ''
								let evalObj = {
									src:haveH + item.account.headimgurl,
									name:newname,
									xingj:item.grade,
									content:item.content,
									title:item.orderSku.spu_name,
									time:item.created_at,
									imgList:imgArr
								}
								this.evalArr.push(evalObj)
							})
							// console.log(this.evalArr);
						}
					}
				},error=>{})
			}
        }
    }
</script>

<style>

</style>
