From 55f0be610b3adae8cc0d83e6d33ff71075f1b9de Mon Sep 17 00:00:00 2001 From: zjh <2207896513@qq.com> Date: 星期六, 09 八月 2025 11:15:01 +0800 Subject: [PATCH] 扫码优化 --- pages/BasePages/login.vue | 776 ++++++++++++++++++++++++++++++++--------------------------- 1 files changed, 416 insertions(+), 360 deletions(-) diff --git a/pages/BasePages/login.vue b/pages/BasePages/login.vue index d8306da..03a6745 100644 --- a/pages/BasePages/login.vue +++ b/pages/BasePages/login.vue @@ -1,144 +1,133 @@ <template> - <view class="login-page"> - <view class="login-content"> - <view class="logo-area"> - <image src="../../static/img/bj/gs.png" alt="骞挎繁绉戞妧" class="company-logo"></image> - - </view> - - <form class="login-form" @submit.prevent="handleSubmit"> - <view class="form-group"> - <text class="form-label">璐﹀彿</text> - <input - type="text" - id="username" - v-model="username" - placeholder="璇疯緭鍏ヨ处鍙�" - class="form-input" - autocapitalize="off" - autocomplete="username" - @keyup.enter="handleSubmit" - /> - </view> - - <view class="form-group"> - <text class="form-label">瀵嗙爜</text> - <input - :type="showPassword ? 'text' : 'password'" - id="password" - v-model="password" - placeholder="璇疯緭鍏ュ瘑鐮�" - class="form-input" - autocomplete="current-password" - @keyup.enter="handleSubmit" - /> - <view class="password-toggles"> - <text class="show-password" @tap="toggleShowPassword"> - {{ showPassword ? '闅愯棌瀵嗙爜' : '鏄剧ず瀵嗙爜' }} - </text> - </view> - </view> - - <button form-type="submit" class="login-button">鐧� 褰�</button> - </form> - - <view class="footer"> - <text>骞挎繁绉戞妧鎶�鏈敮鎸�</text> - <text class="version">鐗堟湰鍙� v1.0.1</text> - </view> - </view> - </view> + <view class="login-page"> + <view class="login-content"> + <view class="logo-area"> + <image src="../../static/img/bj/gs.png" alt="骞挎繁绉戞妧" class="company-logo"></image> + + </view> + + <form class="login-form" @submit.prevent="handleSubmit"> + <view class="form-group"> + <text class="form-label">璐﹀彿</text> + <input type="text" id="username" v-model="username" placeholder="璇疯緭鍏ヨ处鍙�" class="form-input" + autocapitalize="off" autocomplete="username" @keyup.enter="handleSubmit" /> + </view> + + <view class="form-group"> + <text class="form-label">瀵嗙爜</text> + <input :type="showPassword ? 'text' : 'password'" id="password" v-model="password" + placeholder="璇疯緭鍏ュ瘑鐮�" class="form-input" autocomplete="current-password" + @keyup.enter="handleSubmit" /> + <view class="password-toggles"> + <text class="show-password" @tap="toggleShowPassword"> + {{ showPassword ? '闅愯棌瀵嗙爜' : '鏄剧ず瀵嗙爜' }} + </text> + </view> + </view> + + <button form-type="submit" class="login-button">鐧� 褰�</button> + </form> + + <view class="footer"> + <text>骞挎繁绉戞妧鎶�鏈敮鎸�</text> + <text class="version">鐗堟湰鍙� {{version}}</text> + </view> + </view> + </view> </template> <script> -export default { - data() { - return { - username: '', - password: '', - showPassword: false, - accountFocus: false, - passwordFocus: false, - tokenId: '', - account: '', - factoryArray: [], - //selectFactory: { value: this.$loginInfo.factoryKey||'',text:this.$loginInfo.factoryName||'',index: this.$loginInfo.factoryIndex}, //閫夋嫨鐨勮处濂椾俊鎭� - selectFactory: {}, - selectLanguage: {}, //閫夋嫨鐨勮瑷� - } - }, - async onReady() { - this.account = this.$loginInfo.account || ''; - this.selectFactory = this.$loginInfo.factory || 0; - this.selectLanguage = this.$loginInfo.language || 0; - }, - methods: { - toggleShowPassword() { - this.showPassword = !this.showPassword; - }, - handleSubmit() { - // uni.showToast({ - // title: '鐧诲綍鍔熻兘浠呬负婕旂ず', - // icon: 'none' - // }); - // 瀹為檯鐧诲綍閫昏緫鍙互鍦ㄨ繖閲屽疄鐜� - // this.$request.post('/login', { - // username: this.username, - // password: this.password - // }).then(...) - console.log(this.username) - if (!this.username) { - uni.showToast({ - icon: 'none', - title: '璇疯緭鍏ヨ处鍙�' - }); - this.accountFocus = true; - return; - } - if (!this.password) { - uni.showToast({ - icon: 'none', - title: '璇疯緭鍏ュ瘑鐮�' - }); - this.passwordFocus = true; - return; - } - uni.showLoading({ - mask: true, - title: "鐧诲綍涓�..." - }); - uni.request({ - url: this.$store.state.serverInfo.serverAPI + '/login/login', - method: "POST", - header: { - 'content-type': "application/json" - }, - data: { - userID: this.username, - userPass: this.password - }, - success: res => { - if (res.data.status == 0) { - this.toMain(res.data.data.tbBillList[0]); - } else { - uni.showToast({ - icon: 'none', - title: res.data.message - }); - } - }, - fail(err) { - uni.showToast({ - icon: 'none', - title: "鏈嶅姟鍣ㄦ柇寮�" - }); - }, - complete: () => { - uni.hideLoading(); - } - }); - - }, + export default { + data() { + return { + username: '', + password: '', + showPassword: false, + accountFocus: false, + passwordFocus: false, + tokenId: '', + account: '', + factoryArray: [], + //selectFactory: { value: this.$loginInfo.factoryKey||'',text:this.$loginInfo.factoryName||'',index: this.$loginInfo.factoryIndex}, //閫夋嫨鐨勮处濂椾俊鎭� + selectFactory: {}, + selectLanguage: {}, //閫夋嫨鐨勮瑷� + version:'v'+uni.getSystemInfoSync().appVersion + + } + }, + async onReady() { + this.account = this.$loginInfo.account || ''; + this.selectFactory = this.$loginInfo.factory || 0; + this.selectLanguage = this.$loginInfo.language || 0; + }, + methods: { + toggleShowPassword() { + this.showPassword = !this.showPassword; + }, + handleSubmit() { + + // uni.showToast({ + // title: '鐧诲綍鍔熻兘浠呬负婕旂ず', + // icon: 'none' + // }); + // 瀹為檯鐧诲綍閫昏緫鍙互鍦ㄨ繖閲屽疄鐜� + // this.$request.post('/login', { + // username: this.username, + // password: this.password + // }).then(...) + + if (!this.username) { + uni.showToast({ + icon: 'none', + title: '璇疯緭鍏ヨ处鍙�' + }); + this.accountFocus = true; + return; + } + if (!this.password) { + uni.showToast({ + icon: 'none', + title: '璇疯緭鍏ュ瘑鐮�' + }); + this.passwordFocus = true; + return; + } + uni.showLoading({ + mask: true, + title: "鐧诲綍涓�..." + }); + uni.request({ + url: this.$store.state.serverInfo.serverAPI + '/login/login', + method: "POST", + header: { + 'content-type': "application/json" + }, + data: { + userID: this.username, + userPass: this.password + }, + success: res => { + if (res.data.status == 0) { + this.toMain(res.data.data.tbBillList[0]); + } else { + uni.showToast({ + icon: 'none', + title: res.data.message + }); + } + }, + fail(err) { + uni.showToast({ + icon: 'none', + title: "鏈嶅姟鍣ㄦ柇寮�" + }); + }, + complete: () => { + uni.hideLoading(); + } + }); + + }, toMain(user) { this.$loginInfo.account = user.fcode; this.$loginInfo.userName = user.fname; @@ -148,7 +137,22 @@ this.$loginInfo.deptNo = user.departmentid; this.$loginInfo.chineseName = user.fname; this.$loginInfo.id = user.fid; - this.$loginInfo.roleid=user.roleids; + this.$loginInfo.roleid = user.roleids; + + uni.setStorage({ + key: 'gs_mes_pad_userid', + data: this.username, + success: function() { + + } + }); + uni.setStorage({ + key: 'gs_mes_pad_userkey', + data: this.password, + success: function() { + + } + }); this.$login(); if (this.$loginInfo.forcedLogin) { uni.reLaunch({ @@ -158,246 +162,298 @@ uni.navigateBack(); } } - } -} + }, + onLoad(options) { + try { + const id = uni.getStorageSync('gs_mes_pad_userid'); + const pwd = uni.getStorageSync('gs_mes_pad_userkey'); + if(id){ + this.username=id; + } + if(pwd){ + this.password=pwd; + } + if (id&&pwd) { + + uni.showLoading({ + mask: true, + title: "鐧诲綍涓�..." + }); + uni.request({ + url: this.$store.state.serverInfo.serverAPI + '/login/login', + method: "POST", + header: { + 'content-type': "application/json" + }, + data: { + userID: id, + userPass: pwd + }, + success: res => { + if (res.data.status == 0) { + this.toMain(res.data.data.tbBillList[0]); + } else { + uni.showToast({ + icon: 'none', + title: res.data.message + }); + } + }, + fail(err) { + uni.showToast({ + icon: 'none', + title: "鏈嶅姟鍣ㄦ柇寮�" + }); + }, + complete: () => { + uni.hideLoading(); + } + }); + } + } catch (e) { + // error + } + } + } </script> <style> -/* 鍩虹鏍峰紡 */ -* { - margin: 0; - padding: 0; - box-sizing: border-box; - font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Microsoft YaHei', sans-serif; -} + /* 鍩虹鏍峰紡 */ + * { + margin: 0; + padding: 0; + box-sizing: border-box; + font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Microsoft YaHei', sans-serif; + } -.login-page { - width: 100%; - min-height: 96vh; - display: flex; - flex-direction: column; - background-color: #f5f7fa; -} + .login-page { + width: 100%; + min-height: 96vh; + display: flex; + flex-direction: column; + background-color: #f5f7fa; + } -.login-content { - width: 100%; - margin: 0 auto; - display: flex; - flex-direction: column; - justify-content: center; - flex-grow: 1; - padding: 20px; -} + .login-content { + width: 100%; + margin: 0 auto; + display: flex; + flex-direction: column; + justify-content: center; + flex-grow: 1; + padding: 20px; + } -/* 鏍囧織鍖哄煙 */ -.logo-area { - margin-bottom: 6vh; - text-align: center; -} + /* 鏍囧織鍖哄煙 */ + .logo-area { + margin-bottom: 6vh; + text-align: center; + } -.company-logo { - width: 25vw; - height: 25vw; - max-width: 100px; - max-height: 100px; - margin-bottom: 2vh; -} + .company-logo { + width: 25vw; + height: 25vw; + max-width: 100px; + max-height: 100px; + margin-bottom: 2vh; + } -.welcome-text { - color: #333; - font-size: 7vw; - font-weight: 500; - line-height: 1.3; -} + .welcome-text { + color: #333; + font-size: 7vw; + font-weight: 500; + line-height: 1.3; + } -/* 琛ㄥ崟鏍峰紡 */ -.login-form { - display: flex; - flex-direction: column; - gap: 4vh; - width: 100%; -} + /* 琛ㄥ崟鏍峰紡 */ + .login-form { + display: flex; + flex-direction: column; + gap: 4vh; + width: 100%; + } -.form-group { - text-align: left; - width: 100%; -} + .form-group { + text-align: left; + width: 100%; + } -.form-label { - display: block; - margin-bottom: 2vh; - font-size: 4.5vw; - color: #666; - font-weight: 500; -} + .form-label { + display: block; + margin-bottom: 2vh; + font-size: 4.5vw; + color: #666; + font-weight: 500; + } -.form-input { - width: 100%; - padding: 4.5vw; - border: 1px solid #e0e0e0; - border-radius: 2vw; - font-size: 4.8vw; - transition: all 0.3s; - -webkit-appearance: none; - background-color: white; - height: 12vw; - min-height: 50px; -} + .form-input { + width: 100%; + padding: 4.5vw; + border: 1px solid #e0e0e0; + border-radius: 2vw; + font-size: 4.8vw; + transition: all 0.3s; + -webkit-appearance: none; + background-color: white; + height: 12vw; + min-height: 50px; + } -.form-input:focus { - border-color: #3498db; - box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1); - outline: none; -} + .form-input:focus { + border-color: #3498db; + box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1); + outline: none; + } -/* 瀵嗙爜鐩稿叧鎺у埗 */ -.password-toggles { - display: flex; - justify-content: space-between; - margin-top: 2vh; - font-size: 4vw; -} + /* 瀵嗙爜鐩稿叧鎺у埗 */ + .password-toggles { + display: flex; + justify-content: space-between; + margin-top: 2vh; + font-size: 4vw; + } -.show-password { - color: #3498db; - padding: 1vw 0; -} + .show-password { + color: #3498db; + padding: 1vw 0; + } -/* 鐧诲綍鎸夐挳 */ -.login-button { - background-color: #3498db; - color: white; - border: none; - padding: 4.5vw; - border-radius: 2vw; - font-size: 5vw; - font-weight: 500; - transition: all 0.3s; - margin-top: 4vh; - width: 100%; - height: 12vw; - min-height: 50px; -} + /* 鐧诲綍鎸夐挳 */ + .login-button { + background-color: #3498db; + color: white; + border: none; + padding: 4.5vw; + border-radius: 2vw; + font-size: 5vw; + font-weight: 500; + transition: all 0.3s; + margin-top: 4vh; + width: 100%; + height: 12vw; + min-height: 50px; + } -.login-button:active { - background-color: #2980b9; -} + .login-button:active { + background-color: #2980b9; + } -/* 椤佃剼 */ -.footer { - margin-top: 6vh; - color: #999; - font-size: 3.8vw; - line-height: 1.5; - text-align: center; -} + /* 椤佃剼 */ + .footer { + margin-top: 6vh; + color: #999; + font-size: 3.8vw; + line-height: 1.5; + text-align: center; + } -.version { - margin-top: 1vh; - font-size: 3.5vw; - margin-left: 1vh; -} + .version { + margin-top: 1vh; + font-size: 3.5vw; + margin-left: 1vh; + } -/* 骞虫澘鍜屾闈㈡牱寮� */ -@media (min-width: 768px) { - .login-content { - max-width: 800px; - padding: 40px; - } - - .company-logo { - width: 80px; - height: 80px; - } - - .welcome-text { - font-size: 28px; - } - - .login-form { - gap: 25px; - } - - .form-label { - font-size: 16px; - margin-bottom: 12px; - } - - .form-input { - padding: 16px; - font-size: 16px; - height: auto; - border-radius: 8px; - } - - .password-toggles { - font-size: 14px; - } - - .login-button { - padding: 0px; - font-size: 18px; - border-radius: 8px; - height: auto; - } - - .footer { - font-size: 14px; - } - - .version { - font-size: 13px; - } -} -/* 鎵嬫満鏍峰紡 */ -@media (min-width: 300px) { - .login-content { - max-width: 800px; - padding: 40px; - } - - .company-logo { - width: 80px; - height: 80px; - } - - .welcome-text { - font-size: 28px; - } - - .login-form { - gap: 25px; - } - - .form-label { - font-size: 0px; - margin-bottom: 12px; - } - - .form-input { - padding: 16px; - font-size: 16px; - height: auto; - border-radius: 8px; - } - - .password-toggles { - font-size: 14px; - } - - .login-button { - padding: 0px; - font-size: 18px; - border-radius: 8px; - height: auto; - } - - .footer { - font-size: 14px; - } - - .version { - font-size: 13px; - } -} + /* 骞虫澘鍜屾闈㈡牱寮� */ + @media (min-width: 768px) { + .login-content { + max-width: 800px; + padding: 40px; + } + + .company-logo { + width: 80px; + height: 80px; + } + + .welcome-text { + font-size: 28px; + } + + .login-form { + gap: 25px; + } + + .form-label { + font-size: 16px; + margin-bottom: 12px; + } + + .form-input { + padding: 16px; + font-size: 16px; + height: auto; + border-radius: 8px; + } + + .password-toggles { + font-size: 14px; + } + + .login-button { + padding: 0px; + font-size: 18px; + border-radius: 8px; + height: auto; + } + + .footer { + font-size: 14px; + } + + .version { + font-size: 13px; + } + } + + /* 鎵嬫満鏍峰紡 */ + @media (min-width: 300px) { + .login-content { + max-width: 800px; + padding: 40px; + } + + .company-logo { + width: 80px; + height: 80px; + } + + .welcome-text { + font-size: 28px; + } + + .login-form { + gap: 25px; + } + + .form-label { + font-size: 0px; + margin-bottom: 12px; + } + + .form-input { + padding: 16px; + font-size: 16px; + height: auto; + border-radius: 8px; + } + + .password-toggles { + font-size: 14px; + } + + .login-button { + padding: 0px; + font-size: 18px; + border-radius: 8px; + height: auto; + } + + .footer { + font-size: 14px; + } + + .version { + font-size: 13px; + } + } </style> \ No newline at end of file -- Gitblit v1.9.3