<template>
	<view>
		<view class="list">
			<view class="btn_box">
				<view class="btn" @click="go_oa_url()">
					<view class="text">我的申请</view>
					<view class="icon">
						<uni-icons type="right" color="#fff" size="16"></uni-icons>
					</view>
				</view>
			</view>
			<view class="item" v-for="(item,index) in list" :key="index">
				<div class="line">
					<view class="title">{{item.car_type}}</view>
					<view class="btn" @click="go_oa_url_2(item)">
						<view class="icon">
							<uni-icons type="list" color="#fff" size="16"></uni-icons>
						</view>
						<view class="text">申请</view>
					</view>
				</div>
				<div class="label_box">
					<view class="label" v-for="(item_2,index_2) in item.con" :key="index_2" v-if="item_2.is_show == 1">
						<view class="name">{{item_2.title}}</view>
						<view class="num">{{item_2.con}}</view>
					</view>
				</div>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				mine_code:"",
				base_url:"http://oa_system.nxmy.com:8011",
				list: []
			};
		},
		onLoad(option) {
			console.log(uni.getStorageSync('mine_code'))
			if(uni.getStorageSync('mine_code').indexOf("_neiwang") != -1){
				console.log("内网")
				this.base_url = "http://oa_system.nxmy.com:8011"
			}else{
				console.log("公网")
			}
			
			console.log(option)

			uni.setNavigationBarTitle({
				title: option.title
			})
		},
		mounted() {
			this.get_list()
		},
		methods: {
			go_oa_url() {
				uni.navigateTo({
					url: "../../origanization/OA/h5/h5",
					success: (res) => {
						// 通过eventChannel向被打开页面传送数据
						res.eventChannel.emit('acceptDataFromOpenerPage', {
							url: this.base_url + "/?m=ying&d=we&mnum=rjz_car_apply&show=we&hideheader=true",
							title: "用车申请"
						})
					}
				})
			},
			go_oa_url_2(item) {
				console.log(item)
				uni.navigateTo({
					url: "../../origanization/OA/h5/h5",
					success: (res) => {
						// 通过eventChannel向被打开页面传送数据
						res.eventChannel.emit('acceptDataFromOpenerPage', {
							url: this.base_url + "/index.php?a=lum&m=input&d=flow&num=rjz_car_apply&hideheader=true&show=we&car_type="+item.car_type+"&free_con="+item.con[1].con,
							title: "用车申请"
						})
					}
				})
			},
			get_list() {
				uni.request({
					method: "GET",
					url: this.base_url + "/api.php?m=rjzcarlist&a=getFreeCarCon&ischeck=0",
					success: (res) => {
						console.log(res.data);

						this.list = res.data.data
					}
				})
			}
		}
	}
</script>

<style lang="scss">
	.list {
		box-sizing: border-box;
		padding: 25rpx;

		.btn_box {
			display: flex;
			justify-content: flex-end;
			margin-bottom: 30rpx;

			.btn {
				width: 230rpx;
				height: 60rpx;
				line-height: 60rpx;
				background: #00A0E8;
				border-radius: 32rpx;

				display: flex;
				align-items: center;
				justify-content: center;

				.text {
					font-size: 30rpx;
					color: #fff;
					font-weight: 700;
					margin-right: 10rpx;
				}

				.icon {
					font-weight: 700;
				}
			}
		}

		.item {
			margin-bottom: 30rpx;
			box-shadow: 1rpx 10rpx 16rpx 0rpx rgba(0, 0, 0, 0.13);
			border-radius: 20rpx;

			box-sizing: border-box;
			padding: 30rpx;

			.line {
				display: flex;
				justify-content: space-between;
				align-items: center;

				.title {
					font-size: 32rpx;
					font-weight: 700;
					border-bottom: 6rpx solid #009fe8;
				}

				.btn {
					width: 140rpx;
					height: 46rpx;
					background: #00A0E8;
					border-radius: 28rpx;

					display: flex;
					align-items: center;
					justify-content: center;

					.text {
						font-size: 26rpx;
						color: #fff;
						margin-left: 10rpx;
					}
				}


			}

			.label_box {
				margin-top: 30rpx;
				display: flex;
				justify-content: space-between;
				align-items: center;

				.label {
					text-align: center;

					.name {
						color: #6F6F6F;
						font-size: 24rpx;
					}

					.num {
						font-size: 26rpx;
						font-weight: 700;
					}
				}
			}
		}
	}
</style>
