<template>
	<view class="p-person-inedx g_w_all g_bg_f_5 g_kuaishou">
		<view class="g_h_10"></view>
		<!-- 基本信息 -->
		<view style="" class="g_mb_10">
			<g-panel-card-info
				:info="{
					avatar: userinfo.avatar ? userinfo.avatar : svgBaseImg + 'defaultAva.svg',
					title: userinfo.name,
					num: userinfo.tel,
					isHaveOrder: false,
				}"
				@clickCard="goPage('/root/person/info')"
			/>
		</view>
		<!-- <view class="g_mt_10 g_mb_10">
			<g-panel-form-item
				:list="[
					{
						icon: 'wodegongzuo2',
						label: '我的报名',
						result: '',
						path: '/root/person/enrollList',
						tip: 'set',
						pRow: 12,
					},
				]"
				@clickItem="goPage('/root/person/enrollList')"
			/>
		</view> -->
		<g-panel-card-num :list="cardList" :speed="1" :marginBottom="16" cusType="image" :height="26" :num="4" cusTitle="我的卡包" @clickItem="handleClickNum" />
		<view class="g_mt_10" hover-class="none" hover-stop-propagation="false">
			<g-panel-card-num :list="serverList" :marginBottom="16" class="" :height="26" :speed="1" :num="4" cusType="image" cusTitle="我的服务" @clickItem="handleClickNum" />
		</view>

		<view class="g_mt_10">
			<g-panel-form-item
				:list="[
					{
						icon: 'fankuiyujianyi',
						label: '反馈与建议',
						result: '',
						path: '/root/person/feedback',
						tip: 'set',
						pRow: 12,
					},
				]"
				@clickItem="goPage('/root/person/feedback')"
			/>
		</view>
		<view class="g_mt_10">
			<g-panel-form-item
				:list="[
					{
						icon: 'shezhi',
						label: '设置',
						result: '',
						path: '/root/person/set',
						tip: 'set',
						pRow: 12,
					},
				]"
				@clickItem="goPage('/root/person/set')"
			/>
		</view>
		<view class="g_bg_f g_h_56 g_ml_12 g_mr_12 g_mt_24 g_radius_8 g_flex_row_center flex_center g_position_rela" @click="goPage('/root/merchantManagement/merchantManagement')" hover-class="thover" v-if="isMember && hasPermission">
			<view class="iconfont icon-shangjiahoutai g_mr_6 g_mt_2"></view>
			<view class="g_fw_600 g_fs_17">商家管理后台</view>
			<u-badge v-if="hasNewResume > 0" :offset="[20, 200]" :count="hasNewResume"></u-badge>
		</view>
		<view class="g_h_100"></view>
	</view>
</template>

