<template>
	<u-loadmore v-if="flag" status="loading" :load-text="loadText" color="#C4CCD8" font-size="24" />
	<view v-else class="container-main">
		<view class="food-list" v-for="(item,index) in foodList" :key="index" @click="goPath(item)">
			<view class="food-left">
				<view class="image">
					<!-- <image :src="item.image" mode=""></image> -->
					<image :src="baseImgUrl + 'liao-ning/hot3.png'" mode=""></image>
				</view>
				<view class="text">
					<text class="title">{{item.productName}}</text>
					<uni-rate allow-half :value="item.grade" :size="18" color="#C4CCD8" activeColor="#ED7043"
						readonly />
					<text class="rate" :class="item.grade< 4 ? 'rad':''">总评分：{{item.grade}}分</text>
				</view>		
			</view>
			<u-icon name="arrow-right" color="#D5D5D5"></u-icon>
		</view>
		<u-loadmore :status="status" :load-text="loadText" color="#C4CCD8" font-size="24" />
	</view>
</template>

<script>
	import {
		gardeFood
	} from "@/api/shianliaoning/foodMsg.js";
	//根据统一社会信用代码查询产品
	// import {
	// 	getAllFoodList
	// } from "@/api/shianliaoning/enterpriseSEARCH.js";
	//查询产品评价
	import {foodAllPJ} from "@/api/shianliaoning/enterpriseSEARCH.js"
	export default {
		data() {
			return {
				baseImgUrl: getApp().globalData.config.iamgeBaseUrl,

				foodList: [],
				loadText: {
					nomore: "已经到底了~",
					loading: "努力加载中",
				},
				status: "",
				flag: true,
				from: {
					// pageNum: 1,
					// pageSize: 10,
					// uniscid: "",
				},
			};
		},
		onLoad() {
			this.productList();
		},
		methods: {
			//获取产品列表
			productList() {
				foodAllPJ(this.from).then((res) => {
					console.log(res);
					this.foodList = res.rows
					this.flag = false
					// console.log(this.foodList);
				});
			},
			goPath(item) {
				console.log(item);
				uni.navigateTo({
					url: `/sub-enterprise/company-eval/company-eval?productName=${item.productName}&productId=${item.productId}&gradeNum=${item.grade}`,
				});
			},
		},
	};
</script>

<style lang="scss" scoped>
	.container-main {
		padding: 20rpx;
		box-sizing: border-box;
		display: grid;
		grid-template-columns: 1fr;
		grid-row-gap: 30rpx;

		.food-list {
			display: flex;
			justify-content: space-between;
			align-items: center;
			padding: 30rpx;
			box-sizing: border-box;
			background-color: #fff;
			border-radius: 30rpx;

			.food-left {
				display: flex;

				.image {
					margin-right: 30rpx;

					image {
						width: 200rpx;
						height: 150rpx;
						border-radius: 20rpx;
					}
				}

				.text {
					display: flex;
					flex-direction: column;
					justify-content: space-between;

					.title {
						font-size: 34rpx;
						font-weight: 600;
						color: #34373b;
						line-height: 40rpx;
					}

					.rate {
						font-size: 28rpx;
						font-weight: 400;
						color: #02d1a6;
					}

					.rad {
						color: #f76359;
					}
				}
			}
		}
	}
</style>