| | |
| | | watch: { |
| | | token(newVal) { |
| | | if (newVal) { |
| | | this.startLocationPolling() |
| | | this.checkAndStartLocationPolling() |
| | | this.bindJPushAlias() |
| | | } else { |
| | | this.stopLocationPolling() |
| | |
| | | }, |
| | | 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() { |
| | |
| | | }, |
| | | |
| | | 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() { |
| | |
| | | }, |
| | | |
| | | 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 |
| | |
| | | } else { |
| | | console.log('更新位置失败') |
| | | } |
| | | }).catch(err => { |
| | | console.log('更新位置请求失败:', err) |
| | | }) |
| | | }, |
| | | fail: (err) => { |
| | | console.log('获取位置失败:', err.errMsg) |
| | | } |
| | | }) |
| | | }, |
| | |
| | | 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) |