<template>
	<view class="list">
		<comment></comment>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				score: '',
				goodsId: '',
				commentList: [],
				currentPage: 1,
				isEmpty: false,
			};
		},
		onLoad(options) {
			this.goodsId = options.goodsId
			this.score = options.score
			// this.getCommentList()
		},
		methods: {
			// 获取评价列表
			getCommentList() {
				const params = {
					url: '/api/order/comment_list',
					data: {
						page: this.currentPage,
						goods_id: this.goodsId
					}
				}
				this.$request(params).then(res => {
					// console.log(res)
					this.commentList = this.commentList.concat(res.data.data)
					if (this.commentList.length >= res.data.total) {
						this.isEmpty = true
					}
				}).catch(err => {

				})
			},
			scrolltolower(e) {
				if (!this.isEmpty) {
					this.currentPage += 1
					this.getCommentList()
				}
			},
			onPreviewImage(imgList, index) {
				let imgData = []
				imgList.map(item => {
					imgData.push(this.$config.domain + item)
				})
				uni.previewImage({
					current: index,
					urls: imgData
				})
			}
		},
	};
</script>

<style scoped>
	.list {
		padding: 20rpx;
	}
</style>