From 20d63bf572e4d8e2ee94fb038a658a63c609e7ae Mon Sep 17 00:00:00 2001
From: whycq <913841844@qq.com>
Date: 星期一, 16 十月 2023 13:38:38 +0800
Subject: [PATCH] #

---
 pages/LoginDemo/LoginDemo.vue |  188 ++++++++++++++++++++++++++++++++--------------
 1 files changed, 129 insertions(+), 59 deletions(-)

diff --git a/pages/LoginDemo/LoginDemo.vue b/pages/LoginDemo/LoginDemo.vue
index c8e00f4..590a03f 100644
--- a/pages/LoginDemo/LoginDemo.vue
+++ b/pages/LoginDemo/LoginDemo.vue
@@ -17,51 +17,38 @@
 					<switch :checked='remberPassword' color="#FFCC33" style="zoom:.5" @change="remberChange"/>
 				</view>
 			</view>
-			<view class="button" @click="login">
-				鐧诲綍
-			</view>
+			<!-- <view class="button" @click="login" :loading="load.loading">
+				{{load.btnText}} 
+			</view> -->
+			<button class="button" @click="onLogin()" :loading="load.loading">{{load.btnText}}</button>
 		</view>
 		<!-- 璁剧疆寮圭獥鍖哄煙 -->
 		<uni-popup ref="settings" type="dialog">
 			<view class="popup">
 				<!-- 鏍囬 -->
 				<view class="title">缃� 缁� 閰� 缃�</view>
-					<scroll-view scroll-y="true" style="height: 20vh;">
-						<view style="margin: 4px;color: #a8abb2; font-size: 12px; " v-for="it in 10">
-							<text style="font-size: 14px;">WCS 閰嶇疆</text>
+					<scroll-view scroll-y="true" style="height: 23vh;touch-action: none;">
+						<view style="margin: 4px; color: #606266;font-size: 12px; " v-for="net in network">
+							<text style="font-size: 14px;">{{net.name}}</text>
 							<view style="display: flex;align-items: center;">
-								<input class="settings-input1" type="text"> 
+								<input class="settings-input1" type="text" v-model="net.ip"> 
 								<text style="font-weight: 900;">:</text>
-								<input class="settings-input2" type="text"> 
+								<input class="settings-input2" type="text" v-model="net.port"> 
 								<text style="font-weight: 900;">/</text>
-								<input class="settings-input3" type="text">
+								<input class="settings-input3" type="text" v-model="net.address">
 							</view>
 						</view>
 					</scroll-view>
-				<view class="">
-					<view class="">
+				<view class="operate">
+					<view class="operate-cancel" @click="cancel">
 						鍙栨秷
 					</view>
-					<view class="">
+					<view class="operate-confirm" @click="confirm">
 						纭
 					</view>
 				</view>
-				<!-- <view class="popup-item">
-					<view class="popup-item-left">IP:</view>
-					<view class="popup-item-right"><input type="text" v-model="url.ip"></view>
-				</view>
-				<view class="popup-item">
-					<view class="popup-item-left">绔彛:</view>
-					<view class="popup-item-right"><input type="text" v-model="url.port"></view>
-				</view>
-				<view class="popup-item">
-					<view class="popup-item-left">椤圭洰:</view>
-					<view class="popup-item-right"><input type="text" v-model="url.project"></view>
-				</view> -->
 			</view>
 		</uni-popup>
-		
-		
 		
 		<!-- 鐗堟湰鍙� -->
 		<!-- #ifdef APP-PLUS -->
@@ -73,18 +60,27 @@
 </template>
 
 <script>
