<script>
	import { mapMutations, mapState } from 'vuex';
	export default {
		globalData: {  
			im: {}  
		},  
        computed: {
            ...mapState(["hasLogin"])
        },
		onLaunch() {
			getApp().globalData.im = this.imService
			// 缓存token
			uni.getStorage({
				key: "token",
				success: (res) => {
					this.loginIn(res.data);
				}
			})
            // 刷新token
            if (this.hasLogin) {
                this.refreshToken_function();
            }
		},
		methods: {
			...mapMutations(['loginIn']),
            // 刷新token
            refreshToken_function(){
            	this.$u.api.refreshToken({}).then((res) => {
            		// console.log(res);
            		if (res.errCode == 0) {
            			let token = res.data.token;
            			uni.setStorageSync('token', token);//存储toke值
            		}
            	})
            },
		}
	}
</script>
<style lang="scss">
	/* #ifndef APP-PLUS-NVUE */
	@import "/static/css/normalize";
    /* 顶部自定义导航留白 */
    .status_bar {
    	width: 100%;
    	height: var(--status-bar-height);
    }
    /* 自定义下拉 */
    .load-size {
        ::v-deep.u-more-text {
            font-size: 20rpx !important;
        }
    }
	/* #endif */
</style>
