<template>
	<view class="main">
		<view class="one">
			<view class="one_1">
				<image class="image" :src="user.logo&&user.logo.length>0?user.logo[0].url:'../../static/doctor.jpg'"
					mode=""></image>
				<view class="right">
					<text class="name">{{user.name||'微信用户'}}</text>
					<text class="phone">电话：{{user.phone||'暂无'}}</text>
				</view>
			</view>
		</view>
		<view class="two">
			<view class="list" v-for="(item, index) in menuList" :key="index" @click="toCommon(item.route)">
				<view class="left">
					<view class="icon">
						<text class="iconfont" :class="[item.icon]"></text>
					</view>
					<text class="title">{{item.title||'暂无'}}</text>
				</view>
				<view class="right">
					<text class="iconfont icon-dayuhao"></text>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				user: {},
				// 菜单
				menuList: []
			}
		},
		onLoad: async function() {
			const that = this;
			await that.searchOther();
		},
		onShow: async function(e) {
			const that = this;
			that.searchToken();
			await that.search();
		},
		methods: {
			searchToken() {
				const that = this;
				try {
					const res = uni.getStorageSync('token');
					if (res) that.$set(that, `user`, res);
				} catch (e) {
					uni.showToast({
						title: err.errmsg,
						icon: 'error',
						duration: 2000
					});
				}
			},
			// 查询
			async search() {
				const that = this;
				let res;
				// res = await that.$api(`/user`, 'GET', {
				// 	user: that.user._id
				// })
				// if (res.errcode == '0') {
				// 	that.$set(that, `list`, res.data)
				// } else {
				// 	uni.showToast({
				// 		title: res.errmsg,
				// 	});
				// }
			},
			// 公共跳转
			toCommon(e) {
				uni.navigateTo({
					url: `/${e}`
				})
			},
			async searchOther() {
				const that = this;
				let config = that.$config;
				that.$set(that, `menuList`, config.menuList);
			}
		}
	}
</script>

<style lang="scss" scoped>
	.main {
		display: flex;
		flex-direction: column;
		width: 100vw;
		height: 100vh;
		background-image: linear-gradient(to top, rgba(241, 241, 241, 1), rgba(241, 241, 241, 1), rgba(0, 122, 255, 1));

		.one {
			.one_1 {
				padding: 15vw 5vw;
				display: flex;
				align-items: center;

				.image {
					width: 15vw;
					height: 15vw;
					border-radius: 2vw;
					margin: 0 2vw;
				}

				.right {
					display: flex;
					flex-direction: column;

					.name {
						font-size: var(--font18Size);
					}

					.phone {
						margin: 1vw 0 0 0;
						font-size: var(--font14Size);
						color: var(--f99Color);
					}
				}
			}
		}

		.two {
			display: flex;
			flex-direction: column;
			padding: 2vw;
			margin: 2vw;
			border-radius: 10px;
			background-color: var(--mainColor);

			.list {
				display: flex;
				justify-content: space-between;
				padding: 2vw;
				border-bottom: 1px solid var(--f9Color);

				.left {
					display: flex;
					align-items: center;

					.icon {
						padding: 0 1vw 0 0;

						.iconfont {
							color: var(--f3CColor);
							font-size: var(--font18Size);
						}
					}

					.title {
						display: inline-block;
						font-size: var(--font14Size);
					}
				}

				.right {
					font-size: var(--font12Size);
					color: var(--f99Color);
				}
			}
		}
	}
</style>