Login.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300
  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: `admin123`,
  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. localStorage.setItem(`token`, res.token)
  97. this.$router.push({
  98. path: `/page1`,
  99. })
  100. })
  101. .catch((xx) => {
  102. console.log(`xxx`, xx)
  103. this.$Toast({
  104. content: `请输入正确的用户名和密码`,
  105. type: `error`,
  106. })
  107. })
  108. },
  109. confirm() {
  110. this.visible = false
  111. console.log(`点击确定`)
  112. },
  113. },
  114. }
  115. </script>
  116. <style lang="less" scoped>
  117. .login-container {
  118. .layer {
  119. position: absolute;
  120. height: 100%;
  121. width: 100%;
  122. }
  123. #particles-js {
  124. position: absolute;
  125. top: 0;
  126. left: 0;
  127. width: 100%;
  128. height: 100%;
  129. z-index: 1000;
  130. }
  131. .some-space {
  132. color: white;
  133. font-weight: 100;
  134. letter-spacing: 2px;
  135. position: absolute;
  136. top: 50%;
  137. left: 50%;
  138. z-index: 1001;
  139. -webkit-transform: translate3d(-50%, -50%, 0);
  140. transform: translate3d(-50%, -50%, 0);
  141. -ms-animation: cloud 2s 3s ease-in infinite alternate;
  142. -moz-animation: cloud 2s 3s ease-in infinite alternate;
  143. -webkit-animation: cloud 2s 3s ease-in infinite alternate;
  144. -o-animation: cloud 2s 3s ease-in infinite alternate;
  145. -webkit-animation: cloud 2s 3s ease-in infinite alternate;
  146. animation: cloud 2s 3s ease-in infinite alternate;
  147. .form {
  148. width: 460px;
  149. height: auto;
  150. background: rgba(36, 36, 85, 0.5);
  151. margin: 0 auto;
  152. padding: 35px 30px 25px;
  153. box-shadow: 0 0 25px rgba(255, 255, 255, 0.5);
  154. border-radius: 10px;
  155. .item {
  156. display: flex;
  157. align-items: center;
  158. margin-bottom: 25px;
  159. border-bottom: 1px solid #d3d7f7;
  160. i {
  161. color: #d3d7f7;
  162. margin-right: 10px;
  163. }
  164. }
  165. h2 {
  166. text-align: center;
  167. font-weight: normal;
  168. font-size: 26px;
  169. color: #d3d7f7;
  170. padding-bottom: 35px;
  171. }
  172. .input {
  173. font-size: 16px;
  174. line-height: 30px;
  175. width: 100%;
  176. color: #d3d7f7;
  177. outline: none;
  178. border: none;
  179. background-color: rgba(0, 0, 0, 0);
  180. padding: 10px 0;
  181. }
  182. .loginBtn {
  183. width: 100%;
  184. padding: 12px 0;
  185. border: 1px solid #d3d7f7;
  186. font-size: 16px;
  187. color: #d3d7f7;
  188. cursor: pointer;
  189. background: transparent;
  190. border-radius: 4px;
  191. margin-top: 10px;
  192. &:hover {
  193. color: #fff;
  194. background: #0090ff;
  195. border-color: #0090ff;
  196. }
  197. }
  198. .tip {
  199. font-size: 12px;
  200. padding-top: 20px;
  201. }
  202. }
  203. }
  204. }
  205. input::-webkit-input-placeholder {
  206. color: #d3d7f7;
  207. }
  208. input::-moz-placeholder {
  209. /* Mozilla Firefox 19+ */
  210. color: #d3d7f7;
  211. }
  212. input:-moz-placeholder {
  213. /* Mozilla Firefox 4 to 18 */
  214. color: #d3d7f7;
  215. }
  216. input:-ms-input-placeholder {
  217. /* Internet Explorer 10-11 */
  218. color: #d3d7f7;
  219. }
  220. @-ms-keyframes cloud {
  221. 0% {
  222. -ms-transform: translate(-50%, -50%);
  223. }
  224. 40% {
  225. opacity: 1;
  226. }
  227. 60% {
  228. opacity: 1;
  229. }
  230. 100% {
  231. -ms-transform: translate(-50%, -40%);
  232. }
  233. }
  234. @-moz-keyframes cloud {
  235. 0% {
  236. -moz-transform: translate(-50%, -50%);
  237. }
  238. 40% {
  239. opacity: 1;
  240. }
  241. 60% {
  242. opacity: 1;
  243. }
  244. 100% {
  245. -moz-transform: translate(-50%, -40%);
  246. }
  247. }
  248. @-o-keyframes cloud {
  249. 0% {
  250. -o-transform: translate(-50%, -50%);
  251. }
  252. 40% {
  253. opacity: 1;
  254. }
  255. 60% {
  256. opacity: 1;
  257. }
  258. 100% {
  259. -o-transform: translate(-50%, -40%);
  260. }
  261. }
  262. @-webkit-keyframes cloud {
  263. 0% {
  264. -webkit-transform: translate(-50%, -50%);
  265. }
  266. 40% {
  267. opacity: 1;
  268. }
  269. 60% {
  270. opacity: 1;
  271. }
  272. 100% {
  273. -webkit-transform: translate(-50%, -40%);
  274. }
  275. }
  276. @keyframes cloud {
  277. 0% {
  278. transform: translate(-50%, -50%);
  279. }
  280. 40% {
  281. opacity: 1;
  282. }
  283. 60% {
  284. opacity: 1;
  285. }
  286. 100% {
  287. transform: translate(-50%, -40%);
  288. }
  289. }
  290. </style>