<template>
	<view class="container">
		<view class="content" v-if="pageData">
			<view class="content-item">
				<text>员工姓名</text>
				<view>{{pageData.name}}</view>
			</view>
			<view class="content-item">
				<text>手机号码</text>
				<view>{{pageData.phone}}</view>
			</view>
			<view class="content-item">
				<text>性别</text>
				<view>{{pageData.sex|fiterSex}}</view>
			</view>
			<view class="content-item">
				<text>角色</text>
				<view>{{pageData.roles | filterRoles}}</view>
			</view>
			<view class="content-item">
				<text>所属机构</text>
				<view>{{pageData.orgCodePaths}}</view>
			</view>
			<view class="content-item">
				<text>可点检门店</text>
				<view style="color: #007AFF;" @click="viewStores">
					{{pageData.userStoreList&&pageData.userStoreList.length}}个 <u-icon name="icon-xian-11" custom-prefix="xd-icon" size="28" color="#888888"></u-icon>
				</view>
			</view>
		</view>
		<view v-else>
			<view class="loadingStyle">
				<u-loading mode="circle"></u-loading>
				<view>正在加载</view>
			</view>
		</view>
	</view>
</template>

<script>
	import { findUserInfo } from '@/api/user.js'
	export default{
		data(){
			return{
				pageData:null,		// 接受上个页面传的数据
			}
		},
		onShow() {
			this.getDetail()
		},
		// 角色
		filters: {
			fiterSex(val){
				return ['女','男'][val]
			},
			filterRoles(val){
				 if(val){
					let arr = []
					val.map(item => {
						arr.push(item.name)
					})
					return arr.join(',') 
				 }
			}
		},
		methods:{
			// 查询详细信息
			getDetail(){
				findUserInfo().then(res => {
					console.log(res)
					this.pageData = res.data || null
				})
			},
			viewStores(){
				let item = this.pageData.userStoreList
				if(item.length>0){
					uni.navigateTo({
						url: '/pages/userCenter/viewStores?item='+encodeURIComponent(JSON.stringify(item))
					})
				}
			}
		}
	}
</script>

<style lang="less">
	.loadingStyle{
		text-align: center;
		padding: 10vh 0 10vh 0;
	}
	.container{
		color:#666;
		font-size: 28rpx;
		.content{
			position: relative;
			background-color: #FFFFFF;
			margin-bottom: 60rpx;
			.content-item{
				display: flex;
				justify-content: space-between;
				padding: 30rpx;
				border-bottom: 1px solid #e5e5e5;
				> view{
					color: #666;
				}
			}
		}
		
	}
</style>
