<template>
	<!--  -->
	<view class="evaluation-bar">
		<view class="title">
			<view>所有评价 ({{scoreData.total?scoreData.total:0}})</view>
			<!-- <text>查看全部</text> -->
		</view>
		<view v-for="item in scoreData.list" v-if="scoreData.list" style="margin-bottom: 40rpx;">
			<view class="people">
				<view>
					<image :src="item.avatar?item.avatar:'../../static/images/userimg.png'"></image>
				</view>
				<view>
					<view>{{item.name}}</view>
					<view class="time">{{item.createDate}}</view>
				</view>
			</view>
			<view class="content">{{item.content?item.content:'暂无内容'}}</view>
			<view class="image-list" v-if="item.evaluateImg">
				<image v-for="pitem,pindex in item.evaluateImgUrls" :src="pitem" mode="aspectFit" @click="previewImage(pindex,item.evaluateImgUrls)"></image>
			</view>
		</view>
	</view>

</template>

<script>
	const app = getApp();
	const req = require('../../utils/request.js');
	export default {
		data() {
			return {
				scoreData: {}, //晒单数据
				groupId: null,
				page: 1,
				limit: 10,
				total: 0
			}
		},
		onLoad(options) {
			this.groupId = options.groupId
			this.getScoreList()
		},
		onReachBottom() {
			this.getScoreList(true)
		},
		methods: {
			// 图片预览
			previewImage(index,list) {
				uni.previewImage({
					current: index, 
					urls: list 
				})
			},
			// 获取晒单信息
			getScoreList(isPage) {
				if (!this.groupId) {
					this.scoreData.list = []
					this.scoreData.total = 0
					return
				}
				if (!isPage) {
					this.page = 1
				}
				let queryData = {
					page: this.page,
					limit: this.limit,
					bindId: this.groupId,
					type: 2
				}
				req.getRequest('/api/evaluate/page', queryData, res => {
					if (res != null && res.list.length > 0) {
						if (!isPage) {
							this.scoreData.list = res.list
							this.scoreData.total = res.total
						} else {
							this.scoreData.list = this.scoreData.list.concat(res.list)
						}
						this.page++
					} else {
						if (!isPage) {
							this.scoreData.list = res.list
							this.scoreData.total = res.total
						} else {}
					}
				})
			},
		}
	}
</script>

<style>
	@import './evaluateList.css';
</style>
