App.vue 2.1 KB
Newer Older
1
<script>
2
	import initApp from '@/common/appInit.js';
DCloud_JSON's avatar
DCloud_JSON 已提交
3
	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 8
			appVersion: {},
			config:{}
9 10
		},
		onLaunch: function() {
11 12 13 14
			console.log('App Launch')
			
			initApp();
			
L
123  
linju 已提交
15
			// #ifdef APP-PLUS
DCloud_JSON's avatar
DCloud_JSON 已提交
16
			//checkIsAgree(); 暂时先用默认生成的,自定义的等待原生支持后实现。因为启动vue界面时已经,请求了部分权限这并不符合国家的法规
17 18 19
			// #endif

			// #ifdef APP-PLUS
DCloud_JSON's avatar
DCloud_JSON 已提交
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
			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));
			})
			// #endif

			//clientDB的错误提示
			const db = uniCloud.database()
			function onDBError({
				code, // 错误码详见https://uniapp.dcloud.net.cn/uniCloud/clientdb?id=returnvalue
				message
			}) {
				// 处理错误
				console.log(code,message);
				if([
					'TOKEN_INVALID_INVALID_CLIENTID',
					'TOKEN_INVALID',
					'TOKEN_INVALID_TOKEN_EXPIRED',
					'TOKEN_INVALID_WRONG_TOKEN',
					'TOKEN_INVALID_ANONYMOUS_USER',
				].includes(code)){
					uni.navigateTo({
						url:'/pages/ucenter/login-page/index/index'
L
123  
linju 已提交
60
					})
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
				}
			}
			// 绑定clientDB错误事件
			db.on('error', onDBError)
			// 解绑clientDB错误事件
			//db.off('error', onDBError)
		},
		onShow: function() {
			console.log('App Show')
		},
		onHide: function() {
			console.log('App Hide')
		}
	}
</script>

<style>
	/*每个页面公共css */
DCloud_JSON's avatar
DCloud_JSON 已提交
79
/* #ifndef APP-NVUE */
80 81 82 83 84 85 86 87 88 89 90 91 92 93
	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 已提交
94
/* #endif */
芊里 已提交
95
</style>