From e6a02c8b09a796e436a501e9b87d19e25c34c9d1 Mon Sep 17 00:00:00 2001
From: zjj <3272660260@qq.com>
Date: 星期日, 07 四月 2024 15:53:37 +0800
Subject: [PATCH] #

---
 pages/login/login.vue |  334 +++++++++++++++++++++++++++++++++++++++++++++----------
 1 files changed, 271 insertions(+), 63 deletions(-)

diff --git a/pages/login/login.vue b/pages/login/login.vue
index d03e312..fb7237e 100644
--- a/pages/login/login.vue
+++ b/pages/login/login.vue
@@ -4,24 +4,45 @@
 		<!-- 鐧诲綍淇℃伅 -->
 		<view class="user-info">
 			<view class="user-info-item shadow-warp">
-				<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;">
+				<view class="icons">
+					<uni-icons type="person" size="20"></uni-icons>
+				</view>
+				<text>鎵嬫満鍙凤細</text>
+				<input type="text" placeholder="璇疯緭鍏ヨ处鍙�!" v-model="user.phone"
+					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>
-				<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>
+				<view class="icons">
+					<uni-icons type="locked" size="20"></uni-icons>
+				</view>
+				<text>楠岃瘉鐮侊細</text>
+				<input :password="!showPassword" v-model="user.code" placeholder="璇疯緭鍏ラ獙璇佺爜!"
+					placeholder-style="font-size:14px;color:#ccc;">
+				<view style="font-size: 24rpx;" >
+					<text @click="getCode" v-show="!codeTimeShow">鑾峰彇楠岃瘉鐮�</text>
+					<text v-show="codeTimeShow">{{codeTime}}绉掑悗閲嶈幏</text>
+				</view>
+				<!-- <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>
 		<!-- 鐧诲綍鎸夐挳 -->
 		<view class="loging">
 			<button class="button" @click="onLogin()" :loading="load.loading">{{load.btnText}}</button>
 		</view>
+		
+		<view>
+			<!-- 鎻愮ず绐楃ず渚� -->
+			<uni-popup ref="upVersion" type="dialog">
+				<uni-popup-dialog :type="msgType" title="閫氱煡" :content="dialogContent" @confirm="dialogConfirm"
+					@close="dialogClose"></uni-popup-dialog>
+			</uni-popup>
+		</view>
+		
 		<!-- #ifdef APP-PLUS -->
 		<view class="version">
 			褰撳墠鐗堟湰: {{version}}
@@ -36,68 +57,238 @@
 		data() {
 			return {
 				version: '',
-				showPassword: false,
+				showPassword: true,
 				user: {
-					userName: '',
-					password: '',
+					phone: '',
+					code: '',
 				},
 				load: {
 					loading: false,
 					btnText: '鐧诲綍'
-				}
+				},
+				msgType: 'success',
+				filename: '',
+				dialogContent: '',
+				codeTime: 60,
+				codeTimeShow: false,
+				download: '' 
 			}
 		},
