App.vue 2.18 KB
Newer Older
huahua committed
1 2 3 4 5 6 7 8 9
<script>
	import updata from '@/util/updata.js'; //版本更新
	import homeservice from '@/service/homeservice.js';
	export default {
		globalData: {  
			typefacedata: [],
			num:0
		},
		onLaunch: function() {
huahua committed
10
			//字体列表
huahua committed
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98
			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>