<script>
	import Vue from 'vue'
  import util from '@/common/utils'
	import {
		mapGetters,
		mapActions,
		mapMutations
	} from 'vuex'
	export default {

		computed:{
			...mapGetters({'user':'getUser'})
		},
		methods: {

			...mapActions(['memberLogin','getLoginCode']),
			...mapMutations(['setVisitChannels']),
		},
		onLaunch: function(options) {
			uni.getSystemInfo({
				success: function(e) {
					// #ifndef MP
					Vue.prototype.StatusBar = e.statusBarHeight;
					if (e.platform == 'android') {
						Vue.prototype.CustomBar = e.statusBarHeight + 50;
					} else {
						Vue.prototype.CustomBar = e.statusBarHeight + 45;
					};
					// #endif

					// #ifdef MP-WEIXIN
					Vue.prototype.StatusBar = e.statusBarHeight;
					let custom = wx.getMenuButtonBoundingClientRect();
					Vue.prototype.Custom = custom;
					Vue.prototype.CustomBar = custom.bottom + custom.top - e.statusBarHeight;
					Vue.prototype.pageWindowHeight = e.screenHeight-custom.bottom - custom.top + e.statusBarHeight;;
					// #endif


				}
			})

			let _this = this
			if (this.user.WeChat_MiniProToken) {
        console.log('有')
				this.memberLogin()
			} else {
        console.log('无')
				this.getLoginCode()
			}

			this.setVisitChannels(options.scene)
			const updateManager = uni.getUpdateManager()
			updateManager.onUpdateReady(function(res) {
				uni.showModal({
					title: '更新提示',
					content: '新版本已经准备好，是否重启应用？',
					success(res) {
						if (res.confirm) {
							// 新的版本已经下载好，调用 applyUpdate 应用新版本并重启
							updateManager.applyUpdate();
						}
					}
				});

			});
			this.$util.addUserBehavior( {intoRoute: '/'+options.path, outtoRoute: ''}) // 记录用户行为

		},
		onShow: function() {

			// var pages = getCurrentPages() // 获取加载的页面
			//     let len = pages.length
			//     if (len > 0) {
			//       var currentPage = pages[len - 1] // 获取当前页面的对象
			//       var nowRoute = '/' + currentPage.route // 当前页面url
			//       this.$util.addUserBehavior({intoRoute: nowRoute, outtoRoute: ''}) // 记录用户行为
			//     }
			console.log('App Show')
      // uni.hideTabBar()
		},
		onHide: function(options) {
			let pages = getCurrentPages() // 获取加载的页面

			let len = pages.length
			if (len > 0) {
				let currentPage = pages[len - 1] // 获取当前页面的对象
				let nowRoute = '/' + currentPage.route // 当前页面url
				this.$util.addUserBehavior( {intoRoute: '', outtoRoute:nowRoute}) // 记录用户行为
			}
			console.log('App Hide')
		}
	}
</script>

<style>
	@import url("./common/uni.css");
	/*每个页面公共css */
	page {
		font-size: 26rpx;
		color: #333;
		height: 100%;
		background-color: #f8f9fb;
		line-height: 1.2;

	}

	/* 加载更多 */
	.load-more {
		text-align: center;
		width: 100%;
		height: 80rpx;
		color: #9999;
		font-size: 24rpx;
	}

	/* 审核环节最后一个加底部边距 */
	.process-box.uni-active {
		padding-bottom: 30rpx;
	}
	.process-box process-unit:nth-last-child(1) .prosess-unit::before{
		content: '';
		width: 0rpx;
	}
	.ico,
	.ico-s {
		display: block;

	}

	.ico-s:before,
	.ico:before {
		content: '';
		width: 36rpx;
		height: 34rpx;
		display: block;

		margin-right: 6rpx;
		background-repeat: no-repeat;
		background-size: contain;
		background-position: center;
	}

	.ico-s:before {
		width: 18rpx;
		height: 18rpx;
	}

	.ico-fj:before {
		background-image: url('./static/images/fjwj.png');
	}

	.ico-tp:before {
		background-image: url('./static/images/fjtp.png');
	}

	.ico-bz:before {
		background-image: url('./static/images/tender/yj.png');
	}

	/* #ifdef MP-WEIXIN */
	/*
		checkbox .wx-checkbox-input {
			border-radius: 20%;
			border: 1rpx solid #91A6D7;
			width: 42rpx;
			height: 42rpx;

		}

		checkbox .wx-checkbox-input.wx-checkbox-input-checked {
			background-color: #91A6D7;
			color: #fff !important;
		}

		checkbox .wx-checkbox-input.wx-checkbox-input-checked::before {
			font-size: 30rpx;
		} */

		 checkbox .wx-checkbox-input {
			border-radius: 50% ;
			background-color: #D8DFEE ;
			width: 38rpx ;
			height: 38rpx ;
			color: #fff;
		 }

		 checkbox .wx-checkbox-input.wx-checkbox-input-checked {
			background-color: #2E6CF6;
			border-color: #2E6CF6 ;
			color: #fff !important;
		 }

		 checkbox .wx-checkbox-input.wx-checkbox-input-checked::before {
			font-size: 30rpx;
		 }
	/* #endif */
	button::after{
		border: none;
	}
</style>
