login.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. <template>
  2. <!-- 开启顶部安全区适配 -->
  3. <van-nav-bar
  4. :border="false"
  5. safe-area-inset-top
  6. style="background-color: #5c8fff"
  7. />
  8. <div class="page_login">
  9. <div class="login_bg">
  10. <div class="bg_title">
  11. <van-image
  12. :src="require('@/assets/logo.svg')"
  13. width="32"
  14. height="32"
  15. fit="contain"
  16. />
  17. <span>双碳感知资产运营管理平台</span>
  18. </div>
  19. </div>
  20. <div class="login_info">
  21. <div class="info_content">
  22. <div class="title">
  23. <span>登录</span>
  24. </div>
  25. <van-form @submit="onSubmit">
  26. <van-cell-group>
  27. <van-field
  28. v-model="tel"
  29. name="手机号"
  30. :left-icon="require('@/assets/phone.svg')"
  31. placeholder="请输入手机号码"
  32. :clearable="true"
  33. :rules="[{ required: true, message: '请输入手机号码' }]"
  34. style="margin-bottom: 20px"
  35. />
  36. <van-field
  37. v-model="password"
  38. type="password"
  39. name="密码"
  40. :left-icon="require('@/assets/password.svg')"
  41. placeholder="请输入密码"
  42. :clearable="true"
  43. :rules="[{ required: true, message: '请输入密码' }]"
  44. />
  45. </van-cell-group>
  46. <div style="margin-top: 50px">
  47. <van-button
  48. round
  49. block
  50. type="primary"
  51. color="#2E69EB"
  52. :loading="loading"
  53. loading-text="登陆中。。。"
  54. native-type="submit"
  55. >
  56. 登录
  57. </van-button>
  58. </div>
  59. </van-form>
  60. </div>
  61. </div>
  62. </div>
  63. </template>
  64. <script>
  65. import { getUserInfo } from "../utils/api";
  66. export default {
  67. data() {
  68. return {
  69. loading: false,
  70. tel: "",
  71. password: "",
  72. };
  73. },
  74. mounted() {
  75. window.localStorage.setItem("token", "");
  76. window.localStorage.setItem("role", "");
  77. },
  78. methods: {
  79. onSubmit() {
  80. this.loading = true;
  81. setTimeout(() => {
  82. this.loading = false;
  83. this.$router.push("/home");
  84. }, 2000);
  85. // Api.loginByPwd({
  86. // username: this.tel,
  87. // password: this.password,
  88. // captcha: "1",
  89. // uuid: "1",
  90. // }).then((res) => {
  91. // this.loading = false
  92. // if (res.code == 0) {
  93. // this.$toast.clear();
  94. // window.localStorage.setItem("token", res.data.token);
  95. // this.getUserInfo();
  96. // } else {
  97. // this.$notify({ type: "danger", message: res.msg });
  98. // }
  99. // });
  100. },
  101. getUserInfo() {
  102. Api.getUserInfo({
  103. username: this.tel,
  104. password: this.password,
  105. }).then((res) => {
  106. if (res.code == 0) {
  107. } else {
  108. this.$notify({ type: "danger", message: res.msg });
  109. }
  110. });
  111. },
  112. },
  113. };
  114. </script>
  115. <style lang="scss" scoped>
  116. .page_login {
  117. position: relative;
  118. .login_bg {
  119. width: 100%;
  120. height: 245px;
  121. background: #5c8fff;
  122. border-radius: 0px 0px 16px 16px;
  123. padding-top: 16px;
  124. .bg_title {
  125. display: flex;
  126. align-items: center;
  127. justify-content: center;
  128. span {
  129. height: 24px;
  130. font-size: 18px;
  131. font-weight: 600;
  132. color: #ffffff;
  133. line-height: 24px;
  134. text-align: center;
  135. }
  136. }
  137. }
  138. .login_info {
  139. position: absolute;
  140. top: 142px;
  141. width: calc(100% - 32px);
  142. padding: 0 16px;
  143. .info_content {
  144. background: #ffffff;
  145. box-shadow: 0px 0px 8px 0px rgba(51, 51, 51, 0.08);
  146. border-radius: 16px;
  147. padding: 30px 20px 50px 20px;
  148. .title {
  149. display: flex;
  150. align-items: center;
  151. justify-content: center;
  152. margin-bottom: 30px;
  153. span {
  154. height: 24px;
  155. font-size: 20px;
  156. font-weight: 600;
  157. color: #0c1935;
  158. line-height: 24px;
  159. }
  160. }
  161. }
  162. }
  163. /deep/ {
  164. --van-cell-vertical-padding: 8px;
  165. .van-icon__image {
  166. margin-top: 4px;
  167. }
  168. .van-field {
  169. background: #f4f7ff;
  170. border-radius: 18px;
  171. border: 1px solid #5c8fff;
  172. }
  173. }
  174. }
  175. </style>