<style lang="scss">
	/* 注意要写在第一行，同时给style标签加入lang="scss"属性 */
	@import "uview-ui/index.scss";
</style>

<script>
	import store from "@/store";
	import socket from "@/config/socket";
	import DB from "@/common/sqlite";
	export default {
		onLaunch: function(e) {
			//取出缓存数据
			store.commit("setCacheData");
			if (store.state.token) {
				socket.init();
			} else {
				var url = window.location.href;
				if ((url.indexOf("pages/carInsure/quoteDetail1") > 0) || (url.indexOf("pages/carInsure/quoteDetail") >
						0) || (url.indexOf("pages/register/register") > 0) ||
					(url.indexOf("pages/register/registerSuccess") > 0) || (url.indexOf("pages/carInsure/payVerify") >
						0) || (url.indexOf("pages/login/mimi") > 0) || (url.indexOf("pages/login/xieyi") > 0) || (url
						.indexOf("pages/carInsure1/yonganCode") > 0)) {
					uni.navigateTo({
						url: url
					})
				} else {

				}
			}
			// #ifdef H5
			if (store.state.token) {
				socket.init();
			} else {
				var url = window.location.href;
				if ((url.indexOf("pages/carInsure/quoteDetail") > 0) || (url.indexOf("pages/register/register") > 0) ||
					(url.indexOf("pages/register/registerSuccess") > 0) || (url.indexOf("pages/carInsure/payVerify") >
						0) || (url.indexOf("pages/login/mimi") > 0) || (url.indexOf("pages/login/xieyi") > 0) || (url
						.indexOf("pages/carInsure1/yonganCode") > 0)) {
					uni.navigateTo({
						url: url
					})
				} else {

				}
			}
			// #endif
			// #ifdef APP-PLUS
			this.launch()
			if (store.state.token) {} else {
				var url = window.location.href;
				if ((url.indexOf("pages/carInsure/quoteDetail1") > 0) || (url.indexOf("pages/carInsure/quoteDetail") >
						0) || (url.indexOf("pages/register/register") > 0) ||
					(url.indexOf("pages/register/registerSuccess") > 0) || (url.indexOf("pages/carInsure/payVerify") >
						0) || (url.indexOf("pages/login/mimi") > 0) || (url.indexOf("pages/login/xieyi") > 0) || (url
						.indexOf("pages/carInsure1/yonganCode") > 0)) {
					uni.navigateTo({
						url: url
					})
				} else {

				}
			}
			// #endif
		},
		onShow: function(e) {

		},
		onHide: function() {},

		methods: {
			//  TODO 开屏广告 后续优化添加
			launch() {
				try {
					var date = new Date();
					var year = date.getFullYear();
					var month = date.getMonth() + 1;
					var strDate = date.getDate();
					var currentdate = year + '' + month + '' + strDate + '' + plus.runtime.version;

					// 获取本地存储中launchFlag标识(不可动)
					const value = uni.getStorageSync("launchFlag");
					if (value == currentdate) {} else {
						//app启动时打开启动广告页
						var w = plus.webview.open(
							"/hybrid/html/advertise/advertise.html",
							"本地地址", {
								top: 0,
								bottom: 0,
								zindex: 999,
							},
							"fade-in",
							500
						);
						//设置定时器，4s后关闭启动
						setTimeout(function() {
							uni.setStorage({
								key: "launchFlag",
								data: currentdate
							});
							plus.webview.close(w);
						}, 3000);
					}
				} catch (e) {
					// error
					uni.setStorage({
						key: "launchFlag",
						data: currentdate,
						success: function() {
							console.log("error时存储launchFlag");
						},
					});
				}
			},
		}
	};
</script>

<style>
	/* #ifndef APP-NVUE */
	@import "/style/uni.css";
	/* 官方ui库 */
	@import "/style/animate.min.css";
	/* 第三方动画库 */
	/* @import "/style/icon.css";	 */
	/* 自定义图标库 */
	@import 'http://at.alicdn.com/t/font_1807257_t3nqcuysmns.css';
	@import "/style/common.css";
	/* 公共样式库 */
	@import "/style/zcm-main.css";
	/* UI基础库 */
	/* @import "/style/input.scss"; */
	/* 基础表单样式*/
	/* #endif */


	/* #ifdef H5 */
	/* 修复H5底部导航挡住内容bug */
	uni-app {
		height: auto;
	}

	/* 修复H5输入框上下不居中bug */
	.uni-input-form {
		height: 100%;
	}

	/* 去除地图上高德地图标识符 */
	.amap-copyright {
		display: none !important;
	}

	.amap-logo {
		display: none !important;
	}

	.amap-ui-control-zoom {
		width: 60upx !important;
	}

	.amap-ui-control-zoom>* {
		width: 60upx !important;
		height: 60upx !important;
		line-height: 60upx !important;
	}

	.amap-ui-control-theme-dark {
		display: none !important;
	}

	/* #endif */
</style>