<template>
	<ciy-header title="广场" mode="scroll"></ciy-header>
	<view v-if="init.code != 1">
		<view class="px4 py4">
			<view style="height:12rem;width:100%;" class="ciy-skeleton"></view>
			<view style="height:2rem;width:60%;" class="ciy-skeleton"></view>
			<view style="height:1rem;width:40%;margin-left:1rem;" class="ciy-skeleton"></view>
			<view style="height:3rem;width:70%;" class="ciy-skeleton"></view>
			<view style="height:3rem;width:70%;" class="ciy-skeleton"></view>
			<view style="height:3rem;width:70%;" class="ciy-skeleton"></view>
		</view>
	</view>
	<view v-else>
		<ciy-swiper :banner="init.banner" height="60vw"></ciy-swiper>
		<view class="bg1">
			<view class="ciy-grid">
				<view class="grid" @tap="gourl" data-url="/pages/demo/index">
					<view class="icon" :style="{backgroundImage:svg2bg(svg.ctg)}"></view>
					<view class="name">Demo</view>
				</view>
				<view class="grid" @tap="gourl" data-url="/pages/pub/paper?id=1">
					<view class="icon" :style="{backgroundImage:svg2bg(svg.cqd)}"></view>
					<view class="name">游客页面</view>
				</view>
				<view class="grid" @tap="gourl" data-url="$/pages/me/suggest">
					<view class="icon" :style="{backgroundImage:svg2bg(svg.cjf)}"></view>
					<view class="name">用户页面</view>
				</view>
				<view class="grid" @tap="gourl" data-url="!4187|js_shangpin">
					<view class="icon" :style="{backgroundImage:svg2bg(svg.cmh)}"></view>
					<view class="name">原型演示</view>
				</view>
			</view>
		</view>
		<view class="ciy-caption mk sti" :style="{top:(header_statusbar_height+header_title_height)+'px'}">
			<view class="title">主标题</view>
			<view class="sub">小标题小标题小标题小标题小标题</view>
		</view>
		<view>
			<diy-xxlist v-for="(item,index) in init.demos" :key="item.id" :index="index" :data="item" :initdata="init"></diy-xxlist>
		</view>
		<view :style="{height:header_statusbar_height+'px'}"></view>
	</view>
	<ciy-tabbar ref="tabbar"></ciy-tabbar>
</template>

<style scoped>
</style>

<script>
	export default {
		data() {
			return {
				svg: {},
			}
		},
		onLoad() {
			if (this.opn.u) {
				uni.navigateTo({
					url: decodeURIComponent(this.opn.u)
				});
			}
			setTimeout(() => {
				this.executepnt(1);
			}, 3000);
			this.getauth().then(auth => {
				if (auth.me.id == 0)
					return;
				this.pageno = 0;
				this.getinit();
			});
			this.load_svgicon(this.file_stor('/svgicon/index.txt')).then(svgs => {
				this.svg = svgs;
			});
		},
		onShow() {
			if (this._meid === this.me.id)
				return;
			this._meid = this.me.id;
			this.pageno = 0;
			this.init.members = [];
			this.getinit();
		},
		onShareAppMessage(res) {
			return this.shareparam({
				type: 'message',
				title: this.init.sharename,
				img: this.file_stor(this.init.shareicon),
				path: this.getroute(),
				query: {
					...this.opn
				}
			});
		},
		onShareTimeline(res) {
			return this.shareparam({
				type: 'timeline',
				title: this.init.sharename,
				img: this.file_stor(this.init.shareicon),
				path: this.getroute(),
				query: {
					...this.opn
				}
			});
		},
		onPullDownRefresh(b) {
			this._stopPullDown = true;
			this.getinit();
		},
		methods: {
			async getinit() {
				var retjson = await this.callfunc({
					func: 'main.index_init'
				});
				if (retjson.code != 1)
					return this.alert(retjson.errmsg);
				this.init = retjson;
			},
		}
	}
</script>