<template>
	<view class="container  safe-area-inset-bottom" :style="{ height: screenHeight }">
		<image class="image" src="/static/login/bg_shh.png" mode=""></image>
		<view class="bg">
			<view class="img">
				<image :src="doctorInfo.DoctorInfo.avatar || doctorInfo.avatar" mode=""></image>
			</view>

			<view class="box">
				<view class="name">
					<text>{{doctorInfo.DoctorInfo.name || doctorInfo.name}}</text>{{doctorInfo.DoctorInfo.title.name || doctorInfo.titles.name}}
				</view>
				<view class="store">
					{{doctorInfo.store.store.name || doctorInfo.store.name}}
					{{doctorInfo.DoctorInfo.depart.name || doctorInfo.depart.name || ''}}
				</view>
				<image src="/static/login/bg_shhz.png" mode=""></image>
				<!-- doctorInfo.DoctorInfo.user.status<=1 -->
				<view class="state" v-if="role==1">
					{{ doctorInfo.DoctorInfo.user.status<=1&&'您的申请已提交，请耐心等待！感谢您的配合！' ||doctorInfo.DoctorInfo.user.status==3&&'抱歉您的申请已被驳回！'}}
				</view>
				<view class="state" v-if="role==2">
					{{ doctorInfo.user.status<=1&&'您的申请已提交，请耐心等待！感谢您的配合！' ||doctorInfo.user.status==3&&'抱歉您的申请已被驳回！'}}
				</view>
				<view class="store" v-if="role==1">
					<text v-if="doctorInfo.DoctorInfo.user.status<=1">申请提交后预计1~2个工作日返回结果！</text>
					<view class="_bx" v-if="doctorInfo.DoctorInfo.user.status==3">
						<text style="color: #FF0000;">驳回原因：</text>
						<text>{{doctorInfo.ServiceUser.reason}}</text>
					</view>
				</view>
				<view class="store" v-if="role==2">
					<text v-if="doctorInfo.user.status<=1">申请提交后预计1~2个工作日返回结果！</text>
					<view class="_bx" v-if="doctorInfo.user.status==3">
						<text style="color: #FF0000;">驳回原因：</text>
						<text>{{doctorInfo.user.reason}}</text>
					</view>
				</view>
			</view>
		</view>
		<button class="btn" v-if="doctorInfo.DoctorInfo.user.status==3 && role==1"
			@click="toNew(doctorInfo.DoctorInfo.su_id)">重新申请</button>

		<button class="btn" v-if="doctorInfo.user.status==3 && role==2" @click="toNew(doctorInfo.su_id)">重新申请</button>
	</view>
</template>

<script>
	import {
		failNew,
		getUserInfo,
		info,
		personalData
	} from '@/api/all.js'
	export default {
		data() {
			return {
				doctorInfo: [],
				screenHeight: 0,
				role: uni.getStorageSync('role'),
				// status: 1,
				reason: "",
			};
		},
		onLoad() {
			// this.$go('../../subPackages/sub_workbench/workbench_recipe/index')
			// console.log(1);
			this.screenHeight = uni.getSystemInfoSync().windowHeight
		},
		onShow() {
			if (this.role == 1) {
				this.getInfo()
			}

			if (this.role == 2) {
				this.getPerInfo()
			}
		},
		methods: {
			// 医生详情
			getInfo() {
				info({
					store_id: uni.getStorageSync('store_id') || '11001'
				}).then((res) => {
					if (res.errcode == 0) {
						this.doctorInfo = res.data
						if (res.data.user.status == 2) {
							setTimeout(() => {
								this.$go('/pages/workbench/index', 2)
							}, 20000)
						}
					}
				})
			},
			// 药师详情
			getPerInfo() {
				personalData({
					store_id: uni.getStorageSync('store_id') || '11001'
				}).then((res) => {
					if (res.errcode == 0) {
						this.doctorInfo = res.data
						if (res.data.user.status == 2) {
							setTimeout(() => {
								this.$go('/pages/pharmacist/index', 2)
							}, 20000)
						}
					}
				})
			},
			// // 状态
			// getStatus() {
			// 	getUserInfo({
			// 		store_id: uni.getStorageSync('store_id') || '11001',
			// 	}).then((res) => {
			// 		if (res.errcode ==0) {
			// 			uni.setStorageSync('loginInfo', res.data)
			// 			this.status=res.data.status
			// 			this.reason = res.data.reason
			// 		}
			// 	})
			// },
			toNew(e) {
				failNew({
					store_id: uni.getStorageSync('store_id') || '11001',
					id: e
				}).then((res) => {
					if (res.errcode == 0) {
						this.$toast('申请成功，请重新注册')
						setTimeout(() => {
							uni.navigateTo({
								url:'../../subPackages/sub_workbench/workbench_upInfo/index'
							})
						}, 100)
					}
				})
			},
			getNewinfo() {
				if (this.role == 1 && uni.getStorageSync('login_status') != 2) {
					setTimeout(() => {
						this.getInfo()
					}, 100000)
				} else {
					setTimeout(() => {
						this.getPerInfo()
					}, 100000)
				}
			}
		},
		mounted() {
			this.getNewinfo()
			// this.getStatus()
		},
	};
</script>
<style>
	page {
		background-color: #eeeeef;
		width: 100%;
		height: 100%;
	}
</style>
<style lang="scss" scoped>
	.container {
		width: 100vw;
		min-height: 100vh;
		padding: 0;
		margin: 0;
		position: relative;

		.image {
			width: 100vw;
			min-height: 100vh;
			max-height: 100%;
		}

		.bg {
			z-index: 9999999999 !important;
			position: absolute;
			left: 13%;
			top: 120rpx;
			text-align: center;
			border-radius: 36rpx;
			background: #F8FAFF;

			.img {
				width: 180rpx;
				height: 180rpx;
				margin: -80rpx auto 20rpx;

				image {
					width: 100%;
					height: 100%;
					border-radius: 50%;
				}
			}

			.box {
				z-index: 9999999;
				width: 560rpx;
				font-family: PingFang SC-Regular, PingFang SC;
				color: #1E293B;
				padding: 20rpx 28rpx;

				.name {
					font-size: 28rpx;
					font-weight: 400;

					text {
						font-size: 36rpx;
						margin-right: 10rpx;
						font-weight: bold;
						color: #000000;
					}

					margin: 8rpx 0;
				}

				.store {
					font-size: 24rpx;
					font-weight: 400;
					color: #666666;
					line-height: 48rpx;
					margin: 5rpx auto;

					._bx {
						display: flex;
						flex-direction: column;
					}
				}

				.state {
					font-size: 28rpx;
					font-weight: bold;
					color: #333333;
					line-height: 48rpx;
					margin: 0 auto 50rpx;
				}

				image {
					width: 215rpx;
					height: 241rpx;
					vertical-align: middle;
					margin: 68rpx 0;
				}
			}
		}
	}


	.btn {
		width: 380rpx;
		height: 84rpx;
		background: #FFFFFF;
		font-size: 32rpx;
		font-family: PingFang SC-Regular, PingFang SC;
		font-weight: 400;
		color: #333333;
		border: 0;
		border-radius: 64rpx;
		text-align: center;
		line-height: 80rpx;
		position: absolute;
		left: 40%;
		margin-left: -130rpx;
		bottom: 13%;
	}
</style>