<template>
	<view class="content">
		
		<view class="banner">
			<view class="head-div flex">
				<view style="width: 118rpx;height: 118rpx;overflow: hidden;border-radius: 50%;">
					<image style="width: 118rpx;" :src="userInfo.image" mode="widthFix"></image>
				</view>
				<view style="padding: 10rpx 34rpx;">
					<view class="nickname">{{ userInfo.title }}</view>
					<view class="days">{{ userInfo.notes }}</view>
					<view class="font-n" v-if="userInfo.realOk == 'Y'">已完成实名认证</view>
				</view>
			</view>
			<view style="position: absolute; top: 96rpx;right: 32rpx;">
				<image src="/static/icons/icon8.png" mode="aspectFit" style="width: 32rpx; height: 32rpx"></image>
			</view>
		</view>
		
		<view class="flex"
		style="padding: 30rpx;">
			<view style="
			width: 13rpx;height: 30rpx;
			background: #EF8C94;border-radius: 6rpx;"/>
			<view class="head-title">总佣金</view>
		</view>

		<view class="one-card b-relative">
			<image style="width: 675rpx;height: 200rpx;" 
			src="/static/ms/tx.png"></image>
			<view class="font-4">
				<view>总佣金</view>
				<view class="font-5">
					<span style="font-size: 32rpx;margin-right: 10rpx">¥</span>{{ belece.money }}
				</view>
			</view>
			<view class="button-cz" @click="clickWallet">立即提现</view>
		</view>
		
		<view class="flex"
		style="padding: 30rpx;">
			<view style="
			width: 13rpx;height: 30rpx;
			background: #EF8C94;border-radius: 6rpx;"/>
			<view class="head-title">一键求救</view>
		</view>
		
		<view class="Ask-for-help">
			<view class=""
			style="height: 270rpx;
			margin: 10rpx;
			flex: 1;background-color: #000;
			position: relative;">
				
				<!-- 这里调用地图 -->
				
				<view style="position: absolute;
				bottom: 0;
				left: 0;
				height: 50rpx;
				width: 100%;
				color: #FF6470;
				font-size: 24rpx;
				text-align: center;
				line-height: 50rpx;
				background-color: #EF8C9499;
				">
					实时获取你当前的位置
				</view>
			</view>
			<view
			style="height: 300rpx;flex: 1;font-size: 26rpx;">
				<view style="background-color: #00000011;
				color: #0E510D;
				margin: 10rpx auto;width: 80%;padding: 10rpx;">
					如果你遇到了让你感到不安全情况下，可点击下方
				</view>
				<view
				style="width: 80%;margin: 20rpx auto;
				background-color: #FF6470;padding: 20rpx 0;
				color: #fff;text-align: center;
				border-radius: 10rpx;">
					一键求救
				</view>
				<view style="font-size: 22rpx;text-align: center;">
					我们会立即发送您的求救位置
				</view>
			</view>
		</view>
		
		<!-- <view class="flex"
		style="padding: 30rpx;">
			<view style="
			width: 13rpx;height: 30rpx;
			background: #EF8C94;border-radius: 6rpx;"/>
			<view class="head-title">请假日历</view>
		</view> -->
		
		<van-calendar
		title="请假日历"
		color="rgb(255, 100, 112)"
		type="multiple"
		:default-date="defaultDate"
		@select="onConfirm"
		switch-mode="year-month"
		:formatter="formatter"
		:style="{ height: '300px' }"
		/>
		
		<view class="two-card">
			<view class="flex">
				<view style="width: 10rpx;height: 30rpx;
				background: #EF8C94;border-radius: 6rpx;"/>
				<view class="head-title">常用功能</view>
			</view>
			<view style="background-color: #fff;border-radius: 16rpx;">
				<view class="flex icons">
					<view class="menuItem" @click="clickUpload">
						<image class="icon" src="/static/icons/photo-album.png"/>
						<view class="title">我的相册</view>
					</view>
					<view class="menuItem" @click="clickSettled">
						<image class="icon" src="/static/icons/m2.png" />
						<view class="title">邀请入驻</view>
					</view>
					<view class="menuItem" @click="clickService">
						<image class="icon" src="/static/icons/m3.png" />
						<view class="title">联系客服</view>
					</view>
					<view class="menuItem" @click="clickAuthentication">
						<image class="icon" src="/static/icons/m4.png" />
						<view class="title">实名认证</view>
					</view>
				</view>
				<view class="flex icons"
				style="margin-top: 0;">
					<view class="menuItem" @click="clickServerTime">
						<image class="icon" src="/static/icons/m1.png" />
						<view class="title">服务时间</view>
					</view>
					<view class="menuItem" @click="logout">
						<image class="icon" src="/static/icons/exit.png" />
						<view class="title">退出登录</view>
					</view>
				</view>
			</view>
		</view>
		
		
		<configPopup
		:keyValue="keyValue"
		:show="configPopupShow"
		:list="config"
		@close="configPopupShow = false"/>
	</view>
</template>

