From b56625267d0b53e2feaa6019609913af84bdea28 Mon Sep 17 00:00:00 2001
From: whycq <10027870+whycq@user.noreply.gitee.com>
Date: 星期三, 22 三月 2023 14:11:01 +0800
Subject: [PATCH] #

---
 pages/login/login.vue |  142 ++++++++++++++++++++++++++++++++++++++++++++--
 manifest.json         |   10 ++-
 2 files changed, 141 insertions(+), 11 deletions(-)

diff --git a/manifest.json b/manifest.json
index da872e9..a1d0f9a 100644
--- a/manifest.json
+++ b/manifest.json
@@ -2,7 +2,7 @@
     "name" : "涓壃WMS",
     "appid" : "__UNI__DA5854D",
     "description" : "",
-    "versionName" : "1.0.0",
+    "versionName" : "9.0.0",
     "versionCode" : "100",
     "transformPx" : false,
     /* 5+App鐗规湁鐩稿叧 */
@@ -41,9 +41,13 @@
                 ]
             },
             /* ios鎵撳寘閰嶇疆 */
-            "ios" : {},
+            "ios" : {
+                "dSYMs" : false
+            },
             /* SDK閰嶇疆 */
-            "sdkConfigs" : {}
+            "sdkConfigs" : {
+                "ad" : {}
+            }
         }
     },
     /* 蹇簲鐢ㄧ壒鏈夌浉鍏� */
diff --git a/pages/login/login.vue b/pages/login/login.vue
index cfb94da..69d3dfb 100644
--- a/pages/login/login.vue
+++ b/pages/login/login.vue
@@ -84,6 +84,14 @@
 			</uni-popup>
 		</view>
 		
+		<view>
+			<!-- 鎻愮ず绐楃ず渚� -->
+			<uni-popup ref="upVersion" type="dialog">
+				<uni-popup-dialog :type="msgType" title="閫氱煡" content="鍙戠幇鏂扮増鏈�,鏄惁闇�瑕佹洿鏂�" @confirm="dialogConfirm"
+					@close="dialogClose"></uni-popup-dialog>
+			</uni-popup>
+		</view>
+		
 		<!-- 鐗堟湰鍙� -->
 		<!-- #ifdef APP-PLUS -->
 		<view class="version">
@@ -116,6 +124,8 @@
 					loading: false,
 					btnText: '鐧诲綍'
 				},
+				msgType: 'success',
+				filename: '',
 			}
 		},
 		onLoad() {
@@ -128,14 +138,17 @@
 			if (!this.url) {
 				this.url = {ip: '',port: '',project: ''}
 			}
-			
+			// this.getVersion()
+		},
+		onShow () {
 			// 鎵嬫満绔増鏈彿
-			// #ifdef APP-PLUS
-			var that = this
-			plus.runtime.getProperty(plus.runtime.appid, function(wgtinfo) {
-				that.version = wgtinfo.version
-			});
-			// #endif
+			// // #ifdef APP-PLUS
+			// var that = this
+			// plus.runtime.getProperty(plus.runtime.appid, function(wgtinfo) {
+			// 	that.version = wgtinfo.version
+			// });
+			// // #endif
+			this.getVersion()
 		},
 		methods: {
 			// 鏄剧ず/闅愯棌瀵嗙爜
@@ -216,7 +229,120 @@
 						}
 					},
 				})
-			}
+			},
+			//妫�娴嬪綋鍓嶅钩鍙帮紝濡傛灉鏄畨鍗撳垯鍚姩瀹夊崜鏇存柊
+			getVersion() {
+				let that = this;
+				uni.getSystemInfo({
+					success: (res) => {
+						console.log(res.platform);
+						if (res.platform == "android") {
+							that.AndroidCheckUpdate();
+						}
+					}
+				})
+			},
+			// 鑾峰彇褰撳墠鐗堟湰鍙�
+			AndroidCheckUpdate() {
+				let that = this;
+				plus.runtime.getProperty(plus.runtime.appid, (wgtinfo) => {
+					that.version = wgtinfo.version //瀹㈡埛绔増鏈彿
+					console.log('褰撳墠app鐗堟湰淇℃伅锛�' + that.version);
+				})
+				setTimeout(()=>{
+					that.getUpdateVersion()
+				},1000)
+			},
+			// 鏍¢獙鐗堟湰
+			getUpdateVersion() {
+				console.log(this.version);
+				let that = this
+				let type = 0
+				if (that.baseUrl == 'http://undefined:undefined/undefined') {
+					return
+				}
+				console.log(2);
+				
+				let url = that.baseUrl + '/appVersion/checkUpdate/' + that.version + '/' + type
+				console.log(url);
+				uni.request({
+					url: url,
+					method: 'GET',
+					success(res) {
+						console.log(res);
+						var res = res.data
+						if (res.data) {
+							that.filename = res.data.path
+							that.$refs.upVersion.open()
+						}
+						
+					}
+				})
+			},
+			dialogConfirm() {
+				this.$refs.upVersion.close()
+				this.downWgt()
+			},
+			dialogClose() {
+				this.$refs.upVersion.close()
+			},
+			downWgt() {
+				let that = this;
+				const downloadUrl = that.baseUrl + "/appVersion/downloadApp/" + that.filename
+				console.log(downloadUrl);
+				uni.showLoading({
+					title: '鏇存柊涓�︹��'
+				})
+				console.log('*************************************');
+				const downloadTask = uni.downloadFile({ //鎵ц涓嬭浇
+					url: downloadUrl, //涓嬭浇鍦板潃
+					timeout: 1000 * 30, //30绉掕秴鏃舵椂闂�
+					success: downloadResult => { //涓嬭浇鎴愬姛
+						console.log(downloadResult);
+						// that.showdownLine = false
+						uni.hideLoading();
+						console.log('downloadResult.statusCode' + downloadResult.statusCode)
+						if (downloadResult.statusCode == 200) {
+							console.log('鏇存柊涓�')
+							uni.showModal({
+								title: '',
+								content: '鏇存柊鎴愬姛锛岀‘瀹氱幇鍦ㄩ噸鍚悧锛�',
+								confirmText: '閲嶅惎',
+								confirmColor: '#EE8F57',
+								success: function(res) {
+									if (res.confirm == true) {
+										plus.runtime.install( //瀹夎
+											downloadResult.tempFilePath, {
+												force: true
+											},
+											function(res) {
+												utils.showToast('鏇存柊鎴愬姛锛岄噸鍚腑');
+												plus.runtime.restart();
+											}
+										);
+									}
+								}
+							});
+						}
+					},
+					fail: err => {
+						uni.hideLoading();
+						that.showdownLine = false
+						that.$u.toast(err.errMsg)
+						console.log(err)
+					},
+					complete: com => {
+						console.log(com)
+					}
+				});
+			
+				// 涓嬭浇杩涘害
+				downloadTask.onProgressUpdate(res => {
+					that.downloadNum = res.progress
+					console.log('涓嬭浇杩涘害' + that.downloadNum);
+				});
+			},
+			
 		}
 	}
 </script>

--
Gitblit v1.9.1