<template>
	<view>
		<u-navbar autoBack placeholder bgColor="#FFFFFF">
			<view class="navSlot" slot="center">
				<!-- <u-icon name="arrow-left" size="19"></u-icon> -->
				<view class="title">评价管理</view>
			</view>
		</u-navbar>
		<view class="search">
			<u-search placeholder="搜索商品名称、评价内容" :showAction="false" @search="search" bgColor="#FAF7F6"
				:animation="false"></u-search>
		</view>

		<view class="bgMains">
			<view class="evaluationList" v-for="(item, index) in dataList">
				<view>
					<view class="evaluationItem">
						<view class="">
							<image class="img" :src="item.goodsImage"></image>
						</view>

						<view class="evaluatInfo">
							<view class="goodsNmae">{{item.goodsName}}</view>

							<view class="goodprice">
								<view class="title">商品总售：</view>
								<view class="goodsPrice">{{item.totalSales}}</view>
							</view>
							<view class="price">
								<view style="color: #FF4502;font-weight: 800;">￥{{item.goodsPrice}}</view>
								<view class="inventory">库存：{{item.inventory}}</view>
							</view>
						</view>

					</view>
					<u-line class="line" length="100%"></u-line>

					<view class="selComment">
						<view></view>
						<view class="comment" @click="selComment(item)">
							查看评价
						</view>
					</view>
				</view>

			</view>
			<view v-if="dataList.length == 0">
				<image style="width: 376rpx;display: block;margin: 0 auto;" src="../../static/icon_xx_k.png">
				</image>
				<text style="display: block;text-align: center;color: #ccc;">暂无数据</text>
			</view>
		</view>

	</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				dataList: [],
				pageNum: 1,
				total: 0
			}
		},
		onLoad() {
			this.getGoodsLiat()
		},
		onPullDownRefresh() {
			this.pageNum = 1,
				this.getGoodsLiat()
		},
		onReachBottom() {
			console.log(this.total, this.list.length);
			if (this.total > this.list.length) {
				this.pageNum = this.pageNum + 1
				this.getGoodsLiat()
			} else {
				wx.showToast({
					title: '没有更多啦！',
					icon: 'none'
				})
			}
		},
		methods: {
			selComment(item) {
				uni.navigateTo({
					url: '/pages/productEvaluation/productEvaluation?id=' + item.goodsId
				})
				// uni.navigateTo({
				// 	url:'/pages/commentManager/reviewsGoods'
				// })
			},
			getGoodsLiat() {
				this.$http.post("/api/store/goodsComment/goodsLiat", {
					pageNum: this.pageNum,
					pageSize: '20',
					field: this.keyword
				}).then(res => {
					if (res.code == 200)
						console.log(res.data.rows)
					this.dataList = res.data.rows
					this.total = res.data.total

				})
			}
		}
	}
</script>

<style lang="less">
	.bgMains{
		padding: 24rpx;
		background: #f9f6f4;
		min-height: 100vh;
	}
	
	.evaluationList {
		margin-top: 20rpx;
		padding: 21rpx;
		background: #FFFFFF;
		border-radius: 14rpx 14rpx 14rpx 14rpx;

		.selComment {
			margin-top: 10rpx;
			display: flex;
			justify-content: space-between;

			.comment {
				font-size: 28rpx;
				color: #FF4502;
			}
		}

		.line {
			padding-left: 20rpx;
			padding-top: 10rpx;
		}

		.evaluationItem {

			display: flex;

			.evaluatInfo {
				flex: 1;
				padding-left: 10rpx;

				.goodsNmae {

					display: flex;
					font-size: 28rpx;
					color: #333333;
				}

				.goodprice {
					padding-top: 13rpx;
					display: flex;

					.title {
						font-size: 24rpx;
						color: #333333;
					}

					.goodsPrice {
						font-size: 24rpx;
						color: #999999;
					}
				}

				.price {
					padding-top: 15rpx;
					display: flex;
					align-items: center;
					justify-content: space-between;

					.inventory {
						font-size: 24rpx;
						color: #999999;


					}
				}
			}

		}
	}

	.img {
		width: 156rpx;
		height: 156rpx;
	}

	.search {
		padding: 24rpx;
	}
</style>