From 2c3b495c8b7c673b4918ab61d510830fba4a78e2 Mon Sep 17 00:00:00 2001
From: MrShi <1878285526@qq.com>
Date: 星期二, 28 四月 2026 21:16:13 +0800
Subject: [PATCH] 小程序改bug

---
 app/App.vue |   42 ++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 42 insertions(+), 0 deletions(-)

diff --git a/app/App.vue b/app/App.vue
index e4066ef..237c93d 100644
--- a/app/App.vue
+++ b/app/App.vue
@@ -24,6 +24,7 @@
 		onLaunch: function() {
 			this.initJPush()
 			this.checkAndStartLocationPolling()
+			this.checkAppUpdate()
 		},
 		onShow: function() {
 			console.log('App Show')
@@ -134,6 +135,47 @@
 						})
 					}
 				})
+			},
+
+			compareVersion(localVersion, serverVersion) {
+				const v1 = localVersion.split('.')
+				const v2 = serverVersion.split('.')
+				for (let i = 0; i < Math.max(v1.length, v2.length); i++) {
+					const n1 = parseInt(v1[i] || 0)
+					const n2 = parseInt(v2[i] || 0)
+					if (n1 < n2) return -1
+					if (n1 > n2) return 1
+				}
+				return 0
+			},
+
+			checkAppUpdate() {
+				this.$u.api.getApiVersion({ type: 0 }).then(res => {
+					if (res.code === 200 && res.data) {
+						const localVersionCode = plus.runtime.versionCode
+						const serverVersionCode = res.data.versionCode
+						if (serverVersionCode && localVersionCode < serverVersionCode) {
+							const isForce = res.data.isForce === 1
+							uni.showModal({
+								title: '鍙戠幇鏂扮増鏈�',
+								content: res.data.versionInfo || '鏈夋柊鐗堟湰鍙敤锛屾槸鍚︾珛鍗虫洿鏂帮紵',
+								showCancel: !isForce,
+								cancelText: isForce ? '' : '鏆備笉鏇存柊',
+								confirmText: '绔嬪嵆鏇存柊',
+								success: (modalRes) => {
+									if (modalRes.confirm) {
+										if (res.data.fileUrl) {
+											plus.runtime.openURL(res.data.fileUrl)
+										}
+									}
+									if (isForce && modalRes.cancel) {
+										this.checkAppUpdate()
+									}
+								}
+							})
+						}
+					}
+				})
 			}
 		}
 	}

--
Gitblit v1.9.3