<script>
	import updata from '@/util/updata.js'; //版本更新
	import homeservice from '@/service/homeservice.js';
	export default {
		globalData: {  
			typefacedata: [],
			num:0
		},
		onLaunch: function() {
			//字体列表
			homeservice.queryList({
				s: 'Material.fontFamilyList'
			}).then(result => {
				result.forEach(item=>{
					item.long = false
					item.textlong = null
				})
				result.unshift({
					id: 0,
					key: "SourceHanSansCN-Normal",
					remark: "",
					title: "思源黑体",
					textlong:true,
					long:true
				})
				this.globalData.typefacedata = result
				this.$base.typefacedata = this.globalData.typefacedata
				var t1 = new Date().getTime();
				var that = this
				this.globalData.typefacedata.forEach(textlist => {
					wx.loadFontFace({
						global:true,
						family: textlist.key,
						source: 'url(' + textlist.remark + ')',
						desc: {
							weight: 100
						},
						success: function(message) {
							textlist.textlong = true
						},
						fail: function(message) {
							textlist.textlong = false
						},
						complete(res) {
							textlist.long = true
							that.globalData.typefacedata.forEach(item=>{
								if(item.long == true){
									that.globalData.num++
								}
							})
							that.$base.typefacedata = that.globalData.typefacedata
							if(that.globalData.num == that.globalData.typefacedata.length){
								that.$base.typefacedata = that.globalData.typefacedata
							}
							that.globalData.num = 0
						}
					})
				})
			}).catch(err => {
				
			});
		},
		onShow: function() {
			//调用监听网络状态的方法
			wx.getNetworkType({
				success: function(res) {
					if (res.networkType == 'none') {
						uni.showToast({
							title: '网络似乎不太顺畅',
							icon: 'none',
							duration: 2000
						});
					}
				}
			})
		},
		onHide: function() {
			//console.log('App Hide');
		}
	};
</script>

<style lang="scss">
	page,
	.page {
		height: 100%;
		width: 100%;
		background-color: #ebeef5;
		font-size: 28upx;
		font-family: -apple-system-font, Helvetica Neue, Helvetica, sans-serif;
	}
	.hover-class-bg {
		background: #888888 !important;
	}
	.hover-class-text {
		color: #888888 !important;
	}
</style>
