LFPay app项目
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

223 lines
5.5 KiB

<template>
<view class="normal-login-container container-with-elep full-height-with-titile">
<view style="background-color: white; margin-top: 0; border-radius: 20px; padding: 20px;">
<view class="login-form-content">
<view class="input-item flex align-center" style="margin: 0px;">
<view class="iconfont icon-code icon"></view>
<input cursor-spacing="15" v-model="loginForm.phone" type="text" class="input" :placeholder="$languageData.log.phonePh" maxlength="20" />
</view>
<view class="input-item flex align-center" style="width: 60%;margin: 0px; margin-top: 20px;">
<view class="iconfont icon-code icon"></view>
<input v-model="loginForm.verCode" cursor-spacing="15" type="number" class="input" :placeholder="$languageData.log.codePh" maxlength="4" />
<view class="login-code">
<u-button @click="sendCode" class="login-code-img" color="#144F9B" :text="count < 1 ? $languageData.log.sendCode : count + 's'"></u-button>
</view>
</view>
<view class="input-item flex align-center">
<view class="iconfont icon-password icon"></view>
<input cursor-spacing="15" v-model="loginForm.password" type="password" class="input" :placeholder="$languageData.password.setPayPwd"
maxlength="6" />
</view>
<view class="input-item flex align-center">
<view class="iconfont icon-password icon"></view>
<input cursor-spacing="15" v-model="loginForm.rePasswd" class="input" type="password" :placeholder="$languageData.log.pwdRepPh" maxlength="6" />
</view>
<view class="action-btn">
<button @click="handleLogin" style="background-color: #FDBE44; color: #322C20;" class="login-btn cu-btn block bg-blue lg round">{{$languageData.overview.submit}}</button>
</view>
</view>
</view>
</view>
</template>
<script>
import {
getCodeImg
} from '@/api/login'
export default {
data() {
return {
timer: null,
count: 0,
languageData: null,
codeUrl: "",
captchaEnabled: true,
// 用户注册开关
register: true,
globalConfig: getApp().globalData.config,
loginForm: {
phone:'',
username: "",
password: "",
// username: "",
// password: "",
code: "",
uuid: ''
}
}
},
created() {
// alert(uni.getLocale())
this.getCode()
this.languageData = this.$languageData;
},
methods: {
sendCode(){
if(this.count > 0)
return;
this.count = 60;
this.timer = setInterval(()=>{
// setTimeout(()=>{
// this.count-=1;
// },1000)
this.count-=1;
if(this.count < 1) clearInterval(this.timer)
}, 1000)
},
// 获取图形验证码
getCode() {
getCodeImg().then(res => {
this.captchaEnabled = res.data.captchaEnabled === undefined ? true : res.data.captchaEnabled
if (this.captchaEnabled) {
this.codeUrl = 'data:image/gif;base64,' + res.data.img
this.loginForm.uuid = res.data.uuid
}
})
},
// 登录方法
async handleLogin() {
let flag = true;
if (this.loginForm.phone === "") {
this.$modal.msgError(this.languageData.log.usernamePh)
flag = false
} else if (this.loginForm.verCode === "") {
this.$modal.msgError(this.languageData.log.codePh)
flag = false
} else if (this.loginForm.password === "") {
this.$modal.msgError(this.languageData.log.passwordPh)
flag = false
} else if (this.loginForm.rePasswd === ""){
this.$modal.msgError(this.languageData.log.pwdRepPh)
flag = false
}
if(this.loginForm.rePasswd.length !== 6 || this.loginForm.password.length!==6){
this.$modal.msgError(this.languageData.password.pwdConstitute)
flag = false
}
if(this.loginForm.rePasswd !== this.loginForm.password){
this.$modal.msgError(this.languageData.password.errSame)
flag = false
}
if(flag) {
this.$modal.msg(this.languageData.log.verCodeErr);
//TODO
return;
this.$modal.loading(this.languageData.log.loginWait)
this.pwdLogin()
}
},
// 密码登录
async pwdLogin() {
this.$store.dispatch('Login', this.loginForm).then(() => {
this.$modal.closeLoading()
this.loginSuccess()
}).catch(() => {
if (this.captchaEnabled) {
this.getCode()
}
})
},
// 登录成功后,处理函数
loginSuccess(result) {
// 设置用户信息
this.$store.dispatch('GetInfo').then(res => {
this.$tab.reLaunch('/pages/home/index')
})
}
}
}
</script>
<style lang="scss">
page {
background-color: #ffffff;
}
.normal-login-container {
width: 100%;
.logo-content {
width: 100%;
font-size: 21px;
padding-top: 5%;
display: flex;
flex-direction: column;
justify-content: left;
image {
align-self: center;
border-radius: 4px;
}
.title {
text-align: center;
// margin-left: 2em;
}
}
.login-form-content {
text-align: center;
margin: 0px auto;
margin-top: 5%;
width: 80%;
.input-item {
margin: 20px auto;
background-color: #f5f6f7;
height: 45px;
border-radius: 20px;
.icon {
font-size: 38rpx;
margin-left: 10px;
color: #999;
}
.input {
width: 100%;
font-size: 14px;
line-height: 20px;
text-align: left;
padding-left: 15px;
}
}
.login-btn {
margin-top: 40px;
height: 45px;
}
.reg {
margin-top: 15px;
}
.xieyi {
color: #333;
margin-top: 10px;
}
.login-code {
height: 38px;
float: right;
.login-code-img {
height: 38px;
position: absolute;
margin-left: 10px;
width: 200rpx;
}
}
}
}
</style>