<template>
	<view class="content">
		<view class="section" v-for="(item,index) in list" :key="index">
			<view class="title">{{item.title}}</view>
			<view class="list">
				<view class="item" v-for="(item_2,index_2) in item.children" :key="index_2" @click="go_record(item_2.link)">
					{{item_2.title}}
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		name: "t-i-yangchangwan",
		props:[
			"mine_code"
		],
		data() {
			return {
				list: [],
			};
		},
		created() {
			this.get_home_link()
		},
		methods: {
			get_home_link() {
				this.$api.home_link({

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

					this.list = res.data.data
				})
			},
			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{
					console.log(link)
				}
				
			}
		}
	}
</script>

<style lang="scss">
	.content {
		margin-top: 20rpx;
		background-color: #FFFFFF;
		
		padding-top: 20rpx;
	}
	
	.section{
		box-sizing: border-box;
		padding: 0 25rpx;
		
		margin-top: 10rpx;
	}
	
	.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;
		}
	}
</style>