-		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
-			
-			
+		},
+		onShow() {
+			this.getVersion()
 		},
 		methods: {
+			// 鑾峰彇楠岃瘉鐮�
+			getCode() {
+				let _this = this
+				uni.request({
+					url: `${_this.baseUrl}/smsCode/sendCode`,
+					header: {'content-type': 'application/x-www-form-urlencoded;charset=UTF-8'},
+					data: {phone: _this.user.phone},
+					sslVerify: false,
+					method: 'POST',
+					success(res) {
+						res = res.data 
+						_this.codeTimeShow = true
+						let time = setInterval(()=>{
+							_this.codeTime--
+						},1000)
+						setTimeout(()=>{
+							_this.codeTimeShow = false
+							clearTimeout(time);
+							_this.codeTime = 60
+						},60000)
+					}
+				})
+			},
 			changePassword: function() {
-			    this.showPassword = !this.showPassword;
+				this.showPassword = !this.showPassword;
+			},
+			//妫�娴嬪綋鍓嶅钩鍙帮紝濡傛灉鏄畨鍗撳垯鍚姩瀹夊崜鏇存柊
+			getVersion() {
+				let that = this;
+				uni.getSystemInfo({
+					success: (res) => {
+						if (res.platform == "android") {
+							that.AndroidCheckUpdate();
+						}
+					}
+				})
+			},
+			// 鑾峰彇褰撳墠鐗堟湰鍙�
+			AndroidCheckUpdate() {
+				let that = this;
+				plus.runtime.getProperty(plus.runtime.appid, (wgtinfo) => {
+					that.version = wgtinfo.version //瀹㈡埛绔増鏈彿
+				})
+				setTimeout(()=>{
+					that.getUpdateVersion()
+				},100)
+			},
+			// 鏍¢獙鐗堟湰
+			getUpdateVersion() {
+				let that = this
+				let type = 0
+				if (that.baseUrl == 'http://undefined:undefined/undefined') {
+					return
+				}
+				
+				let url = that.baseUrl + '/appVersion/checkUpdate/' + that.version + '/' + type
+				uni.request({
+					url: url,
+					method: 'GET',
+					success(res) {
+						console.log(res);
+						var res = res.data
+						if (res.data) {
+							console.log(res);
+							that.filename = res.data.path
+							that.dialogContent = '鍙戠幇鏂扮増鏈�:' + res.data.version + ', 鏄惁绔嬪嵆鏇存柊'
+							that.download = res.data.url
+							that.$refs.upVersion.open()
+						} else {
+							uni.showToast({
+								title: res.msg,
+								icon: "none",
+								position: 'top'
+							})
+						}
+						
+					}
+				})
+			},
+			dialogConfirm() {
+				this.$refs.upVersion.close()
+				this.downWgt()
+			},
+			dialogClose() {
+				this.$refs.upVersion.close()
+			},
+			downWgt() {
+				let that = this;
+				const downloadUrl = that.download
+				uni.showLoading({
+					title: '鏇存柊涓�︹��'
+				})
+				const downloadTask = uni.downloadFile({ //鎵ц涓嬭浇
+					url: downloadUrl, //涓嬭浇鍦板潃
+					timeout: 1000 * 30, //30绉掕秴鏃舵椂闂�
+					success: downloadResult => { //涓嬭浇鎴愬姛
+						console.log(downloadResult);
+						that.showdownLine = false
+						uni.hideLoading();
+						if (downloadResult.statusCode == 200) {
+							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();
+											}
+										);
+									}
+								}
+							});
+						} else {
+							uni.hideLoading();
+							that.showdownLine = false
+							uni.showToast({
+								title:'璇峰厛涓婁紶瀹夎鍖�',
+								icon: 'error'
+							})
+						}
+					},
+					fail: err => {
+						uni.hideLoading();
+						that.showdownLine = false
+						that.$u.toast(downloadResult.errMsg)
+					},
+					complete: com => {
+						
+						console.log(com)
+					}
+				});
+			
+				// 涓嬭浇杩涘害
+				downloadTask.onProgressUpdate(res => {
+					that.downloadNum = res.progress
+					console.log('涓嬭浇杩涘害' + that.downloadNum);
+				});
 			},
 			onLogin() {
 				let that = this
+				if (that.user.phone == '') {
+					uni.showToast({ title: '璇疯緭鍏ユ墜鏈哄彿', icon: "none" })
+					return
+				}
+				if (that.user.code == '') {
+					uni.showToast({ title: '楠岃瘉鐮佷笉鑳戒负绌�', icon: "none" })
+					return
+				}
 				uni.request({
-					url: 'http://localhost:9528/login.action',
+					url: that.baseUrl + '/smsLogin.action',
 					fail(result) {
-						uni.showToast({title: '璇锋眰澶辫触'})
+						uni.showToast({
+							icon: 'error',
+							title: '璇锋眰澶辫触'
+						})
 					},
 					data: {
-					  username:that.user.userName,
-					  password:md5.hex_md5(that.user.password) 
+						phone: that.user.phone,
+						code: that.user.code
 					},
-					header: {
-						"content-type": "application/json"
-					},
+					header: { "content-type": "application/json" },
 					success(result) {
+						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('baseUrl','http://localhost:9528')
-							setTimeout(()=> {
-								uni.showToast({title: '鐧诲綍鎴愬姛'})
-								setTimeout(()=> {
+							uni.setStorageSync('password', that.user.password);
+							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
+							})
 						}
 					},
-					
-					
+
+
 				})
 			},
 		}
@@ -111,6 +302,7 @@
 		width: 100%;
 		min-height: 93.4vh;
 	}
+
 	.logo {
 		width: 300px;
 		height: 163px;
@@ -119,44 +311,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{
-		width: 400rpx;
-		color:#606266;
+
+	.user-info-item>input {
+		width: 300rpx;
+		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;
@@ -169,19 +368,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;
@@ -189,34 +391,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