From 03231f2215f02af381b5d7d9e5908071c151f135 Mon Sep 17 00:00:00 2001
From: whycq <10027870+whycq@user.noreply.gitee.com>
Date: 星期一, 21 八月 2023 12:50:25 +0800
Subject: [PATCH] #

---
 pages/login/login.vue |  213 ++++++++++++++++++++++++++++++++++++++++------------
 1 files changed, 162 insertions(+), 51 deletions(-)

diff --git a/pages/login/login.vue b/pages/login/login.vue
index d9d9ccd..1d0dcd3 100644
--- a/pages/login/login.vue
+++ b/pages/login/login.vue
@@ -4,18 +4,26 @@
 		<!-- 鐧诲綍淇℃伅 -->
 		<view class="user-info">
 			<view class="user-info-item shadow-warp">
-				<view class="icons"><uni-icons type="person" size="20"></uni-icons></view>
+				<view class="icons">
+					<uni-icons type="person" size="20"></uni-icons>
+				</view>
 				<text>璐﹀彿锛�</text>
 				<input type="text" placeholder="璇疯緭鍏ヨ处鍙�!" v-model="user.userName"
-				placeholder-style="font-size:14px;color:#ccc;">
+					placeholder-style="font-size:14px;color:#ccc;">
 			</view>
 			<view class="user-info-item shadow-warp">
-				<view class="icons"><uni-icons type="locked" size="20"></uni-icons></view>
+				<view class="icons">
+					<uni-icons type="locked" size="20"></uni-icons>
+				</view>
 				<text>瀵嗙爜锛�</text>
 				<input :password="!showPassword" v-model="user.password" placeholder="璇疯緭鍏ュ瘑鐮�!"
-				placeholder-style="font-size:14px;color:#ccc;">
-				<view class="showPassword" v-if="showPassword" @click="changePassword"><uni-icons type="eye" size="20"></uni-icons></view>
-				<view class="showPassword" v-if="!showPassword" @click="changePassword"><uni-icons type="eye-slash" size="20"></uni-icons></view>
+					placeholder-style="font-size:14px;color:#ccc;">
+				<view class="showPassword" v-if="showPassword" @click="changePassword">
+					<uni-icons type="eye" size="20"></uni-icons>
+				</view>
+				<view class="showPassword" v-if="!showPassword" @click="changePassword">
+					<uni-icons type="eye-slash" size="20"></uni-icons>
+				</view>
 			</view>
 		</view>
 		<!-- 鐧诲綍鎸夐挳 -->
@@ -47,62 +55,148 @@
 				},
 			}
 		},
-		onLoad:function(){
+		onLoad: function() {
 			this.user.userName = uni.getStorageSync('userName')
 			this.user.password = uni.getStorageSync('password')
 			// #ifdef APP-PLUS
-			var that=this
-			plus.runtime.getProperty( plus.runtime.appid, function ( wgtinfo ) {
-				that.version=wgtinfo.version
+			var that = this
+			plus.runtime.getProperty(plus.runtime.appid, function(wgtinfo) {
+				that.version = wgtinfo.version
 			});
 			// #endif
-			
-			
+			this.getVersion()
+
 		},
 		methods: {
 			changePassword: function() {
-			    this.showPassword = !this.showPassword;
+				this.showPassword = !this.showPassword;
+			},
+			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);
+				})
+				that.getUpdateVersion()
+			},
+			getUpdateVersion() {
+				let that = this;
+				// 鑾峰彇褰撳墠app鐗堟湰淇℃伅
+				return
+				that.$req.get("/appUpdate/queryUpdate", {}, {}).then(function(res) {
+					console.log('res.data:' + JSON.stringify(res.data))
+					console.log("鐜板湪鐨勭増鏈�" + that.version + "鏁版嵁搴撶増鏈�" + res.data.data.version + "杩涘叆鏌ユ壘app鐗堟湰");
+					if (res.data.data.version > that.version) {
+						// 杩欓噷涓嬭浇apkurl浠�/appUpdate/queryUpdate鎺ュ彛璇锋眰杩斿洖鏁版嵁涓幏鍙�
+						that.downloadUrl = BaseUrl + '/' + res.data.data.androidUrl
+						// 鏄惁寮哄埗鏇存柊锛�0 鍚︼紱1 鏄級
+						that.isForceUpdate = res.data.data.isForceUpdate
+						uni.showModal({
+			  		// 鏇存柊鎻愰啋
+							title: '鍙戠幇鏂扮増鏈紝鏄惁鏇存柊',
+							content: '姝ょ増鏈彿锛�' + that.version + '\xa0\xa0\xa0' + '寰呮洿鏂扮増鏈彿锛�' + res.data.data
+								.version,
+							success: res => {
+			 				if (res.confirm) {
+									that.downWgt(); //涓嬭浇鏂囦欢
+									// that.showdownLine = true;
+									// plus.runtime.openURL(androidUrl)
+								} else if (res.cancel) {
+									console.log('that.isForceUpdate锛�' + that.isForceUpdate);
+									// 涓嶆洿鏂板己鍒堕��鍑篴pp
+									if (that.isForceUpdate == 1) {
+										console.log('that.isForceUpdate1锛�' + that.isForceUpdate);
+										uni.showModal({
+											// 鏇存柊鎻愰啋
+											title: '鍙戠幇鏂扮増鏈紝鏄惁鏇存柊',
+											content: '姝ょ増鏈负寮哄埗鏇存柊鐗堟湰濡備笉鍗囩骇灏嗛��鍑篈PP',
+											success: res => {
+												if (res.confirm) {
+													console.log('涓嶆洿鏂板己鍒堕��鍑篴pp');
+													plus.runtime.quit();
+												} else if (res.cancel) {
+													that.AndroidCheckUpdate();
+												}
+											}
+										});
+									}
+								}
+							}
+						});
+						//dtask.start();   
+					}
+				}).catch(error => {
+					uni.showToast({
+						title: '璋冪敤璇锋眰澶辫触',
+						mask: false,
+						duration: 5000,
+						icon: "none"
+					});
+				});
+				complete: () => {}
 			},
 			onLogin() {
 				let that = this
 				uni.request({
 					url: that.baseUrl + '/login.action',
 					fail(result) {
-						uni.showToast({icon:'error',title: '璇锋眰澶辫触'})
+						uni.showToast({
+							icon: 'error',
+							title: '璇锋眰澶辫触'
+						})
 					},
 					data: {
-					  username:that.user.userName,
-					  password:md5.hex_md5(that.user.password) 
+						username: that.user.userName,
+						password: md5.hex_md5(that.user.password)
 					},
 					header: {
 						"content-type": "application/json"
 					},
 					success(result) {
-						if (result.statusCode ===  404) {
-							uni.showToast({title: '鐧诲綍澶辫触', icon: "error"})
+						if (result.statusCode === 404) {
+							uni.showToast({
+								title: '鐧诲綍澶辫触',
+								icon: "error"
+							})
 							return
 						}
 						let res = result.data
-						if (res.code === 200 ){
+						if (res.code === 200) {
 							that.load.loading = true;
 							that.load.btnText = '鐧诲綍涓�';
 							uni.setStorageSync('token', res.data.token);
 							uni.setStorageSync('userName', that.user.userName);
 							uni.setStorageSync('password', that.user.password);
-							setTimeout(()=> {
-								uni.showToast({title: '鐧诲綍鎴愬姛'})
-								setTimeout(()=> {
+							setTimeout(() => {
+								uni.showToast({
+									title: '鐧诲綍鎴愬姛'
+								})
+								setTimeout(() => {
 									uni.reLaunch({
 										url: '../index/index'
 									});
-								},300)
-							},700)
+								}, 300)
+							}, 700)
 						} else {
-							uni.showToast({title: res.msg})
+							uni.showToast({
+								title: res.msg
+							})
 						}
 					},
-					
-					
+
+
 				})
 			},
 		}
@@ -116,6 +210,7 @@
 		width: 100%;
 		min-height: 93.4vh;
 	}
