/**
 *  Web唐明明
 *  匆匆数载恍如梦，岁月迢迢华发增。
 *  碌碌无为枉半生，一朝惊醒万事空。
 */

import { tabBar } from "../../lib/storeConfig"
import { mall, video, ticket, user } from "../../lib/tabBarData"

Page({
    /**
     * 生命周期函数--监听页面加载
     */
    onLoad(e) {
        if (e.companyoid && e.companyoid == "") {
            wx.showToast({
                title: "参数错误，缺少companyoId"
            })
            return
        }

        wx.$api.publics.storeConfig({
            company_id: e.companyoid
        }).then(res => {
            let tabBarVal = res.concat({})
            tabBarVal.forEach(res => {
                switch (res.slug) {
                    case "video":
                        tabBar.push(video)
                        break;
                    case "mall":
                        tabBar.push(mall)
                        break;
                    case "ticket":
                        tabBar.push(ticket)
                        break;
                    default :
                        tabBar.push(user)
                        break;
                }
            })
            wx.switchTab({
                url: tabBar[0].pagePath
            })
        })
    }
})