Login.vue 5.8 KB

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