<template>
	<view class="container">

		<u-subsection :list="top_list" :current="current" keyName="name" activeColor="#f56c6c" mode="subsection"
			@change="sectionChange"></u-subsection>

		<view class="list">
			<scroll-view :scroll-top="scrollTop" scroll-y="true" class="scroll-Y" @scrolltoupper="upper"
				@scrolltolower="lower" @scroll="scroll">
				<view class="card" v-for="(item,index) in list" @click="toNotice(item.id)">
					<view class="title">品类库与应急预案关联书本名称 <u-icon name="arrow-right" size="12"></u-icon></view>
					<view class="name_1 flex"><u-icon name="car-fill" class="icon-right" color="#2979ff"
							size="12"></u-icon>应急类别：应急预案库</view>
					<view class="name_2 flex"><u-icon name="car-fill" class="icon-right" color="#ddbb0b"
							size="12"></u-icon>预案名称：{{item.car ? item.car.name : ''}}</view>
				</view>
			</scroll-view>


		</view>


	</view>
</template>

<script>
	import {
		get,
		post
	} from '@/common/request.js'
	export default {
		data() {
			return {
				top_list: [{
					name: '应急预案库'
				}, {
					name: '重大事故'
				}],
				current: 0,
				scrollTop: 0,
				list:[],
			}
		},
		onLoad(){
			this.getList()
		},
		methods: {
			onPullDownRefresh() {
				setTimeout(() => {
					this.getList()
					uni.stopPullDownRefresh();
				}, 500);
			},
			async getList(){
				await get('/myapi/api/yq_driver/alarmList',{cate_id:this.current}).then(res => {
					this.list = res.data
				})
			},
			sectionChange(current) {
				this.current = current
				this.getList()
			},
			toNotice(id){
				uni.navigateTo({
					url:'/pages/index/messageDetails?id='+id
				})
			},
			upper: function(e) {
				console.log(e)
			},
			lower: function(e) {
				console.log(e)
			},
			scroll: function(e) {
				console.log(e)
				this.old.scrollTop = e.detail.scrollTop
			},
		}
	}
</script>

<style scoped lang="less">
	.container {
		padding-top: 2px;
		background-color: #f4f4f4;
		height: calc(100vh - 46px);

		.list {
			padding: 5px 20px;

			.scroll-Y {
				height: calc(100vh - 86px);

				.card {
					background-color: #fff;
					padding: 10px;
					margin-bottom: 10px;
					font-size: 14px;
					border-radius: 10px;

					.title {
						font-size: 16px;
						height: 40px;
						line-height: 40px;
						border-bottom: 1px solid #f4f4f4;
						display: flex;
						justify-content: space-between;
						align-items: center;
					}

					.flex {
						display: flex;

						.icon-right {
							margin-right: 5px;
						}
					}

					.name_1 {
						margin: 10px 0;

					}
				}
			}
		}
	}
</style>