+
 	.logo {
 		width: 300px;
 		height: 163px;
@@ -124,44 +219,51 @@
 		margin-right: auto;
 		margin-bottom: 50rpx;
 	}
+
 	.user-info {
 		display: flex;
-		align-items:center;
+		align-items: center;
 		flex-direction: column;
 		width: 100%;
 		height: 400rpx;
 		font-size: 14px;
-		letter-spacing:1px;
+		letter-spacing: 1px;
 	}
+
 	.user-info-item {
 		display: flex;
-		width:650rpx;
+		width: 650rpx;
 		height: 100rpx;
 		line-height: 100rpx;
-		align-items:center;
+		align-items: center;
 		background-color: #fff;
 		margin-bottom: 30rpx;
 		font-size: 28rpx;
 		font-weight: 500;
 	}
-	.user-info-item>input{
+
+	.user-info-item>input {
 		width: 400rpx;
-		color:#606266;
+		color: #606266;
 		font-weight: 500;
-		caret-color:#606266; // 鍏夋爣棰滆壊
+		caret-color: #606266; // 鍏夋爣棰滆壊
 	}
+
 	.icons {
 		margin-left: 20rpx;
 		margin-right: 18rpx;
 	}
+
 	.showPassword {
 		position: absolute;
 		right: 10rpx;
 	}
+
 	.shadow-warp {
 		position: relative;
 		box-shadow: 0 0 10upx rgba(0, 0, 0, 0.1);
 	}
+
 	.shadow-warp:before,
 	.shadow-warp:after {
 		position: absolute;
@@ -174,19 +276,22 @@
 		transform: rotate(-3deg);
 		z-index: -1;
 	}
+
 	.shadow-warp:after {
 		right: 20upx;
 		left: auto;
 		transform: rotate(3deg);
 	}
+
 	.loging {
 		position: fixed;
 		bottom: 100rpx;
-		left:0;
-		right:0;
-		margin-left:auto;
-		margin-right:auto;
+		left: 0;
+		right: 0;
+		margin-left: auto;
+		margin-right: auto;
 	}
+
 	.button {
 		color: #fff;
 		background-color: #409EFF;
@@ -194,34 +299,40 @@
 		height: 40px;
 		line-height: 40px;
 	}
-	button::after{border: initial;}
-	.button-hover {
-		color:#fff;
-		background-color:#6fc1ff;
+
+	button::after {
+		border: initial;
 	}
+
+	.button-hover {
+		color: #fff;
+		background-color: #6fc1ff;
+	}
+
 	.version {
 		width: 100%;
 		position: fixed;
 		bottom: 30rpx;
-		left:0;
-		right:0;
-		margin-left:auto;
-		margin-right:auto;
+		left: 0;
+		right: 0;
+		margin-left: auto;
+		margin-right: auto;
 		text-align: center;
 		font-size: 10px;
 		color: #C0C4CC;
 	}
+
 	.input {
 		display: block;
 		font-size: 14px;
 	}
+
 	.uni-input {
 		height: 50rpx;
 		padding: 15rpx 25rpx;
-		line-height:50rpx;
-		font-size:28rpx;
-		background:#FFF;
+		line-height: 50rpx;
+		font-size: 28rpx;
+		background: #FFF;
 		flex: 1;
 	}
-	
-</style>
\ No newline at end of file
+</style>

--
Gitblit v1.9.1