Login.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298
  1. <!--
  2. 描述: 登录模板
  3. 作者: Jack Chen
  4. 日期: 2020-04-18
  5. -->
  6. <template>
  7. <div class="login-container">
  8. <div class="layer">
  9. <div class="some-space">
  10. <div class="form">
  11. <h2>大数据可视化平台</h2>
  12. <div class="item">
  13. <i class="iconfont icon-user"></i>
  14. <input
  15. autocomplete="off"
  16. type="text"
  17. class="input"
  18. v-model="userName"
  19. placeholder="请输入用户名"
  20. />
  21. </div>
  22. <div class="item">
  23. <i class="iconfont icon-password"></i>
  24. <input
  25. autocomplete="off"
  26. type="password"
  27. class="input"
  28. v-model="userPwd"
  29. maxlength="20"
  30. @keyup.enter="login"
  31. placeholder="请输入密码"
  32. />
  33. </div>
  34. <button class="loginBtn" :disabled="isLoginAble" @click.stop="login">
  35. 立即登录
  36. </button>
  37. <div class="tip">默认用户名:admin ,默认密码:123456</div>
  38. </div>
  39. </div>
  40. </div>
  41. <vue-particles
  42. color="#6495ED"
  43. :particleOpacity="0.7"
  44. :particlesNumber="80"
  45. shapeType="circle"
  46. :particleSize="4"
  47. linesColor="#6495ED"
  48. :linesWidth="1"
  49. :lineLinked="true"
  50. :lineOpacity="0.6"
  51. :linesDistance="150"
  52. :moveSpeed="3"
  53. :hoverEffect="true"
  54. hoverMode="grab"
  55. :clickEffect="true"
  56. clickMode="push"
  57. >
  58. </vue-particles>
  59. <bgAnimation />
  60. <modal
  61. title="提示"
  62. :content="modalContent"
  63. :visible.sync="visible"
  64. @confirm="confirm"
  65. >
  66. </modal>
  67. </div>
  68. </template>
  69. <script>
  70. export default {
  71. name: `Login`,
  72. components: {},
  73. data() {
  74. return {
  75. userName: `admin`,
  76. userPwd: `123456`,
  77. visible: false,
  78. modalContent: `这是一段自定义模态框消息`,
  79. }
  80. },
  81. computed: {
  82. isLoginAble() {
  83. return !(this.userName && this.userPwd)
  84. },
  85. },
  86. created() {},
  87. mounted() {},
  88. methods: {
  89. async login() {
  90. await this.$http
  91. .post(`/api/login`, {
  92. userName: this.userName,
  93. userPwd: this.userPwd,
  94. })
  95. .then((res) => {
  96. this.$router.push({
  97. path: `/page1`,
  98. })
  99. })
  100. .catch(() => {
  101. this.$Toast({
  102. content: `请输入正确的用户名和密码`,
  103. type: `error`,
  104. })
  105. })
  106. },
  107. confirm() {
  108. this.visible = false
  109. console.log(`点击确定`)
  110. },
  111. },
  112. }
  113. </script>
  114. <style lang="less" scoped>
  115. .login-container {
  116. .layer {
  117. position: absolute;
  118. height: 100%;
  119. width: 100%;
  120. }
  121. #particles-js {
  122. position: absolute;
  123. top: 0;
  124. left: 0;
  125. width: 100%;
  126. height: 100%;
  127. z-index: 1000;
  128. }
  129. .some-space {
  130. color: white;
  131. font-weight: 100;
  132. letter-spacing: 2px;
  133. position: absolute;
  134. top: 50%;
  135. left: 50%;
  136. z-index: 1001;
  137. -webkit-transform: translate3d(-50%, -50%, 0);
  138. transform: translate3d(-50%, -50%, 0);
  139. -ms-animation: cloud 2s 3s ease-in infinite alternate;
  140. -moz-animation: cloud 2s 3s ease-in infinite alternate;
  141. -webkit-animation: cloud 2s 3s ease-in infinite alternate;
  142. -o-animation: cloud 2s 3s ease-in infinite alternate;
  143. -webkit-animation: cloud 2s 3s ease-in infinite alternate;
  144. animation: cloud 2s 3s ease-in infinite alternate;
  145. .form {
  146. width: 460px;
  147. height: auto;
  148. background: rgba(36, 36, 85, 0.5);
  149. margin: 0 auto;
  150. padding: 35px 30px 25px;
  151. box-shadow: 0 0 25px rgba(255, 255, 255, 0.5);
  152. border-radius: 10px;
  153. .item {
  154. display: flex;
  155. align-items: center;
  156. margin-bottom: 25px;
  157. border-bottom: 1px solid #d3d7f7;
  158. i {
  159. color: #d3d7f7;
  160. margin-right: 10px;
  161. }
  162. }
  163. h2 {
  164. text-align: center;
  165. font-weight: normal;
  166. font-size: 26px;
  167. color: #d3d7f7;
  168. padding-bottom: 35px;
  169. }
  170. .input {
  171. font-size: 16px;
  172. line-height: 30px;
  173. width: 100%;
  174. color: #d3d7f7;
  175. outline: none;
  176. border: none;
  177. background-color: rgba(0, 0, 0, 0);
  178. padding: 10px 0;
  179. }
  180. .loginBtn {
  181. width: 100%;
  182. padding: 12px 0;
  183. border: 1px solid #d3d7f7;
  184. font-size: 16px;
  185. color: #d3d7f7;
  186. cursor: pointer;
  187. background: transparent;
  188. border-radius: 4px;
  189. margin-top: 10px;
  190. &:hover {
  191. color: #fff;
  192. background: #0090ff;
  193. border-color: #0090ff;
  194. }
  195. }
  196. .tip {
  197. font-size: 12px;
  198. padding-top: 20px;
  199. }
  200. }
  201. }
  202. }
  203. input::-webkit-input-placeholder {
  204. color: #d3d7f7;
  205. }
  206. input::-moz-placeholder {
  207. /* Mozilla Firefox 19+ */
  208. color: #d3d7f7;
  209. }
  210. input:-moz-placeholder {
  211. /* Mozilla Firefox 4 to 18 */
  212. color: #d3d7f7;
  213. }
  214. input:-ms-input-placeholder {
  215. /* Internet Explorer 10-11 */
  216. color: #d3d7f7;
  217. }
  218. @-ms-keyframes cloud {
  219. 0% {
  220. -ms-transform: translate(-50%, -50%);
  221. }
  222. 40% {
  223. opacity: 1;
  224. }
  225. 60% {
  226. opacity: 1;
  227. }
  228. 100% {
  229. -ms-transform: translate(-50%, -40%);
  230. }
  231. }
  232. @-moz-keyframes cloud {
  233. 0% {
  234. -moz-transform: translate(-50%, -50%);
  235. }
  236. 40% {
  237. opacity: 1;
  238. }
  239. 60% {
  240. opacity: 1;
  241. }
  242. 100% {
  243. -moz-transform: translate(-50%, -40%);
  244. }
  245. }
  246. @-o-keyframes cloud {
  247. 0% {
  248. -o-transform: translate(-50%, -50%);
  249. }
  250. 40% {
  251. opacity: 1;
  252. }
  253. 60% {
  254. opacity: 1;
  255. }
  256. 100% {
  257. -o-transform: translate(-50%, -40%);
  258. }
  259. }
  260. @-webkit-keyframes cloud {
  261. 0% {
  262. -webkit-transform: translate(-50%, -50%);
  263. }
  264. 40% {
  265. opacity: 1;
  266. }
  267. 60% {
  268. opacity: 1;
  269. }
  270. 100% {
  271. -webkit-transform: translate(-50%, -40%);
  272. }
  273. }
  274. @keyframes cloud {
  275. 0% {
  276. transform: translate(-50%, -50%);
  277. }
  278. 40% {
  279. opacity: 1;
  280. }
  281. 60% {
  282. opacity: 1;
  283. }
  284. 100% {
  285. transform: translate(-50%, -40%);
  286. }
  287. }
  288. </style>