Login.vue 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <template>
  2. <view class="content">
  3. <image class="logo" src="/static/icons/logo.png"></image>
  4. <view class="title">
  5. 管理后台
  6. </view>
  7. <form @submit="loginSubmit">
  8. <view class="section">
  9. <input class="input-account" name="username" placeholder="请输入用户名" />
  10. </view>
  11. <view class="section">
  12. <input class="input-pwd" password name="password" placeholder="请输入密码" />
  13. </view>
  14. <view class="btn-area">
  15. <button type="primary" formType="submit" :loading="isLoading">{{loginBtnLabel}}</button>
  16. </view>
  17. </form>
  18. </view>
  19. </template>
  20. <script>
  21. import { mapState } from 'vuex';
  22. export default {
  23. computed: {
  24. ...mapState(['isLoading']),
  25. loginBtnLabel() {
  26. return this.isLoading ? '' : '登录';
  27. }
  28. },
  29. methods: {
  30. loginSubmit(event) {
  31. uni.hideKeyboard();
  32. const { value: loginForm } = event.detail;
  33. this.$store.dispatch('login', loginForm)
  34. .then(_ => {
  35. // uni.redirectTo({
  36. // url: '/pages/Charts/column',
  37. // });
  38. uni.reLaunch({
  39. url: '/pages/Charts/mainStatistics',
  40. });
  41. });
  42. }
  43. }
  44. }
  45. </script>
  46. <style lang="scss">
  47. page {
  48. padding: 200upx 0 0 0;
  49. background-image: url('~@/static/backgrounds/login_bg.png');
  50. background-repeat: no-repeat;
  51. background-size: 100% 100%;
  52. position: absolute;
  53. top: 0;
  54. left: 0;
  55. right: 0;
  56. bottom: 0;
  57. .content {
  58. padding: 0 20upx;
  59. display: flex;
  60. flex-flow: column nowrap;
  61. align-items: center;
  62. .logo {
  63. width: 401upx;
  64. height: 125upx;
  65. text-align: center;
  66. margin: 50upx;
  67. }
  68. form {
  69. width: calc(100% - 100upx);
  70. padding: 50upx;
  71. .section {
  72. margin: 50upx 0;
  73. }
  74. .btn-area {
  75. margin-top: 100upx;
  76. button {
  77. background-color: $uni-color-primary;
  78. }
  79. }
  80. }
  81. }
  82. }
  83. </style>