<template>
	<view>
		<view class="wrap">
			<view class="cu-list grid" :class="['col-' + gridCol,gridBorder?'':'no-border']">
				<view class="cu-item" v-for="(item,index) in gridList" :key="index" @click="gridClick(item, index)"
					v-if="index<gridCol*2 && item.show">
					<view :class="['cuIcon-' + item.cuIcon,'text-' + item.color]">
						<image :src="item.src" class="sign"></image>
					</view>
					<text>{{item.name}}</text>
				</view>
			</view>
		</view>
		<u-modal v-model="isShowAlert" :title-style="{fontSize: '18px',fontWeight:'500'}"
			:content-style="{fontSize: '14px',fontWeight:'400'}" confirm-color='#22C572' confirm-text='确定' title='温馨提示'
			:showCancelButton='false' :content="content" @confirm="goOpenService" @cancel="cancelClick"></u-modal>
		<u-modal v-model="isShowAlert1" :title-style="{fontSize: '18px',fontWeight:'500'}"
			:content-style="{fontSize: '14px',fontWeight:'400'}" confirm-color='#22C572' confirm-text='确定' title='提示'
			:showCancelButton='false' :content="content1" @confirm="alertBtn1" @cancel="cancelClick1"></u-modal>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				isShowAlert1: false,
				content1: '当前登入信息验证失败，是否重新登录？',
				isShowAlert: false,
				content: '您确定要退出吗?',
				a: false,
				inputShow: false,
				modalName: '',
				mycarStyle: '',
				feild: undefined,
				inputContent: '',
				coverTransform: 'translateY(0px)',
				coverTransition: '0s',
				moving: false,
				footprintList: [],
				isVip: false,
				userInfoTmp: [],
				inputStatus: 'none',
				carInfo: [],
				gridCol: 4,
				gridBorder: false,
				headUrl: "../../static/img/myimg/YongHu@3x.png",
				userphone: "",
				username: "请更改昵称",
				gridList: [{
						num: 0,
						name: '打卡',
						// icon: 'cuIcon-edit',
						src: '../../static/img/oa_office/clock.png',
						tips: 0,
						url: `/pages/clock/the_clock`,
						show: true
					},
					{
						num: 1,
						name: '请假',
						// icon: 'cuIcon-edit',
						src: '../../static/img/oa_office/leave.png',
						tips: 0,
						url: `/pages/leave/the_leave`,
						show: true
					},
					{
						num: 2,
						name: '加油申请',
						// icon: 'cuIcon-edit',
						src: '../../static/img/oa_office/fulling.png',
						tips: 0,
						url: `/pages/fuelfilling/the_fuel_filling`,
						show: true
					},
					{
						num: 3,
						name: '短途记录',
						// icon: 'cuIcon-edit',
						src: '../../static/img/oa_office/shortfull.png',
						tips: 0,
						url: `/pages/shortDistance/short_distance_record`,
						show: true
					},
					{
						num: 4,
						name: '报销',
						// icon: 'cuIcon-edit',
						src: '../../static/img/oa_office/reimbursement.png',
						tips: 0,
						url: `/pages/reimbursement/the_reimbursement`,
						show: true
					},
					{
						num: 5,
						name: '申请审批',
						// icon: 'cuIcon-edit',
						src: '../../static/img/oa_office/shneqingshenpi.png',
						tips: 0,
						url: `/pages/universalityAudit/list`,
						show: true
					}
				],

			}
		},
		onShow() {
			uni.hideKeyboard()
			// uni.showTabBar()
			// this.$api.doRequest('get', '/commonUser/api/checkSession').then(res => {
			// 	console.log("checkSession", res)
			// 	if (res.data.data == "INVALID") {
			// 		this.isShowAlert1 = true;
			// 	}
			// })
			console.log("hasLogin", this.hasLogin)
			if (this.userInfo) {
				if (!this.userInfo.avatarUrl) {
					this.headUrl = "../../static/img/myimg/YongHu@3x.png"
				} else {
					this.headUrl = this.userInfo.avatarUrl
				}
				this.username = this.userInfo.userName
				this.userphone = this.userInfo.phone
				var that = this
				this.$api.doRequest('get', '/newNoticeTask/query/noticeTasks').then(res => {
					console.log("noticeNumber", res)
					if (res.data.data) {
						let name = 'myTip';
						let value = res.data.data.total;
						that.$store.commit('$uStore', {
							name,
							value
						});
						if (value != 0 && value) {
							uni.setTabBarBadge({
								index: 4,
								text: value + ""
							})
						}
						name = 'taskTip';
						value = res.data.data.total;
						that.$store.commit('$uStore', {
							name,
							value
						});
					}
				})
			} else {
				this.headUrl = "../../static/img/myimg/YongHu@3x.png"
				this.username = "立即登录"
			}
			console.log("this.userInfo", this.userInfo)
		},
		methods: {
			alertBtn1() {
				uni.navigateTo({
					url: '/pages/public/login'
				})
			},
			cancelClick() {
				this.isShowAlert = false
			},
			cancelClick1() {
				this.isShowAlert = false
			},
			goOpenService() {
				uni.hideTabBarRedDot({
					index: 3
				})
				this.$store.commit('logout')
				this.$api.logout()
				uni.navigateTo({
					url: `/pages/public/login`
				})
			},
			gridClick(item, index) {
				var that = this
				if (!this.hasLogin) {
					uni.showModal({
						title: '提示',
						content: '您尚未登录，是否立即登录？',
						showCancel: true,
						confirmText: '登录',
						success: (e) => {
							if (e.confirm) {
								uni.navigateTo({
									url: '/pages/public/login'
								})
							}
						},
						fail: () => {},
						complete: () => {}
					})
				} else {
					if (item.url) {
						uni.navigateTo({
							url: item.url
						})
					}
				}
			},
		}
	}
