血透系统pad前端

login.vue 4.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. <template>
  2. <div class="container">
  3. <div class="login">
  4. <div class="logo"><img src="../../assets/login/logo.png" alt=""></div>
  5. <div class="reg">
  6. <div class="form">
  7. <ul>
  8. <li>
  9. <span class="iconfont">&#xe78b;</span>
  10. <input placeholder="请输入手机号" type="tel" class="tel" v-model="form.mobile">
  11. </li>
  12. <li>
  13. <span class="iconfont">&#xe6c0;</span>
  14. <input placeholder="请输入密码" type="password" class="tel" v-model="form.pwd">
  15. </li>
  16. </ul>
  17. </div>
  18. <!-- <router-link to="/product"> -->
  19. <button class="loginBtn" @click="loginAction" :class="loginDisable ? 'disableLoginBtn' : ''" :disabled="loginDisable">登录</button>
  20. <!-- </router-link> -->
  21. <!-- <div class="forget">
  22. <a href="">免密码登录</a>
  23. <a href="">忘记密码?</a>
  24. </div> -->
  25. </div>
  26. </div>
  27. </div>
  28. </template>
  29. <script>
  30. import {loginByPwd} from "@/api/login"
  31. import {hex_md5} from "@/utils/md5"
  32. import { getLoginInfoCache, cacheLoginInfo } from '@/utils/admin_info_cache'
  33. export default {
  34. name: "Home",
  35. data() {
  36. return {
  37. form: {
  38. mobile: "",
  39. pwd: "",
  40. },
  41. }
  42. },
  43. computed: {
  44. loginDisable() {
  45. // return false
  46. return this.form.mobile.length == 0 || /^1[234578]\d{9}$/.test(this.form.mobile) == false || this.form.pwd.length == 0
  47. }
  48. },
  49. created() {
  50. var loginInfo = getLoginInfoCache()
  51. this.form.mobile = loginInfo.mobile
  52. this.form.pwd = loginInfo.password
  53. },
  54. methods: {
  55. loginAction: function() {
  56. loginByPwd(this.form.mobile, hex_md5(this.form.pwd)).then(rs => {
  57. var resp = rs.data
  58. if (resp.state == 1) {
  59. cacheLoginInfo(this.form.mobile, this.form.pwd)
  60. var user = resp.data.user
  61. var org = resp.data.org
  62. var subscibe = resp.data.subscibe
  63. var config_list = resp.data.config_list
  64. this.$store.dispatch("InitUserInfo", {user: user, org: org, subscibe: subscibe })
  65. this.$store.dispatch("SetConfigList", config_list)
  66. // this.$router.push({path: "/product"})
  67. this.$router.push({path: "/main"})
  68. } else {
  69. this.$toast({
  70. message: resp.msg,
  71. })
  72. }
  73. })
  74. }
  75. }
  76. };
  77. </script>
  78. <style rel="stylesheet/scss" lang="scss" scoped >
  79. .container {
  80. background: $white-bg;
  81. @include box-sizing;
  82. position: fixed;
  83. width: 100%;
  84. height: 100%;
  85. .login {
  86. // @include box-shadow;
  87. @include text-align;
  88. @include display-flex;
  89. @include align-items-center;
  90. @include justify-content-center;
  91. @include flex-direction;
  92. height: 100%;
  93. .logo {
  94. padding: 0 0 1rem;
  95. img {
  96. width: 70%;
  97. height: auto;
  98. display: inline-block;
  99. }
  100. }
  101. .reg {
  102. width: 10.77rem;
  103. .form {
  104. border: 1px $border-color solid;
  105. border-radius: 4px;
  106. li {
  107. border-bottom: 1px $border-color solid;
  108. @include align-items-center;
  109. @include text-align;
  110. @include display-flex;
  111. @include box-sizing;
  112. .tel {
  113. padding: 0.4rem 0;
  114. width: 90%;
  115. border: none;
  116. outline: none;
  117. font-size: 0.34rem;
  118. }
  119. .mint-cell {
  120. width: 100%;
  121. }
  122. &:last-child {
  123. border: none;
  124. }
  125. .iconfont {
  126. color: $main-color;
  127. font-size: 0.5rem;
  128. margin: 0 0.46rem;
  129. }
  130. }
  131. }
  132. .forget {
  133. text-align: left;
  134. padding: 0.45rem 1rem;
  135. a {
  136. float: left;
  137. font-size: 0.28rem;
  138. color: $main-color;
  139. &:nth-child(2) {
  140. color: #999999;
  141. float: right;
  142. }
  143. &:active {
  144. background: $white-bg;
  145. }
  146. }
  147. }
  148. .loginBtn {
  149. width: 100%;
  150. height: 1rem;
  151. line-height: 1rem;
  152. background: $main-color;
  153. color: #fff;
  154. font-size: 0.36rem;
  155. @include text-align;
  156. border-radius: 4px;
  157. margin: 40px 0 0 0;
  158. }
  159. .disableLoginBtn {
  160. background: lightgray;
  161. }
  162. }
  163. }
  164. }
  165. </style>