From 941156cdf84f2574d7eb0af8b253708441aead26 Mon Sep 17 00:00:00 2001 From: whycq <10027870+whycq@user.noreply.gitee.com> Date: 星期四, 08 十二月 2022 15:40:39 +0800 Subject: [PATCH] # --- pages/login/login.vue | 60 +++++++++++++++++++++++++++++++++++++++++++++++++----------- 1 files changed, 49 insertions(+), 11 deletions(-) diff --git a/pages/login/login.vue b/pages/login/login.vue index 628d129..1e2fad5 100644 --- a/pages/login/login.vue +++ b/pages/login/login.vue @@ -6,13 +6,13 @@ <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="璇疯緭鍏ヨ处鍙�!" + <input type="text" placeholder="璇疯緭鍏ヨ处鍙�!" v-model="user.userName" 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="password" placeholder="璇疯緭鍏ュ瘑鐮�!" + <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> @@ -20,7 +20,7 @@ </view> <!-- 鐧诲綍鎸夐挳 --> <view class="loging"> - <button class="button" @click="onLogin()" >鐧诲綍</button> + <button class="button" @click="onLogin()" :loading="load.loading">{{load.btnText}}</button> </view> <!-- #ifdef APP-PLUS --> <view class="version"> @@ -31,12 +31,20 @@ </template> <script> + import md5 from '../../common/md5.js' export default { data() { return { - version:'', - showPassword:false, - password:'', + version: '', + showPassword: false, + user: { + userName: '', + password: '', + }, + load: { + loading: false, + btnText: '鐧诲綍' + } } }, onLoad:function(){ @@ -46,17 +54,47 @@ that.version=wgtinfo.version }); // #endif - + let that = this + that.user.userName = uni.getStorageSync('userName') }, methods: { changePassword: function() { this.showPassword = !this.showPassword; }, onLogin() { - uni.reLaunch({ - url:"/pages/home/home", - animationType: 'pop-in', - animationDuration: 2000 + let that = this + uni.request({ + url: 'http://127.0.0.1:9528/login.action', + fail(result) { + uni.showToast({title: '璇锋眰澶辫触'}) + }, + data: { + username:that.user.userName, + password:md5.hex_md5(that.user.password) + }, + header: { + "content-type": "application/json" + }, + success(result) { + let res = result.data + if (res.code === 200 ){ + that.load.loading = true; + that.load.btnText = '鐧诲綍涓�'; + uni.setStorageSync('token', res.data.token); + uni.setStorageSync('userName', that.user.userName); + setTimeout(()=> { + uni.showToast({title: '鐧诲綍鎴愬姛'}) + setTimeout(()=> { + uni.reLaunch({ + url: '../index/index' + }); + },300) + },700) + } else { + uni.showToast({title: res.msg}) + } + }, + }) }, -- Gitblit v1.9.1