From 2d43a1df3f5ba42710e6d21c27d1e13bdb8dfd56 Mon Sep 17 00:00:00 2001
From: zhangwei <1504152376@qq.com>
Date: 星期一, 24 三月 2025 09:23:08 +0800
Subject: [PATCH] -

---
 src/App.vue |  144 ++++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 122 insertions(+), 22 deletions(-)

diff --git a/src/App.vue b/src/App.vue
index dfbe4ea..fb73310 100644
--- a/src/App.vue
+++ b/src/App.vue
@@ -1,22 +1,122 @@
-<script>
	import { http } from '@/uni_modules/uview-plus'
-	export default {
-		onLaunch: function() {
-			console.log('App Launch')
-		},
-		onShow: async function() {
-			console.log('App Show')
-			// let res = await http.get('/')
			// console.log(res)
-		},
-		onHide: function() {
-			console.log('App Hide')
-		}
-	}
-</script>
-
-<style lang="scss">
-	/*姣忎釜椤甸潰鍏叡css */
-	// @import "uview-plus/index.scss";
	@import "@/uni_modules/uview-plus/index.scss";
-	@import "common/demo.scss";
-	@import "@/static/css/comm.scss";
-	@import "@/static/css/iconfont.css";
-</style>
+<script>
+	import {
+		http
+	} from '@/uni_modules/uview-plus'
+	export default {
+		// globalData: {
+		//     showLoginTip: false,
+		// },
+		onLaunch: function() {
+			// let isjump = this.$db.get('identity')
+			// console.log(isjump,'isjumpisjump');
+			// if (isjump) {
+			// 	uni.switchTab({
+			// 		url: '/pages/index/index'
+			// 	});
+			// }
+
+			let token = this.$db.get('userToken')
+			if (token) {
+				this.$store.dispatch('getUserInfo')
+			}
+			// #ifdef MP-WEIXIN
+			this.autoUpdate();
+			// #endif
+			console.log('App Launch')
+		},
+		onShow: async function() {
+			console.log('App Show')
+			// let res = await http.get('/')
+			// console.log(res)
+		},
+		onHide: function() {
+			console.log('App Hide')
+		},
+		methods: {
+			// #ifdef MP-WEIXIN
+			//寰俊灏忕▼搴忔娴嬫洿鏂版帾鏂斤紝鏂瑰紡鏇存柊鍔熻兘鍚庯紝瑕佺瓑寰�24灏忔椂鍐呮墠鍒锋柊鐨勯棶棰樸��
+			autoUpdate() {
+				var self = this
+				// 鑾峰彇灏忕▼搴忔洿鏂版満鍒跺吋瀹�
+				if (wx.canIUse('getUpdateManager')) {
+					//console.log("杩涘叆灏忕▼搴忚嚜鍔ㄦ洿鏂版娴�");
+					const updateManager = wx.getUpdateManager()
+					//1. 妫�鏌ュ皬绋嬪簭鏄惁鏈夋柊鐗堟湰鍙戝竷
+					updateManager.onCheckForUpdate(function(res) {
+						//console.log("杩涘叆灏忕▼搴忔娴嬫槸鍚﹂渶瑕佽嚜鍔ㄦ洿鏂�");
+						//console.log(res);
+						// 璇锋眰瀹屾柊鐗堟湰淇℃伅鐨勫洖璋�
+						if (res.hasUpdate) {
+							//妫�娴嬪埌鏂扮増鏈紝闇�瑕佹洿鏂帮紝缁欏嚭鎻愮ず
+							wx.showModal({
+								title: '鏇存柊鎻愮ず',
+								content: '妫�娴嬪埌鏂扮増鏈紝鏄惁涓嬭浇鏂扮増鏈苟閲嶅惎灏忕▼搴忥紵',
+								success: function(res) {
+									if (res.confirm) {
+										//2. 鐢ㄦ埛纭畾涓嬭浇鏇存柊灏忕▼搴忥紝灏忕▼搴忎笅杞藉強鏇存柊闈欓粯杩涜
+										self.downLoadAndUpdate(updateManager)
+									} else if (res.cancel) {
+										//鐢ㄦ埛鐐瑰嚮鍙栨秷鎸夐挳锛岄渶瑕佸己鍒舵洿鏂帮紝浜屾寮圭獥
+										wx.showModal({
+											title: '娓╅Θ鎻愮ず~',
+											content: '鏈鐗堟湰鏇存柊娑夊強鍒版柊鐨勫姛鑳芥坊鍔狅紝鏃х増鏈棤娉曟甯歌闂殑鍝',
+											showCancel: false,
+											confirmText: "纭畾鏇存柊",
+											success: function(res) {
+												if (res.confirm) {
+													//涓嬭浇鏂扮増鏈紝骞堕噸鏂板簲鐢�
+													self.downLoadAndUpdate(updateManager)
+												}
+											}
+										})
+									}
+								}
+							})
+						}
+					})
+				} else {
+					// 濡傛灉甯屾湜鐢ㄦ埛鍦ㄦ渶鏂扮増鏈殑瀹㈡埛绔笂浣撻獙鎮ㄧ殑灏忕▼搴忥紝鍙互杩欐牱瀛愭彁绀�
+					wx.showModal({
+						title: '鎻愮ず',
+						content: '褰撳墠寰俊鐗堟湰杩囦綆锛屾棤娉曚娇鐢ㄨ鍔熻兘锛岃鍗囩骇鍒版渶鏂板井淇$増鏈悗閲嶈瘯銆�'
+					})
+				}
+			},
+			downLoadAndUpdate(updateManager) {
+				var self = this
+				wx.showLoading();
+				//闈欓粯涓嬭浇鏇存柊灏忕▼搴忔柊鐗堟湰
+				updateManager.onUpdateReady(function() {
+					wx.hideLoading()
+					//鏂扮殑鐗堟湰宸茬粡涓嬭浇濂斤紝璋冪敤 applyUpdate 搴旂敤鏂扮増鏈苟閲嶅惎
+					updateManager.applyUpdate()
+				})
+				updateManager.onUpdateFailed(function() {
+					// 鏂扮殑鐗堟湰涓嬭浇澶辫触
+					wx.showModal({
+						title: '宸茬粡鏈夋柊鐗堟湰浜嗗摕~',
+						content: '鏂扮増鏈凡缁忎笂绾垮暒~锛岃鎮ㄥ垹闄ゅ綋鍓嶅皬绋嬪簭锛岄噸鏂版悳绱㈡墦寮�鍝焴',
+					})
+				})
+			},
+			// #endif
+		}
+	}
+</script>
+
+<style lang="scss">
+	// page{
+	//   height: 100vh
+	// }
+	// .page {
+	//   display: flex;
+	//   flex-direction: column;
+	//   overflow-x: hidden;
+	// }
+	/*姣忎釜椤甸潰鍏叡css */
+	// @import "uview-plus/index.scss";
+	@import "common/demo.scss";
+	@import "@/static/css/comm.scss";
+	@import "@/static/css/iconfont.css";
+	@import "@/uni_modules/uview-plus/index.scss";
+</style>
\ No newline at end of file

--
Gitblit v1.9.1