index.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. <template>
  2. <div>
  3. <div class="img_top">
  4. <img class="img" src="../../assets/login/bg.jpeg" />
  5. </div>
  6. <p class="title">邹平未保客户端</p>
  7. <van-form>
  8. <van-field
  9. v-model="username"
  10. name="用户名"
  11. label="用户名:"
  12. placeholder="用户名"
  13. :rules="[{ required: true, message: '请输入用户名' }]"
  14. />
  15. <van-field
  16. v-model="password"
  17. type="password"
  18. name="密码:"
  19. label="密码:"
  20. placeholder="密码"
  21. :rules="[{ required: true, message: '请输入密码' }]"
  22. />
  23. <div class="submit_bg" style="margin: 60px 26px">
  24. <van-button
  25. round
  26. block
  27. type="info"
  28. native-type="submit"
  29. @click="onSubmit"
  30. >登录</van-button
  31. >
  32. </div>
  33. </van-form>
  34. <div class="img_bottom">
  35. <img class="img" src="../../assets/login/bottomBg1.png" />
  36. </div>
  37. </div>
  38. </template>
  39. <script>
  40. import { loginApp } from '../../../../api/index.js'
  41. export default {
  42. components: {},
  43. name: "Login",
  44. data() {
  45. return {
  46. imgUrl: "../../assets/login/bg.jpeg",
  47. username: "",
  48. password: "",
  49. };
  50. },
  51. created() {},
  52. methods: {
  53. async onSubmit() {
  54. if(this.username == "" || this.password == "") {
  55. this.$toast("请输入账号或密码");
  56. return;
  57. }
  58. const res = await loginApp({
  59. loginName: this.username,//'15620220622'
  60. // loginName: '16601217325',
  61. password: this.password,//'123456'
  62. })
  63. if(res.data.jwtToken) {
  64. // this.$toast.success("登录成功");
  65. sessionStorage.setItem('userInfo', JSON.stringify(res.data))
  66. sessionStorage.setItem('x-token', res.data.jwtToken)
  67. this.$router.replace('/home')
  68. } else {
  69. this.$toast.fail("账号或密码错误");
  70. }
  71. }
  72. },
  73. };
  74. </script>
  75. <style lang="scss" scoped>
  76. .img_top {
  77. .img {
  78. width: 100%;
  79. height: 100%;
  80. position: fixed;
  81. top: 0;
  82. left: 0;
  83. z-index: -1;
  84. }
  85. }
  86. .title {
  87. margin: 300px 0 100px;
  88. height: 50px;
  89. line-height: 50px;
  90. font-style: normal;
  91. font-weight: 500;
  92. font-size: 48px;
  93. color: #1a1a1a;
  94. text-align: center;
  95. }
  96. /deep/.van-cell {
  97. margin-top: 100px;
  98. background-color:transparent;
  99. width: 94%;
  100. margin: 0 auto;
  101. border-bottom: 1px solid rgba(0, 0, 0, 0.35);
  102. .van-field__label {
  103. color: #2a2a2a;
  104. font-size: 30px;
  105. width: 120px;
  106. text-align: center;
  107. line-height: 80px;
  108. }
  109. .van-field__control {
  110. height: 80px;
  111. padding-left: 8px;
  112. box-sizing: border-box;
  113. color: #3d3d3d;
  114. font-size: 28px;
  115. }
  116. .van-field__control::placeholder {
  117. color: #3d3d3d;
  118. }
  119. .van-field__error-message {
  120. color: #1a1a1a;
  121. }
  122. }
  123. .img_bottom {
  124. .img {
  125. position: fixed;
  126. z-index: -1;
  127. bottom: 0;
  128. left: 0;
  129. width: 100%;
  130. }
  131. }
  132. </style>