App.vue 2.8 KB
Newer Older
1
<script>
DCloud_JSON's avatar
DCloud_JSON 已提交
2
	import initApp from '@/common/appInit.js';
3
	import checkIsAgree from '@/pages/uni-agree/utils/uni-agree.js';
4 5 6
	export default {
		globalData: {
			searchText: '',
DCloud_JSON's avatar
DCloud_JSON 已提交
7
			appVersion: {},
8 9 10
			config: {},
			$i18n: {},
			$t: {}
11
		},
12 13 14
		setup() {
		},
		onLaunch: function() {
DCloud_JSON's avatar
DCloud_JSON 已提交
15
			console.log('App Launch')
16 17 18 19
			
			this.globalData.$i18n = this.$i18n
			this.globalData.$t = str => this.$t(str)

DCloud_JSON's avatar
DCloud_JSON 已提交
20 21
			initApp();
			// #ifdef APP-PLUS
22
			//checkIsAgree(); APP端暂时先用原生默认生成的。目前,自定义方式启动vue界面时,原生层已经请求了部分权限这并不符合国家的法规
23
			// #endif
24

25 26
			// #ifdef H5
			// checkIsAgree(); // 默认不开启。目前全球,仅欧盟国家有网页端同意隐私权限的需要。如果需要
27 28
			// #endif

29
			// #ifdef APP-PLUS
30 31 32 33 34 35 36 37 38 39 40 41
			//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));  
					}  
				});
			}*/
42 43
			// #endif

44
			let initLanguageAfter = () => {
45
				console.log('作用于多语言国际化功能,这里获取语言包lang/en.js、lang/zh-Hans.js的tabbar中配置的值更新当前应用的底部tabbar,如果你不需要多语言国际化。直接删除App.vue页面的47-55行即可');
46
				//底部tabbar更新
47 48 49 50 51 52 53 54
				this.$t('tabbar').split(',').forEach((text, index) => {
					uni.setTabBarItem({
						index,
						text,
						complete: e => {
							// console.log("e: " + JSON.stringify(e));
						}
					})
55 56
				})
				//更新 uni-starter.config
57 58 59 60 61 62 63 64 65 66 67 68 69
				//agreements
				let agreements = [{
						"title": "用户服务协议", //协议名称
						"url": "请填写用户服务协议链接" //对应的网络链接
					},
					{
						"title": "隐私政策",
						"url": "请填写隐私政策链接"
					}
				]
				if(getApp().globalData.$i18n.locale == 'en'){
					agreements = [{
							"title": "User service agreement", //协议名称
70 71 72
							"url": "请填写用户服务协议链接" //对应的网络链接
						},
						{
73
							"title": "Privacy policy",
74 75 76
							"url": "请填写隐私政策链接"
						}
					]
77 78 79
				}
				// console.log(getApp().globalData.config)
				getApp().globalData.config.about.agreements = agreements
80 81 82 83
			}
			setTimeout(()=>{
				initLanguageAfter()
			},1000)
84 85
			uni.$on('changeLanguage', e => {
				console.log('changeLanguage',e);
86
				initLanguageAfter(e)
87
			})
88 89
		},
		onShow: function() {
90
			console.log('App Show')
91 92 93 94 95 96 97 98 99
		},
		onHide: function() {
			console.log('App Hide')
		}
	}
</script>

<style>
	/*每个页面公共css */
100
</style>