<template>
	<view class="content">
		<view class="section_1">
			<view class="tab">
				<view class="title" @click="change_active(1)" :class="active==1?'active':''">机关部室</view>
				<view class="title" @click="change_active(2)" :class="active==2?'active':''">基层区队</view>
			</view>
			<view class="list">
				<view class="item" v-for="(item,index) in list.children" :key="index" @click="go_record(item.link)">
					{{item.title}}
				</view>
			</view>
		</view>
		
		<!-- 图片链接 -->
		<view class="section_2">
			<view class="list">
				<view class="item" v-for="(item,index) in list_3.children" :key="index"  @click="go_record(item.link)">
					<image :src="item.thumb" mode=""></image>
				</view>
			</view>
		</view>
		
		<!-- 快速通道 -->
		<view class="section_3">
			<view class="title">快速通道</view>
			<view class="list">
				<view class="item" v-for="(item,index) in list_4.children" :key="index" @click="go_record(item.link)">
					<image :src="item.thumb" mode=""></image>
				</view>
			</view>
		</view>
		

	</view>
</template>

<script>
	export default {
		name: "t-i-jinjiaqu",
		props:[
			"mine_code"
		],
		data() {
			return {
				active: 1,
				list: [],
				list_1: [],
				list_2: [],
				
				// 图片链接
				list_3:[],
				// 快速通道
				list_4:[]
			};
		},
		created() {
			this.get_home_link()
		},
		methods: {
			change_active(item) {
				this.active = item

				if (item == 1) {
					this.list = this.list_1
				} else if (item == 2) {
					this.list = this.list_2
				}
			},

			get_home_link() {
				this.$api.home_link({

				}).then((res) => {
					// console.log(res.data.data)

					// 机关部室
					this.list = res.data.data[2]
					this.list_1 = res.data.data[2]
					// 基层区队
					this.list_2 = res.data.data[3]
					
					// 图片链接
					this.list_3 = res.data.data[1]
					// 快速通道
					this.list_4 = res.data.data[0]
				})
			},
			go_record(link){
				// 二维码
				if(link.indexOf("pageId") != -1 && link.indexOf("app:") == -1){
					let pageId = ""
					function GetQueryString(name) {
						var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
						var r = link.match(reg);
						if (r != null) return unescape(r[2]);
						return null;
					}
					console.log(GetQueryString("pageId"))
					if (GetQueryString("pageId")) {
						pageId = GetQueryString("pageId")
					} else {
						pageId = link.split('=')[1]
					}
					
					uni.navigateTo({
						url:"../../index/record/record?pageId=" + pageId + "&mine_code=" + this.mine_code,
					})
				}else if(link.indexOf("webdevelop.nxjiewei.com/assets/html/pingce") != -1){
					uni.navigateTo({
						url:"../../index/h5/h5?url=jinjiaqu_pingce"
					})
				}else if(link.indexOf("/wordorder/wordOrderGrid_win") != -1){
					console.log(link)
					uni.navigateTo({
						url:"../../index/business_approval/business_approval"
					})
				}else{
					console.log(link)
				}
				
			}
		}
	}
</script>

<style lang="scss">
	.content {
		margin-top: 20rpx;
		background-color: #FFFFFF;
	}

	.section_1 {
		box-sizing: border-box;
		padding: 25rpx;

		.tab {
			display: flex;
			justify-content: space-around;

			.title {
				line-height: 80rpx;
				font-weight: 700;
			}

			.active {
				color: #009fe8;
				border-bottom: 6rpx solid #009fe8;
			}
		}

		.list {
			margin-top: 30rpx;
			overflow: hidden;
			.item{
				float: left;
				margin-right: 20rpx;
				margin-bottom: 30rpx;
				
				width: 160rpx;
				box-sizing: border-box;
				border: 2rpx solid #009fe8;
				border-radius: 20rpx;
				font-size: 28rpx;
				line-height: 70rpx;
				//超过一行省略号
				overflow: hidden;
				white-space: nowrap;
				text-overflow: ellipsis;
				
				padding: 0 10rpx;
				background-color: #66C7F218;
				color: #009FE8;
			
				text-align: center;
			}
			.item:nth-child(4n){
				margin-right: 0;
			}
		}

	}
	
	.section_2{
		box-sizing: border-box;
		padding: 0 25rpx;
		.list{
			display: flex;
			flex-wrap: wrap;
			justify-content: space-between;
			.item{
				margin-bottom: 20rpx;
				width: 340rpx;
				height: 180rpx;
				
				border-radius: 20rpx;
				overflow: hidden;
				
				image{
					width: 340rpx;
					height: 180rpx;
				}
			}
		}
	}
	.section_3{
		box-sizing: border-box;
		padding: 0 25rpx;
		.title{
			line-height: 120rpx;
			font-size: 36rpx;
			font-weight: 700;
		}
		.list{
			display: flex;
			flex-wrap: wrap;
			justify-content: space-between;
			.item{
				margin-bottom: 20rpx;
				width: 340rpx;
				height: 220rpx;
				
				border-radius: 20rpx;
				overflow: hidden;
				
				image{
					width: 340rpx;
					height: 220rpx;
				}
			}
		}
	}
</style>
