<template>
	<!-- 申遗历程 -->
	<view class="apply">
		<navbar title="申遗历程" leftClick @leftClick="$utils.navigateBack" />
		<view class="top-img">
			<uv-swiper
			:list="banner.course" 
			indicator
			height="420rpx"
			keyName="imageContent"></uv-swiper>
		</view>

		<view class="middle-box">
			<view class="middle-img">
				<view>
					<image src="../static/applyRelic/2.png" mode="aspectFill" />
				</view>
				<view>
					<image src="../static/applyRelic/2.png" mode="aspectFill" />
				</view>
				<view>
					<image src="../static/applyRelic/2.png" mode="aspectFill" />
				</view>
			</view>
			<view class="middle-font">
				<view @click="selectMiddle(0)">
					申遗历程
				</view>
				<view @click="selectMiddle(1)">
					申遗缘由
				</view>
				<view @click="selectMiddle(2)">
					遗产价值
				</view>
			</view>
		</view>

		<view class="apply-list">
			<uv-list @scrolltolower="scrolltolower">
				<uv-list-item 
				:title="item.articleTitle" 
				:note="$dayjs(item.createTime).format('YYYY-MM-DD')"
				:border="true"
				v-for="(item,index) in list" 
				:key="index"
				:clickable="true"
				@click="toUrl(item)"
				>
					<template #footer>
						<uv-image :src="item.articleImage" radius="10rpx" width="240rpx"
							height="160rpx" />
					</template>
				</uv-list-item>
			</uv-list>
		</view>
		<tabber />
	</view>
</template>

<script>
	import { mapState } from 'vuex'
	export default {
		data() {
			return {
				queryParams: {
					pageNo: 1,
					pageSize: 10,
				},
				total : 0,
				list : [],
				articleType : -1,
			}
		},
		computed : {
			...mapState(['banner']),
		},
		onShow() {
			this.queryArticleListByType()
		},
		onReachBottom() {
			this.loadMoreData()
		},
		onPullDownRefresh(){
			this.queryArticleListByType()
		},
		methods: {
			queryArticleListByType(){
				
				let query = {
					...this.queryParams,
				}
				
				if(this.articleType != -1){
					query.articleType = this.articleType
				}
				
				this.$api('queryArticleListByType', query, res => {
					uni.stopPullDownRefresh()
					if(res.code == 200){
						this.list = res.result.records
						this.total = res.result.total
					}
				})
			},
			loadMoreData(){
				if(this.queryParams.pageSize < this.total){
					this.queryParams.pageSize += 10
					this.queryArticleListByType()
				}
			},
			toUrl(item){
				console.log(item);
				this.$utils.navigateTo(`/pages_order/service/articleDetail?id=${item.id}&type=1`)
			},
			selectMiddle(e){
				console.log(e);
				if(this.articleType != e){
					this.articleType = e
				}else{
					this.articleType = -1
				}
				this.queryArticleListByType()
			},
		}
	}
</script>

<style scoped lang="scss">
	.apply {

		.top-img {
		}

		.middle-box {
			display: flex;
			position: relative;
			height: 220rpx;
			align-items: center;
			justify-content: space-around;
			background-color: #fff;

			.middle-img {
				display: flex;
				align-items: center;
				justify-content: space-around;
				width: 100%;

				view {
					width: 160rpx;
					height: 160rpx;

					image {
						width: 100%;
						height: 100%;
					}
				}
			}

			.middle-font {
				position: absolute;
				display: flex;
				width: 100%;
				justify-content: space-around;

				view {
					width: 60rpx;
					color: #FFFDF6;
					font-weight: 600;
				}
			}
		}

		.apply-list {
			width: 94%;
			margin-left: 3%;
			/deep/ .uv-list-item{
				background-color: #FFFDF6 !important;
			}
		}
	}
</style>