let _Http = getApp().globalData.http

Page({
    data: {
        account_list: []
    },
    onLoad(options) {
        for (var key in options) {
            if (key.length > 30 && key.includes("_")) {
                let value = key.split("_")
                wx.setNavigationBarTitle({
                    title: 'loading...',
                })
                _Http.appName = value[1];
                const languages = value[2] ? value[2].toUpperCase() : 'ZH';
                getApp().globalData.Language.getLanguages(languages).then(s => {
                    _Http.base({
                        "id": 2024092514364201,
                        accesstoken: value[0]
                    }).then(res => {
                        console.log('通过token获取登录数据', res);
                        if (res.code != 1) {
                            wx.showToast({
                                title: res.msg,
                                icon: "none",
                                mask: true
                            })
                            setTimeout(() => {
                                wx.redirectTo({
                                    url: '/pages/login/phone',
                                })
                            }, 500);
                            return
                        }
                        wx.removeStorageSync('userMsg');
                        wx.removeStorageSync('account_list');
                        wx.setStorageSync('userMsg', res.data);
                        wx.setStorageSync('account_list', [res.data])
                        require('./modules/login').init();
                    })
                })
            }
        }
        this.setData({
            account_list: wx.getStorageSync('account_list')
        })
    },
    toHome(e) {
        wx.removeStorageSync('userMsg')
        wx.setStorageSync('userMsg', e.currentTarget.dataset.item);
        require('./modules/login').init();
    },
    onShow() {
        getApp().globalData.Language.setNavBarTitle('选择站点')
        this.setData({
            account_list: wx.getStorageSync('account_list')
        })
    }
})