123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504 |
- <template>
- <div class="login">
- <div class="login-bg">
- <img :src="BG" alt="" />
- <div class="footer">
- <img :src="footer" alt="" />
- </div>
- </div>
- <div class="login-main">
- <div class="logo-header">
- <p class="logo-header-title">Hello!</p>
- <p class="logo-header-tips">欢迎登录藏金·1745平台</p>
- </div>
- <div class="loginBox">
- <div class="loginBox-div">
- <div class="loginBox-bg">
- <img :src="loginBox" alt="" />
- </div>
- <van-form validate-first class="login-form">
- <ul class="ul">
- <li class="li-div">
- <ul class="clear">
- <li><img :src="user" alt="" /></li>
- <li>
- <div class="zdyDiv">
- <span class="zdyName">CJ1745</span>
- <van-field
- size="large"
- v-model="form.mobile"
- name="mobile"
- placeholder="xxxxxxxxx"
- type="text"
- style="background: transparent"
- maxlength="9"
- :rules="[{ validator: asyncmobileValidator }]"
- >
- </van-field>
- </div>
- </li>
- </ul>
- </li>
- <li class="li-div">
- <ul class="clear">
- <li><img :src="pwod" alt="" /></li>
- <li>
- <van-field
- size="large"
- v-model="form.code"
- name="code"
- maxlength="6"
- style="background: transparent"
- placeholder="请输入密码"
- :rules="[{ validator: asyncpwodValidator }]"
- :type="!passwordStatus ? 'password' : 'text'"
- @click-right-icon="showPassword"
- ></van-field>
- <!-- :right-icon="!passwordStatus ? 'eye-o' : 'closed-eye'" -->
- </li>
- </ul>
- </li>
- </ul>
- </van-form>
- </div>
- </div>
- <div class="login-form-button clear">
- <van-button
- block
- type="info"
- :disabled="loadding"
- :loadding="loadding"
- loadding-text="加载中..."
- native-type="submit"
- @click="onSubmit()"
- >
- 登 录
- </van-button>
- <span class="fr reset-span" @click="loginSuccess('/reset')"
- >修改密码</span
- >
- </div>
- </div>
- <van-overlay :show="show">
- <div class="wrapper">
- <div class="block">
- <h3>系统公告:</h3>
- <div class="content">持卡人持有的2022年TK专享藏金大米金卡及TK专享藏金大米银卡已于2023年10月31日到期,现公司将产品兑换时间延期至2023年12月31日,请持卡人在以上时间内兑换,避免造成产品兑换不便事项,特此通知。</div>
- <div class="button__wrapper">
- <div>
- <div v-if="countdown !== 0">{{countdown}}s</div>
- </div>
- <van-button type="primary" @click.stop="show = false" :disabled="countdown !== 0">确定</van-button>
- </div>
- </div>
- </div>
- </van-overlay>
- </div>
- </template>
- <script>
- import { isnumber, validAlphabets } from "@/utils/validate";
- import asyncRequest from "@/apis/my/index";
- import dayjs from "dayjs"
- import resToken from "@/mixins/resToken";
- import { Dialog } from "vant";
- export default {
- mixins: [resToken],
- data() {
- return {
- showTime:"",
- passwordStatus: false, //默认隐藏密码
- BG: require("@/assets/images/login.png"),
- user: require("@/assets/images/cardNo.png"),
- pwod: require("@/assets/images/password.png"),
- loginBox: require("@/assets/images/loginBox.png"),
- footer: require("@/assets/images/footer.png"),
- loadding: false,
- countdown : 3,
- show: true,
- isRed:"",
- form: {
- mobile: "",
- code: ""
- }
- };
- },
- mounted() {
- // Dialog({
- // title: "春节公告",
- // message:
- // "尊敬的藏金客户,因春节将至,目前五常物流已停止接单,恢复时间为1月30日。在此期间可正常下单,节后陆续发出,感谢大家理解,预祝新春快乐!",
- // messageAlign: "left",
- // theme: "round-button",
- // className: "login-notice"
- // });
- this.startConfirmTime();
- },
- 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(async (res) => {
- const userinfo = await asyncRequest.detail();
- const expireTime = userinfo.data.expiretime;
- const expireTimeDay = dayjs(expireTime);
- const alerttime = dayjs("2023-12-31 23:59:59")
- const chunks = expireTime.split(" ")
- const chunks1 = chunks[0].split("-")
- this.showTime = chunks1[0] + "年" + chunks1[1] + "月" + chunks1[2] + "日";
- this.expiretime = expireTime;
- const reg = /TKR/
- this.isRed = reg.test(userinfo.data.username);
- // 获取用户信息
- // if(expireTimeDay.isBefore(alerttime)){
- // if(isnumber(status)){
- // this.theme("active2")
- // }else{
- // this.theme("active1")
- // }
- // this.loadding = false;
- // this.startConfirmTime();
- // } else {
- // 获取用户信息
- //登录成功后根据当前账号设置主题
- //截取输入框账号第一位进行判断
- // let status = this.form.mobile.substr(0,1)
- // if(isnumber(status)){
- // this.theme("active2")
- // }else{
- // this.theme("active1")
- // }
- this.loadding = false;
- if (res.code === 0) {
- this.loginSuccess("/home/paddy");
- } 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;
- });
- }
- },
- startConfirmTime(){
- this.show = true;
- this.countdown = 3;
- const timer = setInterval(() => {
- if(this.countdown === 0){
- timer && clearInterval(timer);
- return
- }
- this.countdown = this.countdown - 1;
- }, 1000)
- },
- async loginSuccess(path) {
- window.vm.$router.push({
- path: path
- });
- },
- async asyncmobileValidator(val) {
- return new Promise(resolve => {
- let type = true;
- if (val === "") {
- this.show_title("请输入卡号!");
- type = false;
- } else {
- if (val.length !== 9) {
- this.show_title("卡号不正确!");
- type = false;
- } else {
- let a = val.slice(0, 3);
- let b = val.slice(3, 9);
- if (a == "TKS" || a == "TKR") {
- if (!isnumber(b)) {
- 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 {
- box-sizing: border-box;
- // .van-field__control{
- // font-size: 15px!important;
- // }
- .login-bg {
- position: relative;
- z-index: 1;
- width: 100%;
- height: 100%;
- box-sizing: border-box;
- overflow: hidden;
- background: #e6e6dc;
- img {
- display: inline-block;
- box-sizing: border-box;
- width: 100%;
- }
- .footer {
- position: absolute;
- box-sizing: border-box;
- z-index: 2;
- bottom: 0;
- left: 0;
- img {
- display: inline-block;
- width: 100%;
- padding: 0 30px 30px 30px;
- }
- }
- }
- .login-main {
- position: absolute;
- width: 100%;
- height: 100%;
- z-index: 9;
- top: 0;
- left: 0;
- .logo-header {
- //上半部分登陆盒子,用来展示一张图片
- width: 100%;
- padding: 8vh 30px 30px 30px;
- .logo-header-title {
- font-size: 30px;
- // font-family: DIN;
- font-weight: bold;
- color: #daad70;
- margin: 12px 0;
- }
- .logo-header-tips {
- font-size: 15px;
- font-weight: 200;
- color: #daad70;
- margin: 10px 0;
- }
- }
- .loginBox {
- padding: 0 30px;
- box-sizing: border-box;
- position: relative;
- .loginBox-bg {
- position: relative;
- width: 100%;
- // height: 100px;
- img {
- width: 100%;
- display: inline-block;
- }
- }
- .login-form {
- position: absolute;
- top: 0;
- left: 30px;
- width: calc(100% - 60px);
- padding: 5.5vh 20px 0 14px;
- box-sizing: border-box;
- ul.ul {
- width: 100%;
- li.li-div {
- width: 100%;
- height: 55px;
- padding: 0 0 0.5vh;
- ul {
- li {
- float: left;
- &:first-child {
- width: 40px;
- height: 48px;
- line-height: 50px;
- text-align: center;
- img {
- display: inline-block;
- height: 18px;
- margin: 14px 0 0 0;
- }
- }
- &:last-child {
- width: calc(100% - 40px);
- }
- .zdyDiv {
- float: left;
- width: 100%;
- .zdyName {
- width: 55px;
- line-height: 48px;
- float: left;
- color: #000;
- text-align: right;
- font-size: 16px;
- }
- }
- .van-cell {
- float: left;
- background: transparent !important;
- padding-left: 1px;
- .van-cell__value {
- background: transparent !important;
- > div {
- background: transparent !important;
- input {
- background: transparent !important;
- }
- }
- }
- .van-field__control {
- font-size: 15px !important;
- }
- }
- }
- }
- &:first-child {
- ul {
- li {
- &:last-child {
- .van-cell {
- width: calc(100% - 55px);
- }
- }
- }
- }
- }
- }
- }
- }
- }
- .login-form-button {
- padding: 10vh 30px 0 30px;
- .van-button {
- background: linear-gradient(0deg, #a67e4b, #efc180);
- border-radius: 8px;
- overflow: hidden;
- color: #111111;
- border: 0;
- font-weight: bolder;
- }
- .reset-span {
- padding: 10px;
- color: #454545;
- }
- }
- }
- }
- .wrapper {
- display: flex;
- align-items: center;
- justify-content: center;
- height: 100%;
- }
- .block {
- width: 85%;
- border-radius:10px;
- background-color: #fff;
- font-size:14px;
- padding: 10px;
- text-align: left;
- h3{
- text-align: center;
- }
- .content{
- text-align: justify;
- text-indent:30px;
- padding:10px;
- line-height: 28px;
- }
- .button__wrapper{
- display: flex;
- align-items: center;
- justify-content: space-between;
- white-space: inherit;
- padding:0 10px;
- margin-bottom: 10px;
- button{
- height:32px;
- }
- }
- }
- </style>
|