<template>
	<div class="p-merchantManagement-container g_bg_page">
		<div v-show="currentPage === 0" class="">
			<workbench :hasNewResume="hasNewResume" :hasNewApply="hasNewApply"></workbench>
		</div>
		<div v-if="currentPage === (isAdmin ? 1 : 2)">
			<jobList :show="showJob" :cuindex="cuindex"></jobList>
		</div>
		<div v-if="currentPage === (isAdmin ? 2 : 1)">
			<resumeNew />
		</div>
		<div v-show="currentPage === 3">
			<tools :firstLoad="firstLoad"></tools>
		</div>
		<!-- <u-tabbar :iconSize="48" imgType="custom" v-model="currentPage" :hideTabBar="false" :list="list" :active-color="themeColor" :before-switch="handleTab" class="tabbar" iconSize="48" @change="handleChange"></u-tabbar> -->
	</div>
</template>

<script>
import workbench from "./child/workbench.vue";
import jobList from "./child/jobList.vue";
import tools from "./child/tools.vue";
import resumeNew from "./child/resumeNew.vue";

export default {
	onLoad() {},
	onShow() {
		this.themeColor = getApp().globalData.themeColor;
		this.getResumeInfo();
	},
	onMounted() {
		// console.log("mountedmountedmountedmountedmountedmounted");
		const query = uni.createSelectorQuery().in(instance);
		// console.log("query", query);
		// 选择指定的 DOM 元素
		query
			.select(".tabbar")
			.boundingClientRect((res) => {
				uni.setStorageSync("TABBAR_HEIGHT", res.height);
			})
			.exec();
	},
	data() {
		return {
			isAdmin: uni.getStorageSync("IS_MINIAPP_ADMIN"), // 管理员判断
			hasNewResume: 0,
			hasNewApply: 0,

			cdnBaseImg: this.G.store().cdnBaseImg,
			showJob: false,
			currentPage: 0,
			list: [],
			pageTitle: "工作台",
			firstLoad: false,
			appid: uni.getAccountInfoSync().miniProgram.appId,
			cuindex: 0,
			themeColor: getApp().globalData.themeColor,
		};
	},
	components: {
		workbench,
		jobList,
		tools,
		resumeNew,
	},
	watch: {
		showJob(val) {
			console.log(val);
		},
	},
	created() {
		this.list = this.isAdmin
			? [
					{
						iconPath: "appstore g_c_9 iconfont ",
						selectedIconPath: "appstore iconfont ",
					selectedIconStyle: `color: ${getApp().globalData.themeColor}`,
						// iconPath: this.cdnBaseImg + "home.png",
						// selectedIconPath: this.cdnBaseImg + "homeActive0925.png",
						text: "工作台",
						customIcon: true,
						imgType: "custom",
						iconSize: 48,
						// pagePath: "/pages/home/index",
					},
					{
						iconPath: "detail g_c_9 iconfont ",
						selectedIconPath: "detail iconfont ",
					selectedIconStyle: `color: ${getApp().globalData.themeColor}`,
						// iconPath: this.cdnBaseImg + "bill.png",
						// selectedIconPath: this.cdnBaseImg + "billActive0925.png",
						text: "职位管理",
						customIcon: true,
						imgType: "custom",
						iconSize: 48,
						// pagePath: "/pages/bill/index",
					},
					{
						iconPath: "solution g_c_9 iconfont ",
						selectedIconPath: "solution iconfont ",
					selectedIconStyle: `color: ${getApp().globalData.themeColor}`,
						// iconPath: this.cdnBaseImg + "apply.png",
						// selectedIconPath: this.cdnBaseImg + "applyActive0925.png",
						text: "简历工单",
						customIcon: true,
						imgType: "custom",
						iconSize: 48,
						// pagePath: "/pages/bill/index",
					},
					// {
					// 	iconPath: this.cdnBaseImg + "apply.png",
					// 	selectedIconPath: this.cdnBaseImg + "applyActive0925.png",
					// 	text: "工具",
					// 	customIcon: false,
					// 	// pagePath: "/pages/apply/index",
					// },
				]
			: [
					{
						iconPath: "icon-appstore g_c_9",
						selectedIconPath: "icon-appstore",
					selectedIconStyle: `color: ${getApp().globalData.themeColor}`,
						// iconPath: this.cdnBaseImg + "home.png",
						// selectedIconPath: this.cdnBaseImg + "homeActive0925.png",
						text: "工作台",
						customIcon: true,
						imgType: "custom",
						// pagePath: "/pages/home/index",
					},
					{
						iconPath: "icon-solution g_c_9",
						selectedIconPath: "icon-solution",
					selectedIconStyle: `color: ${getApp().globalData.themeColor}`,
						// iconPath: this.cdnBaseImg + "apply.png",
						// selectedIconPath: this.cdnBaseImg + "applyActive0925.png",
						text: "简历工单",
						customIcon: false,
						imgType: "custom",
						// pagePath: "/pages/bill/index",
					},
				];
	},

	methods: {
		handleChange(e) {
			console.log("ee", e);
			this.cuindex = e;
			if (e == 1) {
				this.showJob = true;
			} else {
				this.showJob = false;
			}
		},
		getResumeInfo() {
			let that = this;
			that.G.Get(`/yishoudan/order/helper/check/neworder`, {}, (res) => {
				console.log("res", res);
				if (res > 0) {
					that.hasNewResume = res;
				}
				console.log("that.hasNewResume", that.hasNewResume);
				that.$forceUpdate();
			});
		},
		leftClick() {
			console.log("leftClick");
		},
		handleTab(e) {
			console.log(e);
			this.pageTitle = this.list[e].text;
			uni.setNavigationBarTitle({
				title: this.list[e].text,
			});
			return true;
		},
		goBack() {
			uni.navigateBack({
				delta: 1,
			});
		},
	},
};
</script>

<style>
.p-merchantManagement-container {
}
page {
	/* background-color: #f5f5f5; */
}
</style>
