<template>
	<view>
		<view v-if="user.userType != '3'" style="padding: 15px 30rpx 5rpx 30rpx;">
			<view class="" style="display: flex;flex-flow: row wrap;">
				<view class="topTools" @click="toTXLPage()">
					<view>
						<image src="../../static/img/app/txl.png"></image>
						通讯录
					</view>
				</view>
				<view class="topTools">
					<view>
						<image src="../../static/img/app/zzgl.png"></image>
						组织
					</view>
				</view>
				<view class="topTools" @click="$goto('../../pageApp/my/MyApproval')">
					<view>
						<image src="../../static/img/app/wddb.png"></image>
						待办
					</view>
				</view>
				<view class="topTools">
					<view>
						<image src="../../static/img/app/rc.png"></image>
						日程
					</view>
				</view>
			</view>
		</view>
		<view v-if="user.userType != '3'" class="view view1">
			<view>
				我的
			</view>
			<classify1 :list="me"></classify1>
		</view>
		<view v-if="type === 3">
			<view v-if="user.userType != '3'" class="view">
				<view>
					人事管理
				</view>
				<classify1 :list="personnel"></classify1>
			</view>
			<view v-if="user.userType != '3'" class="view">
				<view>
					行政管理
				</view>
				<classify1 :list="administrative"></classify1>
			</view>
			<view v-if="user.userType != '3'" class="view">
				<view>
					工会服务
				</view>
				<classify1 :list="workerAssociationAppData"></classify1>
			</view>
			<view v-if="user.userType != '3'" class="view">
				<view>
					其他
				</view>
				<classify1 :list="elseAppData"></classify1>
			</view>
		</view>
		<view v-if="type === 4">
			<view v-for="item in hsjkAppPageData" class="view">
				<view>
					{{item.modelName}}
				</view>
				<classify1 :list="item.data"></classify1>
			</view>
		</view>
		<view class="view">
			<view>
				平台应用
			</view>
			<classify1 :list="indexConfig.middleIcon" :url="baseURL"></classify1>
		</view>
	</view>
</template>

