<template>
	<view class="admin-jiazheng-list">
		<view class="icon-title-navBar-box">
			<view @click="goUpPage" class="nav-bar-icon"></view>
			<text class="nav-bar-title">家政人员</text>
		</view>
		<v-tabs v-model="current" :tabs="tabs" :scroll="false" @change="changeTab" field="name"
			class="admin-tab-box"></v-tabs>
		<uni-list v-if="current ==1" class="jz-scroll-view">
			<uni-list-item v-for="item in list" class="jz-list-item-box">
				<template v-slot:body>

					<view @click="lookUserInfo(item)" class="card-body-row">
						<view class="card-img-box">
							<img :src="item.pic" v-if="item.pic">
							<icon class="phone-default-userImg" v-else></icon>
						</view>
						<view class="body-content-row">
							<view class="content-text-row">
								<view> {{item.name}}</view>
							</view>

						</view>
					</view>
				</template>
			</uni-list-item>
		</uni-list>
		<uni-list v-if="current ==2" class="jz-scroll-view">
			<view class="jz-new-btn-box">
				<button type="default" class="phone-green-btn" @click="addJiazhengRenyuan">新增人员</button>
			</view>

			<uni-list-item v-for="item in list" class="jz-list-item-box">
				<template v-slot:body>

					<view @click="lookUserInfo(item)" class="card-body-row">
						<view class="card-img-box">
							<img :src="item.pic" v-if="item.pic">
							<icon class="phone-default-userImg" v-else></icon>
						</view>
						<view class="body-content-row">
							<view class="content-text-row">
								<view> {{item.name}}</view>
							</view>

						</view>
					</view>
				</template>
			</uni-list-item>
		</uni-list>
	</view>
</template>

<script>
	import {
		ref
	} from "vue";
	import {
		kcSelectList
	} from "@/api/jiazheng.js";
	import commonDialog from '@/components/dialog/commonDialog.vue';

	export default {
		data() {
			return {
				kcClassifyId: 0,
				id: '',
				current: 1,
				list:[],
				tabs: [{
						id: 1,
						name: '未绑定课程',

					},
					{
						id: 2,
						name: '已绑定课程',

					},
				],
			}
		},
		components: {
			commonDialog,
		},
		onLoad(options) {
			this.id = options.id
			this.getList()
		},
		methods: {
			changeTab(data){
				console.log('data',data);
			},
			goUpPage() {
				if (this.pageInfo.from == 'banzheng') {
					uni.redirectTo({
						url: "/pages/admin/banzheng/list"
					})
				} else {
					uni.redirectTo({
						url: "/pages/admin/Jiazheng/index"
					})
				}
			},
			getList() {
				let req = {
					id: this.id,
					"kcClassifyId": this.kcClassifyId,
				}
				kcSelectList(req).then(res => {
					if (res.code == 0) {
						this.list = res.data
					} else {
						return false
					}
				})
			},
		}
	}
</script>