|
|
@@ -0,0 +1,170 @@ |
|
|
|
<template> |
|
|
|
<div class="app-container"> |
|
|
|
<div class="title"> |
|
|
|
<img style="display: block;width: 90%;margin: 0 auto;" src="../../static/images/yinnong/yinnongLogo1.png" alt=""> |
|
|
|
</div> |
|
|
|
<div style="background: rgba(255, 255, 255, .2);margin:1.5rem auto 0;width: calc(100% - 40px);border-radius: 20px;overflow: hidden;border: 1px solid #fff;"> |
|
|
|
<p class="login-title">用户登录</p> |
|
|
|
<van-form style="padding:30px 0;"> |
|
|
|
<van-field |
|
|
|
v-model="formData.username" |
|
|
|
placeholder="请输入手机号/账号" |
|
|
|
left-icon="contact-o" |
|
|
|
:rules="[{ required: true, message:'' }]" |
|
|
|
/> |
|
|
|
<van-field |
|
|
|
v-model="formData.password" |
|
|
|
type="password" |
|
|
|
left-icon="edit" |
|
|
|
style="margin-top: 20px" |
|
|
|
placeholder="请输入密码" |
|
|
|
:rules="[{ required: true, message:'' }]" |
|
|
|
/> |
|
|
|
<div style="display: flex;width: 90%;margin: 20px auto 0;"> |
|
|
|
<van-field |
|
|
|
v-model="formData.code" |
|
|
|
left-icon="shield-o" |
|
|
|
center |
|
|
|
clearable |
|
|
|
placeholder="图形验证码" |
|
|
|
/> |
|
|
|
<div style="border-radius: 100vh;width: 120px;margin-left: 20px;overflow: hidden;flex-shrink: 0;"> |
|
|
|
<img style="width: 120px;display: block;transform: scale(1.1);" :src="codeUrl" @click="getCode" /> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<van-checkbox style="float: left;margin-top:10px;margin-left:20px;" v-model="formData.rememberMe" shape="square">记住密码</van-checkbox> |
|
|
|
<!-- <p style="float: right;margin-top:10px;margin-right:20px;color:#1D6FE9 ">忘记密码</p>--> |
|
|
|
<div class="clear"></div> |
|
|
|
<div style="margin: 50px 16px 16px;border-radius: 100vh;overflow: hidden;"> |
|
|
|
<van-button block type="info" color="linear-gradient(to right, #97eedc, #5166f5)" native-type="submit" @click="handleLogin">登录</van-button> |
|
|
|
<!-- <p style="text-align: center;margin-top: 20px;color:#878787 " @click="showMessagePop">短信验证码登录</p>--> |
|
|
|
</div> |
|
|
|
</van-form> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</template> |
|
|
|
<style scoped lang="scss"> |
|
|
|
.app-container{ |
|
|
|
background: #fafafa url("../../static/images/yinnong/login_bg.png") no-repeat top; |
|
|
|
background-size: 100% auto; |
|
|
|
min-height: 100vh; |
|
|
|
/*overflow: hidden;*/ |
|
|
|
} |
|
|
|
/deep/ .van-cell{ |
|
|
|
background: #eaeef6; |
|
|
|
border-radius: 100vh; |
|
|
|
width: 90%; |
|
|
|
margin: 0 auto; |
|
|
|
} |
|
|
|
|
|
|
|
.title{ |
|
|
|
padding-top: 15%; |
|
|
|
width: 100%; |
|
|
|
margin: 0 auto; |
|
|
|
} |
|
|
|
|
|
|
|
.login-title { |
|
|
|
text-align: center; |
|
|
|
font-size: .5rem; |
|
|
|
font-weight: bold; |
|
|
|
color: white; |
|
|
|
background: linear-gradient(to right, rgb(151, 238, 220), rgb(81, 102, 245)); |
|
|
|
padding-top: .3rem; |
|
|
|
padding-bottom: .3rem; |
|
|
|
} |
|
|
|
</style> |
|
|
|
<script> |
|
|
|
import { getCodeImg, } from "../api/login"; |
|
|
|
import Cookies from "js-cookie"; |
|
|
|
import { encrypt, decrypt } from "../utils/jsencrypt"; |
|
|
|
//引用wx sdk |
|
|
|
import wx from "weixin-js-sdk"; |
|
|
|
export default { |
|
|
|
name: "yinnongLogin", |
|
|
|
data() { |
|
|
|
return { |
|
|
|
smsCodeValue:"", |
|
|
|
showKeyboard:false, |
|
|
|
formData: { |
|
|
|
username: "", //账号 |
|
|
|
password: "", //密码 |
|
|
|
code: null, //图片验证码 |
|
|
|
uuid: null, //识别uuid |
|
|
|
mobile: null, //手机号 |
|
|
|
smsCode: null, //短信验证码 |
|
|
|
memberName:null, //身份信息 |
|
|
|
idcard:null, //身份号码 |
|
|
|
rememberMe:false |
|
|
|
}, |
|
|
|
loading: false, |
|
|
|
codeUrl: "", //验证码 |
|
|
|
}; |
|
|
|
}, |
|
|
|
created() { |
|
|
|
this.getCode(); |
|
|
|
this.getCookie(); |
|
|
|
this.reset(); |
|
|
|
}, |
|
|
|
methods: { |
|
|
|
reset(){ |
|
|
|
|
|
|
|
}, |
|
|
|
getCode() { |
|
|
|
getCodeImg().then((res) => { |
|
|
|
this.formData.uuid = res.uuid; |
|
|
|
this.codeUrl = "data:image/gif;base64," + res.img; |
|
|
|
}); |
|
|
|
}, |
|
|
|
getCookie() { |
|
|
|
const username = Cookies.get("username"); |
|
|
|
const password = Cookies.get("password"); |
|
|
|
const rememberMe = Cookies.get("rememberMe"); |
|
|
|
this.formData = { |
|
|
|
username: username === undefined ? this.formData.username : username, |
|
|
|
password: |
|
|
|
password === undefined ? this.formData.password : decrypt(password), |
|
|
|
rememberMe: rememberMe === undefined ? false : Boolean(rememberMe), |
|
|
|
}; |
|
|
|
}, |
|
|
|
handleLogin(values) { |
|
|
|
if (this.formData.rememberMe) { |
|
|
|
Cookies.set("username", this.formData.username, { expires: 30 }); |
|
|
|
Cookies.set("password", encrypt(this.formData.password), { expires: 30 }); |
|
|
|
Cookies.set("rememberMe", this.formData.rememberMe, { expires: 30 }); |
|
|
|
} else { |
|
|
|
Cookies.remove("username"); |
|
|
|
Cookies.remove("password"); |
|
|
|
Cookies.remove("rememberMe"); |
|
|
|
} |
|
|
|
//账号密码登录 |
|
|
|
if (this.formData.username == "") { |
|
|
|
this.$dialog.alert({ |
|
|
|
message: '账号不能为空', |
|
|
|
}); |
|
|
|
return false; |
|
|
|
} else if (this.formData.password == "") { |
|
|
|
this.$dialog.alert({ |
|
|
|
message: '密码不能为空', |
|
|
|
}); |
|
|
|
return false; |
|
|
|
} else if (!this.formData.code) { |
|
|
|
this.$dialog.alert({ |
|
|
|
message: '图片验证码不能为空', |
|
|
|
}); |
|
|
|
return false; |
|
|
|
} |
|
|
|
this.$store |
|
|
|
.dispatch("Login", this.formData) |
|
|
|
.then(() => { |
|
|
|
this.$router.push({ path: "/yinnong/doneCompleted/completedNew" }).catch(() => {}); |
|
|
|
}) |
|
|
|
.catch((error) => { |
|
|
|
//console.log(error) |
|
|
|
this.formData.code = ''; |
|
|
|
this.loading = false; |
|
|
|
this.getCode(); |
|
|
|
}); |
|
|
|
}, |
|
|
|
}, |
|
|
|
}; |
|
|
|
</script> |