<template>
	<view style="width: 100;height: 100%;background-color: #f6f6f6;padding: 20rpx 30rpx;">
		<view class="list" v-for="item,index in listArray" :key='index' @click="open(item.article.id,item.article.title)">
			<view class="text">
				<view class="title">{{item.article.title}}</view>
				<view class="type">{{item.article.created_at}}</view>
			</view>
			<view class="img">
				<image :src="imghost+item.article.banner_url" class="i" mode="aspectFit"></image>
			</view>
		</view>
		<u-empty text="暂无数据" mode="order" :show="show" margin-top="250"></u-empty>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				listArray: [],
				pageindex: 1,
				show: false,
				imghost:""
			}
		},
		mounted() {
			this.imghost = this.$imgHost
			this.getcollectionList()
		},
		methods: {
			//点击文章
			open(id, title) {
				uni.navigateTo({
					url: '/pages/common_tools/collection/collection_details?id=' + id + '&title=' + title
					// url: '/pages/customer/customer-datails?n=' + n
				})
			},
			getcollectionList: async function() {
				let res = await this.$request.post("/api/v1/collection/collectList", {
					page: this.pageindex,
					type: 2
				})
				console.log(res)
				if (res.status == 0) {
					if (this.pageindex > res.data.last_page) {
						uni.showToast({
							title: "没有更多了",
							icon: "none"
						})
					} else {
						this.listArray = this.listArray.concat(res.data.data)
						this.pageindex++
					}
				}
				if (this.listArray.length == 0) {
					this.show = true
				} else {
					this.show = false
				}
			}
		},

	}
</script>

<style lang="scss">
	//每一条文章
	.list {
		margin-bottom: 20rpx;
		border-radius: 12rpx;
		background-color: #ffffff;
		padding: 25rpx 20rpx;
		display: flex;
		box-shadow: 0px 2px 12px 0px rgba(0, 0, 0, 0.04);

		.text {
			width: 60%;
			height: 165rpx;
			padding-right: 25rpx;

			.title {
				height: 80%;
				font-size: 30rpx;
				font-weight: bold;
				// overflow: hidden; //超出一行文字自动隐藏 
				// text-overflow: ellipsis; //文字隐藏后添加省略号
				// white-space: nowrap; //强制不换行
			}

			.type {
				font-size: 26rpx;
				color: #666666;
				font-weight: 400;
				height: 20%;
				bottom: 0;
			}
		}

		.img {
			width: 40%;
			height: 100%;

			.i {
				width: 272rpx;
				height: 157rpx;
			}
		}
	}
</style>
