From 3800e6e0c8f64ff548a20788d00f0acce39295dc Mon Sep 17 00:00:00 2001
From: whycq <10027870+whycq@user.noreply.gitee.com>
Date: 星期三, 29 十一月 2023 15:02:47 +0800
Subject: [PATCH] #

---
 pages/login/login.vue |   70 ++++++++++++++++++++++++++--------
 1 files changed, 53 insertions(+), 17 deletions(-)

diff --git a/pages/login/login.vue b/pages/login/login.vue
index 1d24776..e7dfe8d 100644
--- a/pages/login/login.vue
+++ b/pages/login/login.vue
@@ -7,23 +7,27 @@
 				<view class="icons">
 					<uni-icons type="person" size="20"></uni-icons>
 				</view>
-				<text>璐﹀彿锛�</text>
-				<input type="text" placeholder="璇疯緭鍏ヨ处鍙�!" v-model="user.userName"
+				<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="璇疯緭鍏ュ瘑鐮�!"
+				<text>楠岃瘉鐮侊細</text>
+				<input :password="!showPassword" v-model="user.code" placeholder="璇疯緭鍏ラ獙璇佺爜!"
 					placeholder-style="font-size:14px;color:#ccc;">
-				<view class="showPassword" v-if="showPassword" @click="changePassword">
+				<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>
 		<!-- 鐧诲綍鎸夐挳 -->
@@ -53,10 +57,10 @@
 		data() {
 			return {
 				version: '',
-				showPassword: false,
+				showPassword: true,
 				user: {
-					userName: '',
-					password: '',
+					phone: '',
+					code: '',
 				},
 				load: {
 					loading: false,
@@ -64,7 +68,9 @@
 				},
 				msgType: 'success',
 				filename: '',
-				dialogContent: ''
+				dialogContent: '',
+				codeTime: 60,
+				codeTimeShow: false
 			}
 		},
 		onLoad: function() {
@@ -81,6 +87,30 @@
 			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 
+						console.log(res);
+						_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;
 			},
@@ -203,8 +233,16 @@
 			},
 			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: that.baseUrl + '/login.action',
+					url: that.baseUrl + '/smsLogin.action',
 					fail(result) {
 						uni.showToast({
 							icon: 'error',
@@ -212,12 +250,10 @@
 						})
 					},
 					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({
@@ -297,7 +333,7 @@
 	}
 
 	.user-info-item>input {
-		width: 400rpx;
+		width: 300rpx;
 		color: #606266;
 		font-weight: 500;
 		caret-color: #606266; // 鍏夋爣棰滆壊

--
Gitblit v1.9.1