<script>
	import initApp from "@/util/router.js";
	import {interceptor} from "@/util/interceptor";
	import {baseURL,apiURL,cffpURL} from "@/environments/environment";
	export default {
		onLaunch: function() {
			console.log('App Launch');
			// #ifdef APP-PLUS
			// uni.downloadFile({
			//     url: '/cffpUpdate/__UNI__ED34740.wgt',  
			//     success: (downloadResult) => {  
			//         if (downloadResult.statusCode === 200) {  
			//             plus.runtime.install(downloadResult.tempFilePath, {  
			//                 force: true  
			//             }, function() {  
			//                 console.log('install success...');  
			//                 plus.runtime.restart();  
			//             }, function(e) {  
			//                 console.error('install fail...');  
			//             });  
			//         }
			//     }  
			// });
			// #endif
			// #ifdef APP-PLUS
			plus.runtime.getProperty(plus.runtime.appid, (wgtinfo) => {
				uni.getSystemInfo({
					success:(systemInfo)=> {
						uni.request({
						    url: `${apiURL}/appVersion/checkIsUpdate`,  
							method:'POST',
						    data: {  
						        appType: 1,  
						        version: wgtinfo.version,
								systemType:systemInfo.osName.toLowerCase() === 'ios' ? 2 : 1
						    },  
						    success: (result) => { 
								console.log(wgtinfo)
								console.log(result)
						        const data = result.data.data['appVersionInfo'];
								if (data.status==1 && data.isForceUpdate && data.wgtUrl) {
									    uni.downloadFile({  
									        url: `${baseURL}${data.wgtUrl}`,  
									        success: (downloadResult) => {  
									            if (downloadResult.statusCode === 200) {  
									                plus.runtime.install(downloadResult.tempFilePath, {  
									                    force: true  
									                }, function() {  
									                    console.log('install success...');  
									                    plus.runtime.restart();  
									                }, function(e) {  
									                    console.error('install fail...');  
									                });  
									            }  
									        }  
									    });  
								} 
						    }  
						}); 
					}
				})
			})
			
		// #endif
			interceptor();
			initApp();
		},
		onShow: function() {3,
			console.log('App Show')
		},
		onHide: function() {
			console.log('App Hide')
		},
		methods:{
		}
	}
</script>

<style>
	@import "@/static/font/iconfont.css"; 
	/*每个页面公共css */
	@font-face {
		font-family: 'iconfont';
		src:url('data:application/x-font-woff2;charset=utf-8;base64,[encoded data, 13736 characters]')
	}
	.iconfont{
	    font-family:"iconfont" !important;
	    font-size:16px;
		font-style:normal;
	    -webkit-font-smoothing: antialiased;
	    -webkit-text-stroke-width: 0.2px;
	    -moz-osx-font-smoothing: grayscale;
	}
	image{
		width: 100%!important;
	}
	.container{
		background-color: #FBFBFB;
	}
	.uni-popup .uni-popup__wrapper{
		margin: 30rpx!important;
	}
	.richTextContent img{
		width: 100% !important;
	}
	.popupContainer .uni-popup .uni-popup__wrapper{
		width: 80%;
		border-radius: 20rpx;
	}
	.container uni-slider{
		margin: 0;
	}
	.container uni-slider .uni-slider-value{
		text-align: right;
	}
	.noListTip{
		text-align: center;
		margin-top: 10%;
		color: #999;
	}
	.container uni-slider .uni-slider-value{
		width: 5ch;
	}
	.btn{
		background: #3671F4;
		color: #fff;
		width: 60%;
		margin: 0 auto;
		height: 80rpx;
		line-height: 80rpx;
		text-align: center;
		border-radius: 40rpx;
		position: absolute;
		bottom: 0;
		left: 0;
		right: 0;
	}
	.uni-calendar-item--extra{
		white-space: nowrap !important;
	}
	.zuojiantou{
		display: inline-block;
		transform: rotate(180deg)!important;
		font-size: 30rpx;
		z-index: 1;
		position: absolute;
		left: 20rpx;
		width: 50rpx;
		height: 50rpx;
		text-align: center;
		line-height: 50rpx;
	}
</style>
