<template>
	<view class="flex-col flex-ali-center">
		<image :src="`../../static/image/${type==0?'activate':'succee'}.png`"></image>
		<view class="title">
			{{type==0?'账号待激活':'提交成功'}}
		</view>
		<view class="hiht">
			{{type==0?'系统已录入，激活账号权限':'您的认证资料需要1-3个工作日审核'}}
		</view>
		<view style="width: 400rpx;" class="btn">
			<u-button :throttle-time="0" shape="circle" @click="getInfo" :ripple="true">
				{{type==0?'激活并补充资料':'去首页'}}
			</u-button>
		</view>
	</view>
</template>

<script>
	import {
		info,
		personalData,
		leadInfo,
		servInfo,
		getUserInfo,
	} from "@/api/all.js"
	export default {
		data() {
			return {
				type: 0,
				identity: uni.getStorageSync('identity') || (uni.getStorageSync('userInfo') || {}).role || 1,
			}
		},
		onLoad(op) {
			this.type = op['type'] || 0
			let title = this.type == 0 ? '激活账号' : '提交成功';
			uni.setNavigationBarTitle({
				title: title
			})

			// console.log(op);
		},
		methods: {
			async getInfo() {
				if (this.type == 0) {
					this.$go('./workbench_upInfo/index')
					return
				}
				let role = uni.getStorageSync('role')
				let req = {};
				const data = {
					store_id: uni.getStorageSync('store_id') || '11001',
				}
				role == 1 && (req = await getUserInfo(data))
				role == 2 && (req = await getUserInfo(data))

				if (req.errcode != -1) {
					
					if (req.data) {
						// 药师
						if (req.data.role == 2 && req.data.status ==2 ) {
							setTimeout(() => {
								this.$go('/pages/pharmacist/index', 3)
							}, 600)
							return
						}
						
						// 医生  res.data.ServiceUser.status > 0 && res.data	.ServiceUser.status != 3
						if (req.data.role == 1 && req.data.status==2 ) {
							setTimeout(() => {
								this.$go('/pages/workbench/index', 2)
							}, 600)
							return
						}
						
						//  医生审核中  1
						if (req.data.status == 0) {
							this.$toast('您还没有完善信息，请先完善信息')
							setTimeout(() => {
								uni.navigateTo({
									url:'../../subPackages/sub_workbench/workbench_upInfo/index'
								})
							}, 2000)
							return
						}
						
						// 医生未通过审核 3 
						if (req.data.role == 1 && req.data.status != 2) {
							this.$toast(req.data.reason)
							setTimeout(() => {
								this.$go('/pages/workbench/examine')
							}, 2000)
							return
						}
						
						
						// 药师未通过审核 3  药师审核中  1
						if (req.data.role == 2 && req.data.status != 2) {
							this.$toast(req.data.reason)
							setTimeout(() => {
								this.$go('/pages/workbench/examine')
							}, 2000)
							return
						}
						
						return
					}

				} else {
					this.$toast(req.msg)
				}
			},
			activate() {
				if (this.type != 0) {
					this.identity == 1 && uni.navigateTo({
						url: '/pages/workbench/examine'
					})
					this.identity == 2 && uni.switchTab({
						url: '/pages/pharmacist/index'
					})
					return
				}
				this.$go('./workbench_upInfo/index')
			}
		}
	}
</script>
<style>
	page {
		padding: 80rpx 0;
	}
</style>
<style lang="scss" scoped>
	image {
		width: 256rpx;
		height: 256rpx;
	}

	.title {
		font-size: 36rpx;
		font-family: PingFang SC-Medium, PingFang SC;
		font-weight: 500;
		color: #0D111A;
		margin-top: 32rpx;
	}

	.hiht {
		font-size: 28rpx;
		font-family: PingFang SC-Regular, PingFang SC;
		font-weight: 400;
		color: #6C7380;
		margin-top: 16rpx;
		margin-bottom: 32rpx;
	}

	.btn {
		::v-deep button {
			border: 0;
			background: #6ACDBB;
			font-size: 32rpx;
			font-family: PingFang SC-Regular, PingFang SC;
			font-weight: 400;
			color: #FFFFFF;
		}
	}
</style>