<template>
	<view id="warp">
		<view v-if="overspeedTime"  class="message_box" @tap="goWarnItem('/pages/warnItem/warnItem')">
			<view class="header_image">
				<image src="/static/images/common/warn.png"></image>
				<text class="unread_num" v-if="overspeedCount > 0">
					{{ overspeedCount > 99 ? '99+' : overspeedCount }}
				</text>
			</view>
			<view class="message_item">
				<view class="message_item_top">
					<text class="title">超速报警</text>
					<text class="time" v-if="overspeedTime">{{overspeedTime}}</text>
				</view>
				<view class="message_item_bottom">
					<text>{{vehicleCode}}({{vehiclePlate}})</text>
				</view>
			</view>
		</view>
		<!-- <view class="message_box" @tap="goWarnItem('/pages/out_partner/out_partner')">
			<view class="header_image">
				<image src="/static/images/common/wz.png"></image>
				<text class="unread_num" v-if="overspeedCount > 0">
					{{ overspeedCount > 99 ? '99+' : overspeedCount }}
				</text>
			</view>
			<view class="message_item">
				<view class="message_item_top">
					<text class="title">同行叫车</text>
					<text class="time" v-if="overspeedTime">{{overspeedTime}}</text>
				</view>
				<view class="message_item_bottom">
					<text>{{vehicleCode}}({{vehiclePlate}})</text>
				</view>
			</view>
		</view> -->
		<view class="none" v-else>
			<image src="/static/images/common/empty.png"></image>
			<text>没有报警信息</text>
		</view>
	</view>
</template>

<script>
	const {urlList,https} = require('@/static/api');
	export default {
		data() {
			return {
				overspeedCount:0,
				overspeedTime:'',
				vehicleCode:'',
				vehiclePlate:'',
			};
		},
		onLoad() {
			uni.showNavigationBarLoading();
			this.getUnreadCount();
		},
		methods:{
			getUnreadCount(){
				const _that = this;
				https(urlList.getUnreadCount,'GET','','').then(data => {
					console.log('信息未读数',data)
					_that.overspeedCount = data.data.overspeedCount;
					_that.overspeedTime = data.data.overspeedTime;
					_that.vehicleCode = data.data.vehicleCode;
					_that.vehiclePlate = data.data.vehiclePlate;
				}).catch(err => {
					uni.showToast({
						title:err,
						icon:'none',
						duration:1500
					});
				})
				uni.hideNavigationBarLoading()
			},
			goWarnItem(url){
				uni.navigateTo({
					url
				})
			},
		},
	}
</script>

<style lang="scss" scoped>
#warp{
	width: 100%;
	display: flex;
	flex-direction: column;
	align-items: center;
	.message_box {
		display: flex;
		width: 95%;
		padding: 30rpx 0rpx 20rpx 0rpx;
		border-bottom: 1rpx solid #e9e8ec;
		.header_image{
			position: relative;
			image{
				height: 90rpx;
				width: 90rpx;
			}
			.unread_num{
				position: absolute;
				top: -15rpx;
				right: -15rpx;
				width: 47rpx;
				height: 47rpx;
				border-radius: 50%;
				color: white;
				background: #FB0000FF;
				font-size: 20rpx;
				text-align: center;
				line-height: 47rpx;
			}
		}
		.message_item{
			width: 100%;
			height: 100rpx;
			padding-left: 28rpx;
			box-sizing: border-box;
			.message_item_top{
				display: flex;
				align-items: center;
				justify-content: space-between;
				.title{
					font-size: 32rpx;
					color: #333333FF;
					font-weight: bold;
				}
				.time{
					font-size: 24rpx;
					color: #999999FF;
				}
			}
			.message_item_bottom {
				font-size: 28rpx;
				color: #666666FF;
				margin-top: 8rpx;

				display: flex;
				align-items: center;
				justify-content: space-between;
			}
		}
	}
	.none{
			width: 100vw;
			height: 100vh;
			font-size: 28rpx;
			color: #999999FF;
			position: fixed;
			top: 0;
			left: 0;
			display: flex;
			flex-direction: column;
			align-items: center;
			image{
				width: 256rpx;
				height: 244rpx;
				margin-bottom: 40rpx;
				margin-top: 220rpx;
			}
		}
}
</style>
