<script>
	import Vue from 'vue'
	// import TIM from 'tim-wx-sdk';
	// import COS from 'cos-wx-sdk-v5';
	export default {
		globalData: {
			// wsUrl: 'wss://websocket.cdwjyyh.com',
			wsUrl: '',
			appId: 'wxd2892bb660356ecf',
		},
		onLoad: function (){
			
		},
		onLaunch: function() {
			this.$store.dispatch('getAppInfos');
			this.checkUpdate()
			// 看课题目字体跟随系统变化
			const systemInfo = uni.getSystemInfoSync();
			const baseFontSize = 14; // 标准字体大小（你可以自定义）
			const userFontSize = systemInfo.fontSizeSetting || baseFontSize;
			// 计算比例
			const scale = userFontSize / baseFontSize;
			// 存储到全局变量或 Vuex
			uni.setStorageSync('fontScale', scale);
		},
		onShow: function () {
			this.$store.dispatch('getAppInfos');
		    console.log('App Show')
		    uni.getSystemInfo({
				success: (result) => {
					// 获取手机系统的状态栏高度（不同手机的状态栏高度不同）
					// console.log('当前手机的状态栏高度',result.statusBarHeight)
					let statusBarHeight = result.statusBarHeight + 'px'
					
					// 获取右侧胶囊的信息 单位px
					//#ifndef H5 || APP-PLUS
					const menuButtonInfo = uni.getMenuButtonBoundingClientRect()
					
					//bottom: 胶囊底部距离屏幕顶部的距离
					//height: 胶囊高度
					//left:   胶囊左侧距离屏幕左侧的距离
					//right:  胶囊右侧距离屏幕左侧的距离
					//top:    胶囊顶部距离屏幕顶部的距离
					//width:  胶囊宽度
					// console.log(menuButtonInfo.width, menuButtonInfo.height, menuButtonInfo.top)
					// console.log('计算胶囊右侧距离屏幕右边距离', result.screenWidth - menuButtonInfo.right)
					let menuWidth = menuButtonInfo.width + 'px'
					let menuHeight = menuButtonInfo.height + 'px'
					let menuBorderRadius = menuButtonInfo.height / 2 + 'px'
					let menuRight = result.screenWidth - menuButtonInfo.right + 'px'
					let menuTop = menuButtonInfo.top + 'px'
					let contentTop = result.statusBarHeight + 44 + 'px'
			
					let menuInfo = {
						statusBarHeight: statusBarHeight,//状态栏高度----用来给自定义导航条页面的顶部导航条设计padding-top使用：目的留出系统的状态栏区域
						menuWidth: menuWidth,//右侧的胶囊宽度--用来给自定义导航条页面的左侧胶囊设置使用
						menuHeight: menuHeight,//右侧的胶囊高度--用来给自定义导航条页面的左侧胶囊设置使用
						menuBorderRadius: menuBorderRadius,//一半的圆角--用来给自定义导航条页面的左侧胶囊设置使用
						menuRight: menuRight,//右侧的胶囊距离右侧屏幕距离--用来给自定义导航条页面的左侧胶囊设置使用
						menuTop: menuTop,//右侧的胶囊顶部距离屏幕顶部的距离--用来给自定义导航条页面的左侧胶囊设置使用
						contentTop: contentTop,//内容区距离页面最上方的高度--用来给自定义导航条页面的内容区定位距离使用
					}
					uni.setStorageSync('menuInfo', menuInfo)
					//#endif
				},
				fail: (error) => {
					console.log(error)
				}
		    })
		},
		onHide: function() {
			console.log('App Hide')
		},
		 
		methods: {
			checkUpdate() {
				const updateManager = uni.getUpdateManager();
				updateManager.onCheckForUpdate(function(res) {
					// 请求完新版本信息的回调
					console.log('是否有新版本：', res.hasUpdate);
				});
			
				updateManager.onUpdateReady(function() {
					uni.showModal({
						title: '更新提示',
						content: '新版本已经准备好，是否重启小程序？',
						confirmText: '立即重启',
						confirmColor: '#2179f5',
						showCancel: false,
						success(res) {
							if (res.confirm) {
								// 新的版本已经下载好，调用 applyUpdate 应用新版本并重启
								updateManager.applyUpdate();
							}
						}
					});
				});
			
				updateManager.onUpdateFailed(function() {
					// 新的版本下载失败
					uni.showModal({
						title: '更新提示',
						content: '新版本下载失败，请检查网络后重试。',
						showCancel: false
					});
				});
			},
			// TODO:
			resetLoginData() {
			},
			onTIMError() {},
			onSDKReady({name}) {
				 console.log("im注册:"+name)
				  const isSDKReady = name === uni.$TUIKitEvent.SDK_READY ? true : false
				  console.log("im注册:"+isSDKReady)
					uni.$emit('isSDKReady', {
						isSDKReady: true
					});
			},
			onNetStateChange() {},
			onSDKReload() {},
			onSdkNotReady() {},
			onKickedOut() {
				uni.showToast({
					title: '您被踢下线',
					icon: 'error'
				});
				
			}
		}
	}
