From a240b43f1908abdecb87092502b3ed69d665336c Mon Sep 17 00:00:00 2001
From: MrShi <1878285526@qq.com>
Date: 星期四, 30 四月 2026 13:41:12 +0800
Subject: [PATCH] 小程序 | app

---
 app/App.vue |   36 ++++++++++++++++++++++++++++--------
 1 files changed, 28 insertions(+), 8 deletions(-)

diff --git a/app/App.vue b/app/App.vue
index ef8d60f..9a731a9 100644
--- a/app/App.vue
+++ b/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)

--
Gitblit v1.9.3