let _Http = getApp().globalData.http
Page({
    data: {
        verification: false,
        password: ""
    },
    onLoad(options) {
        if (_Http.ENV != 'develop') {
            this.setData({
                verification: true
            })
        } else {
            this.init();
        }
    },
    init() {
        this.setData({
            runtimeEnvironment: _Http.ENV == 'develop' ? '开发环境' : '生产环境',
            "baseUrl": _Http.baseUrl,
            urls: _Http.urls,
            verification: false
        })
    },
    onInput(e) {
        this.setData({
            password: e.detail
        })
    },
    enterInto() {
        if (this.data.password != 'jxys@12345') return wx.showToast({
            title: '密码错误',
            icon: "none"
        })
        this.init()
    },
    onChange({
        detail
    }) {
        console.log(detail)
        let that = this;
        wx.showModal({
            title: '提示',
            content: `是否确定将服务地址修改为“${detail}”?`,
            complete: (res) => {
                if (res.cancel) that.setData({
                    baseUrl: that.data.baseUrl
                })
                if (res.confirm) {
                    that.setData({
                        baseUrl: detail
                    })
                    _Http.baseUrl = detail;
                    wx.showToast({
                        title: '修改成功',
                    })
                }
            }
        })
    }
})