let app = getApp()
Page({

    /**
     * 页面的初始数据
     */
    data: {
        // tabBar param
        tabBarParam: {
            selected: 2,
            color: "#515151",
            selectedColor: "#217CFF",
            backgroundColor: "#ffffff",
        },
        // tabBar menu
        tabBarList: [{
                "pagePath": "pages/index/index",
                "iconPath": "/images/tabbar/home.png",
                "selectedIconPath": "/images/tabbar/home-select.png",
                "text": "首页"
            },
            {
                "pagePath": "pages/meeting/accessControl/accessControl",
                "iconPath": "/images/tabbar/openDoor.png",
                "selectedIconPath": "/images/tabbar/openDoor.png",
                "text": "开门",
                "bulge": true,
            },
            {
                "pagePath": "pages/my/my",
                "iconPath": "/images/tabbar/my.png",
                "selectedIconPath": "/images/tabbar/my-select.png",
                "text": "我的"
            },
        ],
        DOMAIN_NAME: app.IMG_NAME,
        customerPages: [
            [{
                    listIcon: "icontubiao-1",
                    zh: "我的活动",
                    url: "/pages/myActivities/myActivities",
                    borderRadius: '20rpx 20rpx 0 0'
                },
                {
                    listIcon: "iconqiyexinxi",
                    zh: "业务申请",
                    url: "../my/serviceApply/serviceApply"
                },
                {
                    listIcon: "iconqiyexinxi",
                    zh: "园区建议",
                    url: "/pages/complaint/complaint",
                    borderRadius: '0 0 20rpx 20rpx',
                    marginbottom: true
                },
                {
                    listIcon: "iconzhanghaoshezhi",
                    zh: "账号设置",
                    url: "/pages/my/accountSetting/accountSetting",
                    borderRadius: '20rpx 20rpx 0 0'
                },
                {
                    listIcon: "iconfuwu",
                    zh: "我的服务",
                    url: "/pages/enterpriseServices/myServiceList/myServiceList"
                },
                {
                    listIcon: "iconguzhangbaoxiu",
                    zh: "我的报修",
                    url: "/pages/parkRepair/parkRepair",
                    borderRadius: '0 0 20rpx 20rpx'
                }
            ]
        ],
        memberInfo: {}
    },

     // 切换tabbar
     switchTab(e) {
        const data = e.currentTarget.dataset
        console.log('switchTab', data)
        const url = data.path
        if(url == 'pages/meeting/accessControl/accessControl'){
            wx.navigateTo({
                url: '/' + url
            })
        }else{
            wx.switchTab({
                url: '/' + url
            })
        }
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad(options) {},
    onShow() {
        let that = this
        if (wx.getStorageSync('token')) {
            app.AjaxRequest('get', {
                'content-type': 'application/json',
                'Authorization': 'Bearer ' + app.Getopenid()
            }, '/user/profile', {}, function (res) {
                that.setData({
                    memberInfo: res.data
                })
            })
        } else {
            app.getlogin()
        }
    },
    navDetail(e) {
        wx.navigateTo({
            url: e.currentTarget.dataset.url,
        })
    },
    navigateTo(e) {
        if (wx.getStorageSync('token')) {
            if (e.currentTarget.dataset.url == '/pages/parkRepair/parkRepair') {
                wx.switchTab({
                    url: e.currentTarget.dataset.url,
                })
            } else {
                wx.navigateTo({
                    url: e.currentTarget.dataset.url,
                })
            }
        } else {
            app.getlogin()
        }
    },
    navpersonalData() {
        if (wx.getStorageSync('token')) {
            wx.navigateTo({
                url: '../my/personalData/personalData',
            })
        } else {
            wx.navigateTo({
                url: '/pages/login/login',
            })
        }
    }
})