<template>
	<view>
		<view v-if="isInvest">
			<view>
				<pageG v-if="tabBarShow == 0" :user="user" ref="pageG" />
			</view>
			<view>
				<pageH v-if="tabBarShow == 1" :user="user" ref="pageH" />
			</view>
			<view>
				<pageI v-if="tabBarShow == 2" :user="user" ref="pageI" />
			</view>
			<view>
				<pageF v-if="tabBarShow == 3" :user="user" :isInvest="isInvest" @tabChange="tabChange" ref="pageF" />
			</view>
		</view>
		<view v-else>
			<view>
				<pageA v-if="tabBarShow == 0" :user="user" ref="pageA" />
			</view>
			<view>
				<pageB v-if="tabBarShow == 1" :user="user" ref="pageB" />
			</view>
			<view>
				<pageC v-if="tabBarShow == 2" :user="user" ref="pageC" />
			</view>
			<view>
				<pageE v-if="tabBarShow == 3" :user="user" ref="pageE" />
			</view>
			<view>
				<pageF v-if="tabBarShow == 4" :user="user" :isInvest="isInvest" @tabChange="tabChange" ref="pageF" />
			</view>
		</view>
		<cc-myTabbar ref="myTabbar" :tabbar="tabbar" :tabBarShow="tabBarShow" @tabChange="tabChange"></cc-myTabbar>
	</view>
</template>

<script setup>
import { ref } from 'vue';
import { onLoad } from '@dcloudio/uni-app';
import { userHook } from '@/hooks/userInfo.js';
import { getUrlParam } from '@/utils/fun.js';

import pageA from '@/pages/home/components/user/home.vue';
import pageB from '@/pages/home/components/user/index.vue';
import pageC from '@/pages/home/components/user/sweep.vue';
import pageE from '@/pages/home/components/user/find.vue';
import pageF from '@/pages/home/components/user/mine.vue';
import pageG from '@/pages/home/components/Invest/shop.vue';
import pageH from '@/pages/home/components/Invest/order.vue';
import pageI from '@/pages/home/components/Invest/facility.vue';

const { isInvest, user, tabbar } = userHook();
let tabBarShow = ref(0);

onLoad((options) => {
	if (options.q) {
		const q = decodeURIComponent(options.q);
		const query = getUrlParam(q);
		if (query.code) {
			uni.setStorageSync('invite_code', query.code);
		}
	}

	if (options.tabBarShow) {
		tabBarShow.value = options.tabBarShow;
	}
});

const tabChange = (e) => {
	tabBarShow.value = e.index;
};
</script>

<style lang="scss"></style>
