App.vue 1.9 KB
Newer Older
1
<script>
DCloud_JSON's avatar
DCloud_JSON 已提交
2 3
	import initApp from '@/common/appInit.js';
	import checkIsAgree from '@/uni_modules/uni-agree/utils/uni-agree.js';
4 5 6
	export default {
		globalData: {
			searchText: '',
DCloud_JSON's avatar
DCloud_JSON 已提交
7
			appVersion: {},
DCloud_JSON's avatar
DCloud_JSON 已提交
8
			config:{}
9 10
		},
		onLaunch: function() {
DCloud_JSON's avatar
DCloud_JSON 已提交
11 12 13
			console.log('App Launch')
			initApp();
			// #ifdef APP-PLUS
14 15 16 17 18
			//checkIsAgree(); APP端暂时先用原生默认生成的。目前,自定义方式启动vue界面时,原生层已经请求了部分权限这并不符合国家的法规
			// #endif
			
			// #ifdef H5
			checkIsAgree();
19
			// #endif
20

21
			// #ifdef APP-PLUS
DCloud_JSON's avatar
DCloud_JSON 已提交
22
			//一键登录 功能预登录
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
			plus.oauth.getServices(oauthServices => {
				// console.log(oauthServices);
				oauthServices.forEach(({
					_id
				}, item) => {
					if (_id == 'provider') {
						uni.preLogin({
							provider: item,
							complete: e => {
								console.log(e);
							}
						})
					}
				})
				uni.preloadPage({
					url: "/pages/ucenter/login-page/index/index"
				});
			}, err => {
				console.error('获取服务供应商失败:' + JSON.stringify(err));
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
			})
			
			//idfa有需要的用户在应用首次启动时自己获取存储到storage中
			//https://ask.dcloud.net.cn/article/36107
			/*if(~plus.storage.getItem('idfa')){
				plus.device.getInfo({//需要勾选IDFA
					success:function(e){  
						console.log('idfa =  '+JSON.stringify(e.idfa));  
					},
					fail:function(e){
						console.log('getDeviceInfo failed: '+JSON.stringify(e));  
					}  
				});
			}*/
			// #endif
57 58
		},
		onShow: function() {
59
			console.log('App Show')
60 61 62 63 64 65 66 67 68
		},
		onHide: function() {
			console.log('App Hide')
		}
	}
</script>

<style>
	/*每个页面公共css */
DCloud_JSON's avatar
DCloud_JSON 已提交
69
/* #ifndef APP-NVUE */
70 71 72 73 74 75 76 77 78 79 80 81 82 83
	view,
	scroll-view,
	text,
	image,
	switch,
	navigator,
	icons {
		display: flex;
		box-sizing: border-box;
		flex-direction: column;
	}
	scroll-view {
		-webkit-overflow-scrolling: touch;
	}
DCloud_JSON's avatar
DCloud_JSON 已提交
84 85
/* #endif */
</style>