<template>
	<view class="main">
		<!--轮播图-->
		<view class="banner">
			<u-swiper circular :radius="5" :indicator="true" keyName="pic" :list="bannerList" :height="160" class="uni-swiper" @click="click"></u-swiper>
		</view>
		<!--通知公告-->
		<view class="notice">
			<u-notice-bar color="#545555" :text="noticeList" :step="true" direction="column" mode="link" bgColor="white" speed="300" url="/pages/notice/index"></u-notice-bar>
		</view>
		<!--菜单-->
		<view class="menu">
			<view class="cd" @click="url('就业失业登记')">
				<view class="out">
					<view class="int">
						<view class="icon" style="background-color: #f44336">&#xe648;</view>
						<view class="title">就业失业登记</view>
					</view>
				</view>
			</view>
			<view class="cd" @click="url('就业创业补贴')">
				<view class="out">
					<view class="int">
						<view class="icon" style="background-color: #4caf50">&#xe64a;</view>
						<view class="title">就业创业补贴</view>
					</view>
				</view>
			</view>
			<view class="cd">
				<view class="out">
					<view class="int">
						<view class="icon" style="background-color: #ff9800">&#xe73c;</view>
						<view class="title">培训指导</view>
					</view>
				</view>
			</view>
			<view class="cd" @click="url('法务服务')">
				<view class="out">
					<view class="int">
						<view class="icon" style="background-color: #607d8b">&#xe998;</view>
						<view class="title">法务服务</view>
					</view>
				</view>
			</view>
			<view class="cd" @click="url('社保窗口')">
				<view class="out">
					<view class="int">
						<view class="icon" style="background-color: #795548">&#xe6a6;</view>
						<view class="title">社保窗口</view>
					</view>
				</view>
			</view>
			<view class="cd" @click="go('/pages/job/map')">
				<view class="out">
					<view class="int">
						<view class="icon" style="background-color: #f44336">&#xe647;</view>
						<view class="title">地图找工</view>
					</view>
				</view>
			</view>
			<view class="cd" @click="go('/pages/job/list?type=0')">
				<view class="out">
					<view class="int">
						<view class="icon" style="background-color: #4581fb">&#xe9d9;</view>
						<view class="title">全职</view>
					</view>
				</view>
			</view>
			<view class="cd" @click="go('/pages/job/list?type=1')">
				<view class="out">
					<view class="int">
						<view class="icon" style="background-color: #ff5722">&#xe62a;</view>
						<view class="title">兼职</view>
					</view>
				</view>
			</view>
			<view class="cd" @click="go('/pages/job/enterprise/card')">
				<view class="out">
					<view class="int">
						<view class="icon" style="background-color: #ff9800">&#xe725;</view>
						<view class="title">企业卡片</view>
					</view>
				</view>
			</view>
			<view class="cd" @click="go('/pages/statement/index/index')">
				<view class="out">
					<view class="int">
						<view class="icon" style="background-color: #03a9f4">&#xe63c;</view>
						<view class="title">结算广场</view>
					</view>
				</view>
			</view>
		</view>
		<!--新闻-->
		<view class="news">
			<view class="gg">
				<view class="title">最新资讯</view>
				<view class="bor"></view>
				<view class="more" @click="go('/pages/news/index?type=新闻资讯')">
					<text>更多</text>
					<text class="icon">&#xe62b;</text>
				</view>
			</view>
			<view class="bhe" :style="{ height: expand ? 'auto' : '60px' }">
				<view class="item" v-for="(item, index) in newsList" :key="index" @click="go('/pages/news/detail?id=' + item.id)">
					<view class="title omit">{{ item.title }}</view>
					<view class="date">{{ item.createTime.substring(5, 10) }}</view>
				</view>
			</view>
			<view class="expand" @click="expand = !expand">
				<text class="icon" v-if="expand">&#xe61c;</text>
				<text class="icon" v-else>&#xe617;</text>
				<text>{{ expand ? '收起' : '展开' }}</text>
			</view>
		</view>
		<!--横幅-->
		<image :src="img.a1" class="hengfu" @click="go('/pages/news/index?type=政策专题')"></image>
		<!--图片内容-->
		<view class="ad" style="margin-left: -10px; margin-right: -10px">
			<view class="item" style="height: 190px">
				<view class="out" style="padding-right: 0px" @click="go('/pages/news/index?type=就业政策')">
					<view class="int" style="height: 175px; box-shadow: 0 2px 2px 0 rgba(0, 0, 0, 0.2)">
						<image :src="img.a2" style="height: 180px; width: 100%"></image>
					</view>
				</view>
			</view>
			<view class="item" style="height: 190px">
				<view class="out">
					<view class="int">
						<view class="it" style="height: 80px" @click="go('/pages/news/index?type=人才政策')">
							<image :src="img.a3" mode="aspectFill" style="height: 85px; width: 100%"></image>
						</view>
						<view class="it" style="height: 86px; margin-top: 10px" @click="go('/pages/news/index?type=创业政策')">
							<image :src="img.a4" mode="aspectFill" style="height: 83px; width: 100%"></image>
						</view>
					</view>
				</view>
			</view>
		</view>
		<u-action-sheet :title="title" round="20" :actions="urls" @select="selectClick" cancelText="取消" :show="show" @close="show = false"></u-action-sheet>
	</view>
