Browse Source

登录

娄底高职分支
yxq 2 weeks ago
parent
commit
3a7daf850f
2 changed files with 113 additions and 49 deletions
  1. +5
    -1
      Learun.Framework.Ultimate V7/LearunApp-2.2.0/components/learun-mpui/learun-ui-mp/input.vue
  2. +108
    -48
      Learun.Framework.Ultimate V7/LearunApp-2.2.0/pages/login.vue

+ 5
- 1
Learun.Framework.Ultimate V7/LearunApp-2.2.0/components/learun-mpui/learun-ui-mp/input.vue View File

@@ -6,6 +6,7 @@
</view> </view>
<input <input
@input="input" @input="input"
@blur="blur"
:value="value" :value="value"
:type="type" :type="type"
:disabled="disabled" :disabled="disabled"
@@ -38,7 +39,10 @@ export default {
input(e) { input(e) {
this.$emit('input', e.detail.value) this.$emit('input', e.detail.value)
this.$emit('change', e.detail.value) this.$emit('change', e.detail.value)
}
},
blur(e) {
this.$emit('blur', e.detail.value)
}
}, },


computed: { computed: {


+ 108
- 48
Learun.Framework.Ultimate V7/LearunApp-2.2.0/pages/login.vue View File

@@ -27,24 +27,31 @@
</view> </view>


<!-- 账户密码表单 --> <!-- 账户密码表单 -->
<l-input v-if="ready&&!isCode" v-model="username" placeholder="账号" left>
<l-input v-if="ready" v-model="username" @blur="getNeedCode" placeholder="账号" left>
<l-icon slot="title" type="people" /> <l-icon slot="title" type="people" />
</l-input> </l-input>
<l-input v-if="ready&&!isCode" v-model="password" placeholder="请输入密码" password left>
<l-input v-if="ready" v-model="password" placeholder="请输入密码" password left>
<l-icon slot="title" type="lock" /> <l-icon slot="title" type="lock" />
</l-input> </l-input>
<l-input v-model="verifycode" v-if="isCode" placeholder="请输入验证码" left>
<l-input v-model="verifycode" v-if="needCode" placeholder="请输入验证码" left password>
<l-icon slot="title" type="lock" /> <l-icon slot="title" type="lock" />
<template #suffix>
<view style="margin-top: 4px;color: #606266;">
<text :style="{color:time==0?'#409EFF':'#999'}" @click="time==0&&sendCode()">{{hasSendCode?'重新发送':'发送验证码'}}</text>
{{time?'('+time+ 's'+')' :''}}
</view>
</template>
</l-input> </l-input>
<view v-if="isCode" :class="{codeSend:true,ok:time == ''}" style="margin-bottom: 12px;">
未收到验证码?<text class="sendbtn" @click="()=>{isCode=false;if(!time)login(null)}">重新发送</text>
<!-- <l-input v-model="verifycode" v-if="needCode" placeholder="请输入验证码" left>
<l-icon slot="title" type="lock" />
</l-input>
<view v-if="needCode" :class="{codeSend:true,ok:time == ''}" style="margin-bottom: 12px;">
未收到验证码?<text class="sendbtn" @click="()=>{needCode=false;if(!time)login(null)}">重新发送</text>
{{time?'( '+time+ 's'+' )' :''}} {{time?'( '+time+ 's'+' )' :''}}
</view>
</view> -->
<l-button @click="login(null)" size="lg" color="blue" class="margin-top-sm block" block>登 录</l-button> <l-button @click="login(null)" size="lg" color="blue" class="margin-top-sm block" block>登 录</l-button>
<l-button v-if="isCode" @click="toLogin()" size="lg" color="white" class="margin-top-sm block"
block>重新登录</l-button>
<!-- #ifndef APP-PLUS --> <!-- #ifndef APP-PLUS -->
<view class="otherLogin" v-if="!isCode">
<view class="otherLogin">
<navigator url="/pages/forgotPassword">忘记密码?</text></navigator> <navigator url="/pages/forgotPassword">忘记密码?</text></navigator>
<navigator url="/pages/weixinLogin">微信登录</text></navigator> <navigator url="/pages/weixinLogin">微信登录</text></navigator>
</view> </view>
@@ -55,7 +62,7 @@


<!-- 【仅小程序】一键登录按钮 --> <!-- 【仅小程序】一键登录按钮 -->
<!-- #ifdef MP --> <!-- #ifdef MP -->
<l-button v-if="MPLogin&&!isCode" @click="login(PLATFORM)" size="lg" line="green"
<l-button v-if="MPLogin" @click="login(PLATFORM)" size="lg" line="green"
class="margin-top-sm block" block> class="margin-top-sm block" block>
{{ PLATFORM_TEXT }}一键登录 {{ PLATFORM_TEXT }}一键登录
</l-button> </l-button>
@@ -96,7 +103,8 @@
resData: {}, resData: {},
loginResult:{}, loginResult:{},
logininfo:{}, logininfo:{},
isCode: false,
needCode: false,
hasSendCode:false,
mobile: '', mobile: '',
verifycode: '', verifycode: '',
time: 0, time: 0,
@@ -188,10 +196,10 @@
if (!await this.checkupdate()) if (!await this.checkupdate())
return; return;
// #endif // #endif
if (this.isCode) {
this.checkverifycode()
return
}
// if (this.needCode) {
// this.checkverifycode()
// return
// }
const { const {
username, username,
password, password,
@@ -202,6 +210,10 @@
if (!type && !check()) { if (!type && !check()) {
return return
} }
if (this.needCode&&!this.verifycode) {
this.TOAST('请输入验证码');
return
}
this.LOADING('登录中…') this.LOADING('登录中…')


// 根据不同的登录方式,调用 API // 根据不同的登录方式,调用 API
@@ -218,9 +230,16 @@
let postResult = await this.POST('learun/adms/user/login', { let postResult = await this.POST('learun/adms/user/login', {
username, username,
password: this.MD5(password), password: this.MD5(password),
up: up
up: up,
verifycode:this.verifycode||undefined
}) })
if (postResult[1].data.code == '200') { if (postResult[1].data.code == '200') {
if(postResult[1].data.data.sendresult){
// this.TOAST(postResult[1].data.data.msg);
this.HIDE_LOADING()
this.needCode = true
return
}
loginResult = postResult[1].data.data; loginResult = postResult[1].data.data;
this.loginResult = loginResult this.loginResult = loginResult
var logininfo = { var logininfo = {
@@ -231,6 +250,7 @@
this.logininfo = logininfo this.logininfo = logininfo
this.username = "" this.username = ""
this.password = "" this.password = ""
this.verifycode = ""
} else { } else {
this.TOAST(postResult[1].data.info); this.TOAST(postResult[1].data.info);
@@ -280,28 +300,59 @@
user user
} }
this.HIDE_LOADING() this.HIDE_LOADING()
// 如果没发短信直接登录
if(!this.loginResult.sendresult){
this.checkverifycode(false)
return
this.SET_GLOBAL('token', this.resData.token)
this.SET_GLOBAL('loginUser', this.resData.user)
this.SET_STORAGE("logintime", this.resData.user.logTime);
this.SET_STORAGE('token', this.resData.token)
this.SET_STORAGE('logininfo', this.logininfo);
this.SET_STORAGE('userinfo', this.loginResult.baseinfo);
this.HIDE_LOADING()
// 密码强度校验
if (this.loginResult.pwd === true) {
this.SET_STORAGE('pwd', true);
this.TOAST("您的密码不满足强度要求,请您先修改密码后再执行系统其他操作");
setTimeout(()=>{
this.NAV_TO('/pages/my/newpassword')
},1000)
return;
} else {
this.SET_STORAGE('pwd', false);
this.TAB_TO('/pages/home')
} }
// 发了短信 进入输入验证码页面
this.mobile = baseinfo.mobile
this.isCode = true
this.TOAST('已发送短信,请输入验证码');

this.time = 60
this.timeT = setInterval(() => {
this.time--
if (this.time == 0) {
clearInterval(this.timeT)
this.timeT = ''
// // 如果没发短信直接登录
// if(!this.loginResult.sendresult){
// this.checkverifycode(false)
// return
// }
// // 发了短信 进入输入验证码页面
// this.mobile = baseinfo.mobile
// this.needCode = true
// this.TOAST('已发送短信,请输入验证码');

// this.time = 60
// this.timeT = setInterval(() => {
// this.time--
// if (this.time == 0) {
// clearInterval(this.timeT)
// this.timeT = ''
// return
// }
// }, 1000);
},
// 获取是否需要验证码
getNeedCode(){
this.POST('learun/adms/user/loginverify',{account:this.username}).then(res=>{
if (res[1].data.code != '200') {
this.TOAST(res[1].data.info);
return return
} }
}, 1000);
if(res[1].data.data.sendresult){
this.needCode = true
}
})
}, },

// 验证用户输入 // 验证用户输入
check() { check() {
const { const {
@@ -315,7 +366,28 @@


return true return true
}, },

// 发送验证码
sendCode(){
this.LOADING()
this.HTTP_POST('learun/adms/user/sendmsg',{account:this.username}).then(res=>{
this.HIDE_LOADING()
if(!res){
return
}
this.TOAST(res.msg);
if(!res.sendstate)return
this.hasSendCode = true
this.time = 60
this.timeT = setInterval(() => {
this.time--
if (this.time == 0) {
clearInterval(this.timeT)
this.timeT = ''
return
}
}, 1000);
})
},
// 验证码校验 // 验证码校验
async checkverifycode(needCheck=true) { async checkverifycode(needCheck=true) {
if(needCheck){ if(needCheck){
@@ -369,7 +441,7 @@
this.mobile = '' this.mobile = ''
this.verifycode = '' this.verifycode = ''
this.timeT && clearInterval(this.timeT) this.timeT && clearInterval(this.timeT)
this.isCode = false
this.needCode = false
}, },
}, },


@@ -483,17 +555,5 @@
bottom: 10px; bottom: 10px;
/* #endif */ /* #endif */
} }

.codeSend {
color: #999;
}

.codeSend.ok {
color: #666;
}

.codeSend.ok .sendbtn {
color: #409EFF;
}
} }
</style> </style>

Loading…
Cancel
Save