<template>
	<!-- 底部tab导航 -->
	<view>
		<Home :dataList="dataList" :genreTitle="genreTitle" ref="home" v-if="nowchos === 0"></Home>
		<!-- isorders == 0 同时userType == 3 送气员 -->
		<Order v-else-if="nowchos === 1 && isorders == 0 && userType == 3"></Order>
		<Information ref="cylinder" v-else-if="steelCylinder(isorders,userType)"></Information>
		<Mine :token="token" :userInfo="userInfo" v-else-if="getType(isorders,userType)"></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: '',
				aspirated: [{
					id: '25',
					title: '领重瓶出库',
					icon: 'icon-chukudan',
					color: '#f4b237',
				}, {
					id: '27',
					title: '扫空瓶入库',
					icon: 'icon-fankudengji',
					color: '#6db1ff',
				}],
				shopList: [{
					id: '37',
					title: '重瓶出库',
					icon: 'icon-peizaizhuangche',
					color: '#f4b237',
				}, {
					id: '10',
					title: '空瓶出库',
					icon: 'icon-peizaizhuangche-xianxing',
					color: '#6db1ff',
				}, {
					id: '31',
					title: '重瓶入库',
					icon: 'icon-fankudengji',
					color: '#6db1ff',
				}, {
					id: '21',
					title: '回收空瓶',
					icon: 'icon-recycling',
					color: '#8ac247',
				}, {
					id: '35',
					// 未配送
					title: '重瓶返库',
					icon: 'icon-fankudengji',
					color: '#22b9f9',
				}, {
					id: '33',
					title: '重瓶退回',
					icon: 'icon-tuihuo',
					color: '#f3553e',
				}, ],
				driverList: [{
					id: '11',
					title: '门店空瓶装车',
					icon: 'icon-owNote',
					color: '#22b9f9',
				}, {
					id: '12',
					title: '空瓶到达气站',
					icon: 'icon-yidaoda',
					color: '#8ac247',
				}, {
					id: '17',
					title: '气站重瓶出库',
					icon: 'icon-chukudan',
					color: '#6db1ff',
				}, {
					id: '19',
					title: '重瓶交付门店',
					icon: 'icon-yunsonghejiaofu',
					color: '#f4b237',
				}],
				stationList: [{
					id: '13',
					title: '空瓶到达气站',
					icon: 'icon-daichuku',
					color: '#37c4f4',
				}, {
					id: '14',
					title: '气站充装空瓶',
					icon: 'icon-peizaizhuangche-xianxing',
					color: '#6db1ff',
				}, {
					id: '15',
					title: '气站重瓶出库',
					icon: 'icon-owNote',
					color: '#8ac247',
				}, {
					id: 'inspect',
					title: '充气前后检查',
					icon: 'icon-jianchaxiang',
					color: '#f4b237',
				}, ],
				dataList: [],
				genreTitle: '',
			}
		},
		onReachBottom() {
			this.$refs.cylinder.bottomingEvent()
		},
		onLoad(value) {
			console.log(value, 333)
			if (value.page) {
				this.nowchos = value.page
			}
			var userInfo = this.$cache.getCache('userInfo')
			if (userInfo.provUser) {
				if (userInfo.provUser.isorders == 0 && userInfo.provUser.userType == 3) {
					this.dataList = this.aspirated
					this.genreTitle = '送气员端'
				} else if (userInfo.provUser.userType == 3) {
					this.dataList = this.shopList
					this.genreTitle = '门店端'
				} else if (userInfo.provUser.userType == 4) {
					this.dataList = this.driverList
					this.genreTitle = '司机端'
				} else if (userInfo.provUser.userType == 5) {
					this.dataList = this.stationList
					this.genreTitle = '气站端'
				}
			} else {
				this.dataList = this.aspirated
				this.genreTitle = '送气员端'
			}
		},
		onShow() {
			var token = this.$cache.getToken()
			this.token = token
			var userInfo = this.$cache.getCache('userInfo')
			if (userInfo) {
				this.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) {
				uni.setStorageSync('nowchos', e);
				this.nowchos = e
			},
			getType(isorders, userType) {
				if (isorders == 0) {
					if (userType == 3) {
						if (this.nowchos == 3) {
							return true
						}
					} else {
						if (this.nowchos == 2) {
							return true
						}
					}
				} else {
					if (this.nowchos == 2) {
						return true
					}
				}
			},
			steelCylinder(isorders, userType) {
				if (isorders == 0) {
					if (userType == 3) {
						if (this.nowchos == 2) {
							return true
						}
					} else {
						if (this.nowchos == 1) {
							return true
						}
					}
				} else {
					if (this.nowchos == 1) {
						return true
					}
				}
			}
		}
	}
</script>

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