123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478 |
- <template>
- <div class="login">
- <div class="bg">
- <!-- <img :src="loginBG" alt="" /> -->
- </div>
- <div class="login-main">
- <div class="logo-header">
- <div class="login-img">
- <img src="@/assets/img/login.png" alt="" />
- </div>
- <p class="logo-header-title">Hello</p>
- <p class="logo-header-tips">欢迎登录藏金·1745平台</p>
- </div>
- <van-form validate-first class="login-form">
- <div class="loginBox">
- <img src="@/assets/img/loginBox.png" alt="" />
- </div>
- <ul class="clear oUl" style="width: 83vw">
- <!-- <li class="label">
- 卡号:
-
- </li> -->
- <li class="van-field-input">
- <van-row style="width: 83vw">
- <van-col span="3" style="width: 14px">
- <div class="cardNo">
- <img src="@/assets/img/cardNo.png" alt="" />
- </div>
- </van-col>
- <van-col span="5" style="width: 42px">
- <div class="myCard">CJ1745</div>
- </van-col>
- <van-col span="16" style="width: calc(100% - 86px)">
- <van-field
- style="margin: 0 0 0 30px; background: transParent"
- size="large"
- v-model="form.mobile"
- name="mobile"
- placeholder="XXXXXX"
- type="text"
- maxlength="6"
- :rules="[{ validator: asyncmobileValidator }]"
- >
- </van-field>
- </van-col>
- </van-row>
- </li>
- </ul>
- <ul class="clear" style="width: 83vw; border-radius: 10px">
- <!-- <li class="label">
- 密码:
- <img src="@/assets/img/password.png" alt="" />
- </li> -->
- <van-row style="width: 84vw">
- <van-col span="3" style="width: 14px">
- <div class="cardPwd">
- <img src="@/assets/img/password.png" alt="" />
- </div>
- </van-col>
- <van-col :span="21" style="width: calc(100% - 50px)">
- <li class="van-field-input">
- <van-field
- style="background: transparent; margin: 0 0 0 28px"
- size="large"
- v-model="form.code"
- name="code"
- maxlength="6"
- placeholder="请输入密码"
- :rules="[{ validator: asyncpwodValidator }]"
- :type="!passwordStatus ? 'password' : 'text'"
- :right-icon="!passwordStatus ? 'eye-o' : 'closed-eye'"
- @click-right-icon="showPassword"
- >
- </van-field>
- </li> </van-col
- ></van-row>
- </ul>
- <van-button
- class="login-form-button"
- block
- type="info"
- :disabled="loadding"
- :loadding="loadding"
- loadding-text="加载中..."
- native-type="submit"
- @click="onSubmit()"
- >
- 登 录
- </van-button>
- </van-form>
- <div class="footerP">
- <div class="footer">
- <img src="@/assets/img/footer.png" alt="" />
- </div>
- </div>
- </div>
- </div>
- </template>
- <script>
- import { isnumber, validAlphabets } from "@/utils/validate";
- import resToken from "@/mixins/resToken";
- export default {
- mixins: [resToken],
- data() {
- return {
- passwordStatus: false, //默认隐藏密码
- loginBG: require("@/assets/images/login/bg.png"),
- user: require("@/assets/images/login/user.png"),
- pwod: require("@/assets/images/login/pwod.png"),
- loadding: false,
- form: {
- mobile: "",
- code: "",
- },
- };
- },
- methods: {
- // 点击 登陆按钮 后执行提交
- async onSubmit() {
- if (!this.loadding) {
- this.loadding = true;
- await this.asyncmobileValidator(this.form.mobile) //校验表单卡号
- .then(async (res) => {
- if (res === "ok") {
- let parmValue = {
- code: this.form.code,
- mobile: "CJ1745" + this.form.mobile,
- };
- await this.asyncpwodValidator(this.form.code)
- .then(async (res) => {
- if (res === "ok") {
- this.$store
- .dispatch("user/login", parmValue)
- .then((res) => {
- this.loadding = false;
- if (res.code === 0) {
- this.loginSuccess();
- } else {
- this.show_title(res.msg);
- }
- })
- .catch((err) => {
- console.log(err);
- this.loadding = false;
- });
- } else {
- this.loadding = false;
- }
- })
- .catch(() => {
- this.loadding = false;
- });
- } else {
- this.loadding = false;
- }
- console.log(res);
- })
- .catch(() => {
- this.loadding = false;
- });
- }
- },
- async loginSuccess(data) {
- window.vm.$router.push({
- path: "/home/paddy",
- });
- },
- async asyncmobileValidator(val) {
- return new Promise((resolve) => {
- let type = true;
- if (val === "") {
- this.show_title("请输入卡号!");
- type = false;
- } else {
- if (val.length !== 6) {
- this.show_title("卡号不正确!");
- type = false;
- }
- if (!isnumber(val)) {
- this.show_title("卡号不正确!");
- type = false;
- }
- }
- resolve(type ? "ok" : "error");
- });
- },
- async asyncpwodValidator(val) {
- return new Promise((resolve) => {
- let type = true;
- if (val === "") {
- this.show_title("请输入密码!");
- type = false;
- } else {
- if (val.length !== 6) {
- this.show_title("密码为2位字母+4位数字!");
- type = false;
- } else {
- let a = val.slice(0, 2);
- let b = val.slice(2, 4);
- if (!isnumber(b)) {
- this.show_title("密码为2位字母+4位数字!");
- type = false;
- }
- if (!validAlphabets(a)) {
- this.show_title("密码为2位字母+4位数字!");
- type = false;
- }
- }
- }
- resolve(type ? "ok" : "error");
- });
- },
- showPassword() {
- //展示/隐藏密码
- console.log(this.passwordStatus);
- this.passwordStatus = !this.passwordStatus;
- },
- },
- };
- </script>
- <style lang="scss" scoped>
- .login {
- //最外层的登陆盒子
- position: relative;
- width: 100%;
- height: 100%;
- .bg {
- //背景图的盒子
- position: relative;
- width: 100%;
- height: 100%;
- img {
- //背景图
- display: inline-block;
- width: 100%;
- height: 100%;
- }
- }
- .login-main {
- //详情登陆页面
- position: absolute;
- top: 0;
- left: 0;
- width: 100%; //继承最外层login的宽高
- height: 100%;
- // background-color: #fff;
- background-color: #e6e6dc;
- .logo-header {
- //上半部分登陆盒子,用来展示一张图片
- // padding: 50% 0 10% 0;
- width: 100%;
- height: 355px;
- .login-img {
- width: 100%;
- position: absolute;
- left: 0;
- top: 0;
- img {
- width: 100%;
- // height: 209px;
- height: 232px; //新版
- }
- }
- position: relative;
- top: -12px;
- .logo-header-title {
- //登陆字体的盒子
- // margin: 0px 0 0 0;
- // font-weight: bold;
- padding: 0px 211px 0px 55px;
- // width: 81px;
- // height: 37px;
- // font-size: 20px;
- // font-weight: bold;
- // color: #ffffff;
- // line-height: 20px;
- position: absolute;
- // 新版
- width: 62.5px;
- height: 18.5px;
- font-size: 25px;
- font-family: DIN;
- font-weight: bold;
- color: #daad70;
- line-height: 159.5px;
- }
- .logo-header-tips {
- //登陆文字下提示内容
- position: absolute;
- // left: 0;
- // top: 0;
- // padding-top: 0;
- padding: 40px 211px 0px 55px;
- // width: 97px;
- // height: 12px;
- // font-size: 12px;
- // font-weight: 150;
- // color: #ffffff;
- // line-height: 3px;
- // 新版
- width: 136.5px;
- height: 12.5px;
- font-size: 13px;
- font-family: Source Han Sans CN;
- font-weight: 200;
- color: #daad70;
- line-height: 159.5px;
- }
- }
- .loginBox {
- width: 84vw;
- background: rgba(0, 0, 0, 0);
- // border: 1px solid red;
- border-radius: 10px;
- position: absolute;
- margin: 0 30.5px 0 28.5px;
- top: -59px;
- // z-index: 99999;
- img {
- width: 100%;
- }
- }
- .login-form.van-form {
- //登陆框
- // padding: 10% 18%;
- // background-color: #fff;
- // background-color: #e6e6dc; //新版
- background: #e6e6dc;
- // border-top-left-radius: 20px;
- // border-top-right-radius: 20px;
- position: relative;
- // top: -145px;
- top: -135.5px; //新版
- left: 0;
- // border: 1px solid green;
- ul {
- position: relative;
- left: 0;
- top: 0;
- // border-radius: 20px;
- overflow: hidden;
- margin: 0 0 11.5px 30px;
- // border-bottom: 1px solid #f0f0f0;
- z-index: 9999;
- li {
- float: left;
- &.label {
- width: 100%;
- color: #333333;
- font-size: 16px;
- font-weight: bolder;
- }
- &.van-field-input {
- float: left;
- box-sizing: border-box;
- width: 100%;
- margin: 0 0 0 0;
- .van-cell {
- height: 42px;
- line-height: 42px;
- }
- }
- }
- }
- .van-cell--large {
- padding: 0;
- input {
- height: 42px;
- line-height: 42px;
- font-size: 15px;
- }
- .van-field__label {
- line-height: 42px;
- text-align: center;
- font-size: 15px;
- }
- }
- }
- .van-button--small.van-button--plain {
- border: 0;
- }
- .login-form-button.van-button,
- .login-form-button.van-button--disabled {
- border: 0;
- margin: 98px auto 10px auto;
- color: #333;
- // background: #f4d022;
- background: linear-gradient(0deg, #f2c482, #a07947);
- border-radius: 34px;
- // width: 334px;
- width: 90vw;
- height: 45px;
- background: linear-gradient(0deg, #a67e4b, #efc180);
- border-radius: 8px;
- }
- }
- .myCard {
- position: relative;
- padding: 0 0 0 26px;
- height: 42px;
- line-height: 42px;
- z-index: 99999;
- width: 45px;
- height: 41px;
- font-size: 13px;
- font-family: Source Han Sans CN;
- font-weight: 400;
- color: #111111;
- line-height: 41px;
- }
- .cardNo {
- width: 14px;
- height: 11px;
- vertical-align: 10px;
- padding: 15.5px 0 0 21px;
- position: relative;
- img {
- width: 14px;
- height: 11px;
- }
- }
- .cardPwd {
- width: 14px;
- height: 11px;
- vertical-align: 10px;
- padding: 15.5px 0 0 21px;
- position: relative;
- img {
- width: 12px;
- height: 14px;
- }
- }
- .footerP {
- width: 100vw;
- display: flex;
- justify-content: center;
- position: absolute;
- left: 0;
- bottom: 20px;
- }
- .footer {
- width: 90vw;
- height: 57.5px;
- img {
- width: 100%;
- height: 57.5px;
- // border-radius: 10px;
- }
- }
- @media screen and (min-width: 320px) {
- .login-main .login-form.van-form ul {
- top: -25px;
- }
- }
- @media screen and (min-width: 414px) {
- .login-main .login-form.van-form ul {
- top: -10px;
- }
- }
- @media screen and (min-height: 812px) {
- .login-main .login-form.van-form ul {
- top: -18px;
- }
- }
- }
- </style>
|