<script>
export default {
    onLaunch(options) {
        wx.login({
            success: res => {
                this.$http
                    .post('auth/mpLogin', { code: res.code })
                    .then(res => {
                        // console.log(res);
                        this.$http.setToken(res.token);
                        this.$store
                            .dispatch('updateUserInfo')
                            .then(() => {
                                this.globalData.initialize = true;
                                if (this.globalData.initializeCallback) {
                                    this.globalData.initializeCallback();
                                }
                            })
                            .catch(() => {
                                this.globalData.initialize = true;
                            });
                    })
                    .catch(e => {
                        console.log(e);
                    });
            }
        });
    },
    onShow(options) {
        // Do something when show.
        console.log('App onShow');
    },
    onHide() {
        // Do something when hide.
        console.log('App onHide');
    },
    onError(msg) {
        console.log('App onError');
        console.log(msg);
    },
    globalData() {
        return {
            a: 'I am global data'
        };
    }
};
</script>

<style lang="less" scoped>
/deep/.van-image {
    display: block;
}
</style>
