<template>
	<div class="home">
		<div class="header">
			<div class="title">
				<div class="back">
					<!-- <van-icon name="arrow-left" size='20' /> -->
				</div>
				<div class="text">客户画像</div>
				<div class="more"></div>
			</div>
			<div class="user-info">
				<div class="user-icon">
					<img src="../../assets/images/people.png" alt="" />
				</div>
				<div class="user-text">
					<div class="name">{{userInfo.nickName}}</div>
					<div class="company">{{userInfo.dept ? userInfo.dept.deptName  : ''}}</div>
				</div>
				<div class="more">
					<van-icon name="arrow" size="16" />
				</div>
			</div>
		</div>
		<ul class="set-list">
			<li @click="toChanagePassword">
				<div class="icon-box">
					<i class="iconfont icon-icon_pz"></i>
				</div>
				<div class="text">修改密码</div>
				<div class="more">
					<van-icon name="arrow" size="16" />
				</div>
			</li>
		</ul>
		<van-button class="logout" type="primary" @click="logout" block
			>退出登录</van-button
		>
	</div>
</template>
<script setup>
import { ref, getCurrentInstance, onMounted } from 'vue'
import { showSuccessToast, showFailToast,showConfirmDialog } from 'vant'
import { useRoute } from 'vue-router'
import { getUserInfo } from '@/utils/auth'
const onClickLeft = () => history.back()
const proxy = getCurrentInstance().proxy
const userInfo = ref(getUserInfo())
console.log(userInfo)
const toMessageList = () => {
	proxy.$router.push('/main/messageList')
}
const toChanagePassword = () => {
    proxy.$router.push('/main/changePassword')
}
const logout = () => {
	showConfirmDialog({
		title: '提示',
		message: '您确定退出本次登录么？',
	}).then(() => {
		proxy.get('logout').then((res) => {
            if (res.code == 200) {
                showSuccessToast('退出成功')
                //清除路由历史记录
                proxy.$router.replace('/')
            } else {
                showFailToast('退出失败')
            }
        })
	})
	
}
</script>
<style lang="scss">
.home {
	background: #fff;
	min-height: 100vh;
	.van-nav-bar {
		background: rgba(0, 0, 0, 0);
	}
	.logout {
		border-radius: 22px;
		background: #eaf0ff;
		border: 1px solid #eaf0ff;
		color: #3370ff;
		width: 80% !important;
		margin: 0 auto;
		position: fixed;
		bottom: 100px;
		left: 10%;
	}
	.set-list {
		position: relative;
		top: -80px;
		background: #fff;
		min-height: 200px;
		border-radius: 10px;
		padding-top: 10px;
		li {
			display: flex;
			justify-content: space-between;
			align-items: center;
			height: 40px;
			padding: 0 12px;
			.icon-box {
				width: 40px;
				height: 40px;
				text-align: center;
				line-height: 40px;
				i {
					font-size: 20px;
					color: #3370ff;
				}
			}
			.text {
				flex: 1;
				margin: 0 12px;
				font-size: 16px;
				color: #333;
			}
			.more {
				i {
					color: #999;
				}
			}
		}
	}
	.header {
		background: linear-gradient(180deg, #3370ff 0%, #f1f1f1 100%);
		height: 250px;
		.user-info {
			display: flex;
			justify-content: space-between;
			padding: 0 12px;
			height: 60px;
			margin-top: 10px;
			.user-text {
				color: #fff;
				.name {
					font-size: 20px;
					font-weight: bold;
					margin: 5px 0;
					width: calc(100vw - 140px);
				}
			}
			.user-icon {
				width: 60px;
				height: 60px;
				background-color: #f1f1f1;
				border-radius: 50%;
				text-align: center;

				img {
					width: 40px;
					margin-top: 10px;
				}
				overflow: hidden;
			}
			.more {
				line-height: 60px;
				i {
					color: #fff;
				}
			}
		}
		.title {
			display: flex;
			justify-content: space-between;
			height: 46px;
			line-height: 46px;
			padding: 0 12px;
			color: #fff;
			font-size: 16px;
			font-weight: bold;
			.back,
			.more {
				width: 40px;
				height: 100%;
			}
		}
	}
}
</style>
