<template>
	<view class="main">
		<guide v-if="guidePages" :advData="advData"></guide>
	</view>
</template>

<script>
	// +----------------------------------------------------------------------
	// | CRMEB [ CRMEB赋能开发者，助力企业发展 ]
	// +----------------------------------------------------------------------
	// | Copyright (c) 2016~2024 https://www.crmeb.com All rights reserved.
	// +----------------------------------------------------------------------
	// | Licensed CRMEB并不是自由软件，未经许可不能去掉CRMEB相关版权
	// +----------------------------------------------------------------------
	// | Author: CRMEB Team <admin@crmeb.com>
	// +----------------------------------------------------------------------
	import guide from '@/components/guide/index.vue'
	import {
		loadIndexs
	} from '@/api/index.js'
	export default {
		components: {
			guide
		},
		data() {
			return {
				guidePages: false,
				frequency: '',
				advData: {
					config: {
						open_screen_time: 3
					}
				}
			}
		},
		onLoad(option) {
			// #ifdef MP
			if (option.scene) {
				// 存储小程序邀请人
				uni.setStorage({
					key: 'spread_code',
					data: option.scene
				});
			}
			// #endif
			// #ifdef H5
			if (option.spread) {
				// 存储小程序邀请人
				uni.setStorage({
					key: 'spread',
					data: option.spread
				});
			}
			// #endif
		},
		onShow() {
			// // #ifdef H5
			// if(this.$wechat.isWeixin()){
			// 	this.$wechat.wechat();
			// }
			// // #endif
			this.loadExecution()
		},
		methods: {
			loadExecution() {
				loadIndexs().then(res => {
					console.log(res,'res')
					let list = res.data.open_one;
					if(list.length == 0) {
							uni.switchTab({
								url: '/pages/index/index'
							});
					}else {
						this.advData.list = res.data.open_one;
						this.guidePages = true;
					}

				}).catch(err => {
						uni.switchTab({
							url: '/pages/index/index'
						});
				})
			}
		},
		onHide() {
			this.guidePages = false
		}
	}
</script>

<style>
	page,
	.main {
		width: 100%;
		height: 100%;
	}
</style>
