<template>
	<view class="commonPage commonPageBox">
		<view class="bg_top">
			<u-icon @click="goSetting" class="setIcon" labelColor="#5188e5" labelPos="bottom" label="设置" name="setting"
				:style="`top:${(20 + statusBarHeight) * 2}rpx`" color="#5188e5" size="22"></u-icon>
		</view>

		<view class="mine_box" :style="`top:${(80 + statusBarHeight) * 2}rpx`">
			<view class="per_mes">
				<view class="per_mes_user">
					<view style="display: flex; align-items: center; flex-direction: column">
						<image @click="goUserInfo" :src="userMes.avatar" v-if="userMes.avatar&&userMes.avatar!=''"
							class="per_mes_img color_shandow"></image>
						<image src="../../static/image.png" v-if="userMes.avatar == null||userMes.avatar == ''"
							class="per_mes_img color_shandow"></image>
					</view>
				</view>
				<view class="userInfoBox">
					<view class="name">{{ userMes.nickname ? userMes.nickname : "未设置" }}</view>
					<view class="phone" v-if="userMes.tel">手机号：({{ userMes.tel }})</view>
				</view>
				<br clear="both" />
			</view>
			
			<view class="modal_vip" v-if="$platform=='android'">
				<template>
					<view class="chong_zhi boxShadow box_fillet vip_box">
						<view class="noVip">
							<view style="display: flex; align-items: center;">
								<view class="zhanghu" style="text-align: left">
									<image class="vip_image" src="@/static/icon/vip.png" mode="aspectFit"></image>
									<text style="color: #fff; font-size: 60rpx; padding-left: 10rpx;" v-if="aiVipLog==null">VIP</text>
								</view>
								<view class="vip_block" v-if="aiVipLog!=null">
									<view class="vip_infor_item">
										<text v-if="aiVipLog.type==1">月度{{aiVipLog.count}}次</text>
										<text v-if="aiVipLog.type==2">季度{{aiVipLog.count}}次</text>
										<text>（有效期到 {{aiVipLog.endTime.split(' ')[0]}})</text>
									</view>
								</view>
								<view v-else class="vip_null">办理VIP，畅享更多专属权益</view>
							</view>
							<view class="vip_btn" @click="onPageJump('/pages/vip/index?flag='+flag)">
								<button v-if="flag==1">去升级</button>
								<button v-if="flag==0">去办理</button>
							</view>
						</view>
					</view>
				</template>
			</view>
			
			<view class="recharge_block">
				<view class="chong_zhi boxShadow box_fillet chongzhi_box">
					<view class="chong_list">
						<view class="left">
							<view class="chong_list_item" @click="onPageJump('/pages/wallet/account')">
								<view class="pay_item_img">
									天医币
									<u-icon @click.native.stop="openInfo()" 
										name="question-circle"
										style="float: right; margin: 0 6rpx">
									</u-icon>
								</view>
			
								<view class="text" style="line-height:30rpx; display: flex">
									{{userMes.peanutCoin ? userMes.peanutCoin : 0}}
								</view>
							</view>
			
							<view class="chong_list_item" @click="onPageJump('/pages/wallet/points')" v-if="$platform=='android'">
								<view class="pay_item_img">
									积分
								</view>
								<view class="text" style="line-height:30rpx">{{userMes.jf ? userMes.jf : 0}}</view>
							</view>
						</view>
						
						<view class="chong_list_item" style="flex-direction:initial;margin-right:0;">
							<view class="chong_btn" @click="onPageJump('/pages/wallet/recharge')">充 值</view>
						</view>
					</view>
				</view>
			</view>
			
			<view class="list_box">
				<view class="xiugai boxShadow box_fillet">
					<common-list :dataList="pageList" @hancleClick="handleClickTab" label="name">
						<template slot="rightSlot" slot-scope="slotProps">
							<text class="fdButtonBox aui-text-success"
								style="line-height: 40rpx">{{ slotProps.row.content }}</text>
						</template>
					</common-list>
				</view>
			</view>
		</view>
		
		<u-popup :show="infoShow" mode="center" round="6" backgroundColor="#fff">
			<view class="popup_box">
				<view class="title">温馨提示</view>
		
				<view class="content">
					<view class="center">
						&nbsp;&nbsp;&nbsp;&nbsp;【天医币】仅为我平台支付使用币种 。
						一人民币=一天医币，仅为了方便用户支付使用。<br />【天医币】可以用于在我平台支付书籍或课程使用。
						<br />【天医币】这个名称是为适应我们平台的定位属性，所起名称。与区块链虚拟货币无任何关系。
					</view>
		
					<view class="bottom">
						<view class="button_box" style=" align-items: center; justify-content: center;">
							<u-button style="width: 200rpx; float: center" :plain="true" text="知道啦" color="#9b9b9b"
								size="small" @click="infoShow = false"></u-button>
						</view>
					</view>
				</view>
			</view>
		</u-popup>
		
		<z-navigation></z-navigation>
	</view>