<script>
export default {
	onShareAppMessage() {
		return this.G.shareFun();
	},
	onReady() {
		this.G.setNavStyle();
	},
	data() {
		return {
			hasNewResume: 0,
			isMember: uni.getStorageSync("IS_MINIAPP_MEMBER"),
			hasPermission: uni.getStorageSync("HAS_PERMISSION") == 1 ? true : false, // 登陆者是否有权限查看
			miniAppInfo: uni.getStorageSync("miniApp-info"),
			pageSpeed: -1,
			isLogin: null,
			localBaseImg: this.G.store().localBaseImg,
			cdnBaseImg: this.G.store().cdnBaseImg,
			svgBaseImg: this.G.store().svgBaseImg,
			speed: -1,
			navInfo: {},
			userinfo: {
				all: {},
				avatar: "",
				name: "微信用户",
				tel: "全心全意为老乡服务",
				num: [
					{
						name: "",
						num: "",
					},
				],
				agencyName: "",
				teamType: 0,
			},
			numList: [
				{
					name: "完单数",
					num: 28,
				},
				{
					name: "工作时长",
					num: 10,
				},
				{
					name: "好评率",
					num: 100,
				},
				{
					name: "履约率",
					num: 100,
				},
			],
			renList: [
				{
					name: "岗位认证",
					image: "job.svg",
				},
				{
					name: "资质认证",
					image: "zizhirenzheng.svg",
				},
				{
					name: "我的商家",
					image: "myshop.svg",
				},
				{
					name: "更多功能",
					image: "more.svg",
				},
			],
			cardList: [
				{
					name: "证件",
					icon: "zhengjian",
					path: "/root/person/idcardList",
					iconType: 1,
				},
				{
					name: "银行卡",
					icon: "yinhangka",
					path: "/root/person/bankList",
					iconType: 1,
				},
				{
					name: "工资条",
					icon: "gongzitiao",
					path: "/root/other/empty?type=工资条",
					iconType: 1,
				},
				{
					name: "优惠券",
					icon: "youhuiquan",
					path: "/root/other/empty?type=优惠券",
					iconType: 1,
				},
			],
			serverList: [
				// {
				// 	name:'证件',
				// 	icon:'zj911.svg',
				// 	path:'/root/person/idcardList'
				// },
				{
					name: "报名记录",
					icon: "wodebaoming",
					path: "/root/person/enrollList?from=toc",
					iconType: 1,
				},
				{
					name: "想去职位",
					icon: "shoucang1",
					path: "/root/person/collect",
					iconType: 1,
				},
				{
					name: "我的简历",
					icon: "wodejianli",
					path: "/root/other/empty?type=我的简历",
					iconType: 1,
				},

				{
					name: "当前工作",
					icon: "wodeshoucang1",
					path: "/root/other/empty?type=当前工作",
					iconType: 1,
				},
				{
					name: "地址本",
					icon: "dizhiben",
					path: "/root/person/addressList",
					iconType: 1,
				},
				{
					name: "费用报销",
					icon: "feiyongbaoxiao",
					path: "/root/other/empty?type=费用报销",
					iconType: 1,
				},
				{
					name: "我的合同",
					icon: "hetong",
					path: "/root/other/empty?type=我的合同",
					iconType: 1,
				},
				{
					name: "预支薪资",
					icon: "shouye",
					path: "/root/other/empty?type=预支薪资",
					iconType: 1,
				},
			],
		};
	},
	onLoad() {
		let that = this;
		that.navInfo = that.G.getNavInfo();

		if (this.isMember && this.hasPermission) {
			this.serverList.push({
				name: "海报分享",
				icon: "sharing",
				path: "/root/merchantManagement/posterShare",
			});
		}
	},
	onShow() {
		let that = this;
		if (typeof that.$mp.page.getTabBar === "function" && that.$mp.page.getTabBar()) {
			that.$mp.page.getTabBar().setData({
				selected: 2,
				isShow: true,
			});
		}
		if (uni.getStorageSync("apply-token")) {
			that.setUserInfo();
			that.getResumeInfo();
		} else {
			that.pageSpeed = 1;
			that.isLogin = false;
			that.userinfo.avatar = that.G.store().svgBaseImg + "defaultAva.svg";
			that.userinfo.name = "微信用户";
			that.userinfo.tel = that.miniAppInfo.slogan || "全心全意为老乡服务";
			// that.userinfo.tel = "钱多 活少 离家近";
			that.userinfo.agencyName = "";
			that.userinfo.teamType = 0;
			that.speed = 0;
		}
	},
	methods: {
		getResumeInfo() {
			let that = this;
			that.G.Get(`/yishoudan/order/helper/check/neworder`, {}, (res) => {
				console.log("res", res);
				that.hasNewResume = res;
				console.log("that.hasNewResume", that.hasNewResume);
				that.$forceUpdate();
			});
		},
		setUserInfo() {
			let that = this;
			that.speed = 1;
			let userInfo = uni.getStorageSync("apply-userinfo");
			that.isLogin = true;
			that.userinfo.agencyName = userInfo.agencyName;
			that.userinfo.user = userInfo.user;
			that.userinfo.avatar = uni.getStorageSync("apply-avatar");
			that.userinfo.name = userInfo.userName || userInfo.aliasName;
			that.userinfo.tel = uni.getStorageSync("apply-tel");
			that.userinfo.agencyName = userInfo.agencyName;
			that.userinfo.teamType = userInfo.teamType;
		},
		goPage($path) {
			this.G.isLogin();
			if (this.G.isLogin()) {
				uni.navigateTo({
					url: $path,
				});
			}
		},
		handleClickNum(e) {
			console.log("我的服务：", e);
			this.G.isLogin();
			if (this.G.isLogin()) {
				uni.navigateTo({
					url: e.item.path,
				});
			}
		},
	},
};
</script>

<style lang="scss">
.p-person-inedx {
	min-height: 100vh;
	background-repeat: no-repeat;
	background-size: 100% 100%;
	.m-money {
		width: calc(100vw - 20px);
		margin: 10px auto 0;
		height: 84px;
		background-repeat: no-repeat;
		background-size: 100% 100%;
		overflow: hidden;
		border-radius: 6px;
		.con {
			left: 0;
			top: 50%;
			width: 100%;
			height: 200%;
			transform: translateY(-50%);
		}
	}
}
</style>