</template>
<script>
export default {
	data() {
		return {
			title: '就业失业登记',
			urls: [],
			img: {
				a1: 'https://chenglantimes.com/prod-api/profile/upload/2024/06/15/1718439518187.jpg',
				a2: 'https://chenglantimes.com/prod-api/profile/upload/2024/05/20/1716197779982.jpg',
				a3: 'https://chenglantimes.com/prod-api/profile/upload/2024/05/20/1716195826603.jpg',
				a4: 'https://chenglantimes.com/prod-api/profile/upload/2024/05/20/1716198212203.jpg'
			},
			bannerList: [],
			noticeList: [],
			newsList: [],
			expand: false,
			show: false
		};
	},
	onLoad() {
		this.getData();
	},
	methods: {
		getData() {
			//轮播图
			this.http.request({
				url: '/app/home/banner/1',
				success: (res) => {
					this.bannerList = res.data.data;
				}
			});
			//通知公告
			this.http.request({
				url: '/app/home/notice/小程序通知',
				success: (res) => {
					res.data.data.forEach((item) => {
						this.noticeList.push(item.title);
					});
				}
			});
			//资讯
			this.http.request({
				url: '/app/home/news',
				success: (res) => {
					this.newsList = res.data.data;
				}
			});
		},
		url(title) {
			this.title = title;
			this.show = true;
			if (title == '就业失业登记') {
				this.urls = [
					{ name: '就业链接', subname: 'https://ggfw.nn12333.com:8081/gx/wechat/html/jiuyeView/views/self_employmentApplication.html?applySrc=31' },
					{ name: '失业链接', subname: 'https://ggfw.nn12333.com:8081/gx/wechat/html/jiuyeView/views/unemploymentApplication.html?applySrc=31' }
				];
			}
			if (title == '就业创业补贴') {
				this.urls = [
					{ name: '返乡入乡创业人员一次性创业扶持补贴', subname: 'https://ggfw.nn12333.com:8081/gx/wechat/html//returnHomeOneTimeSupport/view/returnHomeOneTimeSupport.html?applySrc=31' },
					{ name: '困难人员灵活就业社保补贴', subname: 'https://ggfw.nn12333.com:8081/gx/wechat/html/jiuyeView/views/knrylhjysbbt.html?applySrc=31' },
					{ name: '毕业生灵活就业社保补贴', subname: 'https://ggfw.nn12333.com:8081/gx/wechat/html/jiuyeView/views/byslhjysbbt.html?applySrc=31' },
					{ name: '一次性创业扶持补贴', subname: 'https://ggfw.nn12333.com:8081/gx/wechat/html/onetimesupport/view/onetimesupport.html?applySrc=31' },
					{ name: '高校毕业生求职创业补贴', subname: 'https://ggfw.nn12333.com:8081/gx/wechat/html/jiuyeView/views/graduatesubsidy.html?applySrc=31' }
				];
			}
			if (title == '法务服务') {
				this.urls = [
					{ name: '劳动维权申请', subname: 'https://ggfw.nn12333.com:8081/gx/wechat/html/laodongweiquanSQ/views/LDWQSQ01.html?applySrc=31' },
					{ name: '劳动监察投诉', subname: 'https://ggfw.nn12333.com:8081/gx/wechat/html/laodongweiquanSQ/views/LDWQSQ01.html?applySrc=31' },
					{ name: '劳动监察举报', subname: 'https://ggfw.nn12333.com:8081/gx/wechat/html/laodongweiquanSQ/views/LDWQSQ01.html?applySrc=31' },
					{ name: '劳动监察登记查询', subname: 'https://ggfw.nn12333.com:8081/wechat/html/laodongbaozhangView/views/caseProgress.html' },
					{ name: '劳动人事仲裁申请', subname: 'https://ggfw.nn12333.com:8081/gx/wechat/html/laodongweiquanSQ/views/LDWQSQ01.html?applySrc=31' },
					{ name: '劳动人事调解申请', subname: 'https://ggfw.nn12333.com:8081/gx/wechat/html/laodongweiquanSQ/views/LDWQSQ01.html?applySrc=31' }
				];
			}
			if (title == '社保窗口') {
				this.urls = [
					{ name: '养老保险待遇发放账户维护申请', subname: 'https://ggfw.nn12333.com:8081/gx/wechat/html/materialApply/view/ylbxdyffMainPage.html?applySrc=31' },
					{ name: '转移查询', subname: 'https://ggfw.nn12333.com:8081/gx/wechat/html/laodongweiquanSQ/views/LDWQSQ01.html?applySrc=31' },
					{ name: '养老待遇发放查询', subname: 'https://ggfw.nn12333.com:8081/gx/wechat/html/yanglaoView/yanglaodyff.html?applySrc=31' }
				];
			}
		},
		selectClick(e) {
			uni.setClipboardData({
				data: e.subname,
				success: (res) => {
					uni.showModal({ content: '复制成功，请在浏览器打开', showCancel: false });
				}
			});
		},
		go(url) {
			uni.navigateTo({ url: url });
		}
	}
};
</script>

