MrShi
8 小时以前 3f9032e92fdd383bfefc87a0bec9b242e1223851
app/App.vue
@@ -29,21 +29,28 @@
      onLaunch: function() {
         uni.$on('locationPermissionGranted', this.handleLocationPermissionGranted)
         uni.$on('loginSuccessStartLocationPolling', this.handleLoginSuccessStartLocationPolling)
         this.initTTS()
         this.initJPush()
         this.checkAppUpdate()
         uni.$on('privacyAgreed', this.handlePrivacyAgreed)
         // 检查是否已经同意过隐私政策,如果是则直接初始化极光推送
         console.log('login_privacy_policy_agreed', uni.getStorageSync('login_privacy_policy_agreed'))
         if (uni.getStorageSync('login_privacy_policy_agreed')) {
            // 初始化极光推送
            this.initJPush()
            // 初始化语音播报
            this.initTTS()
            // 获取版本号
            this.checkAppUpdate()
         }
      },
      onShow: function() {
         console.log('App Show')
         // this.checkAndStartLocationPolling()
      },
      onHide: function() {
         console.log('App Hide')
         // this.stopLocationPolling()
      },
      onUnload() {
         uni.$off('locationPermissionGranted', this.handleLocationPermissionGranted)
         uni.$off('loginSuccessStartLocationPolling', this.handleLoginSuccessStartLocationPolling)
         uni.$off('privacyAgreed', this.handlePrivacyAgreed)
         if (this.tts) {
            try {
               if (this.ttsPlatform === 'android') {
@@ -68,6 +75,10 @@
            }
            this.checkAndStartLocationPolling()
         },
         handlePrivacyAgreed() {
            console.log('隐私政策已同意,初始化极光推送')
            this.initJPush()
         },
         handleLocationPermissionGranted() {
            this.hasGrantedLocationPermission = true
            if (!this.token || this.locationTimer) return