<template>
	<view class="w-body">
		<w-public />
		<w-navbar fixed left-back title="个人信息"></w-navbar>

		<view class="item-group">
			<view class="item">
				<view class="item-title">头像</view>
				<view class="item-body"><u-avatar mode="aspectFill" size="2.5rem" :src="userInfo.avatar"></u-avatar></view>
			</view>
			<view class="item" hover-class="w-hover-before" @longtap="doCopy(userInfo.userName)">
				<view class="item-title">账户</view>
				<view class="item-body">{{userInfo.userName}}</view>
			</view>
			<view class="item">
				<view class="item-title">昵称</view>
				<view class="item-body">{{userInfo.nickName}}</view>
			</view>
			<view class="item">
				<view class="item-title">部门</view>
				<view class="item-body">{{userInfo?.dept?.deptName}}</view>
			</view>
		</view>

		<view class="item-group">
			<view class="item" hover-class="w-hover-before" @longtap="doCopy(userInfo.phonenumber)"
			@click.stop.prevent="$w.uni.makePhoneCall({phoneNumber: userInfo.phonenumber });">
				<view class="item-title" >手机号码</view>
				<view class="item-body">{{userInfo.phonenumber?userInfo.phonenumber:'--'}}</view>
			</view>
			<view class="item" hover-class="w-hover-before" @longtap="doCopy(userInfo.email)">
				<view class="item-title">电子邮箱</view>
				<view class="item-body">{{userInfo.email?userInfo.email:'--'}}</view>
			</view>
		</view>
	</view>
</template>

<script setup>
import { onLoad, onShow } from '@dcloudio/uni-app'
import { ref } from 'vue'
import { get } from '@/api/system/user.js'
import { doCopy } from '@/util'

const userId = ref(0);
const userInfo = ref({});

onLoad(async(event)=>{
	userId.value = event.id;
	let res = await get(userId.value);
	userInfo.value = res.user;
})
</script>

<style lang="scss" scoped>
	.w-body {
		background-color: var(--w-bg);
	}
</style>
