<template>
	<view>
		<scroll-view scroll-y class="page">
			<cu-custom bgColor="bg-gradual-pink" :isBack="true">
				<block slot="backText">返回</block>
				<block slot="content">用户详情</block>
				<!-- <view slot="right"  @tap="rightClick">编辑</view> -->
			</cu-custom>
			<!-- list列表 -->
			<view class="cu-list menu">
				<view class="cu-item animation-slide-bottom" :style="[{animationDelay: '0.1s'}]">
					<view class="content">
						<text class="text-grey">头像</text>
					</view>
					<view class="action">
						<view class="cu-avatar round sm" :style="{backgroundImage: 'url(' + personalMsg.avatar + ')'}"></view>
					</view>
				
				</view>
				<!-- <view class="cu-item animation-slide-bottom" :style="[{animationDelay: '0.2s'}]">
					<view class="content">
						<text class="text-grey">账号</text>
					</view>
					<view class="action">
						<text class="text-grey">{{personalMsg.username}}</text>
					</view>
				</view> -->
				<view class="cu-item animation-slide-bottom" :style="[{animationDelay: '0.3s'}]">
					<view class="content">
						<text class="text-grey">工号</text>
					</view>
					<view class="action">
						<text class="text-grey">{{personalMsg.workNo}}</text>
					</view>
				</view>
				<view class="cu-item animation-slide-bottom" :style="[{animationDelay: '0.4s'}]">
					<view class="content">
						<text class="text-grey">姓名</text>
					</view>
					<view class="action">
						<text class="text-grey">{{personalMsg.realname}}</text>
					</view>
				</view>
				<view class="cu-item animation-slide-bottom" :style="[{animationDelay: '0.5s'}]">
					<view class="content">
						<text class="text-grey">性别</text>
					</view>
					<view class="action">
						<text class="text-grey">{{personalMsg.sex}}</text>
					</view>
				</view>
				<view class="cu-item animation-slide-bottom" :style="[{animationDelay: '0.6s'}]">
					<view class="content">
						<text class="text-grey">英文名</text>
					</view>
					<view class="action">
						<text class="text-grey">{{personalMsg.egName}}</text>
					</view>
				</view>
				<view class="cu-item animation-slide-bottom" :style="[{animationDelay: '0.7s'}]">
					<view class="content">
						<text class="text-grey">职位</text>
					</view>
					<view class="action">
						<text class="text-grey">{{personalMsg.post}}</text>
					</view>
				</view>
				<view class="cu-item animation-slide-bottom" :style="[{animationDelay: '0.8s'}]">
					<view class="content">
						<text class="text-grey">部门</text>
					</view>
					<view class="action">
						<text class="text-grey">{{personalMsg.orgCodeTxt}}</text>
					</view>
				</view>
				<view class="cu-item animation-slide-bottom" :style="[{animationDelay: '0.9s'}]">
					<view class="content">
						<text class="text-grey">邮箱</text>
					</view>
					<view class="action">
						<text class="text-grey">{{personalMsg.email}}</text>
					</view>
				</view>
				<view class="cu-item animation-slide-bottom" :style="[{animationDelay: '1s'}]">
					<view class="content">
						<text class="text-grey">手机号码</text>
					</view>
					<view class="action">
						<text class="text-grey">{{personalMsg.phone}}</text>
					</view>
				</view>
				<view class="cu-item animation-slide-bottom" :style="[{animationDelay: '1.1s'}]">
					<view class="content">
						<text class="text-grey">出生日期</text>
					</view>
					<view class="action">
						<text class="text-grey">{{personalMsg.birthday}}</text>
					</view>
				</view>
				<view class="cu-item animation-slide-bottom" :style="[{animationDelay: '1.2s'}]">
					<view class="content">
						<text class="text-grey">入职日期</text>
					</view>
					<view class="action">
						<text class="text-grey">{{personalMsg.entryDate}}</text>
					</view>
				</view>
				<view class="cu-item animation-slide-bottom" :style="[{animationDelay: '1.3s'}]">
					<view class="content">
						<text class="text-grey">紧急联系人</text>
					</view>
					<view class="action">
						<text class="text-grey">{{personalMsg.urgentName}}</text>
					</view>
				</view>
				
				<view class="cu-item animation-slide-bottom" :style="[{animationDelay: '1.4s'}]">
					<view class="content">
						<text class="text-grey">联系人电话</text>
					</view>
					<view class="action">
						<text class="text-grey">{{personalMsg.urgentPhone}}</text>
					</view>
				</view>
				
			</view>

		</scroll-view>
	</view>
