From ae3855638dba0c927236c1a1b1a85d5b048c40e2 Mon Sep 17 00:00:00 2001 From: Houjie <714924425@qq.com> Date: 星期五, 18 四月 2025 10:31:08 +0800 Subject: [PATCH] 提交 --- pages/login/login.vue | 619 +++++++++++++++++++++++++++++-------------------------- 1 files changed, 328 insertions(+), 291 deletions(-) diff --git a/pages/login/login.vue b/pages/login/login.vue index 0a44541..4679f37 100644 --- a/pages/login/login.vue +++ b/pages/login/login.vue @@ -1,306 +1,343 @@ <template> - <view class="zai-box"> - <scroll-view scroll-y class="page"> - <view class="text-center" :style="[{animation: 'show ' + 0.4+ 's 1'}]"> - <image src="/static/logo-lx.png" mode='aspectFit' class="zai-logo "></image> - <view class="zai-title text-shadow ">璁惧绠$悊 </view> - </view> - <view class="box padding-lr-xl login-paddingtop" :style="[{animation: 'show ' + 0.6+ 's 1'}]"> - <block v-if="loginWay==1"> - <view class="cu-form-group margin-top shadow-warp" :class="[shape=='round'?'round':'']"> - <view class="title"><text class="cuIcon-people margin-right-xs"></text>璐﹀彿:</view> - <input placeholder="璇疯緭鍏ヨ处鍙�" name="input" v-model="userName"></input> - </view> - <view class="cu-form-group margin-top shadow-warp" :class="[shape=='round'?'round':'']"> - <view class="title"><text class="cuIcon-lock margin-right-xs"></text>瀵嗙爜:</view> - <input class="uni-input" placeholder="璇疯緭鍏ュ瘑鐮�" :password="!showPassword" v-model="password" /> - <view class="action text-lg"> - <text :class="[showPassword ? 'cuIcon-attention' : 'cuIcon-attentionforbid']" @click="changePassword"></text> - </view> - </view> - <view class="padding text-center margin-top"> - <button class="cu-btn bg-blue lg margin-right shadow" :loading="loading" :class="[shape=='round'?'round':'']" - @tap="onLogin"><text space="emsp">{{loading ? "鐧诲綍涓�...":" 鐧诲綍 "}}</text> - </button> - <!-- <button class="cu-btn line-blue lg margin-left shadow" :loading="loading" :class="[shape=='round'?'round':'']" + <view class="zai-box"> + <scroll-view scroll-y class="page"> + <view class="text-center" :style="[{animation: 'show ' + 0.4+ 's 1'}]"> + <image src="/static/logo-lx.png" mode='aspectFit' class="zai-logo "></image> + <view class="zai-title text-shadow ">璁惧绠$悊 </view> + </view> + <view class="box padding-lr-xl login-paddingtop" :style="[{animation: 'show ' + 0.6+ 's 1'}]"> + <block v-if="loginWay==1"> + <view class="cu-form-group margin-top shadow-warp" :class="[shape=='round'?'round':'']"> + <view class="title"><text class="cuIcon-people margin-right-xs"></text>璐﹀彿:</view> + <input placeholder="璇疯緭鍏ヨ处鍙�" name="input" v-model="userName"></input> + </view> + <view class="cu-form-group margin-top shadow-warp" :class="[shape=='round'?'round':'']"> + <view class="title"><text class="cuIcon-lock margin-right-xs"></text>瀵嗙爜:</view> + <input class="uni-input" placeholder="璇疯緭鍏ュ瘑鐮�" :password="!showPassword" v-model="password" /> + <view class="action text-lg"> + <text :class="[showPassword ? 'cuIcon-attention' : 'cuIcon-attentionforbid']" + @click="changePassword"></text> + </view> + </view> + <view class="padding text-center margin-top"> + <button class="cu-btn bg-blue lg margin-right shadow" :loading="loading" + :class="[shape=='round'?'round':'']" @tap="onLogin"><text + space="emsp">{{loading ? "鐧诲綍涓�...":" 鐧诲綍 "}}</text> + </button> + <!-- <button class="cu-btn line-blue lg margin-left shadow" :loading="loading" :class="[shape=='round'?'round':'']" @tap="loginWay=3-loginWay">鐭俊鐧诲綍 </button> --> - </view> - </block> - <block v-else> - <view class="cu-form-group margin-top shadow-warp" :class="[shape=='round'?'round':'']"> - <view class="title"><text class="cuIcon-mobile margin-right-xs"></text>鎵嬫満鍙�:</view> - <input placeholder="璇疯緭鍏ユ墜鏈哄彿" type="number" maxlength="11" v-model="phoneNo"></input> - </view> - <view class="cu-form-group margin-top shadow-warp" :class="[shape=='round'?'round':'']"> - <view class="title"><text class="cuIcon-lock margin-right-xs"></text>楠岃瘉鐮�:</view> - <input class="uni-input" placeholder="璇疯緭鍏ラ獙璇佺爜" v-model="smsCode"/> - <view class="action"> - <button class="cu-btn line-blue sm" :disabled="!isSendSMSEnable" @click="onSMSSend"> {{ getSendBtnText }}</button> - </view> - </view> - <view class="padding text-center margin-top"> - <button class="cu-btn bg-blue lg margin-right shadow" :loading="loading" :class="[shape=='round'?'round':'']" - @tap="onSMSLogin"><text space="emsp">{{loading ? "鐧诲綍涓�...":" 鐧诲綍 "}}</text> - </button> - <button class="cu-btn line-blue lg margin-left shadow" :loading="loading" :class="[shape=='round'?'round':'']" - @tap="loginWay=1">璐︽埛鐧诲綍 - </button> - </view> - </block> - - - <!-- #ifdef APP-PLUS --> - <view class="padding flex flex-direction text-center"> - 褰撳墠鐗堟湰:{{version}} - </view> - <!-- #endif --> - - </view> - </scroll-view> - <!-- 鐧诲綍鍔犺浇寮圭獥 --> - <view class="cu-load load-modal" v-if="loading"> - <!-- <view class="cuIcon-emojifill text-orange"></view> --> - <image src="/static/logo-lx.png" mode="aspectFit" class="round"></image> - <view class="gray-text">鐧诲綍涓�...</view> - </view> - </view> + </view> + </block> + <block v-else> + <view class="cu-form-group margin-top shadow-warp" :class="[shape=='round'?'round':'']"> + <view class="title"><text class="cuIcon-mobile margin-right-xs"></text>鎵嬫満鍙�:</view> + <input placeholder="璇疯緭鍏ユ墜鏈哄彿" type="number" maxlength="11" v-model="phoneNo"></input> + </view> + <view class="cu-form-group margin-top shadow-warp" :class="[shape=='round'?'round':'']"> + <view class="title"><text class="cuIcon-lock margin-right-xs"></text>楠岃瘉鐮�:</view> + <input class="uni-input" placeholder="璇疯緭鍏ラ獙璇佺爜" v-model="smsCode" /> + <view class="action"> + <button class="cu-btn line-blue sm" :disabled="!isSendSMSEnable" @click="onSMSSend"> + {{ getSendBtnText }}</button> + </view> + </view> + <view class="padding text-center margin-top"> + <button class="cu-btn bg-blue lg margin-right shadow" :loading="loading" + :class="[shape=='round'?'round':'']" @tap="onSMSLogin"><text + space="emsp">{{loading ? "鐧诲綍涓�...":" 鐧诲綍 "}}</text> + </button> + <button class="cu-btn line-blue lg margin-left shadow" :loading="loading" + :class="[shape=='round'?'round':'']" @tap="loginWay=1">璐︽埛鐧诲綍 + </button> + </view> + </block> -</template> -<script> - import { ACCESS_TOKEN,USER_NAME,USER_INFO } from "@/common/util/constants" - import { mapActions } from "vuex" - import configService from '@/common/service/config.service.js'; - - export default { - data() { - return { - shape:'',//round 鍦嗗舰 - loading: false, - userName: 'admin', - password: '123456', - phoneNo: '', - smsCode: '', - showPassword: false, //鏄惁鏄剧ず鏄庢枃 - loginWay: 1, //1: 璐﹀瘑锛�2锛氶獙璇佺爜 - smsCountDown: 0, - smsCountInterval: null, - toggleDelay: false, - version:'', - //绗笁鏂圭櫥褰曠浉鍏充俊鎭� - thirdType:"", - thirdLoginInfo:"", - thirdLoginState:false, - bindingPhoneModal:false, - thirdUserUuid:'', - url: { - bindingThirdPhone: '/sys/thirdLogin/bindingThirdPhone' - } - }; - }, - onLoad:function(){ - // #ifdef APP-PLUS - var that=this - plus.runtime.getProperty( plus.runtime.appid, function ( wgtinfo ) { - that.version=wgtinfo.version - }); - // #endif - }, - computed: { - isSendSMSEnable() { - return this.smsCountDown <= 0 && this.phoneNo.length > 4; - }, - getSendBtnText() { - if (this.smsCountDown > 0) { - return this.smsCountDown + '绉掑悗鍙戦��'; - } else { - return '鍙戦�侀獙璇佺爜'; - } - }, - canSMSLogin() { - return this.userName.length > 4 && this.smsCode.length > 4; - }, - canPwdLogin() { - return this.userName.length > 4 && this.password.length > 4; - }, - }, - methods: { - ...mapActions([ "mLogin","PhoneLogin","ThirdLogin" ]), - onLogin: function (){ - if(!this.userName || this.userName.length==0){ - this.$tip.toast('璇峰~鍐欑敤鎴峰悕'); - return; - } - if(!this.password || this.password.length==0){ - this.$tip.toast('璇峰~鍐欏瘑鐮�'); - return; - } - let loginParams = { - username:this.userName, - password:this.password - } - this.loading=true; - this.mLogin(loginParams).then((res) => { - this.loading=false; - if(res.data.success){ - // #ifdef APP-PLUS - this.saveClientId() - // #endif - // #ifndef APP-PLUS - this.$tip.success('鐧诲綍鎴愬姛!') - this.$Router.replaceAll({name:'index'}) - // #endif - }else{ - this.$tip.alert(res.data.message); - } - }).catch((err) => { - let msg = err.data.message || "璇锋眰鍑虹幇閿欒锛岃绋嶅悗鍐嶈瘯" - this.loading=false; - this.$tip.alert(msg); - }).finally(()=>{ - this.loading=false; - }) - }, - saveClientId(){ - var info = plus.push.getClientInfo(); - var cid = info.clientid; - this.$http.get("/sys/user/saveClientId",{params:{clientId:cid}}).then(res=>{ - console.log("res::saveClientId>",res) - this.$tip.success('鐧诲綍鎴愬姛!') - this.$Router.replaceAll({name:'index'}) - }) - }, - changePassword() { - this.showPassword = !this.showPassword; - }, - onSMSSend() { - let smsParams = {}; - smsParams.mobile=this.phoneNo; - smsParams.smsmode="0"; - let checkPhone = new RegExp(/^[1]([3-9])[0-9]{9}$/); - if(!smsParams.mobile || smsParams.mobile.length==0){ - this.$tip.toast('璇疯緭鍏ユ墜鏈哄彿'); - return false - } - if(!checkPhone.test(smsParams.mobile)){ - this.$tip.toast('璇疯緭鍏ユ纭殑鎵嬫満鍙�'); - return false - } - this.$http.post("/sys/sms",smsParams).then(res=>{ - if(res.data.success){ - this.smsCountDown = 60; - this.startSMSTimer(); - }else{ - this.smsCountDown = 0; - this.$tip.toast(res.data.message); - } - }); - }, - startSMSTimer() { - this.smsCountInterval = setInterval(() => { - this.smsCountDown--; - if (this.smsCountDown <= 0) { - clearInterval(this.smsCountInterval); - } - }, 1000); - }, - onSMSLogin() { - let checkPhone = new RegExp(/^[1]([3-9])[0-9]{9}$/); - - if(!this.phoneNo || this.phoneNo.length==0){ - this.$tip.toast('璇峰~鍐欐墜鏈哄彿'); - return; - } - if(!checkPhone.test(this.phoneNo)){ - this.$tip.toast('璇疯緭鍏ユ纭殑鎵嬫満鍙�'); - return false - } - if(!this.smsCode || this.smsCode.length==0){ - this.$tip.toast('璇峰~鐭俊楠岃瘉鐮�'); - return; - } - let loginParams = { - mobile:this.phoneNo, - captcha:this.smsCode - }; - this.PhoneLogin(loginParams).then((res) => { - console.log("res====銆�",res) - if(res.data.success){ - this.$tip.success('鐧诲綍鎴愬姛!') - this.$Router.replaceAll({name:'index'}) - }else{ - this.$tip.error(res.data.message); - } - }).catch((err) => { - let msg = ((err.response || {}).data || {}).message || err.data.message || "璇锋眰鍑虹幇閿欒锛岃绋嶅悗鍐嶈瘯" - this.$tip.error(msg); - }); - }, - loginSuccess() { - // 鐧婚檰鎴愬姛锛岄噸瀹氬悜鍒颁富椤� - this.$Router.replace({name:'index'}) - }, - requestFailed(err) { - this.$message.warning("鐧诲綍澶辫触") - }, - }, - beforeDestroy() { - if (this.smsCountInterval) { - clearInterval(this.smsCountInterval); - } - }, - } -</script> + <!-- #ifdef APP-PLUS --> + <view class="padding flex flex-direction text-center"> + 褰撳墠鐗堟湰:{{version}} + </view> + <!-- #endif --> -<style> - .login-paddingtop { - padding-top: 100upx; - } + </view> + </scroll-view> + <!-- 鐧诲綍鍔犺浇寮圭獥 --> + <view class="cu-load load-modal" v-if="loading"> + <!-- <view class="cuIcon-emojifill text-orange"></view> --> + <image src="/static/logo-lx.png" mode="aspectFit" class="round"></image> + <view class="gray-text">鐧诲綍涓�...</view> + </view> + </view> - .zai-box { - padding: 0 20upx; - padding-top: 100upx; - position: relative; - } + </template> - .zai-logo { - width: 200upx; - height: 150px; - } + <script> + import { + ACCESS_TOKEN, + USER_NAME, + USER_INFO + } from "@/common/util/constants" + import { + mapActions + } from "vuex" + import configService from '@/common/service/config.service.js'; - .zai-title { - font-size: 58upx; - color: #000000; - text-align: center; - } + export default { + data() { + return { + shape: '', //round 鍦嗗舰 + loading: false, + userName: 'admin', + password: '123456', + phoneNo: '', + smsCode: '', + showPassword: false, //鏄惁鏄剧ず鏄庢枃 + loginWay: 1, //1: 璐﹀瘑锛�2锛氶獙璇佺爜 + smsCountDown: 0, + smsCountInterval: null, + toggleDelay: false, + version: '', + //绗笁鏂圭櫥褰曠浉鍏充俊鎭� + thirdType: "", + thirdLoginInfo: "", + thirdLoginState: false, + bindingPhoneModal: false, + thirdUserUuid: '', + id: '', + url: { + bindingThirdPhone: '/sys/thirdLogin/bindingThirdPhone' + } + }; + }, + onLoad: function(options) { + this.id = options.id; + // #ifdef APP-PLUS + var that = this + plus.runtime.getProperty(plus.runtime.appid, function(wgtinfo) { + that.version = wgtinfo.version + }); + // #endif + }, + computed: { + isSendSMSEnable() { + return this.smsCountDown <= 0 && this.phoneNo.length > 4; + }, + getSendBtnText() { + if (this.smsCountDown > 0) { + return this.smsCountDown + '绉掑悗鍙戦��'; + } else { + return '鍙戦�侀獙璇佺爜'; + } + }, + canSMSLogin() { + return this.userName.length > 4 && this.smsCode.length > 4; + }, + canPwdLogin() { + return this.userName.length > 4 && this.password.length > 4; + }, + }, + methods: { + ...mapActions(["mLogin", "PhoneLogin", "ThirdLogin"]), + onLogin: function() { + if (!this.userName || this.userName.length == 0) { + this.$tip.toast('璇峰~鍐欑敤鎴峰悕'); + return; + } + if (!this.password || this.password.length == 0) { + this.$tip.toast('璇峰~鍐欏瘑鐮�'); + return; + } + let loginParams = { + username: this.userName, + password: this.password + } + this.loading = true; + this.mLogin(loginParams).then((res) => { + this.loading = false; + if (res.data.success) { + // #ifdef APP-PLUS + this.saveClientId() + // #endif + // #ifndef APP-PLUS + this.$tip.success('鐧诲綍鎴愬姛!') + this.$Router.replaceAll({ + name: 'index' + }) + // if (this.id) { + // uni.navigateTo({ + // url: `/pages/device/deviceWebDeils/deviceWebDeils?equipmentId=${this.id}` + // }); - .input-placeholder, .zai-input { - color: #94afce; - } + // } else { + // this.$tip.success('鐧诲綍鎴愬姛!') + // this.$Router.replaceAll({ + // name: 'index' + // }) + // } - .zai-label { - padding: 60upx 0; - text-align: center; - font-size: 30upx; - color: #a7b6d0; - } - .zai-btn { - background: #ff65a3; - color: #fff; - border: 0; - border-radius: 100upx; - font-size: 36upx; - } + // #endif + } else { + this.$tip.alert(res.data.message); + } + }).catch((err) => { + let msg = err.data.message || "璇锋眰鍑虹幇閿欒锛岃绋嶅悗鍐嶈瘯" + this.loading = false; + this.$tip.alert(msg); + }).finally(() => { + this.loading = false; + }) + }, + saveClientId() { + var info = plus.push.getClientInfo(); + var cid = info.clientid; + this.$http.get("/sys/user/saveClientId", { + params: { + clientId: cid + } + }).then(res => { + console.log("res::saveClientId>", res) + this.$tip.success('鐧诲綍鎴愬姛!') + this.$Router.replaceAll({ + name: 'index' + }) + }) + }, + changePassword() { + this.showPassword = !this.showPassword; + }, + onSMSSend() { + let smsParams = {}; + smsParams.mobile = this.phoneNo; + smsParams.smsmode = "0"; + let checkPhone = new RegExp(/^[1]([3-9])[0-9]{9}$/); + if (!smsParams.mobile || smsParams.mobile.length == 0) { + this.$tip.toast('璇疯緭鍏ユ墜鏈哄彿'); + return false + } + if (!checkPhone.test(smsParams.mobile)) { + this.$tip.toast('璇疯緭鍏ユ纭殑鎵嬫満鍙�'); + return false + } + this.$http.post("/sys/sms", smsParams).then(res => { + if (res.data.success) { + this.smsCountDown = 60; + this.startSMSTimer(); + } else { + this.smsCountDown = 0; + this.$tip.toast(res.data.message); + } + }); + }, + startSMSTimer() { + this.smsCountInterval = setInterval(() => { + this.smsCountDown--; + if (this.smsCountDown <= 0) { + clearInterval(this.smsCountInterval); + } + }, 1000); + }, + onSMSLogin() { + let checkPhone = new RegExp(/^[1]([3-9])[0-9]{9}$/); - .zai-btn:after { - border: 0; - } + if (!this.phoneNo || this.phoneNo.length == 0) { + this.$tip.toast('璇峰~鍐欐墜鏈哄彿'); + return; + } + if (!checkPhone.test(this.phoneNo)) { + this.$tip.toast('璇疯緭鍏ユ纭殑鎵嬫満鍙�'); + return false + } + if (!this.smsCode || this.smsCode.length == 0) { + this.$tip.toast('璇峰~鐭俊楠岃瘉鐮�'); + return; + } + let loginParams = { + mobile: this.phoneNo, + captcha: this.smsCode + }; + this.PhoneLogin(loginParams).then((res) => { + console.log("res====銆�", res) + if (res.data.success) { + this.$tip.success('鐧诲綍鎴愬姛!') + this.$Router.replaceAll({ + name: 'index' + }) + } else { + this.$tip.error(res.data.message); + } + }).catch((err) => { + let msg = ((err.response || {}).data || {}).message || err.data.message || "璇锋眰鍑虹幇閿欒锛岃绋嶅悗鍐嶈瘯" + this.$tip.error(msg); + }); + }, + loginSuccess() { + // 鐧婚檰鎴愬姛锛岄噸瀹氬悜鍒颁富椤� + this.$Router.replace({ + name: 'index' + }) + }, + requestFailed(err) { + this.$message.warning("鐧诲綍澶辫触") + }, + }, + beforeDestroy() { + if (this.smsCountInterval) { + clearInterval(this.smsCountInterval); + } + }, + } + </script> - /*鎸夐挳鐐瑰嚮鏁堟灉*/ - .zai-btn.button-hover { - transform: translate(1upx, 1upx); - } + <style> + .login-paddingtop { + padding-top: 100upx; + } -</style> + .zai-box { + padding: 0 20upx; + padding-top: 100upx; + position: relative; + } + + .zai-logo { + width: 200upx; + height: 150px; + } + + .zai-title { + font-size: 58upx; + color: #000000; + text-align: center; + } + + .input-placeholder, + .zai-input { + color: #94afce; + } + + .zai-label { + padding: 60upx 0; + text-align: center; + font-size: 30upx; + color: #a7b6d0; + } + + .zai-btn { + background: #ff65a3; + color: #fff; + border: 0; + border-radius: 100upx; + font-size: 36upx; + } + + .zai-btn:after { + border: 0; + } + + /*鎸夐挳鐐瑰嚮鏁堟灉*/ + .zai-btn.button-hover { + transform: translate(1upx, 1upx); + } + </style> \ No newline at end of file -- Gitblit v1.9.3