<style lang="scss">
.banner {
	margin-top: -10px;
}
.notice {
	margin-top: 10px;
	border-radius: 5px;
	overflow: hidden;
	box-shadow: $box-shadow;
}
.news {
	margin-top: 10px;
	background-color: white;
	border-radius: 7px;
	overflow: hidden;
	padding: 12px;
	box-shadow: $box-shadow;
	.gg {
		font-weight: bold;
		margin-bottom: 5px;
		border-bottom: 1px solid $line;
		padding-bottom: 10px;
		color: $font-c;
		.title {
			margin-left: 10px;
		}
		.bor {
			width: 5px;
			height: 12px;
			background-color: $main-color;
			border-radius: 20px;
			float: left;
			margin-top: -16px;
		}
		.more {
			float: right;
			font-size: 14px;
			font-weight: normal;
			margin-top: -20px;
		}
	}
	.bhe {
		height: 60px;
		overflow: hidden;
		.item {
			padding-top: 9px;
			font-size: 15px;
			overflow: hidden;
			.title {
				float: left;
				width: 80%;
			}
			.date {
				float: right;
			}
		}
	}
	.expand {
		text-align: center;
		font-size: 15px;
		color: $font-c;
		padding-top: 10px;
		.icon {
			padding-right: 3px;
		}
	}
}
.hengfu {
	height: 100px;
	width: 100%;
	border-radius: 7px;
	margin-top: 10px;
	box-shadow: 0 2px 2px 0 rgba(0, 0, 0, 0.2);
}
.ad {
	.item {
		float: left;
		width: 50%;
		overflow: hidden;
		.out {
			padding: 7px 10px 5px 10px;
			.int {
				overflow: hidden;
				border-radius: 7px;
				image {
					border-radius: 7px;
					box-shadow: 0 2px 2px 0 rgba(0, 0, 0, 0.2);
				}
			}
		}
	}
	.it {
		overflow: hidden;
		border-radius: 7px;
		box-shadow: 0 2px 2px 0 rgba(0, 0, 0, 0.2);
	}
}
</style>