</script>
 
 <style lang="less">
	 @import './assets/css/common.less';
 </style>
 
<style lang="scss">
	
    /*每个页面公共css */
	@import "uview-ui/index.scss";
	@import './assets/iconfont/iconfont.css';
	@import '@/assets/css/common.scss';
	@import './assets/css/theme.scss';
	page{
		background-color: #f6f6f6;
	}
	::-webkit-scrollbar{
	    width: 0 !important;
	    height: 0 !important;
	    
	}
	view{
		box-sizing: border-box;
	}
	.ellipsis{
		overflow: hidden;
		text-overflow: ellipsis;
		white-space: nowrap;
	}
	.single-line-ellipsis {
		width: 480rpx; /* 设置固定宽度 */
		white-space: nowrap; /* 文本不换行 */
		overflow: hidden; /* 隐藏超出部分 */
		text-overflow: ellipsis; /* 超出部分用省略号表示 */
	}
	.single-ellipsis {
		width: 260rpx; /* 设置固定宽度 */
		white-space: nowrap; /* 文本不换行 */
		overflow: hidden; /* 隐藏超出部分 */
		text-overflow: ellipsis; /* 超出部分用省略号表示 */
	}
	.ellipsis2{
		overflow:hidden; 
		text-overflow:ellipsis;
		display:-webkit-box; 
		-webkit-box-orient:vertical;
		-webkit-line-clamp:2; 
	}
	.no-data-box{
		height:100%;
		width: 100%;
		display: flex;
		justify-content: center;
		align-items: center;
		flex-direction: column;
		image{
			width: 264upx;
			height: 212upx;
		}
		.empty-title{
			margin-top: 20rpx;
			font-size: 28rpx;
			color: gray;
			 
		}
	}
	
		.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-9 {
			color: $--base-color-9;
		}
		.base-color-8 {
			color: $--base-color-f8;
		}
		.base-color-6 {
			color: $--base-color-6;
		}
		.base-color-gray {
			color: $--base-color-gray;
		}
		.base-color-red{
				color:#ee0a25;
		}
		.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;
		}
		.base-bg-red{
			background: #ee0a25;
		}
		.base-bg-f{
			background-color:#fff;
		}
		.base-bg-f8{
			background-color: $--base-color-f8;
		}
		.base-bg-f5{
			background-color: $--base-color-f5;
		}
		.base-bg-9{
			background-color: $--base-color-9;
		}
		.base-bg-blue{
			background:$--base-bg-blue;
		}
		.base-bg-sure{
			background:$--base-sure-bg;
		}
		.base-bg-orange{
			background:$--base-bg-orange;
		}
		.base-bg-false{
			background:$--base-false-bg;
		}
		.bor-blue{
			border: 2rpx solid $--base-bor-blue;
		}
		.bor-red{
			border: 2rpx solid $--base-bor-red;
		}
		.colorf {
			color: #fff;
		}
	
		.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;
		}
	
		.lines-3 {
			-webkit-line-clamp: 3 !important;
		}
	
		.bold {
			font-weight: bold;
		}
	
		.line-through {
			text-decoration: line-through;
		}
	
		.nowrap {
			white-space: nowrap;
		}
	
		.scrollx {
			overflow-x: scroll;
		}
	
		.scrolly {
			overflow-y: scroll;
		}
	
		.cvauto {
			content-visibility: auto;
		}
</style>
<style>
	/*每个页面公共css */
	/* 解决小程序和app滚动条的问题 */
	/* #ifdef MP-WEIXIN || APP-PLUS */
		:deep(::-webkit-scrollbar ){
		    display: none !important;
		    width: 0 !important;
		    height: 0 !important;
		    -webkit-appearance: none;
		    background: transparent;
		    color: transparent;
		}
	/* #endif */
	
	/* 解决H5 的问题 */
	/* #ifdef H5 */
	    uni-scroll-view .uni-scroll-view::-webkit-scrollbar {
	    	/* 隐藏滚动条，但依旧具备可以滚动的功能 */
			display: none;
		    width: 0 !important;
		    height: 0 !important;
		    -webkit-appearance: none;
		    background: transparent;
		    color: transparent;
	    }
	/* #endif */
</style>
 
