MrShi
2026-04-30 a240b43f1908abdecb87092502b3ed69d665336c
app/App.vue
@@ -15,7 +15,7 @@
      watch: {
         token(newVal) {
            if (newVal) {
               this.startLocationPolling()
               this.checkAndStartLocationPolling()
               this.bindJPushAlias()
            } else {
               this.stopLocationPolling()
@@ -31,17 +31,18 @@
      },
      onShow: function() {
         console.log('App Show')
         this.checkAndStartLocationPolling()
         // this.checkAndStartLocationPolling()
      },
      onHide: function() {
         console.log('App Hide')
         this.stopLocationPolling()
         // this.stopLocationPolling()
      },
      onUnload() {
         if (this.tts) {
            this.tts.stop()
            this.tts.shutdown()
         }
         this.stopLocationPolling()
      },
      methods: {
         initTTS() {
@@ -217,9 +218,21 @@
         },
         checkAndStartLocationPolling() {
            if (this.token) {
               this.startLocationPolling()
            }
            if (!this.token) return
            uni.getLocation({
               type: 'gcj02',
               success: (res) => {
                  console.log('获取定位权限成功,开始定时更新位置')
                  this.startLocationPolling()
               },
               fail: (err) => {
                  console.log('获取定位权限失败:', err.errMsg)
                  uni.showToast({
                     title: '需要定位权限才能更新位置',
                     icon: 'none'
                  })
               }
            })
         },
         startLocationPolling() {
@@ -238,10 +251,12 @@
         },
         updateLocation() {
            if (!this.token) return
            var that = this;
            uni.getLocation({
               type: 'gcj02',
               success: (res) => {
                  console.log('定时更新位置:', res.latitude, res.longitude)
                  that.$u.api.updateLocation({
                     latitude: res.latitude,
                     longitude: res.longitude
@@ -251,7 +266,12 @@
                     } else {
                        console.log('更新位置失败')
                     }
                  }).catch(err => {
                     console.log('更新位置请求失败:', err)
                  })
               },
               fail: (err) => {
                  console.log('获取位置失败:', err.errMsg)
               }
            })
         },
@@ -259,9 +279,9 @@
         checkAppUpdate() {
            plus.runtime.getProperty(plus.runtime.appid, (inf) => {
               const currentVersion = inf.versionCode
               this.$u.api.getApiVersion().then(res => {
               this.$u.api.getApiVersion({ type: 0 }).then(res => {
                  if (res.code === 200 && res.data) {
                     const latestVersion = res.data.versionCode
                     const latestVersion = res.data.versionNum
                     if (latestVersion > currentVersion) {
                        if (res.data.isForce === 1) {
                           this.showForceUpdateDialog(res.data.fileUrl, res.data.versionNum)