<!-- 我的评价 -->
<template>
	<view class="evaluation">
		<z-paging
			ref="paging"
			v-model="evaluationList"
			@query="queryList"
		>
			<view class="evaluation-list">
				<view class="evaluation-list-item" v-for="(item, index) in evaluationList" :key="index">
					<view class="evaluation-list-item-title">{{ item.title }}</view>
					<view class="evaluation-list-item-content">
						<view class="left">
							<u-avatar :src="item.src" mode="square" size="96"/>
						</view>
						<view class="right">
							<view>{{ item.name }}</view>
							<view>
								<u-rate :count="5" v-model="item.star" active-color="#C4C4C4" disabled/>
								<text>{{ item.date }}</text>
							</view>
							<view>{{ item.remark }}</view>
						</view>
					</view>
				</view>
			</view>
		</z-paging>
		<u-toast ref="uToast" />
	</view>
</template>

<script>
	export default {
		data() {
			return {
				// 评论列表
				evaluationList: []
			}
		},
		methods: {
			/**
			 * 获取我的评价列表
			 * @param { Number } pageNum
			 * @param { Number } pageSize
			 */
			getList(pageNum, pageSize) {
				this.$u.api.evaluation.getEvaluationList({ pageNum, pageSize }).then(res => {
					if (res.code === 200) {
						this.$refs.paging.complete(res.rows)
					} else {
						this.$refs.paging.complete([])
						this.$refs.uToast.show({
							title: err.msg,
							type: 'error'
						})
					}
				}).catch(() => {
					this.$refs.paging.complete([])
					this.$refs.uToast.show({
						title: '程序错误!',
						type: 'error'
					})
				})
			},
			/**
			 * 下拉刷新组件触发
			 * @param { Number } pageNo
			 * @param { Number } pageSize
			 */
			queryList(pageNo, pageSize) {
				this.getList(pageNo, pageSize)
			}
		}
	}
</script>

<style lang="scss" scoped>
@import './myEvaluation.scss';
</style>