+	// import { data } from 'jquery'
+	import { mapState } from 'vuex'//寮曞叆mapState
+	import md5 from '../../static/js/md5.js'
 	export default {
 		data() {
 			return {
 				version: '',
 				remberPassword: true,
-				url: {
-					ip: '',
-					port: '',
-					project: ''
+				network: [
+					{name: 'wms',ip:'192.168.1.1',port: '8080',address: 'pswms'},
+					{name: 'wcs',ip:'192.168.1.1',port: '9090',address: 'pswcs'}
+				],
+				load: {
+					loading: false,
+					btnText: '鐧诲綍'
 				},
 			}
 		},
+		computed: mapState({
+			project: state => state.project
+		}) ,
 		mounted() {
 			uni.getSystemInfo({
 				success(res) {
@@ -106,14 +102,58 @@
 			settings() {
 				this.$refs.settings.open()
 			},
-			login() {
-				let path = 'demo'
-				uni.navigateTo({
-					url: `/pages/project/${path}/home/home`,
-					fail(res) {
-						console.log(`娌℃湁${path}椤圭洰,璇疯仈绯荤鐞嗗厓`);
+			cancel() {
+				console.log(uni.getStorageSync('Network'));
+				this.$refs.settings.close()
+			},
+			confirm() {
+				uni.setStorageSync('Network', this.network);
+				this.$refs.settings.close()
+			},
+			onLogin() {
+				let _this = this,path = 'demo',network = uni.getStorageSync('Network');
+				if(!network) {
+					uni.showToast({
+						icon: 'error',
+						title: '璇烽厤缃綉缁滀俊鎭�'
+					})
+				}
+				// path = network[0].address
+				// path = path.substring(0, path.length - 3);
+				path = _this.project.name
+				let baseUrl = `http://${network[0].ip}:${network[0].port}/${network[0].address}`
+				uni.request({
+					url: `${baseUrl}/login.action`,
+					data: {
+						username: 'super',
+						password: md5.hex_md5('xltys1995')
+					},
+					success(res) {
+						res = res.data
+						if (res.code === 200) {
+							_this.load.loading = true;
+							_this.load.btnText = '鐧诲綍涓�';
+							uni.setStorageSync('token', res.data.token);
+							_this.load.btnText = '鐧诲綍涓�';
+							setTimeout(() => {
+								uni.showToast({
+									title: '鐧诲綍鎴愬姛'
+								})
+								setTimeout(() => {
+									uni.reLaunch({
+										url: `/pages/home/home`,
+									});
+								}, 300)
+							}, 700)
+						}
+						// uni.navigateTo({
+						// 	url: `/pages/project/${path}/home/home`,
+						// 	fail(res) {
+						// 		console.log(`娌℃湁${path}椤圭洰,璇疯仈绯荤鐞嗗厓`);
+						// 	}
+							
+						// })
 					}
-					
 				})
 			}
 		}
@@ -130,28 +170,7 @@
 					inset -2px -2px 2px rgba(255,255,255,.7),
 					-2px -2px 2px rgba(0,0,0,.4);
 	}
-	.settings-input1 {
-		border: 1px solid #dcdfe6;
-		flex: 2;
-		margin: 2px;
-		padding: 4px;
-		border-radius: 4px;
-	}
-	.settings-input2 {
-		border: 1px solid #dcdfe6;
-		flex: 1;
-		margin: 2px;
-		padding: 4px;
-		border-radius: 4px;
-	}
-	.settings-input3 {
-		border: 1px solid #dcdfe6;
-		flex: 2;
-		margin: 2px;
-		padding: 4px;
-		border-radius: 4px;
-		
-	}
+	
 	.main {
 		height: 100%;
 		width: 100%;
@@ -212,6 +231,12 @@
 					inset -4px -4px 4px rgba(255,255,255,.4),
 					-4px -4px 5px rgba(0,0,0,.4);
 	}
+	.button:active {
+	    transform: translateY(5px) scale(0.99, 0.99);
+	    box-shadow: inset 4px 4px 4px rgba(0, 0, 0, .3),
+	        inset -4px -4px 8px rgba(255, 255, 255, .7),
+	        -5px -5px 5px rgba(0, 0, 0, .3);
+	}
 	@media screen and (orientation: portrait) {
 		/* 绔栧睆 */
 		.main {
@@ -269,5 +294,50 @@
 		align-items: center;
 		justify-content: center;
 		font-size: 24px;
+		color: #a8abb2;
+	}
+	.settings-input1 {
+		border: 1px solid #dcdfe6;
+		flex: 2;
+		margin: 2px;
+		padding: 4px;
+		border-radius: 4px;
+	}
+	.settings-input2 {
+		border: 1px solid #dcdfe6;
+		flex: 1;
+		margin: 2px;
+		padding: 4px;
+		border-radius: 4px;
+	}
+	.settings-input3 {
+		border: 1px solid #dcdfe6;
+		flex: 2;
+		margin: 2px;
+		padding: 4px;
+		border-radius: 4px;
+		
+	}
+	.operate {
+		height: 7vh;
+		display: flex;
+		text-align: center;
+		border-top: 1px solid #dcdfe6;
+		font-size: 16px;
+	}
+	.operate-cancel {
+		flex: 1;
+		display: flex;
+		align-items: center;
+		justify-content: center;
+		color: #606266;
+	}
+	.operate-confirm {
+		flex: 1;
+		display: flex;
+		align-items: center;
+		justify-content: center;
+		border-left: 1px solid #dcdfe6;
+		color: #00aeec;
 	}
 </style>
\ No newline at end of file

--
Gitblit v1.9.1