<template>
	<view class="container" :style="{height: winHeight + 'px'}">
		<!-- 状态栏高度 -->
		<view :style="{ height: `${statusBarHeight}px`, width: '100%', backgroundColor: '#FF6702' }"></view>
		<!-- 导航栏 -->
		<view :style="{ height: `${navigationBarHeight}rpx`,lineHeight: `${navigationBarHeight}rpx`}" class="order-nav">
			<!-- <view class="back-button" @tap="handBack()"></view> -->
			{{activeRole == '0' ? '接单' : '我的' }}
		</view>
		<!-- <view class="content-dom"> -->
		<view style="flex: 1;width: 100%;overflow: hidden;" v-if="activeRole == '0'">
			<rider-shipping></rider-shipping>
		</view>
		<view style="flex: 1;width: 100%;overflow: hidden;" v-if="activeRole == '1'">
			<rider-me></rider-me>
		</view>
		<!-- </view> -->
		<!-- 底部导航 -->
		<view class="page-footer">
			<view class="foot-item" :class="item.pagePath == activeRouter?'active':''" v-for="(item,index) in footerList" :key="index"
			 @click="goRouter(item)">
				<block v-if="item.pagePath == activeRouter">
					<image :src="item.selectedIconPath"></image>
					<view class="txt">{{item.text}}</view>
				</block>
				<block v-else>
					<image :src="item.iconPath"></image>
					<view class="txt">{{item.text}}</view>
				</block>
			</view>
		</view>
	</view>
</template>

<script>
	import riderOrder from "@/components/riderOrder/index.vue";
	import riderShipping from "./components/rider_shipping/index.vue";
	import riderMe from "./components/rider_me/index.vue";
	var statusBarHeight = uni.getSystemInfoSync().statusBarHeight + 'px';
	let app = getApp();
	export default {
		components: {
			riderOrder,
			riderShipping,
			riderMe
		},
		data() {
			return {
				winHeight: 0,
				activeRouter: '/pages/rider/rider_shipping/index',
				activeRole: '0',
				footerList: [{
						pagePath: "/pages/rider/rider_shipping/index",
						iconPath: require("./static/ddh.png"),
						selectedIconPath: require("./static/ddl.png"),
						text: "订单",
						role: '0'
					},
					{
						pagePath: "/pages/rider/rider_me/index",
						iconPath: require("./static/wdh.png"),
						selectedIconPath: require("./static/wdl.png"),
						text: "我的",
						role: '1'
					}
				],
				statusBarHeight: app.globalData.statusBarHeight,
				navigationBarHeight: 112,
			}
		},
		methods: {
			goRouter(item) {
				if (this.activeRouter == item.pagePath) return
				this.activeRouter = item.pagePath
				this.activeRole = item.role
				// uni.redirectTo({
				// 	url: item.pagePath,
				// 	animationType: 'none' // 关闭默认的滑动效果
				// });
			},
		},
		onLoad(options) {
			let that = this
			// 隐藏TabBar
			uni.hideTabBar({});
			uni.getSystemInfo({
				success: function(res) {
					that.winHeight = res.windowHeight
				},
			});
		},
		mounted() {

		},
	}
</script>

<style scoped lang="scss">
	.container {
		display: flex;
		align-items: center;
		flex-direction: column;
		justify-content: space-between;
		overflow: hidden;
		position: relative;
	}

	.content-dom {
		width: 100%;
		flex: 1;
	}

	.order-nav {
		width: 100%;
		font-weight: 500;
		font-size: 35rpx;
		margin-top: -2rpx;
		color: #FFFFFF;
		position: relative;
		background-color: #FF6702;
		display: flex;
		align-items: center;
		justify-content: center;

		.back-button {
			position: absolute;
			left: 20rpx;
		}
	}

	.page-footer {
		// position: fixed;
		// bottom: 0;
		// z-index: 9;
		display: flex;
		align-items: center;
		justify-content: space-around;
		width: 100%;
		height: calc(100rpx+ constant(safe-area-inset-bottom)); ///兼容 IOS<11.2/
		height: calc(100rpx + env(safe-area-inset-bottom)); ///兼容 IOS>11.2/
		box-sizing: border-box;
		border-top: solid 1rpx #F3F3F3;
		background-color: #fff;
		// box-shadow: 0px 0px 17rpx 1rpx rgba(206, 206, 206, 0.32);
		padding-bottom: constant(safe-area-inset-bottom); ///兼容 IOS<11.2/
		padding-bottom: env(safe-area-inset-bottom); ///兼容 IOS>11.2/

		.foot-item {
			display: flex;
			width: max-content;
			align-items: center;
			justify-content: center;
			flex-direction: column;
			position: relative;
			padding: 0 20rpx;
			margin-top: 18rpx;

			&.active {
				color: $bg-color-primary
			}
		}

		.foot-item image {
			height: 50rpx;
			width: 50rpx;
			text-align: center;
			margin: 0 auto;
		}

		.foot-item .txt {
			font-size: 27rpx;
			margin-top: 8rpx;
		}
	}
</style>
