<script>
	import {
		useStore
	} from 'vuex'
	import storage from '@/utils/storage'
	export default {
		onLaunch: function(options) {
			// 暂时隐藏uni.hideTabBar()
			// uni.hideTabBar()
			// 分销
			const store = useStore()
			let parent_id
			if (options.query && options.query.scene) {
				parent_id = decodeURIComponent(options.query.scene).split('=')[1]
			} else if (options.query && options.query.parent_id) {
				parent_id = options.query.parent_id
			}
			storage.set('PARENT_ID', parent_id, 30 * 86400 * 3)
			store.commit('M_PARENT_ID', parent_id);
			// #ifdef MP
			this.updateManager()
			// #endif
		},
		onShow: function() {
			console.log('App Show');
			
		},
		onLoad() {
			console.log('App Load');
		},
		onHide: function() {
			console.log('App Hide');
		},
		methods: {
			/**
			 * 小程序主动更新
			 */
			updateManager() {
				const updateManager = uni.getUpdateManager();
				updateManager.onCheckForUpdate(res => {
					// 请求完新版本信息的回调
					// console.log(res.hasUpdate)
				})
				updateManager.onUpdateReady(() => {
					uni.showModal({
						title: '更新提示',
						content: '新版本已经准备好，即将重启应用',
						showCancel: false,
						success(res) {
							if (res.confirm) {
								// 新的版本已经下载好，调用 applyUpdate 应用新版本并重启
								updateManager.applyUpdate()
							}
						}
					})
				})
				updateManager.onUpdateFailed(() => {
					// 新的版本下载失败
					uni.showModal({
						title: '更新提示',
						content: '新版本下载失败',
						showCancel: false
					})
				})
			}
		}
	}
</script>

<style lang="scss">
	/*uview-plus */
	@import "@/uni_modules/uview-plus/index.scss";
	/* 自定义样式 */
	@import "@/common/scss/common.scss";
	@import "@/common/scss/animation.scss";
	@import "@/utils/utils.scss";

	page {
		background-color: $--base-cont-bg;
		font-family: PingFang SC-Bold, PingFang SC;
		/* #ifndef MP-ALIPAY */
		height: 100%;
		/* #endif */
		/* #ifdef MP-ALIPAY */
		height: 100vh;
		/* #endif */
		font-size: 28rpx;
		word-break: break-all;
	}


	.w-calc-30 {
		padding: 0 30rpx;
		width: calc(100% - 60rpx);
	}

	.hb {
		height: 100%;
		box-sizing: border-box;
	}

	.hidden {
		overflow: hidden;
	}

	.base-color {
		color: $--base-color;
	}

	.base-color-2 {
		color: $--base-color2;
	}

	.base-color-3 {
		color: $--base-color3;
	}

	.base-color-red {
		color: $--base-color-red;
	}

	.base-color-gray {
		color: $--base-color-gray;
	}

	.base-color-dark {
		color: $--base-color-dark;
	}

	.base-color-dark2 {
		color: $--base-color-dark2;
	}

	.base-price {
		color: $--base-color-price;
	}

	.base-success {
		color: $--base-color-success;
	}

	.base-bg {
		background: $--base-bg;
	}

	.base-bg-2 {
		background: $--base-bg2;
	}

	.colorf {
		color: #fff;
	}

	.color0 {
		color: #000;
	}

	.color3 {
		color: #333;
	}

	.color6 {
		color: #666;
	}

	.color9 {
		color: #999;
	}

	.bgf {
		background: #fff;
	}

	.fixed {
		position: fixed;
	}

	.absolute {
		position: absolute;
	}

	.relative {
		position: relative;
	}

	.w100 {
		width: 100%;
	}

	.h100 {
		height: 100%;
	}

	.card {
		background: #fff;
		border-radius: 15rpx;
	}

	.cover-height {
		height: 100%;
		display: flex;
		flex-direction: column;
		box-sizing: border-box;
	}

	.row {
		display: flex;
		flex-direction: row;
	}

	.column {
		display: flex;
		flex-direction: column;
	}

	.justify-start {
		display: flex;
		justify-content: flex-start;
	}

	.justify-center {
		display: flex;
		justify-content: center;
	}

	.justify-end {
		display: flex;
		justify-content: flex-end;
	}

	.justify-around {
		display: flex;
		justify-content: space-around;
	}

	.justify-evenly {
		display: flex;
		justify-content: space-evenly;
	}

	.justify-between {
		display: flex;
		justify-content: space-between;
	}

	.align-start {
		display: flex;
		align-items: flex-start;
	}

	.align-center {
		display: flex;
		align-items: center;
	}

	.align-end {
		display: flex;
		align-items: flex-end;
	}

	.center {
		display: flex;
		justify-content: center;
		align-items: center;
	}

	.centerV {
		display: flex;
		justify-content: center;
		align-items: center;
		flex-direction: column;
	}

	.wrap {
		flex-wrap: wrap;
	}

	.flex-1 {
		flex: 1;
	}

	.ellipsis {
		overflow: hidden;
		text-overflow: ellipsis;
		display: -webkit-box;
		-webkit-box-orient: vertical;
		box-sizing: border-box;
		width: 100%;
		-webkit-line-clamp: 1;
	}

	.lines-2 {
		-webkit-line-clamp: 2 !important;
	}

	.bold {
		font-weight: bold;
	}

	.line-through {
		text-decoration: line-through;
	}

	.scrollx {
		overflow-x: scroll;
	}

	.scrolly {
		overflow-y: scroll;
	}
</style>