</template>

<script>
	import api from '@/api/api.js'
	export default {
		data() {
			return {
				 personalMsg:{
					avatar:'',
					realname:'',
					username:'',
					post:'',
					depart:'',
					phone:'',
					workNo:'',
					birthday:'',
					email:'',
					sex:'',
					egName:'',
					birthDate:'',
					entryDate:'',
					urgentName:'',
					urgentPhone:'',
					availableDay:'',
					orgCodeTxt:'',
					leaveDate:'',
					sum:''
				},
				userUrl:'/sys/user/queryById',
				positionUrl:'/sys/position/list',
				departUrl:'/sys/user/userDepartList'
			};
		},
		onLoad() {
			this.loadinfo()
			/* this.tt() */
		},
		methods: {
			/* tt(){
				
				var str="今天上海市有暴雨请带好防护装备";
				var url= "http://tts.baidu.com/text2audio?lan=zh&ie=UTF-8&spd=6&text="+str;   
				      new Audio(url).play();
					
			}, */
			sign(){
				this.$Router.push({name:'usersign'})
			},
			getSubStringText(text,len){
				if(!text || text.length==0){
					return ''
				}
				if(text.length<len){
					return text;
				}
				return text.substr(0,len)+"..."
			},
			rightClick(){
				this.$Router.push({name:'useredit', params:this.personalMsg})
				/* uni.navigateTo({
				    url: '/pages/user/useredit?item='+item
				}); */
			},
			loadinfo(){
				this.$http.get(this.userUrl,{params:{id:this.$store.getters.userid}}).then(res=> {
					console.log("用户",res)
					if (res.statusCode==200) {
						let result = res.data.data
						let avatar=(result.avatar && result.avatar.length > 0)? api.getFileAccessHttpUrl(result.avatar):'/static/avatar_boy.png'
						this.personalMsg.avatar = avatar
						this.personalMsg.realname = result.realname
						this.personalMsg.username = result.username
						this.personalMsg.post = result.post
						this.personalMsg.depart = result.departIds
						this.personalMsg.phone=result.phone
						this.personalMsg.workNo=result.workNo
						this.personalMsg.birthday=result.birthday
						this.personalMsg.email=result.email
						if(result.sex==1){
							this.personalMsg.sex='男';
						}else{
							this.personalMsg.sex='女';
						}
						
						this.personalMsg.egName=result.egName
						this.personalMsg.birthDate=result.birthDate
						this.personalMsg.entryDate=result.entryDate
						this.personalMsg.urgentName=result.urgentName
						this.personalMsg.urgentPhone=result.urgentPhone
						if(res.data.sign!="" &&res.data.sign!=undefined){
							this.personalMsg.availableDay=res.data.sign.availableDay
							this.personalMsg.leaveDate=res.data.sign.leaveDate
						}
						this.personalMsg.orgCodeTxt=result.orgCodeTxt
						
						this.personalMsg.sum=res.data.sum
						
						
					}
				}).catch(e=>{
					console.log("请求错误",e)
				})
				
				/* this.$http.get(this.departUrl,{params:{userId:this.$store.getters.userid}}).then(res=> {
					if (res.success) {
						for (let item of res.result){
							this.personalMsg.orgCode = item.title
							this.personalMsg.departIds = item.title
						}
					}
				}).catch(e=>{
					console.log("请求错误",e)
				})
				
				this.$http.get(this.positionUrl).then(res=> {
					if (res.success) {
						let postArr = res.result.records
						for (let item of postArr ){
							if (this.personalMsg.post == item.code){
								this.personalMsg.post = item.name
							}
						}
					}
				}).catch(e=>{
					console.log("请求错误",e)
				}) */
			},
		}
	}
</script>

<style>
	.page {
		height: 100Vh;
		width: 100vw;
	}

	.page.show {
		overflow: hidden;
	}

	.switch-sex::after {
		content: "\e716";
	}

	.switch-sex::before {
		content: "\e7a9";
	}

	.switch-music::after {
		content: "\e66a";
	}

	.switch-music::before {
		content: "\e6db";
	}
</style>
