<template>
	<!-- 底部tab导航 -->
	<view>
		<Home v-if="nowchos === 0"></Home>
		<Order ref="order" v-else-if="nowchos === 1"></Order>
		<Mine ref="mine" :token="token" :userInfo="userInfo" v-else-if="nowchos === 2"></Mine>
		<!-- <Information v-else-if="nowchos === 2"></Information>
		<Mine ref="mine" v-else-if="nowchos === 3"></Mine> -->
		<view class="bottomboxs">
			<x-navbottom :nowchos='nowchos' @botomchos='botomchos'></x-navbottom>
		</view>
	</view>
</template>

<script>
	import Home from './home/index.vue' // 引入首页
	import Order from './order/index.vue' // 引入收益首页
	import Information from './information/index.vue' // 记录
	import Mine from './mine/index.vue' // 记录
	export default {
		components: { //在这里注册相应的组件
			Home,
			Order,
			Information,
			Mine,
		},
		data() {
			return {
				nowchos: 0, //当前选择了那个底部菜单
				userInfo: {},
				isorders: 0,
				userType: 3,
				token: '',
			}
		},
		onShow() {
			const that = this
			uni.$on('booking', () => {
				that.nowchos = 1
				that.$forceUpdate()
				that.$nextTick(() => {
					setTimeout(function() {
						that.$refs.order.getOrderList()
					});
				})
			})
			if (that.nowchos == 2) {
				that.$nextTick(() => {
					setTimeout(function() {
						// that.$refs.mine.refreshTokenil()
					}, 100);
				})
			}
			var token = that.$cache.getToken()
			that.token = token
			var userInfo = that.$cache.getCache('userInfo')
			if (userInfo) {
				that.userInfo = userInfo
			}
		},
		mounted() {
			var userInfo = this.$cache.getCache('userInfo')
			if (userInfo.provUser) {
				this.isorders = userInfo.provUser.isorders
				this.userType = userInfo.provUser.userType
			}
		},
		methods: {
			// tab
			botomchos(e) {
				const that = this
				if (e == 2) {
					that.$nextTick(() => {
						setTimeout(function() {
							// that.$refs.mine.refreshTokenil()
						}, 100);
					})
				}
				uni.setStorageSync('nowchos', e);
				that.nowchos = e
			},
		}
	}
</script>

<style lang="scss">
	.bottomboxs {
		position: relative;
		bottom: 0;
		z-index: 2023;
		height: 100rpx;
	}
</style>