<script>
	import configPopup from '@/components/configPopup'
	export default {
		components : {
			configPopup
		},
		data() {
			return {
				userInfo : {},
				belece : {},
				configPopupShow : false,
				keyValue : 'phone',
				config : [],
				phone : '',
				defaultDate : []
			}
		},
		onShow() {
			this.getUserInfo()
			this.getConfig()
		},
		methods: {
			formatter(day){
				
				this.defaultDate.forEach(n => {
					if(day.date.getMonth() == n.getMonth()
					&& day.date.getDate() == n.getDate()){
						day.bottomInfo = '请假';
					}
				})
				
				return day
			},
			onConfirm(dates){
				this.defaultDate = dates
			},
			getUserInfo() {
				this.$api('giveTenInfo', {}, res => {
					if (res.code == 200) {
						this.userInfo = res.result.msgTen;
						this.belece = res.result.belece;
					}
					if (res.code == 500 && res.message === '操作失败，用户不存在!') {
						uni.removeStorageSync('token')
						uni.removeStorageSync('userInfo')
						uni.navigateTo({
							url: '/pages/login/login'
						})
					}
				})
			},
			getConfig() {
				// this.vid = uni.getStorageSync("ivcode");
				this.$api('getConfig', {} ,res => {
					if(res.code == 200){
						res.result.forEach(n => {
							if(n.keyValue == 'phone'){
								this.phone = n.name
							}
						})
						this.config = res.result
					}
				})
			},
			logout(){
				uni.removeStorageSync('token')
				uni.removeStorageSync('userInfo')
				uni.showToast({
					title: '已退出',
					icon: 'none'
				})
				uni.navigateTo({
					url: '/pages/login/mobile'
				})
			},
			clickUpload(){ uni.navigateTo({ url: '/pages/mine/upload' }) },
			clickSettled(){ uni.navigateTo({ url: '/pages/mine/settled' }) },
			clickWallet(){ uni.navigateTo({ url: '/pages/mine/wallet'}) },
			clickServerTime(){ uni.navigateTo({ url: `/pages/mine/serverTime?uid=${this.userInfo.id}` }) },
			clickAuthentication(){ uni.navigateTo({ url: '/pages/mine/authentication'}) },
			clickService(){ uni.makePhoneCall({ phoneNumber: this.phone, success:() => {}, fail: () => {} });},
			
		}
	}
</script>

<style scoped>
	body{
		background-color: #f5f5f5;
	}
	.content{
		padding-bottom: 200rpx;
	}
	
	.font-n {
		height: 42rpx;
		line-height: 42rpx;
		font-size: 20rpx;
		font-family: PingFang SC, PingFang SC-Medium;
		font-weight: 500;
		text-align: center;
		color: #fdfaf8;
	
		width: 168rpx;
		background: #4eed78;
		border-radius: 8px;
	
		margin-top: 5rpx;
		margin-left: 0rpx;
	}
	
	.banner {
		width: 100%;
		/* height: calc(392rpx - 60rpx); */
		/* background: #fff; */
	}
	.head-div{
		width: calc(100vw - 72rpx);
		height: 168rpx;
		padding: 72rpx 36rpx 0;
		margin: 0 auto;
	}
	.nickname{
		font-size: 36rpx;
		font-family: PingFang SC, PingFang SC-Bold;
		font-weight: 700;
		text-align: left;
		color: #323232;
		line-height: 42rpx;
	}
	.days{
		font-size: 28rpx;
		font-family: PingFang SC, PingFang SC-Regular;
		font-weight: 400;
		text-align: left;
		color: #ababab;
		line-height: 40rpx;
	}
	
	
	.one-card{
		width: 678rpx;
		border-radius: 16rpx;
		margin: 0 auto 0;
	}

	.two-card{
		width: calc(675rpx);
		height: 228rpx;
		border-radius: 16rpx;
		margin: 20rpx auto;
		padding: 40rpx 0;
	}
	.title{
		height: 40rpx;
		line-height: 40rpx;
		font-size: 28rpx;
		font-family: PingFang SC, PingFang SC-Regular;
		font-weight: 400;
		text-align: center;
		color: #2f2e2e;
		margin-top: 15rpx;
	}
	.icons{
		width: 100%;
		box-sizing: border-box;
		margin-top: 30rpx;
		padding: 20rpx 0rpx;
	}
	.icon{
		margin: 0 32rpx;
		width: 48rpx;
		height: 48rpx;
		border-radius: 50%;
	}
	.head-title{
		font-size: 30rpx;
		font-family: PingFang SC, PingFang SC-Bold;
		color: #2f2e2e;
		line-height: 30rpx;
		margin-left: 10rpx;
		font-weight: 700;
	}


	.font-4{
		font-size: 28rpx;
		font-family: PingFang SC, PingFang SC-Bold;
		font-weight: 700;
		text-align: left;
		color: #ffffff;
		text-shadow: 0 4rpx 6rpx 0 rgba(40,170,133,0.81);
		line-height: 44rpx;

		position: absolute;
		top: 32rpx;
		left: 52rpx;
		z-index: 1;
	}
	.font-5{
		font-size: 42rpx;
		font-family: PingFang SC, PingFang SC-Bold;
		font-weight: bolder;
		text-align: left;
		color: #ffffff;
		line-height: 72rpx;
		text-shadow: 0 4rpx 6rpx 0 rgba(0,0,0,0.16);
	}
	.button-cz{
		width: 200rpx;
		height: 58rpx;
		line-height: 58rpx;
		background: linear-gradient(182deg,#ffffff 2%, #FFD8DC 88%);
		border-radius: 30rpx;
		box-shadow: 0 6rpx 12rpx 0 #ababab55;

		font-size: 28rpx;
		font-family: PingFang SC, PingFang SC-Bold;
		font-weight: 700;
		text-align: center; 
		color: #EF8C94;

		position: absolute;
		top: 72rpx;
		right: 52rpx;
		z-index: 1;
	}
	
	.menuItem{
		width: 25%;
		display: flex;
		flex-direction: column;
		align-items: center;
	}
	
	.Ask-for-help{
		background-color: #ffffff;
		margin: 0 40rpx;
		display: flex;
	}
</style>
