<template>
	<ciy-header :title="init.code==1?init.section.name:'加载中'" ref="header"></ciy-header>
	<view v-if="init.code != 1" class="px4 py4">
		<view class="ciy-skeleton" style="height:2em;width:100%;"></view>
		<view class="ciy-skeleton" style="height:8em;width:100%;"></view>
		<view class="ciy-skeleton" style="height:8em;width:100%;"></view>
	</view>
	<view v-else>
		<view class="sti px2 py2" :style="{top:(header_statusbar_height+header_title_height)+'px'}">
			<ciy-searchbar placeholder="请输入关键字" @confirm="search_change"></ciy-searchbar>
		</view>
		<view class="ciy-list" v-for="(item,index) in init.list" :key="item.id">
			<ciy-svgimg v-if="item.img" :src="item.img"></ciy-svgimg>
			<view class="l1 txt-wb" @tap="gourl" :data-url="'part?id=' + item.id">{{item.name}}</view>
			<view class="l3" v-html="tobr(item.descs)"></view>
		</view>
		<ciy-listend :page="pageno" :listlen="init.list.length" :nodataimg="file_stor('/img/mbnone.png')"></ciy-listend>
	</view>
</template>

<style>
</style>

<script>
	export default {
		data() {
			return {}
		},
		onLoad() {
			this.getlist();
		},
		onReachBottom(b) {
			if (this.init.code != 1)
				return;
			this.getlist();
		},
		onPullDownRefresh(b) {
			this.pageno = 0;
			this._stopPullDown = true;
			this.getlist();
		},
		watch: {},
		computed: {},
		methods: {
			async getlist() {
				if (this.pageno < 0)
					return;
				if (this._loading)
					return;
				this.pagepost.pageno = this.pageno + 1;
				this.pagepost.once = !this.init.once;
				this._loading = true;
				var retjson = await this.callfunc({
					func: 'main.psection_list',
					data: this.pagepost
				});
				this._loading = false;
				if (retjson.code != 1)
					return this.alert(retjson.errmsg);
				this.pageno++;
				if (this.pageno == 1)
					this.init.list = [];
				this.init = this.objdeepmerge(this.init, retjson);
				if (retjson.list.length < retjson.pagecount)
					this.pageno = -1;
			},
			search_change(e) {
				this.pagepost.key = e.value;
				this.pageno = 0;
				this.getlist();
			},
		}
	}
</script>