<template>
	<view>
		<view class="wrap">
			<u-swiper :list="bannerList" keyName="image" img-mode="scaleToFill" :effect3d="true"></u-swiper>
		</view>
		<view class="box menu-box">
			<view class="menu-item">
				<view class="menu-img">
					<image src="../../static/icon/user.png"></image>
				</view>
				<view class="menu-text">购买确认</view>
			</view>
			<view class="menu-item">
				<view class="menu-img">
					<image src="../../static/icon/user.png"></image>
				</view>
				<view class="menu-text">购买确认确</view>
			</view>
			<view class="menu-item">
				<view class="menu-img">
					<image src="../../static/icon/user.png"></image>
				</view>
				<view class="menu-text">购买确认确</view>
			</view>
			<view class="menu-item">
				<view class="menu-img">
					<image src="../../static/icon/user.png"></image>
				</view>
				<view class="menu-text">购买确认确</view>
			</view>
			<view class="menu-item">
				<view class="menu-img">
					<image src="../../static/icon/user.png"></image>
				</view>
				<view class="menu-text">购买确认确</view>
			</view>
			<view class="menu-item">
				<view class="menu-img">
					<image src="../../static/icon/user.png"></image>
				</view>
				<view class="menu-text">购买确认确</view>
			</view>
			<view class="menu-item">
				<view class="menu-img">
					<image src="../../static/icon/user.png"></image>
				</view>
				<view class="menu-text">购买确认确</view>
			</view>
			<view class="menu-item">
				<view class="menu-img">
					<image src="../../static/icon/user.png"></image>
				</view>
				<view class="menu-text">购买确认确</view>
			</view>
		</view>
		<view class="box msg-box">
			<view class="title">
				<u-icon name="calendar" color="#ff0000" size="28"></u-icon>
				<text>最新资讯</text>
			</view>
			<view class="news-box" v-for="(item,index) in newsList">
				<view class="news-img">
					<image src="https://www.leezon.net/uploads/news/20200314160130384800.jpg"></image>
				</view>
				<view class="news-item">
					<view class="new-title">{{item.title}}</view>
					<view class="news-notice">
						<view style="flex: 1;display: flex;"><u-icon name="eye-fill"></u-icon>12</view>
						<view style="flex: 3;text-align: right;">2023-12-34 22:00:00</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				bannerList: [],
				newsList: []
			}
		},
		onLoad() {
			this.getBannerList();
			this.getNewsList();
		},
		methods: {
			getBannerList() {
				this.$api.getBannerList().then(resp => {
					this.bannerList = resp.data;
				})
			},
			getNewsList() {
				this.$api.getNewestList({
					limit: 4
				}).then(resp => {
					this.newsList = resp.data;
				})
			}

		}
	}
</script>

<style scoped lang="scss">
	.wrap {
		padding: 10rpx;
	}

	.menu-box {
		height: 300rpx;
		display: flex;
		flex-wrap: wrap;
		gap: 20rpx 40rpx;

		.menu-item {
			width: 128rpx;
			height: 128rpx;
			position: relative;
			text-align: center;

			.menu-img {
				image {
					height: 64rpx;
					width: 64rpx;
				}
			}

			.menu-text {
				font-size: 16rpx;
			}
		}
	}

	.box {
		padding: 20rpx 40rpx;
		width: 90%;
		margin: auto;
		background: #fff;
		border-radius: 30rpx;
	}

	.msg-box {
		height: 600rpx;
		margin-top: 10rpx;

		.title {
			font-size: 30rpx;
			line-height: 60rpx;
			display: flex;
			width: 30%;
			border-bottom: 1px solid #e2e2e2;

		}
	}

	.news-box {
		margin-top: 20rpx;
		display: flex;
		height: 140rpx;
		widows: 100vw;
		padding-bottom: 20rpx;
		border-bottom: 1px solid #e2e2e2;
		.news-img image {
			width: 140rpx;
			height: 100%;
		}

		.news-item {
			width: 100vw;
			word-break: break-all;
			.new-title {
				font-size: 28rpx;
				padding: 10rpx 20rpx;
			}

			.news-notice {
				display: flex;
				font-size: 28rpx;
				color: #9e9b9b;
				padding: 20rpx 20rpx 0 20rpx;
			}
		}

	}
</style>