App.vue 1.24 KB
<script>
	import config from '@/config.js';
	import {
		getInfo,
		getWebInfo
	} from '@/common/login.js';

	export default {
		globalData: {
			isLogin: false,
			baseUrl_api: '',
			user: null
		},
		onLaunch: function(options) {
			console.log('App Launch', options);
			this.globalData.baseUrl_api = config.baseUrl_api;

			let userName = uni.getStorageSync('userName')
			if (userName) {
				getInfo().then(() => {
					this.globalData.isLogin = true
					uni.reLaunch({
						url: '/pages/index/home'
					})
				}).catch(() => {
					uni.reLaunch({
						url: '/login/login'
					})
				})
				return
			}

			let webUserName = uni.getStorageSync('webUserName')
			if (webUserName) {
				getWebInfo().then(() => {
					uni.reLaunch({
						url: '/personal/home'
					})
				}).catch(() => {
					uni.reLaunch({
						url: '/login/login'
					})
				})
				return
			}

			this.globalData.isLogin = false
			uni.reLaunch({
				url: '/login/login'
			})
		},
		onShow: function() {
			console.log('App Show');
		},
		onHide: function() {
			console.log('App Hide');
		}
	};
</script>

<style lang="scss">
	/*每个页面公共css */
	@import '/common/uni.css';
	@import '/common/mystyle.scss';
</style>