</template>

<script>
import $http from "@/config/requestConfig.js";
import {
	mapState,
	mapMutations
} from "vuex";
export default {
	data() {
		return {
			userMes: {},
			pageList: [
				{
					name: "我的病历夹",
					url: "/pages/folder/index",
					type: "pageJump",
				},
				{
					name: "会话记录",
					url: "/pages/my/recordsList",
					type: "pageJump",
				},
				{
				    name: "我的订单",
				    url: "/pages/order/index",
				    type: "pageJump"
				},
				{
				    name: "我的课程",
				    url: "/pages/curriculum/index/index",
				    type: "pageJump"
				},
				{
					name: "个人资料",
					url: "/pages/my/persData",
					type: "pageJump",
				},
				{
					name: "关于我们",
					url: "/pages/my/aboutUs",
					type: "pageJump",
				},
				{
					name: "问题反馈/申诉",
					url: "/pages/user/workOrder",
					type: "pageJump"
				}
			],
			infoShow: false, // 显示电子书相关
			aiVipLog: null,
			flag: null
		};
	},
	computed: {
		...mapState(["userInfo"]),
	},
	//第一次加载
	onLoad(e) {
		uni.hideTabBar();
	},
	//页面显示
	onShow() {
		this.getData();
		this.getVipData();
	},
	//方法
	methods: {
		...mapMutations(["setUserInfo"]),
		//跳转设置
		goSetting() {
			this.onPageJump("/pages/my/set");
		},
		//获取个人信息
		goUserInfo() {
			this.onPageJump("/pages/my/persData");
		},
		//点击切换
		handleClickTab(v) {
			switch (v.type) {
				case "pageJump":
					this.onPageJump(v.url);
					break;
				case "switchTab":
					this.switchTab(v.url);
					break;
			}
		},
		//点击天医币显示弹窗
		openInfo() {
			this.infoShow = true;
		},
		//获取个人信息
		getData() {
			if (this.userInfo.id != undefined) {
				this.$http.post("common/user/getUserInfo").then((res) => {
					this.userMes = res.result;
				});
			}
		},
		//获取数据
		getVipData() {
			this.$http.request({
				url: 'taihumed/aiVip/getUserAiVip',
				method: "POST",
				data: {},
				header: {
					"Content-Type": "application/json",
				},
			})
			.then(res=> {
				if(res.code==0){
					this.aiVipLog = res.aiVipLog;
					this.flag = res.flag;
				}
			});
		},
		onPageJump(url) {
			uni.navigateTo({
				url: url,
			});
		},
		switchTab(url) {
			uni.switchTab({
				url: url,
			});
		},
	},
};
</script>

