<template>
	<view>
		<!-- <me-tabs v-model="TabCur" :tabs="workTabList" @change="changeTab"></me-tabs> -->
		
		<navigator hover-class='none' @tap="isLogin" :url="login?'/workBenchPages/pages/' + item.name +'/' + item.name : ''" class="nav-li" navigateTo
		 :style="[{animation: 'show ' + ((index+1)*0.2+1) + 's 1'}]" v-for="(item,index) in workTypeList" :key="index" >
			<view class="work-type" :class="item.type">
				<text class="work-cus-text">{{item.title}}</text>
			</view>	
			
		</navigator>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				// workTabList:[
				// 	// {
				// 	// 	name: '基础应用'
				// 	// },
				// 	{
				// 		name: '业务应用'
				// 	},
				// ],
				workTypeList: [
					// {
					// 	title: '客户资源管理系统',
					// 	name: 'customer',
					// 	type: 'customer',
					// 	num:0
					// },
					{
						title: '担保业务管理系统 ',
						name: 'guarantee',
						type: 'guarantee',
						num:1
					},
					// {
					// 	title: '保后业务管理系统',
					// 	name: 'afterGuarantee',
					// 	type: 'afterGuarantee',
					// 	num:1
					// },
				],
				TabCur: 1,
				scrollLeft: 0,
				login:true,// 判断是否登录
			};
		},
		onShow(){
			// 登录过不阻止跳转
			if(uni.getStorageSync('token')){
				this.login = true 
			}else{
				this.login = false
			}
			let arr = uni.getStorageSync('routerArr')
			// 节省性能处理，当切换的列表数组为空，且取得了登录信息，才进行分配
			// 放在onshow是防止用户首次切入到工作台，导致判断无了
			if(arr&&this.workTypeList.length==1){
				if(arr.join().includes('客户资源管理系统')){
					// this.workTabList.unshift({
					// 	name: '基础应用'
					// })
					this.workTypeList.unshift(
						{
							title: '客户资源管理系统',
							name: 'customer',
							type: 'customer',
							num:0
						}
					)
				}
				if(arr.join().includes('保后业务管理系统')){
					this.workTypeList.push(
						{
							title: '保后业务管理系统',
							name: 'afterGuarantee',
							type: 'afterGuarantee',
							num:1
						}
					)
				}
			}
		},
		methods: {
			tabSelect(e) {
				this.TabCur = e.currentTarget.dataset.id;
				this.scrollLeft = (e.currentTarget.dataset.id - 1) * 60
			},
			changeTab(index){
				this.TabCur = index;
			},
			isLogin(){
				if(!this.login){
					uni.showToast({
						title:"请先到'我的'进行登录后再操作",icon:'none'
					})
				}
			}
		}
	}
</script>

<style lang="scss" scoped>
	.customer{
		background: url(../../static/img/btn_1.png) no-repeat;
	}
	.guarantee{
		background: url(../../static/img/btn_2.png) no-repeat;
	}
	// 还有一张保后的图
	.afterGuarantee{
		background: url(../../static/img/btn_3.png) no-repeat;
	}
	.work-type{
		width: 650rpx;
		height: 190rpx;
		position: relative;
		background-size: 100%;
		cursor: pointer;
		top: 30rpx;
		left: 50%;
		transform: translate(-50%,0);
		.work-cus-text{
			position: absolute;
			top: 50%;
			left: 60rpx;
			transform: translate(0,-50%);
			font-size: 28rpx;
			color: #666;
		}
	}
</style>
