<template>
	<view>
		<view class="list">
			<view class="item" v-for="(item, index) in list" :key="index" @click="detail(item)">
				<image :src="ip + item.showPictures" mode="aspectFill" class="pic"></image>
				<view class="con">
					<view class="title omit">{{ item.title }}</view>
					<view class="ms">
						<text class="ll">{{ item.browseNum }}</text>
						<text class="wz">浏览</text>
					</view>
					<view class="lx" @click.stop="lx(item)">
						<text class="icon">&#xe696;</text>
						景区路线
					</view>
				</view>
				<view class="clear"></view>
			</view>
			<view class="loading"><u-loadmore :status="loadMore ? 'loading' : 'nomore'" /></view>
		</view>
	</view>
</template>

<script>
export default {
	data() {
		return {
			ip: this.$http.urls.ip,
			list: [],
			param: { pageNum: 1, pageSize: 10, type: 2 },
			loadMore: true
		};
	},
	onLoad() {
		this.getData();
	},
	methods: {
		//获取数据
		getData() {
			this.$http.request({
				url: this.$http.urls.getPageContent,
				data: this.param,
				loading: 'false',
				success: res => {
					this.loadMore = res.data.pages > this.param.pageNum ? true : false;
					res.data.rows.forEach(item => {
						this.list.push(item);
					});
				}
			});
		},
		//路线
		lx(item) {
			uni.navigateTo({ url: '/pages/travel/route?id=' + item.contentId });
		},
		//详情
		detail(item) {
			uni.navigateTo({ url: '/pages/travel/detail?id=' + item.contentId });
		},
		//刷新数据
		refresh() {
			this.loadMore = true;
			this.param.pageNum = 1;
			this.list = [];
			this.getData();
		}
	},
	//下拉刷新
	onPullDownRefresh() {
		setTimeout(() => {
			uni.stopPullDownRefresh();
			this.refresh();
		}, 1000);
	},
	//上拉加载
	onReachBottom() {
		if (this.loadMore) {
			this.param.pageNum++;
			this.getData();
		}
	}
};
</script>

<style lang="scss">
.list {
	padding: 0px 10px 70px 10px;
	.item {
		background-color: white;
		padding: 15px 8px 15px 8px;
		border-bottom: 1px solid #e5e5e5;
		border-radius: 5px;
		margin-top: 10px;
		box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.2);
		.pic {
			float: left;
			width: 30%;
			border-radius: 3px;
			height: 80px;
			background-color: #dcdcdc;
		}
		.con {
			padding-left: 30px;
			width: 60%;
			float: left;
			.title {
				font-size: 15px;
				text-align: left;
				color: #252525;
				font-weight: bold;
			}
			.ms {
				margin-top: 10px;
				.ll {
					color: #d72424;
					font-size: 16px;
					padding-right: 5px;
				}
				.wz {
					font-size: 12px;
				}
			}
			.lx {
				float: right;
				color: #fff;
				background: #d72424;
				border-radius: 10px;
				padding: 8px 10px;
				font-size: 16px;
				color: white;
				font-weight: 700;
				margin-right: -20px;
				.icon {
					padding-right: 5px;
					font-size: 20px;
				}
			}
		}
	}
}
</style>
