<template>
	<view class="home main-bg shadow">
		<view class="home-header header-long-bg">
			<view class="header-text font-forty font-color1">惠军通</view>
			<image class="header-img" src="../../../static/img.png"></image>
		</view>
		<view class="add">
			<view class="add-title font-thirty font-color3">服务推荐</view>
			<view class="add-view">
				<view class="add-list shadow3 padding" @click="goto('/pages/soldier/home/folder1/index')">
					<view class="list-title font-thirty-two font-color3">
						惠军服务
					</view>
					<view class="list-icon font-twenty-two font-color1">最新</view>
					<image src="../../../static/1.png"></image>
				</view>
				<view class="add-list shadow3" @click="goto('/pages/soldier/home/folder2/index')">
					<view class="list-title font-thirty-two font-color3">
						拥军联盟
					</view>
					<view class="list-icon font-twenty-two font-color1">热门</view>
					<image src="../../../static/3.png"></image>
				</view>
				<!-- @click="makePhone()" -->
				<view class="add-list shadow3 padding" @click="goto('/pages/soldier/home/folder3/index')">
					<view class="list-title font-thirty-two font-color3">
						政策宣传
					</view>
					<image src="../../../static/2.png"></image>
				</view>
				<view class="add-list shadow3" @click="goto('/pages/soldier/home/folder4/index')">
					<view class="list-title font-thirty-two font-color3">
						创业就业
					</view>
					<image src="../../../static/4.png"></image>
				</view>
				<view class="add-list shadow3 padding" @click="goto('/pages/soldier/home/folder5/index')">
					<view class="list-title font-thirty-two font-color3">
						志愿拥军
					</view>
					<image src="../../../static/53.png"></image>
				</view>
				<view class="add-list shadow3" @click="goto('/pages/soldier/home/folder6/index')">
					<view class="list-title font-thirty-two font-color3">
						咨询问答
					</view>
					<image src="../../../static/6.png"></image>
				</view>
				<view class="add-list shadow3 padding" @click="gotoTab('/pages/soldier/home/folder7/index')">
					<view class="list-title font-thirty-two font-color3">
						退役军人管理
					</view>
					<image src="../../../static/7.png"></image>
				</view>
				<view class="add-list shadow3" @click="gotoData('/pages/soldier/user/add')">
					<view class="list-title font-thirty-two font-color3">
						信息采集
					</view>
					<image src="../../../static/8.png"></image>
				</view>
			</view>
		</view>
		<u-tabbar :show="show" :list="tabBarList" :active-color="activeColor" :inactive-color="inactiveColor"
					:border-top="borderTop"></u-tabbar>
		<u-toast ref="uToast" />
	</view>
</template>

<script>
	import server from "@/api/index";
	import { mapGetters } from 'vuex'
	export default {
		data() {
			return {
				borderTop: false,
				inactiveColor: '#ccc',
				activeColor: '#2E4F1C',
				show: false,
			}
		},
		computed: {
			...mapGetters([
				'tabBarList',
				'role'
			])
		},
		onShow(){
			console.log('onShow111')
		},
		onLoad() {
			let role = uni.getStorageSync('role');
			console.log('role', role)
			if(role === '3' || role === '2'){
				this.show = true;
			}else{
				this.show = false;
			}
		},
		methods: {
			showSoldier(){
				console.log("show,solider9999")
				let role = uni.getStorageSync('role');
				console.log('role', role)
				if(role === '3' || role === '2'){
					this.show = true;
				}else{
					this.show = false;
				}
			},
			goto(url){
				uni.navigateTo({
					url
				});
			},
			gotoData(url){
				console.log("===================================================")
				console.log('url',url)
				let role = uni.getStorageSync('role');
				if(role){
					this.role = role;
				}
				if(role === '4'){
					uni.navigateTo({
						url
					});
				}else{
					uni.navigateTo({
						url: '/pages/login/index?id=4&type=add'
					});
				}
			},
			gotoTab(url){
				console.log('url',url)
				let role = uni.getStorageSync('role');
				if(role){
					this.role = role;
				}
				if(role === '4'){
					uni.navigateTo({
						url
					});
				}else{
					uni.navigateTo({
						url: '/pages/login/index?id=4'
					});
				}
			},
			map(){
				this.$refs.uToast.show({
					title: '即将上线，敬请期待!',
					type: 'default',
				})
			},
			makePhone(){
				server.getTelInfo().then(res =>{
					if(res){
						uni.makePhoneCall({
							phoneNumber:res,
							success: (res) => {
								console.log(res)
							},
							fail: (err) => {
								console.error(err)
							}
						})
					}else{
						this.$refs.uToast.show({
							title: '暂无热线电话!',
							type: 'default',
						})
					}
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.home{
		width: 100%;
		min-height: 100vh;
		height: auto;
		position: relative;
		.home-header{
			width: 100%;
			height: 350rpx;
			border-bottom-left-radius: 50rpx;
			border-bottom-right-radius: 50rpx;
			padding-top: 84rpx;
			padding-left: 30rpx;
			position: relative;
			.header-text{
				height: 96rpx;
				line-height: 96rpx;
			}
			.header-img{
				position: absolute;
				top: 180rpx;
				left: 30rpx;
				width: calc(100% - 60rpx);
				height: 360rpx;
				border-radius: 24rpx;
			}
		}
		.add{
			margin-top: 190rpx;
			width: calc(100% - 30rpx);
			height: 1038rpx;
			padding-left: 30rpx;
			.add-title{
				height: 120rpx;
				line-height: 120rpx;
				font-weight: 550;
				letter-spacing: 2rpx;
			}
			.add-view{
				display: flex;
				flex-wrap: wrap;
				justify-content: left;
				.add-list{
					width: calc(50% - 16rpx);
					height: 200rpx;
					border-radius: 8rpx;
					margin-bottom: 30rpx;
					padding-left: 30rpx;
					padding-top: 40rpx;
					position: relative;
					.list-title{
						font-weight: 550;
						letter-spacing: 2rpx;
					}
					.list-icon{
						width: 96rpx;
						height: 36rpx;
						margin-top: 26rpx;
						background: linear-gradient(270deg, rgba(204, 16, 25, 0.5) 0%, #CC1019 100%);
						border-radius: 24rpx;
						text-align: center;
					}
					image{
						width: 128rpx;
						height: 120rpx;
						position: absolute;
						bottom: 5rpx;
						right: 0rpx;
					}
				}
				.padding{
					margin-right: 30rpx;
				}
			}
		}
	}
</style>
