<template>
	<view class="container">
		<view class="name" @click="add()">请选择进入</view>
		<view class="image" @click="ToRegister(1)" v-if="userInfo.type != 2">
			<image src="../../static/img/img030.png"></image>
			<view class="identity">咨询预约</view>
			<view class="info">一对一医生咨询预约</view>
		</view>
		<view class="image" @click="ToRegister(2)">
			<image src="../../static/img/img031.png"></image>
			<view class="identity">科普学习</view>
			<view class="info">医疗知识课程直播详解</view>
		</view>
	</view>
</template>
<script>
	import {
		getUserInfo
	} from '@/api/login.js';
	export default {
		data() {
			return {
				userInfo: ''
			};
		},
		onLoad(option) {
			if (option.spread) {
				// 存储邀请人
				this.spread = option.spread;
				uni.setStorageSync('spread', option.spread);
			}
		},
		onShow() {
			let obj = this;
			getUserInfo({})
				.then(function(e) {
					obj.userInfo = e.data;
					uni.setStorageSync('userInfo', e.data);
					if (obj.userInfo.type == 2) {
						uni.setTabBarItem({
							index: 0,
							text: '首页',
							iconPath: 'static/tabBar/tab-home.png',
							selectedIconPath: 'static/tabBar/tab-home-current.png'
						});
						uni.setTabBarItem({
							index: 1,
							text: '我的病人',
							iconPath: 'static/tabBar/tab-cate.png',
							selectedIconPath: 'static/tabBar/tab-cate-current.png',
							visible: true
						});
						uni.setTabBarItem({
							index: 2,
							text: '科普学习',
							iconPath: 'static/tabBar/tab-study.png',
							selectedIconPath: 'static/tabBar/tab-study-current.png',
							visible: false
						});
						uni.setTabBarItem({
							index: 3,
							text: '接单',
							iconPath: 'static/tabBar/jd.png',
							selectedIconPath: 'static/tabBar/jd-act.png',
							visible: true
						})
						uni.setTabBarItem({
							index: 4,
							text: '我的',
							iconPath: 'static/tabBar/tab-my.png',
							selectedIconPath: 'static/tabBar/tab-my-current.png'
						});
					}
					if (obj.userInfo.type == 3) {
						uni.setTabBarItem({
							index: 0,
							text: '首页',
							iconPath: 'static/tabBar/tab-home.png',
							selectedIconPath: 'static/tabBar/tab-home-current.png'
						});
						uni.setTabBarItem({
							index: 1,
							text: '咨询记录',
							iconPath: 'static/tabBar/tab-cate.png',
							selectedIconPath: 'static/tabBar/tab-cate-current.png',
							visible: true
						});
						uni.setTabBarItem({
							index: 2,
							text: '科普学习',
							iconPath: 'static/tabBar/tab-study.png',
							selectedIconPath: 'static/tabBar/tab-study-current.png',
							visible: false
						});
						uni.setTabBarItem({
							index: 3,
							text: '发布订单',
							iconPath: 'static/tabBar/jd.png',
							selectedIconPath: 'static/tabBar/jd-act.png',
							pagePath: '/pages/dd/dd',
							visible: true
						})

						uni.setTabBarItem({
							index: 4,
							text: '我的',
							iconPath: 'static/tabBar/tab-my.png',
							selectedIconPath: 'static/tabBar/tab-my-current.png'
						});
					}
					if (obj.userInfo.type == 1) {
						uni.setTabBarItem({
							index: 0,
							text: '首页',
							iconPath: 'static/tabBar/tab-home.png',
							selectedIconPath: 'static/tabBar/tab-home-current.png'
						});
						uni.setTabBarItem({
							index: 1,
							text: '咨询记录',
							iconPath: 'static/tabBar/tab-cate.png',
							selectedIconPath: 'static/tabBar/tab-cate-current.png',
							visible: true
						});
						uni.setTabBarItem({
							index: 2,
							text: '科普学习',
							iconPath: 'static/tabBar/tab-study.png',
							selectedIconPath: 'static/tabBar/tab-study-current.png',
							visible: true
						});
						uni.setTabBarItem({
							index: 3,
							text: '接单',
							iconPath: 'static/tabBar/jd.png',
							selectedIconPath: 'static/tabBar/jd-act.png',
							visible: false
						})
						uni.setTabBarItem({
							index: 4,
							text: '我的',
							iconPath: 'static/tabBar/tab-my.png',
							selectedIconPath: 'static/tabBar/tab-my-current.png'
						});
					}
				})
				.catch(function(e) {
					console.log(e);
				});
		},
		methods: {
			ToRegister(item) {
				if (item == 1) {
					uni.navigateTo({
						url: '/pages/doctor/doclist'
					});
				} else {
					uni.switchTab({
						url: '/pages/index/index'
					});
				}
			},
			add() {
				let log = this.$log.getLog();
				// uni.showModal({
				// 	title: '日志',
				// 	content: JSON.stringify(log),
				// 	showCancel: false,
				// });
				this.$log.showLog();
			}
		}
	};
</script>

<style lang="scss">
	page {
		background: #ffffff;
		height: 100%;
	}

	.container {
		width: 100%;
		padding: 90rpx 60rpx;
	}

	.name {
		padding: 60rpx 0rpx;
		color: #323232;
		font-size: 50rpx;
		font-weight: bold;
	}

	.image {
		width: 100%;
		height: 250rpx;
		position: relative;
		margin-bottom: 65rpx;

		image {
			width: 100%;
			height: 100%;
		}

		.identity {
			position: absolute;
			top: 60rpx;
			left: 50rpx;
			color: #ffffff;
			font-size: 40rpx;
		}

		.info {
			position: absolute;
			left: 50rpx;
			top: 125rpx;
			color: #ffffff;
			font-size: 24rpx;
			opacity: 0.5;
		}
	}
</style>
