<template>
	<view>
		<view class="xw_content" v-for="(item,index) in cjsList" :key="index" @click="clickCj(item)">
			<u--image :src="imgUrl+item.cover" width="112rpx" height="112rpx" :lazy-load="true">
			</u--image>
			<view class="xw_right">
				<view class="xw_title">
					{{item.name}}
				</view>
				<view style="display: flex;">
					<!-- <text class="cj_tags" v-for="(tagsItem,tagsIndex) in item.tags" :key="tagsIndex">
						{{tagsItem.tag}}
					</text> -->
					<text class="cj_tags">{{item.tag}}</text>
				</view>
			</view>
		</view>
		<view v-if="cjsShow==0" class="no-data">已经到底啦！</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				cjsShow: '',
				cjsList: [],
				imgUrl: '',
				pageNum: 1, // 当前页
				pageSize: 12, // 每页条数
			}
		},
		onLoad() {
			this.imgUrl = uni.getStorageSync('img_url')
			this.getCertifiedCj()
		},
		onReachBottom() {
			console.log('触底下拉');
			if (this.cjsShow !== 0) {
				this.pageNum++
				this.getCertifiedCj()
			}
		},
		methods: {
			// 获取认证厂家列表
			getCertifiedCj() {
				this.$apiServe.getCertifiedCj({
					pageSize: this.pageSize,
					pageNum: this.pageNum
				}).then(res => {
					console.log('认证厂家', res)
					let cjsData = res.data.data
					for (const item of cjsData) {
						this.cjsShow = item.length
						console.log('this.cjsShow', this.cjsShow);
					}
					this.cjsList = [...this.cjsList, ...res.data.data]
				}).finally(_ => {})
			},
			// 跳转到认证厂家详情页
			clickCj(item) {
				uni.navigateTo({
					url: '../certifiedCjDetail/certifiedCjDetail?id=' + item.id
				})
			}
		}
	}
</script>

<style lang="scss">
	page {
		background: #FFFFFF;
	}

	.no-data {
		text-align: center;
		margin-top: 29rpx;
		font-size: 20rpx;
		font-family: PingFangSC-Regular, PingFang SC;
		font-weight: 400;
		color: #BBBBBB;
		line-height: 28rpx;
	}

	.xw_content {
		background: #FFFFFF;
		border: 1rpx solid #EEEEEE;
		display: flex;
		padding: 29rpx 19rpx;

		.xw_right {
			padding-left: 19rpx;
			display: flex;
			flex-direction: column;

			.xw_title {
				font-size: 30rpx;
				font-family: PingFangSC-Medium, PingFang SC;
				font-weight: bold;
				color: #3E3E3E;
				line-height: 42rpx;
				-webkit-line-clamp: 2;
				display: -webkit-box;
				-webkit-box-orient: vertical;
				overflow: hidden;
				text-overflow: ellipsis;
			}

			.cj_tags {
				font-size: 24rpx;
				font-family: PingFangSC-Regular, PingFang SC;
				font-weight: 400;
				color: #969696;
				line-height: 33rpx;
				padding-right: 10rpx;
				margin-top: 35rpx;
			}
		}
	}
</style>
