splash.vue 4.0 KB

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