index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478
  1. <template>
  2. <div class="login">
  3. <div class="bg">
  4. <!-- <img :src="loginBG" alt="" /> -->
  5. </div>
  6. <div class="login-main">
  7. <div class="logo-header">
  8. <div class="login-img">
  9. <img src="@/assets/img/login.png" alt="" />
  10. </div>
  11. <p class="logo-header-title">Hello</p>
  12. <p class="logo-header-tips">欢迎登录藏金·1745平台</p>
  13. </div>
  14. <van-form validate-first class="login-form">
  15. <div class="loginBox">
  16. <img src="@/assets/img/loginBox.png" alt="" />
  17. </div>
  18. <ul class="clear oUl" style="width: 83vw">
  19. <!-- <li class="label">
  20. 卡号:
  21. </li> -->
  22. <li class="van-field-input">
  23. <van-row style="width: 83vw">
  24. <van-col span="3" style="width: 14px">
  25. <div class="cardNo">
  26. <img src="@/assets/img/cardNo.png" alt="" />
  27. </div>
  28. </van-col>
  29. <van-col span="5" style="width: 42px">
  30. <div class="myCard">CJ1745</div>
  31. </van-col>
  32. <van-col span="16" style="width: calc(100% - 86px)">
  33. <van-field
  34. style="margin: 0 0 0 30px; background: transParent"
  35. size="large"
  36. v-model="form.mobile"
  37. name="mobile"
  38. placeholder="XXXXXX"
  39. type="text"
  40. maxlength="6"
  41. :rules="[{ validator: asyncmobileValidator }]"
  42. >
  43. </van-field>
  44. </van-col>
  45. </van-row>
  46. </li>
  47. </ul>
  48. <ul class="clear" style="width: 83vw; border-radius: 10px">
  49. <!-- <li class="label">
  50. 密码:
  51. <img src="@/assets/img/password.png" alt="" />
  52. </li> -->
  53. <van-row style="width: 84vw">
  54. <van-col span="3" style="width: 14px">
  55. <div class="cardPwd">
  56. <img src="@/assets/img/password.png" alt="" />
  57. </div>
  58. </van-col>
  59. <van-col :span="21" style="width: calc(100% - 50px)">
  60. <li class="van-field-input">
  61. <van-field
  62. style="background: transparent; margin: 0 0 0 28px"
  63. size="large"
  64. v-model="form.code"
  65. name="code"
  66. maxlength="6"
  67. placeholder="请输入密码"
  68. :rules="[{ validator: asyncpwodValidator }]"
  69. :type="!passwordStatus ? 'password' : 'text'"
  70. :right-icon="!passwordStatus ? 'eye-o' : 'closed-eye'"
  71. @click-right-icon="showPassword"
  72. >
  73. </van-field>
  74. </li> </van-col
  75. ></van-row>
  76. </ul>
  77. <van-button
  78. class="login-form-button"
  79. block
  80. type="info"
  81. :disabled="loadding"
  82. :loadding="loadding"
  83. loadding-text="加载中..."
  84. native-type="submit"
  85. @click="onSubmit()"
  86. >
  87. 登&nbsp;录
  88. </van-button>
  89. </van-form>
  90. <div class="footerP">
  91. <div class="footer">
  92. <img src="@/assets/img/footer.png" alt="" />
  93. </div>
  94. </div>
  95. </div>
  96. </div>
  97. </template>
  98. <script>
  99. import { isnumber, validAlphabets } from "@/utils/validate";
  100. import resToken from "@/mixins/resToken";
  101. export default {
  102. mixins: [resToken],
  103. data() {
  104. return {
  105. passwordStatus: false, //默认隐藏密码
  106. loginBG: require("@/assets/images/login/bg.png"),
  107. user: require("@/assets/images/login/user.png"),
  108. pwod: require("@/assets/images/login/pwod.png"),
  109. loadding: false,
  110. form: {
  111. mobile: "",
  112. code: "",
  113. },
  114. };
  115. },
  116. methods: {
  117. // 点击 登陆按钮 后执行提交
  118. async onSubmit() {
  119. if (!this.loadding) {
  120. this.loadding = true;
  121. await this.asyncmobileValidator(this.form.mobile) //校验表单卡号
  122. .then(async (res) => {
  123. if (res === "ok") {
  124. let parmValue = {
  125. code: this.form.code,
  126. mobile: "CJ1745" + this.form.mobile,
  127. };
  128. await this.asyncpwodValidator(this.form.code)
  129. .then(async (res) => {
  130. if (res === "ok") {
  131. this.$store
  132. .dispatch("user/login", parmValue)
  133. .then((res) => {
  134. this.loadding = false;
  135. if (res.code === 0) {
  136. this.loginSuccess();
  137. } else {
  138. this.show_title(res.msg);
  139. }
  140. })
  141. .catch((err) => {
  142. console.log(err);
  143. this.loadding = false;
  144. });
  145. } else {
  146. this.loadding = false;
  147. }
  148. })
  149. .catch(() => {
  150. this.loadding = false;
  151. });
  152. } else {
  153. this.loadding = false;
  154. }
  155. console.log(res);
  156. })
  157. .catch(() => {
  158. this.loadding = false;
  159. });
  160. }
  161. },
  162. async loginSuccess(data) {
  163. window.vm.$router.push({
  164. path: "/home/paddy",
  165. });
  166. },
  167. async asyncmobileValidator(val) {
  168. return new Promise((resolve) => {
  169. let type = true;
  170. if (val === "") {
  171. this.show_title("请输入卡号!");
  172. type = false;
  173. } else {
  174. if (val.length !== 6) {
  175. this.show_title("卡号不正确!");
  176. type = false;
  177. }
  178. if (!isnumber(val)) {
  179. this.show_title("卡号不正确!");
  180. type = false;
  181. }
  182. }
  183. resolve(type ? "ok" : "error");
  184. });
  185. },
  186. async asyncpwodValidator(val) {
  187. return new Promise((resolve) => {
  188. let type = true;
  189. if (val === "") {
  190. this.show_title("请输入密码!");
  191. type = false;
  192. } else {
  193. if (val.length !== 6) {
  194. this.show_title("密码为2位字母+4位数字!");
  195. type = false;
  196. } else {
  197. let a = val.slice(0, 2);
  198. let b = val.slice(2, 4);
  199. if (!isnumber(b)) {
  200. this.show_title("密码为2位字母+4位数字!");
  201. type = false;
  202. }
  203. if (!validAlphabets(a)) {
  204. this.show_title("密码为2位字母+4位数字!");
  205. type = false;
  206. }
  207. }
  208. }
  209. resolve(type ? "ok" : "error");
  210. });
  211. },
  212. showPassword() {
  213. //展示/隐藏密码
  214. console.log(this.passwordStatus);
  215. this.passwordStatus = !this.passwordStatus;
  216. },
  217. },
  218. };
  219. </script>
  220. <style lang="scss" scoped>
  221. .login {
  222. //最外层的登陆盒子
  223. position: relative;
  224. width: 100%;
  225. height: 100%;
  226. .bg {
  227. //背景图的盒子
  228. position: relative;
  229. width: 100%;
  230. height: 100%;
  231. img {
  232. //背景图
  233. display: inline-block;
  234. width: 100%;
  235. height: 100%;
  236. }
  237. }
  238. .login-main {
  239. //详情登陆页面
  240. position: absolute;
  241. top: 0;
  242. left: 0;
  243. width: 100%; //继承最外层login的宽高
  244. height: 100%;
  245. // background-color: #fff;
  246. background-color: #e6e6dc;
  247. .logo-header {
  248. //上半部分登陆盒子,用来展示一张图片
  249. // padding: 50% 0 10% 0;
  250. width: 100%;
  251. height: 355px;
  252. .login-img {
  253. width: 100%;
  254. position: absolute;
  255. left: 0;
  256. top: 0;
  257. img {
  258. width: 100%;
  259. // height: 209px;
  260. height: 232px; //新版
  261. }
  262. }
  263. position: relative;
  264. top: -12px;
  265. .logo-header-title {
  266. //登陆字体的盒子
  267. // margin: 0px 0 0 0;
  268. // font-weight: bold;
  269. padding: 0px 211px 0px 55px;
  270. // width: 81px;
  271. // height: 37px;
  272. // font-size: 20px;
  273. // font-weight: bold;
  274. // color: #ffffff;
  275. // line-height: 20px;
  276. position: absolute;
  277. // 新版
  278. width: 62.5px;
  279. height: 18.5px;
  280. font-size: 25px;
  281. font-family: DIN;
  282. font-weight: bold;
  283. color: #daad70;
  284. line-height: 159.5px;
  285. }
  286. .logo-header-tips {
  287. //登陆文字下提示内容
  288. position: absolute;
  289. // left: 0;
  290. // top: 0;
  291. // padding-top: 0;
  292. padding: 40px 211px 0px 55px;
  293. // width: 97px;
  294. // height: 12px;
  295. // font-size: 12px;
  296. // font-weight: 150;
  297. // color: #ffffff;
  298. // line-height: 3px;
  299. // 新版
  300. width: 136.5px;
  301. height: 12.5px;
  302. font-size: 13px;
  303. font-family: Source Han Sans CN;
  304. font-weight: 200;
  305. color: #daad70;
  306. line-height: 159.5px;
  307. }
  308. }
  309. .loginBox {
  310. width: 84vw;
  311. background: rgba(0, 0, 0, 0);
  312. // border: 1px solid red;
  313. border-radius: 10px;
  314. position: absolute;
  315. margin: 0 30.5px 0 28.5px;
  316. top: -59px;
  317. // z-index: 99999;
  318. img {
  319. width: 100%;
  320. }
  321. }
  322. .login-form.van-form {
  323. //登陆框
  324. // padding: 10% 18%;
  325. // background-color: #fff;
  326. // background-color: #e6e6dc; //新版
  327. background: #e6e6dc;
  328. // border-top-left-radius: 20px;
  329. // border-top-right-radius: 20px;
  330. position: relative;
  331. // top: -145px;
  332. top: -135.5px; //新版
  333. left: 0;
  334. // border: 1px solid green;
  335. ul {
  336. position: relative;
  337. left: 0;
  338. top: 0;
  339. // border-radius: 20px;
  340. overflow: hidden;
  341. margin: 0 0 11.5px 30px;
  342. // border-bottom: 1px solid #f0f0f0;
  343. z-index: 9999;
  344. li {
  345. float: left;
  346. &.label {
  347. width: 100%;
  348. color: #333333;
  349. font-size: 16px;
  350. font-weight: bolder;
  351. }
  352. &.van-field-input {
  353. float: left;
  354. box-sizing: border-box;
  355. width: 100%;
  356. margin: 0 0 0 0;
  357. .van-cell {
  358. height: 42px;
  359. line-height: 42px;
  360. }
  361. }
  362. }
  363. }
  364. .van-cell--large {
  365. padding: 0;
  366. input {
  367. height: 42px;
  368. line-height: 42px;
  369. font-size: 15px;
  370. }
  371. .van-field__label {
  372. line-height: 42px;
  373. text-align: center;
  374. font-size: 15px;
  375. }
  376. }
  377. }
  378. .van-button--small.van-button--plain {
  379. border: 0;
  380. }
  381. .login-form-button.van-button,
  382. .login-form-button.van-button--disabled {
  383. border: 0;
  384. margin: 98px auto 10px auto;
  385. color: #333;
  386. // background: #f4d022;
  387. background: linear-gradient(0deg, #f2c482, #a07947);
  388. border-radius: 34px;
  389. // width: 334px;
  390. width: 90vw;
  391. height: 45px;
  392. background: linear-gradient(0deg, #a67e4b, #efc180);
  393. border-radius: 8px;
  394. }
  395. }
  396. .myCard {
  397. position: relative;
  398. padding: 0 0 0 26px;
  399. height: 42px;
  400. line-height: 42px;
  401. z-index: 99999;
  402. width: 45px;
  403. height: 41px;
  404. font-size: 13px;
  405. font-family: Source Han Sans CN;
  406. font-weight: 400;
  407. color: #111111;
  408. line-height: 41px;
  409. }
  410. .cardNo {
  411. width: 14px;
  412. height: 11px;
  413. vertical-align: 10px;
  414. padding: 15.5px 0 0 21px;
  415. position: relative;
  416. img {
  417. width: 14px;
  418. height: 11px;
  419. }
  420. }
  421. .cardPwd {
  422. width: 14px;
  423. height: 11px;
  424. vertical-align: 10px;
  425. padding: 15.5px 0 0 21px;
  426. position: relative;
  427. img {
  428. width: 12px;
  429. height: 14px;
  430. }
  431. }
  432. .footerP {
  433. width: 100vw;
  434. display: flex;
  435. justify-content: center;
  436. position: absolute;
  437. left: 0;
  438. bottom: 20px;
  439. }
  440. .footer {
  441. width: 90vw;
  442. height: 57.5px;
  443. img {
  444. width: 100%;
  445. height: 57.5px;
  446. // border-radius: 10px;
  447. }
  448. }
  449. @media screen and (min-width: 320px) {
  450. .login-main .login-form.van-form ul {
  451. top: -25px;
  452. }
  453. }
  454. @media screen and (min-width: 414px) {
  455. .login-main .login-form.van-form ul {
  456. top: -10px;
  457. }
  458. }
  459. @media screen and (min-height: 812px) {
  460. .login-main .login-form.van-form ul {
  461. top: -18px;
  462. }
  463. }
  464. }
  465. </style>