</script>

<style lang='scss' scoped>
	page {
		background: #F5F6FA;
	}

	.container {
		padding-top: 85px;
		padding-top: 35px;
		background-color: #F5F6FA;
		position: relative;
		width: 100vw;
		height: 100vh;
		overflow: hidden;
		background: url('~@/static/img/login/bg_slices/bg@3x.png');
		background-size: 100% 100%;
		margin: 0 auto;
	}

	.cu-tag.badge {
		right: 26rpx;
	}

	.path {
		color: #007aff;
		display: inline-block;
		text-align: center;
	}

	.icon {
		margin-right: 10rpx;
	}

	.portrait-box {
		margin-top: 20rpx;
	}

	.qr-wrap {
		margin-top: 20upx;
		color: #fff;
		font-size: 32rpx;
	}

	.cu-list {
		/* height: 483rpx;
		overflow-y: scroll; */
		background: transparent;
	}

	.cu-list.grid.no-border {
		padding: 0;
	}

	.badge_user {
		color: #fff;
		background-color: #dc3545;
		display: inline-block;
		padding: .25em .4em;
		font-size: 75%;
		font-weight: 700;
		line-height: 1;
		text-align: center;
		white-space: nowrap;
		vertical-align: top;
		border-radius: 50%;
		transition: color .15s ease-in-out, background-color .15s ease-in-out, border-color .15s ease-in-out, box-shadow .15s ease-in-out;
	}

	@keyframes move_wave {
		0% {
			transform: translateX(0) translateZ(0) scaleY(1)
		}

		50% {
			transform: translateX(-25%) translateZ(0) scaleY(0.55)
		}

		100% {
			transform: translateX(-50%) translateZ(0) scaleY(1)
		}
	}

	.bg {
		position: relative;
		height: 300rpx;
		/* background: linear-gradient(to bottom, #56ccf2, #2f80ed); */
		/*background: linear-gradient(to bottom, #0be9fe, #4bb0fe); */
		background: linear-gradient(to bottom, #d5f8ff, #56ccf2);

	}

	.bg_ware {
		position: absolute;
		left: 0;
		bottom: -2rpx;
		width: 100%;
		mix-blend-mode: screen;
		height: 224rpx;
	}

	%flex-center {
		display: flex;
		flex-direction: column;
		justify-content: center;
		align-items: center;
	}

	%section {
		display: flex;
		justify-content: space-around;
		align-content: center;
		background: #fff;
		border-radius: 10upx;
	}

	.grid-item-box {
		flex: 1;
		/* position: relative;
 */
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		flex-direction: column;
		align-items: center;
		justify-content: center;
		padding: 15px 0;
	}

	.image {
		width: 80rpx;
		height: 80rpx;
	}

	.text {
		font-size: 26rpx;
		margin-top: 10rpx;
	}

	.user-section {
		height: 520upx;
		padding: 100upx 30upx 0;
		position: relative;

		.bg {
			position: absolute;
			left: 0;
			top: 0;
			width: 100%;
			height: 100%;
			filter: blur(1px);
			box-shadow: 0px 1px 8px #ccc;
			/* background:linear-gradient(#0eb0c9,#126bae); */
			/* opacity: .7; */
		}
	}

	.user-info-box {
		height: 180upx;
		/* display:flex; */
		/* align-items:center; */
		text-align: center;
		position: relative;
		z-index: 1;

		.portrait {
			width: 130upx;
			height: 130upx;
			border: 5upx solid #fff;
			border-radius: 50%;
		}

		.username {
			font-size: $font-lg + 3upx;
			color: #fff;
			margin-top: 20upx;
		}
	}

	.vip-card-box {
		display: flex;
		flex-direction: column;
		color: #f7d680;
		height: 240upx;
		background: linear-gradient(left, rgba(0, 0, 0, .7), rgba(0, 0, 0, .8));
		border-radius: 16upx 16upx 0 0;
		overflow: hidden;
		position: relative;
		padding: 20upx 24upx;

		.card-bg {
			position: absolute;
			top: 20upx;
			right: 0;
			width: 380upx;
			height: 260upx;
		}

		.b-btn {
			position: absolute;
			right: 20upx;
			top: 16upx;
			width: 132upx;
			height: 40upx;
			text-align: center;
			line-height: 40upx;
			font-size: 22upx;
			color: #36343c;
			border-radius: 20px;
			background: linear-gradient(left, #f9e6af, #ffd465);
			z-index: 1;
		}

		.tit {
			font-size: $font-base+2upx;
			color: #f7d680;
			margin-bottom: 28upx;

			.yticon {
				color: #f6e5a3;
				margin-right: 16upx;
			}
		}

		.e-b {
			font-size: $font-sm;
			color: #d8cba9;
			margin-top: 10upx;
		}
	}

	.cover-container {
		padding: 1px 10px;
		padding-bottom: 200upx;

		/* background-color: #F5F6FA; */
		/* 	border-radius: 20px; */
		margin-top: 60upx;

		.arc {
			position: absolute;
			left: 0;
			top: -34upx;
			width: 100%;
			height: 36upx;
		}
	}

	.tj-sction {
		@extend %section;

		.tj-item {
			@extend %flex-center;
			flex-direction: column;
			height: 140upx;
			font-size: $font-sm;
			color: #75787d;
		}

		.num {
			font-size: $font-lg;
			color: $font-color-dark;
			margin-bottom: 8upx;
		}
	}

	.order-section {
		@extend %section;
		padding: 28upx 0;
		margin-top: 20upx;

		.order-item {
			@extend %flex-center;
			width: 120upx;
			height: 120upx;
			border-radius: 10upx;
			font-size: $font-sm;
			color: $font-color-dark;
		}

		.yticon {
			font-size: 48upx;
			margin-bottom: 18upx;
			color: #fa436a;
		}

		.icon-shouhoutuikuan {
			font-size: 44upx;
		}
	}

	.history-section {
		padding: 30upx 0 0;
		margin-top: 20upx;
		background: #fff;
		border-radius: 10upx;

		.sec-header {
			display: flex;
			align-items: center;
			font-size: $font-base;
			color: $font-color-dark;
			line-height: 40upx;
			margin-left: 30upx;

			.yticon {
				font-size: 44upx;
				color: #5eba8f;
				margin-right: 16upx;
				line-height: 40upx;
			}
		}

		.h-list {
			white-space: nowrap;
			padding: 30upx 30upx 0;

			image {
				display: inline-block;
				width: 160upx;
				height: 160upx;
				margin-right: 20upx;
				border-radius: 10upx;
			}
		}
	}

	.grid {
		display: flex;
		align-items: center;
		flex-wrap: wrap;

		/* border-top: 2upx solid rgba(172,172,172,.2); */
		.grid-item-3 {
			box-sizing: border-box;
			width: calc(100% / 3);
			border-bottom: 2upx solid rgba(172, 172, 172, .2);
			border-right: 2upx solid rgba(172, 172, 172, .2);
			text-align: center;
			padding: 40upx 0;
			position: relative;

			/* view{
				font-size: $font-sm;
				margin-top: 16upx;
				color: $font-color-dark;
			} */
			.grid_icon {
				font-size: 48upx;
				margin-bottom: 18upx;
				color: #fa436a;
			}

			.tip_text {
				display: block;
				padding: 4upx 8upx;
				text-align: center;
				border-radius: 36upx;
				font-size: 24upx;
				background-color: #fa436a;
				color: rgba(255, 255, 255, 1);
				position: absolute;
				right: 6upx;
				top: 6upx;
			}
		}

		.grid-item-3:nth-child(3n + 3),
		.grid-item-4:nth-child(4n + 4) {
			border-right: none;
		}
	}

	.headPortrait {
		width: 75px;
		height: 75px;
		border-radius: 40px;
		border: 2px solid #ffffff;
	}

	.personal {
		margin-top: 10px;
		margin-left: 20px;
	}

	.information {
		font-size: 15px;
		font-weight: 600;
		height: 36px;
	}

	.indexlow {
		/* margin-top: 30px; */
		border-radius: 10px;
	}

	.cu-list>.cu-item:after {
		border: none;
	}
	.cu-list>.cu-item{
		text-align:center;
	}
	.sign {
		width: 40px;
		height: 40px;
		top: 4px;
		margin: 3px auto;
	}

	.indexUp {
		padding: 0 20px;
		align-items: center;
	}

	.wrap {
		background: #fff;
		margin: 10px;
		border-radius: 10px;
		padding: 10px;

		.title {
			font-size: 16px;
		}
	}

	.content2 {
		display: flex;
		justify-content: space-between;
	}
</style>