<script>
	import Classify1 from '@/components/classify-1/classify-1.vue'
	import {
		hsjkAppPageData
	} from './hskj.js'
	export default {
		components: {
			Classify1
		},
		data() {
			return {
				hsjkAppPageData: hsjkAppPageData,
				type: undefined,
				baseURL: this.$BASE_URL,
				indexConfig: [{
					name: 'classify-1',
					data: []
				}],
				me: [{
					text: '我的已办',
					imgPath: '../../static/img/app/yiwancheng.png',
					link: "../../pageApp/my/myAll",
				}, {
					text: '我的发起',
					imgPath: '../../static/img/app/wdfq.png',
					link: "../../pageApp/my/myLaunch",
					count: 0
				}, {
					text: '我的审批',
					imgPath: '../../static/img/app/dengdaishenpi.png',
					link: "../../pageApp/my/MyApproval",
					count: 0
				}, {
					text: '抄送记录',
					imgPath: '../../static/img/app/qjjl.png',
					link: "../../pageApp/my/myCc",
					count: 0
				}, {
					text: '我的档案',
					imgPath: '../../static/img/app/wdda.png',
					link: "../../pages/user/profile"
				}],
				personnel: [{
						text: '请假申请',
						imgPath: '../../static/img/app/qingjia.png',
						link: "../../pageApp/hr/leave"
					},
					{
						text: '入职办理',
						imgPath: '../../static/img/app/rzsq.png',
						link: "../../pageApp/hr/entry",
					},
					{
						text: '离职申请',
						imgPath: '../../static/img/app/lzsq.png',
						link: "../../pageApp/hr/dimission",
					}, {
						text: '工资条',
						imgPath: '../../static/img/app/gzt.png',
						link: "../../pageA/salary/salary",
						count: 0
					},
					// {
					// 	text: '面试记录',
					// 	imgPath: '../../static/img/app/gzt.png',
					// 	link: "../../pageApp/hr/interview",
					// 	count: 0
					// }
				],
				administrative: [{
						text: '物资登记',
						imgPath: '../../static/img/app/wuzidengji.png',
						link: "../../pageApp/administration/reserve?pageType=dj"
					}, {
						text: '物资领用',
						imgPath: '../../static/img/app/wupinglinyong.png',
						link: "../../pageApp/administration/reserve?pageType=ly"
					}, 
					// {
					// 	text: '物资归还',
					// 	imgPath: '../../static/img/app/wpgh.png',
					// 	link: "../../pageApp/administration/reserve?pageType=gh"
					// },
					{
						text: '用章申请',
						imgPath: '../../static/img/app/yzsq.png',
						link: "../../pageApp/administration/useSeal"
					}
					// , {
					// 	text: '合同管理',
					// 	imgPath: '../../static/img/app/htgl.png',
					// 	link: "../../pageApp/other/contract"
					// }
				],
				workerAssociationAppData: [{
					text: '福利领取',
					imgPath: '../../static/img/app/fulilingqu.png',
					link: "../../pageA/club/welfareList",
					count: 0
				}, {
					text: '社团预约',
					imgPath: '../../static/img/app/shetuanyuyue.png',
					link: "../../pageA/club/index"
				}, {
					text: '关心关爱',
					imgPath: '../../static/img/app/gxga.png',
					link: "../../pageA/club/careAndLove"
				}],
				elseAppData: [{
					text: '采购申请',
					imgPath: '../../static/img/app/cgsq.png',
					link: "../../pageApp/other/purchase"
				}, 
				// {
				// 	text: '设备报废',
				// 	imgPath: '../../static/img/app/devicebaofei.png',
				// 	link: "../../pageApp/other/scrap"
				// }, 
				{
					text: '报修申请',
					imgPath: '../../static/img/app/devicebaoxiu.png',
					link: "../../pageApp/other/repairs"
				}],
				user: {}
			}
		},
		mounted() {
			this.$wsConnection.reconnect()
			this.type = uni.getStorageSync("tabType")
			this.user = uni.getStorageSync("userInfo")
			let orgInfo = uni.getStorageSync("orgInfo");
			uni.setStorageSync('refreshStart', 1)
			let baseUrlSocket = this.$BASE_URL_SOCKET

			if (!uni.getStorageSync('deptData')) {
				this.$httpRequest({
					url: '/app/deptInfo?id=' + uni.getStorageSync('org_dept_parent_id'),
					urlType: this.$getUrlType()
				}).then(res => {
					if (res.data.code === 200) {
						uni.setStorageSync('deptData', res.data.data)
					}
				})
			}
			if (!uni.getStorageSync('postsData')) {
				this.$httpRequest({
					url: '/app/posts',
					urlType: this.$getUrlType()
				}).then(res => {
					if (res.data.code === 200) {
						uni.setStorageSync('postsData', res.data.data)
					}
				})
			}
			let that = this
			that.updateMsg()
			setInterval(() => {
				that.updateMsg()
			}, 1000);
		},
		onShow() {
			uni.reLaunch({
				url: '/pages/tabbar/wpTabbar'
			})
			// uni.switchTab({
			// 	url: 'pages/integral/index'
			// })
			this.user = {}
			// this.getHomeConfigData()
			this.user = uni.getStorageSync("userInfo")
			let orgInfo = uni.getStorageSync("orgInfo");
			// let pinf = plus.push.getClientInfo();
			// let cid = pinf && pinf.clientid || ''; //客户端标识
		},
		onHide() {},
		methods: {
			updateMsg() {
				//初始化
				this.me[1].count = 0
				this.me[2].count = 0
				this.me[3].count = 0
				this.personnel[3].count = 0
				let data = uni.getStorageSync("msgData")
				if (!data) {
					this.me[1].count = 0
					this.me[2].count = 0
					this.me[3].count = 0
					this.personnel[3].count = 0
					return
				}
				data = JSON.parse(data)
				//参数赋值
				this.me[1].count = data.m4
				this.me[2].count = data.m1 + data.m5
				this.me[3].count = data.m7
				this.personnel[3].count = data.m3
				this.workerAssociationAppData[0].count = data.m8
			},
			toTXLPage() {
				this.$goto("../../pageA/msg/index")
			},
			async getHomeConfigData() {
				const {
					data: res
				} = await this.$httpRequest({
					url: '/config/getHomeConfigData?orgCode=' + uni.getStorageSync("orgInfo")
						.organizationCode,
					method: 'get',
				})
				if (res.code == 200) {
					this.indexConfig = res.data
				} else {
					this.indexConfig = []
					uni.showToast({
						icon: 'none',
						title: res.msg
					})
				}
			}
		}
	}
</script>

<style lang="scss" scoped>
	.view {
		background-color: #ffffff;
		border: 1px solid #e0e0e0;
		color: #616161;
		margin-bottom: 5px;
		margin-left: 15rpx;
		margin-right: 15rpx;
		padding: 5px 10px;
		border-radius: 25rpx;
		font-size: 15px;
		padding: 5px 15px;
	}

	.view1 {
		margin-top: 5px;
	}

	.topTools {
		color: #5a5a5a;
		text-align: center;
		flex-direction: row;
		justify-content: center;
		width: 25%;
		font-size: 14px;
	}

	.topTools image {
		width: 50px;
		height: 50px;
	}

	.uni-tabbar__icon {
		width: 48px;
		height: 24px;
	}
</style>
