From 900e4776223c2a42d8859fc8cd635c13ffcfb3b5 Mon Sep 17 00:00:00 2001
From: 如洲 陈 <1278080563@qq.com>
Date: 星期二, 30 九月 2025 11:12:13 +0800
Subject: [PATCH] 出库检优化

---
 pages/BasePages/main.vue |  122 ++++++++++++++++++++++++----------------
 1 files changed, 73 insertions(+), 49 deletions(-)

diff --git a/pages/BasePages/main.vue b/pages/BasePages/main.vue
index 8f00f8a..4a68a39 100644
--- a/pages/BasePages/main.vue
+++ b/pages/BasePages/main.vue
@@ -18,11 +18,11 @@
 							<navigator navigateTo class="grid-item-box" hover-class="none" :url="`../${item.path}`">
 								<image v-if="item.icoimg" class="imgMenu" :src="`${item.icoimg}`"></image>
 								<image v-else class="imgMenu" src="/static/img/imgMenu/APP01.png"></image>
-								<uni-notice-bar v-if="item.pagE_VIEW.length>6" :speed="30"
+					<uni-notice-bar v-if="item.pagE_VIEW && item.pagE_VIEW.length>6" :speed="30"
 									style="padding:0;margin-bottom:0;font-weight: 900;" textSize="13px"
-									background-color="#ffffff" color="#000000" :scrollable="item.pagE_VIEW.length>6"
-									:single="true" :text="item.pagE_VIEW" />
-								<text v-else class="text">{{ item.pagE_VIEW }}</text>
+								background-color="#ffffff" color="#000000" :scrollable="item.pagE_VIEW && item.pagE_VIEW.length>6"
+								:single="true" :text="item.pagE_VIEW || ''" />
+								<text v-else class="text">{{ item.pagE_VIEW || '' }}</text>
 							</navigator>
 						</uni-grid-item>
 					</uni-grid>
@@ -53,6 +53,8 @@
 					"../../static/img/SN-GG1.png"
 				],
 				col: 4, //鑿滃崟鍒楁暟
+				updateChecked: false,
+				msg: "",
 			};
 		},
 		methods: {
@@ -100,15 +102,21 @@
 				})
 			},
 			checkForUpdate() {
+				if (this.updateChecked) return;
+				if (!this.$post || typeof this.$post !== 'function') return;
 				this.$post({
 					url: "/Login/getAppUpgradeInfo",
 					data: {}
 				}).then(res => {
-
-					let newVersion = res.data.version;
-					let currentVersion = uni.getSystemInfoSync(); // 鑾峰彇褰撳墠 APK 鐗堟湰鍙�
-
-					if (newVersion > currentVersion.appVersion) {
+					const newVersion = res && res.data ? res.data.version : null;
+					const sysInfo = uni.getSystemInfoSync();
+					const currentVersion = sysInfo && sysInfo.appVersion ? sysInfo.appVersion : null;
+					if (!newVersion || !currentVersion) {
+						this.updateChecked = true;
+						return; // 闈� APP 绔垨缂哄皯鐗堟湰淇℃伅鏃惰烦杩�
+					}
+					// 绠�鍗曟瘮杈冿紝涓嶅鐞嗗鏉傝涔夌増鏈�
+					if (String(newVersion) !== String(currentVersion)) {
 						uni.showModal({
 							title: "鍙戠幇鏂扮増鏈�",
 							content: "鏄惁涓嬭浇鏈�鏂扮増鏈�?",
@@ -118,50 +126,57 @@
 								}
 							}
 						});
-						//this.downloadNewApk(res.data.apkUrl);
-						this.updateChecked = true; // 鏍囪鏇存柊宸叉鏌ヨ繃
-						//      // 濡傛灉鏈夋柊鐗堟湰锛屽紑濮嬩笅杞�
-						//download(res.data.apkUrl);
+						this.updateChecked = true;
 					}
+				}).catch(err => {
+					console.error('getAppUpgradeInfo error:', err);
+					this.updateChecked = true;
 				})
-
 			},
-
-
-			downloadNewApk(apkUrl) {
-				uni.showToast({
-					title: "寮�濮嬩笅杞芥洿鏂�...",
-					icon: "none",
-					duration: 2000
-				});
-
-				uni.downloadFile({
-					url: apkUrl,
-					success: (res) => {
-						if (res.statusCode === 200) {
-							plus.runtime.install(res.tempFilePath, {
-								force: true
-							}, function() {
-								console.log("瀹夎鎴愬姛锛岄噸鍚簲鐢�");
-								//plus.runtime.restart();
-								//plus.runtime.quit();
-								// uni.navigateBack()
-							}, function(e) {
-								console.error("瀹夎澶辫触:", e);
+			
+			
+						downloadNewApk(apkUrl) {
+							if (typeof plus === "undefined" || !plus.runtime) {
+								uni.showToast({
+									title: "浠呮敮鎸佸湪APP鍐呮洿鏂�",
+									icon: "none",
+									duration: 2000
+								});
+								return;
+							}
+							uni.showToast({
+								title: "寮�濮嬩笅杞芥洿鏂�...",
+								icon: "none",
+								duration: 2000
+							});
+			
+							uni.downloadFile({
+								url: apkUrl,
+								success: (res) => {
+									if (res.statusCode === 200) {
+										plus.runtime.install(res.tempFilePath, {
+											force: true
+										}, function() {
+											console.log("瀹夎鎴愬姛锛岄噸鍚簲鐢�");
+											//plus.runtime.restart();
+											//plus.runtime.quit();
+											// uni.navigateBack()
+										}, function(e) {
+											console.error("瀹夎澶辫触:", e);
+										});
+									}
+								},
+								fail: (err) => {
+									console.error("涓嬭浇澶辫触:", err);
+									uni.showToast({
+										title: "涓嬭浇澶辫触锛岃妫�鏌ョ綉缁�",
+										icon: "none",
+										duration: 2000
+									});
+								}
 							});
 						}
-					},
-					fail: (err) => {
-						console.error("涓嬭浇澶辫触:", err);
-						uni.showToast({
-							title: "涓嬭浇澶辫触锛岃妫�鏌ョ綉缁�",
-							icon: "none",
-							duration: 2000
-						});
-					}
-				});
-			}
-
+					
 		},
 		onLoad() {
 			if (!this.loginInfo.hasLogin) {
@@ -191,12 +206,21 @@
 				});
 			} else {
 				this.getMenu(true);
+				// 妫�鏌ュ簲鐢ㄦ洿鏂帮紙浠� APP 绔級
+				if (typeof plus !== "undefined") {
+					this.checkForUpdate();
+				}
 			}
 
 		},
 		onPullDownRefresh() {
-			if (this.loginInfo.hasLogin)
+			if (this.loginInfo.hasLogin) {
 				this.getMenu(true);
+				// 涓嬫媺鍒锋柊鏃朵篃妫�鏌ユ洿鏂帮紙浠� APP 绔級
+				if (typeof plus !== "undefined") {
+					this.checkForUpdate();
+				}
+			}
 		},
 
 	}

--
Gitblit v1.9.3