<template>
	<view class="wrap">
		
	</view>
</template>
<script>
	import {
		mapState
	} from 'vuex';

	export default {
		components: {

		},
		data() {
			return {
			
			}
		},

		onLoad() {

		},
		// #ifndef MP
		onNavigationBarButtonTap(e) {
			const index = e.index;
			if (index === 0) {
				this.navTo('/pages/set/set');
			} else if (index === 1) {
				// #ifdef APP-PLUS
				const pages = getCurrentPages();
				const page = pages[pages.length - 1];
				const currentWebview = page.$getAppWebview();
				currentWebview.hideTitleNViewButtonRedDot({
					index
				});
				// #endif
				uni.navigateTo({
					url: '/pages/notice/notice'
				})
			}
		},
		// #endif
		computed: {
			...mapState(['hasLogin', 'userInfo']),
		},
		onShow() {
			this.$api.doRequest('get', '/commonUser/api/checkSession').then(res => {
				console.log("checkSession", res)
				if (res.data.data == "INVALID") {
					uni.showModal({
						title: '登录提示',
						content: '当前登入信息验证失败，是否重新登录？',
						showCancel: true,
						confirmText: '登录',
						success: (e) => {
							if (e.confirm) {
								uni.navigateTo({
									url: '/pages/public/login'
								})
							}
						},
						fail: () => {},
						complete: () => {}
					})
				}
			})
			console.log("hasLogin", this.hasLogin)
		},
		methods: {
			/**
			 * 统一跳转接口,拦截未登录路由
			 * navigator标签现在默认没有转场动画，所以用view
			 */
			navTo(url) {
				if (!this.hasLogin) {
					url = '/pages/public/login';
				}
				uni.navigateTo({
					url
				})
			}
		}
	}
</script>
<style lang='scss' scoped>
	page {
		background: #F5F6FA;
	}

	.wrap {
		background: #fff;
		margin: 10px;
		border-radius: 10px;
		padding: 10px;
	}

	
</style>
