login.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. <template>
  2. <view class="login-page">
  3. <view class="login-container">
  4. <view class="login-header">
  5. <text class="login-title">欢迎使用</text>
  6. </view>
  7. <view class="login-body">
  8. <van-button round type="info" size="large" @click="handleAuthorize" :loading="loading">
  9. 一键授权登录
  10. </van-button>
  11. </view>
  12. <view class="loading-container" v-if="loading">
  13. <view class="loading-spinner"></view>
  14. <text class="loading-text">正在登录...</text>
  15. </view>
  16. </view>
  17. </view>
  18. </template>
  19. <script>
  20. import { mapMutations } from "vuex";
  21. export default {
  22. data() {
  23. return {
  24. loading: false,
  25. };
  26. },
  27. methods: {
  28. ...mapMutations('m_user',['updateToken']),
  29. handleAuthorize() {
  30. this.loading = true;
  31. setTimeout(() => {
  32. this.loading = false;
  33. // 在这里添加登录成功后的逻辑
  34. console.log("登录成功");
  35. this.updateToken('123456')
  36. uni.showToast({
  37. title: '登录成功',
  38. icon: 'success',
  39. duration: 2000,
  40. });
  41. setTimeout(() => {
  42. uni.navigateBack({
  43. delta: 1
  44. })
  45. }, 1000);
  46. }, 3000);
  47. },
  48. },
  49. };
  50. </script>
  51. <style lang="scss">
  52. .login-page {
  53. background: linear-gradient(135deg, #6a82fb, #fc5c7d);
  54. height: 100vh;
  55. display: flex;
  56. justify-content: center;
  57. align-items: center;
  58. .login-container {
  59. background-color: #fff;
  60. border-radius: 12px;
  61. box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  62. padding: 24px;
  63. width: 80%;
  64. max-width: 400px;
  65. .login-header {
  66. text-align: center;
  67. margin-bottom: 24px;
  68. .login-title {
  69. font-size: 24px;
  70. font-weight: bold;
  71. color: #333;
  72. }
  73. }
  74. .login-body {
  75. text-align: center;
  76. }
  77. .loading-container {
  78. display: flex;
  79. flex-direction: column;
  80. align-items: center;
  81. margin-top: 24px;
  82. .loading-spinner {
  83. width: 30px;
  84. height: 30px;
  85. border: 4px solid #fc5c7d;
  86. border-top-color: transparent;
  87. border-radius: 50%;
  88. animation: spin 1s linear infinite;
  89. }
  90. .loading-text {
  91. margin-top: 8px;
  92. color: #666;
  93. font-size: 14px;
  94. }
  95. }
  96. }
  97. }
  98. @keyframes spin {
  99. from {
  100. transform: rotate(0deg);
  101. }
  102. to {
  103. transform: rotate(360deg);
  104. }
  105. }
  106. </style>