// custom-tab-bar/index.js
Component({
	pageLifetimes: {
		show: function () {
			const routeList = getCurrentPages()
			this.setData({
				route: routeList[routeList.length - 1].route
			})
			const userInfo = wx.getStorageSync('userInfo')
			if (!userInfo.isDemonstrate) {
				if (routeList[routeList.length - 1].route === this.data.list[1].pagePath) {
					wx.reLaunch({
						url: '/' + this.data.list[0].pagePath
					})
				}
				this.setData({
					[`list[1].showTab`]: false
				})
			}
		},
	},
	/**
	 * 组件的属性列表
	 */
	properties: {

	},

	/**
	 * 组件的初始数据
	 */
	data: {
		route: '',
		color: "#000000",
		selectedColor: "#1890FF",
		list: [
			{
				pagePath: "pages/my-order/my-order",
				iconPath: "./tabBarImage/order.png",
				selectedIconPath: "./tabBarImage/order-select.png",
				text: "我的订单",
				showTab: true,
			},
			{
				pagePath: "pages/index/index",
				iconPath: "./tabBarImage/home.png",
				selectedIconPath: "./tabBarImage/home-select.png",
				text: "需求大厅",
				showTab: true,
			},
			{
				pagePath: "pages/person/person",
				iconPath: "./tabBarImage/person.png",
				selectedIconPath: "./tabBarImage/person-selected.png",
				text: "个人中心",
				showTab: true,
			},
		]
	},

	/**
	 * 组件的方法列表
	 */
	methods: {
		switchTab(e: any) {
			const data = e.currentTarget.dataset
			const url = data.path
			wx.reLaunch({ url: `/${url}` })
		}
	}
})
