<template>
	<view class="content">

		<u-list @scrolltolower="scrolltolower">
			<u-list-item v-for="(item, index) in pageList" :key="index">
				<view class="evaluateInit">
					<view class="evaluateUserImg">
						<image class="init_image" :src="item.avatar" mode=""></image>
					</view>
					<view class="evaluateInitInfo">
						<view class="evaluateInitInfoName">
							<span>{{item.nickname}}</span><span
								style="color: #999999;font-size: 22rpx;">{{item.addtime}}</span>
						</view>
						<view class="evaluateInitInfoText">
							{{item.content}}
						</view>
					</view>
				</view>
			</u-list-item>
			<u-empty :show="pageList.length == 0" mode="list"
				icon="http://cdn.uviewui.com/uview/empty/list.png"></u-empty>
		</u-list>
		<u-toast ref="uToast"></u-toast>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				pageList: [],
				goods_id: '',
				pageNum: 1
			}
		},
		onLoad(option) {
			this.pageNum = 1;
			this.pageList = [];
			this.goods_id = option.id;
			this.getcomment_list()
		},
		methods: {
			scrolltolower() {
				this.pageNum += 1;
				this.getcomment_list()
			},
			//获取评价列表
			getcomment_list() {
				this.$request('/comment-list', 'GET', {
					gid: this.goods_id,
					page: this.pageNum
				}).then(res => {
					console.log(res.data)
					this.pageList = [...this.pageList, ...res.data.list];
				}).catch(err => {
					uni.showToast({

						icon: 'error',

						title: '' + err.message

					})
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	.content {
		width: 100vw;
		background: #F8F8F8;
	}

	.evaluateInit {
		padding: 30rpx;
		background-color: #ffffff;
		width: calc(100% - 60rpx);
		display: flex;
		flex-direction: row;
		margin-bottom: 20rpx;
	}

	.evaluateUserImg {
		height: 60rpx;
		width: 60rpx;
		border-radius: 60rpx;
		overflow: hidden;
		margin-right: 16rpx;
	}

	.evaluateInitInfo {
		flex: 1;

		.evaluateInitInfoName {
			height: 32rpx;
			font-size: 26rpx;
			color: #303949;
			font-weight: 600;
			padding-bottom: 10rpx;
			display: flex;
			flex-direction: row;
			align-items: center;
			justify-content: space-between;
		}

		.evaluateInitInfoText {
			line-height: 30rpx;
			font-size: 23rpx;
			color: #161C2B;
		}
	}
</style>