<template>
	<view class="main pdt0">
		<view class="cmd pdt0">
			<view class="s_item" @click="go('/pages/user/info')" v-if="user.doctor">
				<text class="icon ic" style="color: #9e9e9e">&#xe616;</text>
				<text class="title">个人信息</text>
				<text class="icon arrow">&#xe62b;</text>
			</view>
			<view class="s_item" @click="go('/pages/user/bind/index')" v-if="!user.doctor">
				<text class="icon ic" style="color: #9e9e9e">&#xe62d;</text>
				<text class="title">绑定就诊人</text>
				<text class="icon arrow">&#xe62b;</text>
			</view>
			<view class="s_item" @click="go('/pages/user/pass')" v-if="user.doctor">
				<text class="icon ic" style="color: #4caf50">&#xe613;</text>
				<text class="title">修改密码</text>
				<text class="icon arrow">&#xe62b;</text>
			</view>
		</view>
		<button class="btn" @click="exit()">退出登陆</button>
	</view>
</template>

<script>
export default {
	data() {
		return {
			user: this.getUser()
		};
	},
	methods: {
		go(url) {
			uni.navigateTo({ url: url });
		},
		exit() {
			uni.showModal({
				title: '提示',
				content: '确定退出登陆?',
				success: (res) => {
					if (res.confirm) {
						this.http.request({
							url: this.getUser().doctor ? '/logout' : '/app/user/exit',
							success: (res) => {
								uni.removeStorageSync('user');
								uni.navigateBack();
							}
						});
					}
				}
			});
		}
	}
};
</script>

<style lang="scss"></style>