<script>
var user = require('./utils/user.js');
export default {
    data() {
        return {};
    },
    onLaunch: function () {
        const updateManager = uni.getUpdateManager();
        uni.getUpdateManager().onUpdateReady(function () {
            updateManager.applyUpdate();
        });
    },
    onLoad() {
        var updateManager = uni.getUpdateManager();
        updateManager.onUpdateReady((res) => {
            uni.showModal({
                title: '更新提示',
                content: '新版本已经准备好，是否重启小程序？',
                success: (res) => {
                    if (res.confirm) {
                        // 新的版本已经下载好，调用 applyUpdate 应用新版本并重启
                        updateManager.applyUpdate();
                    }
                }
            });
        });
        updateManager.onUpdateFailed((err) => {
            // 新的版本下载失败
            console.log('版本下载失败原因', err);
            uni.showToast({
                title: '新版本下载失败，请稍后再试',
                icon: 'none'
            });
        });
    },
    onShow: function (options) {
        /*是否授权登录*/
        user.checkLogin()
            .then((res) => {
                this.globalData.hasLogin = true;
                if (this.globalData.checkLoginReadyCallback) {
                    this.globalData.checkLoginReadyCallback();
                }
            })
            .catch(() => {
                this.globalData.hasLogin = false;
            });
    },
    globalData: {
        hasLogin: false,
        userInfo: {},

        //是否注册过
        mapKey: 'AEZBZ-7JYL6-N4WSL-EFMOK-SAHSO-GLFA4',

        currentLocationName: '位置获取中',
        city: '',

        checkLoginReadyCallback: function () {
            //是否登录
            this.hasLogin = true;
        }
    }
};
</script>
<style>
/**app.ttss**/

.container {
    box-sizing: border-box;
    background-color: #f5f5f5;
    font-family: PingFangSC-Light, helvetica, 'Heiti SC';
}

view,
image,
text,
navigator {
    box-sizing: border-box;
    padding: 0;
    margin: 0;
}
page {
    color: #2a2a2a; /*主要颜色*/
    font-size: 28rpx;
    background: #f5f5f5;
}
text,
view {
    font-family: PingFangSC-Light, helvetica, 'Heiti SC';
    /* font-weight: 500; */
}
.sub-color {
    color: #85868a;
}
.jz-color {
    color: #09afff; /*鲸致色号00AFFF*/
}
.van-tab > view.van-ellipsis {
    color: #888;
}
.van-tab--active.van-tab > view.van-ellipsis {
    color: #09afff;
}

van-dialog .van-button {
    color: #09afff !important;
}
.van-dialog__message-text {
    color: #666;
}
.van-button--info {
    background: #09afff !important;
    border: none !important;
}
.bottom-fixed-btn-wrapper {
    position: fixed;
    bottom: 146rpx;
    left: 0;
    right: 28rpx;
    left: 28rpx;
}
.bottom-fixed-btn-wrapper .van-button {
    height: 74rpx;
    border: none;
}

.common-btn-wrapper {
    margin: 0 28rpx 0;
}
.common-btn-wrapper .van-button {
    height: 74rpx;
    margin: 0 0 48rpx 0;
}
</style>
