<template>
	<view class="phone-jianli-page">
		<view class="phone-navBar-box">
			<view @click="goUpPage" class="nav-bar-icon"></view>
			<text class="nav-bar-title">家政人员信息</text>
			<!-- 删除↓ wgy看这 -->
			<i class="nav-bar-right-icon right-icon-delete-btn" @click="deleteUser"></i>
		</view>
		<view class="jianli-wrap-box">
			<view class="jianli-head-box">
				<view class="head-img-box">
					<img class="head-img" :src="jianliInfo.icon" v-if="jianliInfo.icon">
					<icon class="phone-default-userImg" v-else></icon>
					<view class="head-status" v-if="jianliInfo.zhuangtai">{{jianliInfo.zhuangtai}}</view>
				</view>
				<view class="head-content-box">
					<view class="name-row">{{jianliInfo.realName}}</view>
					<view>
						{{jianliInfo.jiguanShengName === jianliInfo.jiguanShiName ? jianliInfo.jiguanShengName  : `${jianliInfo.jiguanShengName} ${jianliInfo.jiguanShiName}`}}人
					</view>
					<view>
						<text>{{jianliInfo.nianling}}岁</text>
						<text v-if="jianliInfo.jingyan"> | {{jianliInfo.jingyan}}</text>
					</view>
				</view>
			</view>

			<view class="jianli-body-box">
				<view v-if="jianliInfo.zyNames" class="leixing-row">
					<view class="jbxx-label">职 业：</view>
					<text class="leixing-content">{{jianliInfo.zyNames}}</text>
				</view>
				<view class="body-jbxx-box">
					<view class="jbxx-title">基本信息</view>
					<view>
						<view class="jbxx-label">学 历：</view>{{jianliInfo.xueli}}
					</view>
					<view>
						<view class="jbxx-label">民 族：</view>{{jianliInfo.minzu}}
					</view>
					<view v-if="jianliInfo.xingzuoFla =='true'">
						<view class="jbxx-label">属 相：</view>{{jianliInfo.shuxiang}}
					</view>
					<view v-if="jianliInfo.xingzuoFla =='true'">
						<view class="jbxx-label">星 座：</view>{{jianliInfo.xingzuo}}
					</view>
					<view>
						<view class="jbxx-label">性 别：</view>{{jianliInfo.gender}}
					</view>
					<view>
						<view class="jbxx-label">婚姻状况：</view>{{jianliInfo.hunyin}}
					</view>
					<view>
						<view class="jbxx-label">现住地址：</view>{{jianliInfo.juzhuDizhi}}
					</view>
					<view>
						<view class="jbxx-label">家政公司：</view>{{jianliInfo.jzName}}
					</view>
				</view>
			</view>
			<view class="jbxx-tip">{{jianliInfo.tips}} </view>
			<view class="jianli-bottom-box">
				<view @click="goXinyu">
					<icon class="bottom-icon xy-icon"></icon>
					<text class="bottom-text">信誉</text>
				</view>
				<view @click="goJiazhengManage">
					<icon class="bottom-icon zl-icon"></icon>
					<text class="bottom-text">资料编辑</text>
				</view>
				<view @click="goHtBtn">
					<icon class="bottom-icon ht-icon"></icon>
					<text class="bottom-text">合同</text>
				</view>
				<view @click="callPhone">
					<icon class="bottom-icon tel-icon"></icon>
					<text class="bottom-text">拨打电话</text>
				</view>
			</view>
		</view>
		<common-dialog ref="deleteDialogRef" :title="deleteTitle" :content="deleteConcent"
			@confirm-btn="deleteQuerenBtn"></common-dialog>
	</view>
</template>
<script>
	import {
		ref
	} from "vue";
	import {
		getJiazhengJianli,
		jiazhengUserDelete
	} from "@/api/jiazheng.js";
	import commonDialog from '@/components/dialog/commonDialog.vue';
	export default {
		data() {
			return {
				pageInfo: {},
				jianliInfo: {},
				deleteConcent: '你确定要执行这个操作吗？',
				deleteTitle: '删除',
				deleteIndex: '',
			}
		},
		components: {
			commonDialog
		},
		onLoad(options) {
			let data = JSON.parse(options.pageInfo)
			this.pageInfo.status = data.status
			this.pageInfo.id = data.id
			this.pageInfo.userId = data.userId
			this.pageInfo.from = data.from
			this.pageInfo.isZijiazheng = data.isZijiazheng
			this.pageInfo.userIdList = data.userIdList
			this.pageInfo.listIds = data.listIds
			this.pageInfo.startDate = data.startDate
			this.pageInfo.endDate = data.endDate
			this.pageInfo.from = data.from
			this.pageInfo.jzId = data.jzId
			this.getJianliInfo()
		},
		methods: {
			deleteUser() {
				this.$refs.deleteDialogRef.handleShow()
			},
			deleteQuerenBtn() {
				jiazhengUserDelete({
					ids: [this.pageInfo.id]
				}).then(res => {
					if (res.code == 0) {
						uni.showToast({
							title: "成功",
							icon: 'none',
							duration: 2000
						})
						this.goUpPage()
					}
				})
			},
			getJianliInfo() {
				let req = {
					id: this.pageInfo.id,
					userId: this.pageInfo.userId
				}
				getJiazhengJianli(req).then(res => {
					console.log('res', res);
					if (res.code == 0) {
						this.jianliInfo = {
							...res.data
						};
						// if(this.jianliInfo.zyNames){
							
						// }
					}
				})
			},
			callPhone() {
				if (this.jianliInfo.userName) {
					uni.makePhoneCall({
						phoneNumber: this.jianliInfo.userName
					});
				} else {
					uni.showToast({
						title: `无电话号`,
						icon: 'none',
						duration: 2000
					})
					return false
				}

			},
			
			goXinyu() {
				uni.navigateTo({
					url: "/pages/admin/Jiazheng/xinyong?userId=" + this.pageInfo.userId
				})
			},
			
			goJiazhengManage() {
				let pageInfo = {
					status: 'edit',
					id: this.pageInfo.id,
					userId: this.pageInfo.userId,
					isZijiazheng:this.pageInfo.isZijiazheng,
					userIdList:this.pageInfo.userIdList,
					listIds:this.pageInfo.listIds,
					startDate:this.pageInfo.startDate,
					endDate:this.pageInfo.endDate,
					from:this.pageInfo.from,
					jzId:this.pageInfo.jzId,
				}
				uni.redirectTo({
					url: "/pages/admin/Jiazheng/jiazhengUserManager?pageInfo=" + JSON.stringify(pageInfo)
				})
			},
			goUpPage() {
				if (this.pageInfo.from == 'banzheng') {
					uni.redirectTo({
						url: "/pages/admin/banzheng/list"
					})
				} else {
					uni.redirectTo({
					  url: "/pages/admin/Jiazheng/index" +
					       "?isZijiazheng=" + this.pageInfo.isZijiazheng +
					       "&userIdList=" + this.pageInfo.userIdList+
					       "&listIds=" + this.pageInfo.listIds+
					       "&startDate=" + this.pageInfo.startDate+
					       "&endDate=" + this.pageInfo.endDate+
					       "&from=" + this.pageInfo.from+
					       "&jzId=" + this.pageInfo.jzId
					})

				}

			},
			goHtBtn(){
				uni.navigateTo({
					url: `/pages/admin/Hetong/sanfangHetong?jzName=${this.jianliInfo.realName}&from=jiazheng`
				})
			},

		}
	}
</script>