<style lang="scss" scoped>
@import "@/static/mixin.scss";
.commonPage{
	background-image: linear-gradient(to bottom, #d8e6ff 20%, #ffffff 100%);
}
.per_mes {
	padding: 0 30rpx;
	margin-bottom: 20rpx;
	position: relative;
	align-items: center;
	display: flex;
	align-items: center;

	.per_mes_img {
		width: 120rpx;
		height: 120rpx;
		border-radius: 90rpx;
		margin: 0 0 0 0;
		float: left;
	}
	.userInfoBox{
		padding-left: 20rpx;
	}

	view {
		
		.name {
			width: 100%;
			font-size: 30rpx;
			line-height: 40rpx;
			color: #333;
		}

		.phone {
			font-size: 26rpx;
			line-height: 42rpx;
			color: #666;
		}
		.per_user_img {
			display: inline-block;
			width: 40upx;
			height: 40upx;
			margin-left: 10rpx;
			vertical-align: super;
		}
	}
}

.now_vip {
	background-color: #fff;
	margin: 0 0 30upx 0;
	padding: 0 30upx;
	height: 120upx;
	background-image: linear-gradient(90deg, #feeed6 0%, #f5ce99 100%);

	image {
		width: 46rpx;
		height: 50rpx;
		display: inline-block;
		vertical-align: text-bottom;
		margin: 0 10rpx 0 0;
	}

	text {
		font-size: 30upx;
		line-height: 120upx;
		color: #977749;
		font-weight: bold;
	}

	.kt_btn {
		font-size: 26upx;
		display: block;
		float: right;
		border-radius: 50rpx;
		color: #fffbf6;
		padding: 12rpx 26rpx;
		margin: 33rpx 0 0 0;
		background-image: linear-gradient(90deg, #dfa964 0%, #7f5218 100%);
	}
}

.chong_zhi {
	box-shadow: none;
	padding: 0 30upx;
	height: auto;

	.zhanghu {
		width: 100%;
		margin-bottom: 10rpx;
		font-size: 44rpx;
		font-weight: bold;
		display: flex;
		align-items: center;
		justify-content: space-between;
		color: $themeColor;
		font-weight: 700;
	}

	.noVip {
		width: 100%;
		height: 100%;
		display: flex;
		align-items: center;
		justify-content: space-between;
		padding: 0 20rpx;
		.zhanghu {
			font-size: 42rpx;
			width: auto;
			display: inline-block;
			margin-bottom: 0rpx;
			text-align: center;
			display: flex;
			align-items: center;
		}
	}

	.chong_list {
		display: flex;
		align-items: center;
		font-size: 30rpx;
		justify-content: space-between;
		.left {
			display: flex;
			align-items: center;
		}

		.chong_list_item {
			width: auto;
			margin-right: 60rpx;
			text-align: center;
			display: inline-block;
			color: #294a97;
			display: flex;
			align-items: center;
			flex-direction: column;
			justify-content: space-between;

			.text {
				font-size: 30rpx;
				display: block;
				font-weight: 700;
				color: $themeColor;
				padding-top: 20rpx;
			}
		}

		.chong_btn {
			font-size: 26rpx;
			border-radius: 50rpx;
			color: #fffbf6;
			line-height: 40rpx;
			padding: 10rpx 30rpx;
			background: $themeBgColor;
		}
	}
}

.xiugai {
	border-radius: 10rpx !important;
	margin: 0 30rpx;
	background: rgba(255, 255, 255, 0.65);

	.nav_list {
		background-color: #b7e0e2;
		padding: 15rpx 0 15rpx 10rpx;
		display: flex;
		align-items: center;
		font-size: 22rpx;
		position: relative;
		font-weight: bold;
		border-bottom: 1px solid #e5e5e5;

		&:active {
			background-color: #f5f5f5;
		}

		text {
			color: #333;
			margin-left: 10rpx;
		}

		&::after {
			content: "";
			position: absolute;
			right: 20rpx;
			top: 50%;
			transform: translateY(-50%);
			width: 30rpx;
			height: 30rpx;
			background-image: url("@/static/icon/icon_right.png");
			background-position: center center;
			background-repeat: no-repeat;
			background-size: cover;
		}
	}

	.nav_list:nth-last-child(1) {
		border-bottom: 0;
	}
}

.box_fillet {
	border-radius: 40rpx;
	overflow: hidden;
}

.chongzhi_box {
	position: relative;
	width: calc(100%);
	height: 100%;
	float: left;
	padding: 30rpx;
	background: rgba(255, 255, 255, 0.65);
	border-radius: 10rpx;
	box-shadow: 0px 0px 5px 1px rgba(0, 82, 79, 0.1);
}

.bg_top {
	padding: 0 30rpx;
	height: 30vh;
	position: relative;

	.setIcon {
		position: absolute;
		right: 30rpx;
	}
}
.vip_block{
	padding-left: 10rpx;
}

.mine_box {
	width: 100%;
	position: absolute;
	left: 0;
	padding: 0 0rpx;
}

.list_box {
	padding: 20rpx 0;
}

.pay_item_img {
	display: flex;
	align-items: center;
	color: #000;
}

.popup_box {
	width: 80vw;
	overflow: hidden;
	position: relative;
	height: auto;

	.title {
		font-family: PangMenZhengDaoBiaoTiTiMianFeiBan;
		font-weight: normal;
		font-size: 46rpx;
		color: $themeColor;
		padding: 30rpx;
		border-top-left-radius: 6px;
		border-top-right-radius: 6px;
	}

	.content {
		font-size: 28rpx;
		letter-spacing: 0.15rpx;
		padding: 10rpx 30rpx 30rpx;
		color: #3f3f3f;

		.top {
			margin: 30rpx 0;
		}

		.center {
			line-height: 40rpx;
		}

		.bottom {
			width: 100%;
			margin-top: 40rpx;
			margin-bottom: 20rpx;
			font-size: 24rpx;
			line-height: 26rpx;
			color: #b0b0b0;
		}
	}

	.button_box {
		display: flex;
		align-items: center;
		justify-content: space-between;
		margin-top: 20rpx;

		.u-button {
			margin-left: 40rpx;
		}

		.u-button:nth-child(1) {
			margin-left: 0;
		}
	}
}

.modal_vip{
	margin-top: 40rpx;
	padding: 20rpx 30rpx 0;
	height: auto;
	display: flex;
	align-items: center;
	justify-content: space-between;
}

.cate_box {
	width: 100%;
	height: auto;
	display: flex;
	justify-content: center;
	box-shadow: 0rpx 0rpx 6rpx 0rpx #f9f6ea;
	border-radius: 7rpx;
	display: flex;
	align-items: center;
	justify-content: space-around;
	padding: 5rpx 0rpx 20rpx;
	box-sizing: border-box;

	.cate_item_box {
		min-width: 110rpx;
		height: 100%;
		display: flex;
		align-items: center;
		justify-content: center;
		flex-direction: column;

		.cate_item_border {
			position: relative;
			display: flex;
			align-items: center;
			justify-content: center;
		}

		.cate_item_name {
			margin-top: 6rpx;
			font-weight: normal;
			font-size: 28rpx;
			color: #000;
			text-align: center;
		}
	}
}

.order_box {
	.title {
		padding: 20rpx 20rpx 10rpx;
		font-size: 30rpx;
		font-weight: bold;
	}
}

.viptime {
	font-size: 24rpx;
	margin-top: 4rpx;
	border-radius: 50rpx;
	color: rgb(211, 59, 27) !important;
	line-height: 20rpx;
}

.current_identity {
	top: 0;
	line-height: 32rpx;
	position: absolute;
	padding: 2rpx 10rpx;
	border: 4rpx solid #fff;
	border-bottom-right-radius: 20rpx;
	border-top-left-radius: 20rpx;
	font-size: 20rpx;
	font-weight: bold;
}

.hasVipBox {
	padding-top: 45rpx;
	padding-bottom: 0rpx;
	box-shadow: 0px 0px 5px 1px rgba(255, 255, 255, 0.45);
	border-radius: 20rpx;

	.vip_name {
		font-size: 60rpx;
	}

	.vip_info {
		display: flex;
		align-items: center;
		font-size: 24rpx;
		padding: 0 30rpx;
	}

	.viptime {
		text-align: left;
		padding: 0 30rpx;
		font-size: 24rpx;
		color: #333 !important;
		font-weight: 500;
		margin-bottom: 20rpx;
	}
}

.vbg {
	font-size: 300px;
	font-weight: 800;
	position: absolute;
	color: #3e9d78bd !important;
	right: -40rpx;
	top: -10px;
}

.xufei {
	position: absolute;
	height: 46rpx;
	right: 20rpx;
	color: rgba(244, 43, 51, 0.85) !important;
	font-size: 24rpx;
	border-radius: 50rpx;
	line-height: 46rpx;
	padding: 0rpx 20rpx;
	background: rgba(255, 255, 255, 1);
}

.hasVipSuper {
	border: 2rpx solid #fff1ca;
	background-image: linear-gradient(90deg, #fff0dc 0%, #f8e483 100%);

	.current_identity {
		background-color: #fdefb5;

		color: #c47029;
	}

	.PM_font {
		color: #f4a04c;
	}
}

.hasVipZmZm {
	box-shadow: 0px 0px 5px 1px RGBA(235, 247, 243, 0.45);
	background-image: linear-gradient(90deg, #aff7d6 0%, #edf5f1 100%);
	.viptime {
		color: #486a65;
	}

	.vip_name {
		letter-spacing: 1px;
	}

	.current_identity {
		background-color: #a9ddc4;

		color: #20575c;
	}

	.PM_font {
		color: #3e9d78;
	}

	.viptime {
		color: #9acbce;
	}

	.hasVip .quanyi {
		border-color: #b7f6ed;
		color: #ffd598;
	}

	.xufei {
		background-image: linear-gradient(90deg, #f6dc95 0%, #ffc45e 100%);
		color: #3d2700 !important;
	}

	.vip_info_bottom {
		color: #486a65;
	}
}

.hasVipWumen {
	background-image: linear-gradient(90deg, #c4e8fe 0%, #60bcff 100%);
	box-shadow: 0px 0px 5px 1px RGBA(235, 247, 243, 0.45);
	
	.viptime {
		color: #486a65;
	}

	.vip_name {
		letter-spacing: 1px;
	}

	.current_identity {
		background-color: #e8f9ff;

		color: #243a61;
	}

	.PM_font {
		color: #127dff;
	}

	.viptime {
		color: #1d3a65;
	}

	.hasVip .quanyi {
		border-color: #e3f7fe;
		color: #ffd598;
	}

	.xufei {
		background-image: linear-gradient(90deg, #f6dc95 0%, #ffc45e 100%);
		color: #3d2700 !important;
	}

	.vip_info_bottom {
		color: #3583C3;
	}

	.vbg {
		color: #d1effc !important;
	}
}

.hasVip {
	position: relative;
	display: block !important;

	.zhanghu {
		display: block;
	}
	.quanyi {
		border-top: 1rpx solid #f2d494;
		width: 100% !important;
		width: 100% !important;
	}
}
.vip_image {
	width: 55rpx;
	height: 55rpx;
	margin-right: 10rpx;
}
.user_vip_box{
	width: 125rpx;
	position: absolute;
	margin-top: - 37rpx;
	z-index: 99;
}
.user_vip_item{
	display: flex;
	align-items: center;
	justify-content: center;
}

.user_vip_item {
	border-radius: 20rpx;
	background: linear-gradient(90deg, #ff1f00 0%, #fa9f93 100%);
	color: #fff;
	font-size: 20rpx;
	line-height: 40rpx;
	height: 40rpx;
	font-weight: bold;
	margin-bottom: 5rpx;
}
.user_vip_item image{
	width: 49rpx;
	height: 16rpx;
}
.vip_type{
	margin-top: 10rpx;
	display: flex;
	align-items: center;
}
.vip_type_item{
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 0 10rpx;
	background: linear-gradient(90deg, #258feb 0%, #00e1ec 100%);
	border-radius: 20rpx;
	font-size: 20rpx;
	line-height: 40rpx;
	height: 40rpx;
	font-weight: bold;
	color: #fff;
	margin-right: 10rpx;
}
.vip_type_item:last-child{
	margin-right: 0;
}
.vip_type_item image{
	width: 34rpx;
	height: 24rpx;
}
.vip_infor{
	
}
.vip_infor_item{
	display: block;
	color: #fff;
	font-size: 26rpx;
	line-height: 36rpx;
	font-family: PangMenZhengDaoBiaoTiTiMianFeiBan;
	font-weight: normal;
}
.vip_infor_item text{
	color: #fff;
}

.vip_btn button{
	background: none;
	border: 1rpx solid #5188e5;
	border-radius: 40rpx;
	font-size: 24rpx;
	line-height: 42rpx;
	color: #5188e5;
	padding: 0 10rpx;
}
.vip_null{
	color: #fff;
	font-size: 26rpx;
	line-height: 34rpx;
	padding-left: 30rpx;
}
.expired{
	opacity: 0.55;
}

.recharge_block{
	padding: 20rpx 30rpx 0;
	height: auto;
	display: flex;
	align-items: center;
	justify-content: space-between;
}
.vip_box {
	padding: 25rpx 0;
	float: right;
	position: relative;
	width: 100%;
	height: auto;
	border-radius: 20rpx !important;
	background: linear-gradient(90deg, #5188e5 0%, #accafb 80%);

	.PM_font {
		color: #476379;
	}

	.zhanghu {
		font-size: 80rpx;
		text-align: center;
		line-height: 100%;
		margin-bottom: 0;
	}
}
</style>