splash.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. <template>
  2. <view class="splash-container">
  3. <!-- Logo 区域 -->
  4. <view class="logo-section">
  5. <view class="logo-icon">
  6. <!-- 蓝色圆角正方形 logo -->
  7. </view>
  8. <text class="app-name">布尔销销乐</text>
  9. <text class="app-slogan">您的客户关系管理助手</text>
  10. </view>
  11. <!-- 加载动画 -->
  12. <view class="loading-section">
  13. <view class="loading-dots">
  14. <view class="dot dot1"></view>
  15. <view class="dot dot2"></view>
  16. <view class="dot dot3"></view>
  17. </view>
  18. <text class="loading-text">{{ loadingText }}</text>
  19. </view>
  20. <!-- 版本信息 -->
  21. <view class="version-info">
  22. <text class="version-text">v1.0.0</text>
  23. </view>
  24. </view>
  25. </template>
  26. <script setup>
  27. import { ref, onMounted } from 'vue'
  28. import { isLogin } from '@/utils/userCache.js'
  29. const loadingText = ref('正在加载...')
  30. // 页面加载
  31. onMounted(() => {
  32. initApp()
  33. })
  34. /**
  35. * 初始化应用
  36. */
  37. const initApp = async () => {
  38. try {
  39. // 模拟加载延迟(提升用户体验)
  40. // await sleep(500)
  41. loadingText.value = '检查登录状态...'
  42. // 检查登录状态
  43. // const loggedIn = isLogin()
  44. // 再延迟一点,让动画更流畅
  45. // await sleep(800)
  46. if (true) {
  47. // 已登录,跳转首页
  48. uni.reLaunch({
  49. url: '/pages/index/index'
  50. })
  51. } else {
  52. // 未登录,跳转登录页
  53. uni.reLaunch({
  54. url: '/pages/login/login'
  55. })
  56. }
  57. } catch (error) {
  58. console.error('初始化失败:', error)
  59. // 出错时跳转到登录页
  60. uni.reLaunch({
  61. url: '/pages/login/login'
  62. })
  63. }
  64. }
  65. /**
  66. * 延时函数
  67. * @param {number} ms - 毫秒数
  68. */
  69. const sleep = (ms) => {
  70. return new Promise(resolve => setTimeout(resolve, ms))
  71. }
  72. </script>
  73. <style lang="scss" scoped>
  74. .splash-container {
  75. min-height: 100vh;
  76. background: linear-gradient(135deg, #1890ff 0%, #096dd9 100%);
  77. display: flex;
  78. flex-direction: column;
  79. align-items: center;
  80. justify-content: center;
  81. padding: 0 40rpx;
  82. }
  83. // Logo 区域
  84. .logo-section {
  85. display: flex;
  86. flex-direction: column;
  87. align-items: center;
  88. margin-bottom: 120rpx;
  89. .logo-icon {
  90. width: 200rpx;
  91. height: 200rpx;
  92. background: linear-gradient(135deg, #ffffff 0%, #e6f7ff 100%);
  93. border-radius: 40rpx;
  94. box-shadow: 0 16rpx 48rpx rgba(0, 0, 0, 0.2);
  95. display: flex;
  96. align-items: center;
  97. justify-content: center;
  98. animation: logoFloat 2s ease-in-out infinite;
  99. }
  100. .app-name {
  101. font-size: 48rpx;
  102. font-weight: 600;
  103. color: #ffffff;
  104. margin-top: 40rpx;
  105. letter-spacing: 2rpx;
  106. }
  107. .app-slogan {
  108. font-size: 26rpx;
  109. color: rgba(255, 255, 255, 0.8);
  110. margin-top: 16rpx;
  111. }
  112. }
  113. // 加载动画
  114. .loading-section {
  115. display: flex;
  116. flex-direction: column;
  117. align-items: center;
  118. .loading-dots {
  119. display: flex;
  120. justify-content: center;
  121. align-items: center;
  122. margin-bottom: 24rpx;
  123. .dot {
  124. width: 20rpx;
  125. height: 20rpx;
  126. border-radius: 50%;
  127. background-color: #ffffff;
  128. margin: 0 8rpx;
  129. opacity: 0.3;
  130. }
  131. .dot1 {
  132. animation: loadingDot 1.4s ease-in-out infinite;
  133. }
  134. .dot2 {
  135. animation: loadingDot 1.4s ease-in-out 0.2s infinite;
  136. }
  137. .dot3 {
  138. animation: loadingDot 1.4s ease-in-out 0.4s infinite;
  139. }
  140. }
  141. .loading-text {
  142. font-size: 26rpx;
  143. color: rgba(255, 255, 255, 0.9);
  144. }
  145. }
  146. // 版本信息
  147. .version-info {
  148. position: absolute;
  149. bottom: 80rpx;
  150. .version-text {
  151. font-size: 22rpx;
  152. color: rgba(255, 255, 255, 0.6);
  153. }
  154. }
  155. // 动画
  156. @keyframes logoFloat {
  157. 0%, 100% {
  158. transform: translateY(0);
  159. }
  160. 50% {
  161. transform: translateY(-20rpx);
  162. }
  163. }
  164. @keyframes loadingDot {
  165. 0%, 80%, 100% {
  166. transform: scale(0.6);
  167. opacity: 0.3;
  168. }
  169. 40% {
  170. transform: scale(1);
  171. opacity: 1;
  172. }
  173. }
  174. </style>