index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504
  1. <template>
  2. <div class="login">
  3. <div class="login-bg">
  4. <img :src="BG" alt="" />
  5. <div class="footer">
  6. <img :src="footer" alt="" />
  7. </div>
  8. </div>
  9. <div class="login-main">
  10. <div class="logo-header">
  11. <p class="logo-header-title">Hello!</p>
  12. <p class="logo-header-tips">欢迎登录藏金·1745平台</p>
  13. </div>
  14. <div class="loginBox">
  15. <div class="loginBox-div">
  16. <div class="loginBox-bg">
  17. <img :src="loginBox" alt="" />
  18. </div>
  19. <van-form validate-first class="login-form">
  20. <ul class="ul">
  21. <li class="li-div">
  22. <ul class="clear">
  23. <li><img :src="user" alt="" /></li>
  24. <li>
  25. <div class="zdyDiv">
  26. <span class="zdyName">CJ1745</span>
  27. <van-field
  28. size="large"
  29. v-model="form.mobile"
  30. name="mobile"
  31. placeholder="xxxxxxxxx"
  32. type="text"
  33. style="background: transparent"
  34. maxlength="9"
  35. :rules="[{ validator: asyncmobileValidator }]"
  36. >
  37. </van-field>
  38. </div>
  39. </li>
  40. </ul>
  41. </li>
  42. <li class="li-div">
  43. <ul class="clear">
  44. <li><img :src="pwod" alt="" /></li>
  45. <li>
  46. <van-field
  47. size="large"
  48. v-model="form.code"
  49. name="code"
  50. maxlength="6"
  51. style="background: transparent"
  52. placeholder="请输入密码"
  53. :rules="[{ validator: asyncpwodValidator }]"
  54. :type="!passwordStatus ? 'password' : 'text'"
  55. @click-right-icon="showPassword"
  56. ></van-field>
  57. <!-- :right-icon="!passwordStatus ? 'eye-o' : 'closed-eye'" -->
  58. </li>
  59. </ul>
  60. </li>
  61. </ul>
  62. </van-form>
  63. </div>
  64. </div>
  65. <div class="login-form-button clear">
  66. <van-button
  67. block
  68. type="info"
  69. :disabled="loadding"
  70. :loadding="loadding"
  71. loadding-text="加载中..."
  72. native-type="submit"
  73. @click="onSubmit()"
  74. >
  75. 登&nbsp;录
  76. </van-button>
  77. <span class="fr reset-span" @click="loginSuccess('/reset')"
  78. >修改密码</span
  79. >
  80. </div>
  81. </div>
  82. <van-overlay :show="show">
  83. <div class="wrapper">
  84. <div class="block">
  85. <h3>系统公告:</h3>
  86. <div class="content">持卡人持有的2022年TK专享藏金大米金卡及TK专享藏金大米银卡已于2023年10月31日到期,现公司将产品兑换时间延期至2023年12月31日,请持卡人在以上时间内兑换,避免造成产品兑换不便事项,特此通知。</div>
  87. <div class="button__wrapper">
  88. <div>
  89. <div v-if="countdown !== 0">{{countdown}}s</div>
  90. </div>
  91. <van-button type="primary" @click.stop="show = false" :disabled="countdown !== 0">确定</van-button>
  92. </div>
  93. </div>
  94. </div>
  95. </van-overlay>
  96. </div>
  97. </template>
  98. <script>
  99. import { isnumber, validAlphabets } from "@/utils/validate";
  100. import asyncRequest from "@/apis/my/index";
  101. import dayjs from "dayjs"
  102. import resToken from "@/mixins/resToken";
  103. import { Dialog } from "vant";
  104. export default {
  105. mixins: [resToken],
  106. data() {
  107. return {
  108. showTime:"",
  109. passwordStatus: false, //默认隐藏密码
  110. BG: require("@/assets/images/login.png"),
  111. user: require("@/assets/images/cardNo.png"),
  112. pwod: require("@/assets/images/password.png"),
  113. loginBox: require("@/assets/images/loginBox.png"),
  114. footer: require("@/assets/images/footer.png"),
  115. loadding: false,
  116. countdown : 3,
  117. show: true,
  118. isRed:"",
  119. form: {
  120. mobile: "",
  121. code: ""
  122. }
  123. };
  124. },
  125. mounted() {
  126. // Dialog({
  127. // title: "春节公告",
  128. // message:
  129. // "尊敬的藏金客户,因春节将至,目前五常物流已停止接单,恢复时间为1月30日。在此期间可正常下单,节后陆续发出,感谢大家理解,预祝新春快乐!",
  130. // messageAlign: "left",
  131. // theme: "round-button",
  132. // className: "login-notice"
  133. // });
  134. this.startConfirmTime();
  135. },
  136. methods: {
  137. // 点击 登陆按钮 后执行提交
  138. async onSubmit() {
  139. if (!this.loadding) {
  140. this.loadding = true;
  141. await this.asyncmobileValidator(this.form.mobile) //校验表单卡号
  142. .then(async (res) => {
  143. if (res === "ok") {
  144. let parmValue = {
  145. code: this.form.code,
  146. mobile: "CJ1745" + this.form.mobile,
  147. };
  148. await this.asyncpwodValidator(this.form.code)
  149. .then(async (res) => {
  150. if (res === "ok") {
  151. this.$store
  152. .dispatch("user/login", parmValue)
  153. .then(async (res) => {
  154. const userinfo = await asyncRequest.detail();
  155. const expireTime = userinfo.data.expiretime;
  156. const expireTimeDay = dayjs(expireTime);
  157. const alerttime = dayjs("2023-12-31 23:59:59")
  158. const chunks = expireTime.split(" ")
  159. const chunks1 = chunks[0].split("-")
  160. this.showTime = chunks1[0] + "年" + chunks1[1] + "月" + chunks1[2] + "日";
  161. this.expiretime = expireTime;
  162. const reg = /TKR/
  163. this.isRed = reg.test(userinfo.data.username);
  164. // 获取用户信息
  165. // if(expireTimeDay.isBefore(alerttime)){
  166. // if(isnumber(status)){
  167. // this.theme("active2")
  168. // }else{
  169. // this.theme("active1")
  170. // }
  171. // this.loadding = false;
  172. // this.startConfirmTime();
  173. // } else {
  174. // 获取用户信息
  175. //登录成功后根据当前账号设置主题
  176. //截取输入框账号第一位进行判断
  177. // let status = this.form.mobile.substr(0,1)
  178. // if(isnumber(status)){
  179. // this.theme("active2")
  180. // }else{
  181. // this.theme("active1")
  182. // }
  183. this.loadding = false;
  184. if (res.code === 0) {
  185. this.loginSuccess("/home/paddy");
  186. } else {
  187. this.show_title(res.msg);
  188. }
  189. // }
  190. })
  191. .catch((err) => {
  192. console.log(err);
  193. this.loadding = false;
  194. });
  195. } else {
  196. this.loadding = false;
  197. }
  198. })
  199. .catch(() => {
  200. this.loadding = false;
  201. });
  202. } else {
  203. this.loadding = false;
  204. }
  205. console.log(res);
  206. })
  207. .catch(() => {
  208. this.loadding = false;
  209. });
  210. }
  211. },
  212. startConfirmTime(){
  213. this.show = true;
  214. this.countdown = 3;
  215. const timer = setInterval(() => {
  216. if(this.countdown === 0){
  217. timer && clearInterval(timer);
  218. return
  219. }
  220. this.countdown = this.countdown - 1;
  221. }, 1000)
  222. },
  223. async loginSuccess(path) {
  224. window.vm.$router.push({
  225. path: path
  226. });
  227. },
  228. async asyncmobileValidator(val) {
  229. return new Promise(resolve => {
  230. let type = true;
  231. if (val === "") {
  232. this.show_title("请输入卡号!");
  233. type = false;
  234. } else {
  235. if (val.length !== 9) {
  236. this.show_title("卡号不正确!");
  237. type = false;
  238. } else {
  239. let a = val.slice(0, 3);
  240. let b = val.slice(3, 9);
  241. if (a == "TKS" || a == "TKR") {
  242. if (!isnumber(b)) {
  243. this.show_title("卡号不正确!");
  244. type = false;
  245. }
  246. }
  247. }
  248. }
  249. resolve(type ? "ok" : "error");
  250. });
  251. },
  252. async asyncpwodValidator(val) {
  253. return new Promise(resolve => {
  254. let type = true;
  255. if (val === "") {
  256. this.show_title("请输入密码!");
  257. type = false;
  258. } else {
  259. if (val.length !== 6) {
  260. this.show_title("密码为2位字母+4位数字!");
  261. type = false;
  262. } else {
  263. let a = val.slice(0, 2);
  264. let b = val.slice(2, 4);
  265. if (!isnumber(b)) {
  266. this.show_title("密码为2位字母+4位数字!");
  267. type = false;
  268. }
  269. if (!validAlphabets(a)) {
  270. this.show_title("密码为2位字母+4位数字!");
  271. type = false;
  272. }
  273. }
  274. }
  275. resolve(type ? "ok" : "error");
  276. });
  277. },
  278. showPassword() {
  279. //展示/隐藏密码
  280. console.log(this.passwordStatus);
  281. this.passwordStatus = !this.passwordStatus;
  282. }
  283. }
  284. };
  285. </script>
  286. <style lang="scss" scoped>
  287. .login {
  288. box-sizing: border-box;
  289. // .van-field__control{
  290. // font-size: 15px!important;
  291. // }
  292. .login-bg {
  293. position: relative;
  294. z-index: 1;
  295. width: 100%;
  296. height: 100%;
  297. box-sizing: border-box;
  298. overflow: hidden;
  299. background: #e6e6dc;
  300. img {
  301. display: inline-block;
  302. box-sizing: border-box;
  303. width: 100%;
  304. }
  305. .footer {
  306. position: absolute;
  307. box-sizing: border-box;
  308. z-index: 2;
  309. bottom: 0;
  310. left: 0;
  311. img {
  312. display: inline-block;
  313. width: 100%;
  314. padding: 0 30px 30px 30px;
  315. }
  316. }
  317. }
  318. .login-main {
  319. position: absolute;
  320. width: 100%;
  321. height: 100%;
  322. z-index: 9;
  323. top: 0;
  324. left: 0;
  325. .logo-header {
  326. //上半部分登陆盒子,用来展示一张图片
  327. width: 100%;
  328. padding: 8vh 30px 30px 30px;
  329. .logo-header-title {
  330. font-size: 30px;
  331. // font-family: DIN;
  332. font-weight: bold;
  333. color: #daad70;
  334. margin: 12px 0;
  335. }
  336. .logo-header-tips {
  337. font-size: 15px;
  338. font-weight: 200;
  339. color: #daad70;
  340. margin: 10px 0;
  341. }
  342. }
  343. .loginBox {
  344. padding: 0 30px;
  345. box-sizing: border-box;
  346. position: relative;
  347. .loginBox-bg {
  348. position: relative;
  349. width: 100%;
  350. // height: 100px;
  351. img {
  352. width: 100%;
  353. display: inline-block;
  354. }
  355. }
  356. .login-form {
  357. position: absolute;
  358. top: 0;
  359. left: 30px;
  360. width: calc(100% - 60px);
  361. padding: 5.5vh 20px 0 14px;
  362. box-sizing: border-box;
  363. ul.ul {
  364. width: 100%;
  365. li.li-div {
  366. width: 100%;
  367. height: 55px;
  368. padding: 0 0 0.5vh;
  369. ul {
  370. li {
  371. float: left;
  372. &:first-child {
  373. width: 40px;
  374. height: 48px;
  375. line-height: 50px;
  376. text-align: center;
  377. img {
  378. display: inline-block;
  379. height: 18px;
  380. margin: 14px 0 0 0;
  381. }
  382. }
  383. &:last-child {
  384. width: calc(100% - 40px);
  385. }
  386. .zdyDiv {
  387. float: left;
  388. width: 100%;
  389. .zdyName {
  390. width: 55px;
  391. line-height: 48px;
  392. float: left;
  393. color: #000;
  394. text-align: right;
  395. font-size: 16px;
  396. }
  397. }
  398. .van-cell {
  399. float: left;
  400. background: transparent !important;
  401. padding-left: 1px;
  402. .van-cell__value {
  403. background: transparent !important;
  404. > div {
  405. background: transparent !important;
  406. input {
  407. background: transparent !important;
  408. }
  409. }
  410. }
  411. .van-field__control {
  412. font-size: 15px !important;
  413. }
  414. }
  415. }
  416. }
  417. &:first-child {
  418. ul {
  419. li {
  420. &:last-child {
  421. .van-cell {
  422. width: calc(100% - 55px);
  423. }
  424. }
  425. }
  426. }
  427. }
  428. }
  429. }
  430. }
  431. }
  432. .login-form-button {
  433. padding: 10vh 30px 0 30px;
  434. .van-button {
  435. background: linear-gradient(0deg, #a67e4b, #efc180);
  436. border-radius: 8px;
  437. overflow: hidden;
  438. color: #111111;
  439. border: 0;
  440. font-weight: bolder;
  441. }
  442. .reset-span {
  443. padding: 10px;
  444. color: #454545;
  445. }
  446. }
  447. }
  448. }
  449. .wrapper {
  450. display: flex;
  451. align-items: center;
  452. justify-content: center;
  453. height: 100%;
  454. }
  455. .block {
  456. width: 85%;
  457. border-radius:10px;
  458. background-color: #fff;
  459. font-size:14px;
  460. padding: 10px;
  461. text-align: left;
  462. h3{
  463. text-align: center;
  464. }
  465. .content{
  466. text-align: justify;
  467. text-indent:30px;
  468. padding:10px;
  469. line-height: 28px;
  470. }
  471. .button__wrapper{
  472. display: flex;
  473. align-items: center;
  474. justify-content: space-between;
  475. white-space: inherit;
  476. padding:0 10px;
  477. margin-bottom: 10px;
  478. button{
  479. height:32px;
  480. }
  481. }
  482. }
  483. </style>