splash.vue 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363
  1. <template>
  2. <view class="splash-container">
  3. <!-- 背景装饰 -->
  4. <view class="splash-bg-1"></view>
  5. <view class="splash-bg-2"></view>
  6. <!-- Logo 区域 -->
  7. <view class="logo-section">
  8. <view class="logo-wrapper">
  9. <view class="logo-glow"></view>
  10. <image class="logo-icon" src="/static/image/public/logo.png" mode="aspectFit"></image>
  11. </view>
  12. <text class="app-name">{{appName}}</text>
  13. <text class="app-slogan">您的客户关系管理助手</text>
  14. </view>
  15. <!-- 加载动画 -->
  16. <view class="loading-section">
  17. <text class="loading-text">
  18. 正在加载
  19. <view class="loading-dots">
  20. <view class="dot dot1"></view>
  21. <view class="dot dot2"></view>
  22. <view class="dot dot3"></view>
  23. </view>
  24. </text>
  25. </view>
  26. <!-- 版本信息 -->
  27. <view class="version-info">
  28. <text class="version-text">{{version}}</text>
  29. <view class="version-text">
  30. 浙江舒博特网络科技有限公司提供技术支持
  31. </view>
  32. </view>
  33. </view>
  34. </template>
  35. <script setup>
  36. import {
  37. ref,
  38. onMounted,
  39. } from 'vue'
  40. import {
  41. isLogin
  42. } from '@/utils/userCache.js'
  43. import {
  44. useUserStore
  45. } from '@/store/modules/user.js'
  46. import {
  47. onLoad,
  48. } from "@dcloudio/uni-app";
  49. const userStore = useUserStore() || null
  50. import {
  51. getCurrentConfig
  52. } from '@/config/index.js'
  53. const loadingText = ref('正在加载...')
  54. let appName = ref('')
  55. let version = ref('')
  56. // 页面加载
  57. onMounted(async () => {
  58. const config = await getCurrentConfig()
  59. appName.value = config.appName
  60. version.value = config.appVersion
  61. })
  62. onLoad((options) => {
  63. initApp(options?.userId)
  64. })
  65. /**
  66. * 初始化应用
  67. */
  68. const initApp = async (userId = null) => {
  69. try {
  70. // 模拟加载延迟(提升用户体验)
  71. await sleep(500)
  72. loadingText.value = '检查登录状态...'
  73. // 如果没有 token,直接跳转登录页
  74. const loginToggle = isLogin() || !!userId
  75. if (!loginToggle) {
  76. console.log('未登录,token 不存在')
  77. await sleep(800)
  78. uni.reLaunch({
  79. url: '/pages/login/login'
  80. })
  81. return
  82. }
  83. if (loginToggle) {
  84. await userStore.queryCardInfo(userId)
  85. await userStore.queryCompanyInfo(userId)
  86. await userStore.queryCardQrcode(userId)
  87. uni.reLaunch({
  88. url: !!userId ? '/pages/mine/userCard' : '/pages/index/index'
  89. })
  90. } else {
  91. clearUserInfo()
  92. await sleep(800)
  93. uni.reLaunch({
  94. url: '/pages/login/login'
  95. })
  96. }
  97. } catch (error) {
  98. console.error('验证登录态失败:', error)
  99. clearUserInfo()
  100. uni.reLaunch({
  101. url: '/pages/login/login'
  102. })
  103. }
  104. }
  105. /**
  106. * 延时函数
  107. * @param {number} ms - 毫秒数
  108. */
  109. const sleep = (ms) => {
  110. return new Promise(resolve => setTimeout(resolve, ms))
  111. }
  112. </script>
  113. <style lang="scss" scoped>
  114. .splash-container {
  115. min-height: 100vh;
  116. background: linear-gradient(135deg, #4A90E2 0%, #6FB3F2 50%, #87CEEB 100%);
  117. position: relative;
  118. overflow: hidden;
  119. display: flex;
  120. flex-direction: column;
  121. align-items: center;
  122. justify-content: center;
  123. padding: 0 40rpx;
  124. .splash-bg-1 {
  125. position: absolute;
  126. top: -20%;
  127. left: -10%;
  128. width: 60%;
  129. height: 60%;
  130. background: radial-gradient(circle, rgba(255, 255, 255, 0.15) 0%, transparent 70%);
  131. border-radius: 50%;
  132. animation: floatBg1 8s ease-in-out infinite;
  133. }
  134. .splash-bg-2 {
  135. position: absolute;
  136. bottom: -20%;
  137. right: -10%;
  138. width: 70%;
  139. height: 70%;
  140. background: radial-gradient(circle, rgba(255, 255, 255, 0.12) 0%, transparent 70%);
  141. border-radius: 50%;
  142. animation: floatBg2 10s ease-in-out infinite;
  143. }
  144. }
  145. // Logo 区域
  146. .logo-section {
  147. display: flex;
  148. flex-direction: column;
  149. align-items: center;
  150. margin-bottom: 120rpx;
  151. position: relative;
  152. z-index: 10;
  153. .logo-wrapper {
  154. position: relative;
  155. width: 240rpx;
  156. height: 240rpx;
  157. display: flex;
  158. align-items: center;
  159. justify-content: center;
  160. .logo-glow {
  161. position: absolute;
  162. top: 50%;
  163. left: 50%;
  164. transform: translate(-50%, -50%);
  165. width: 280rpx;
  166. height: 280rpx;
  167. background: radial-gradient(circle, rgba(255, 255, 255, 0.3) 0%, transparent 70%);
  168. border-radius: 50%;
  169. animation: logoGlow 3s ease-in-out infinite;
  170. }
  171. .logo-icon {
  172. width: 200rpx;
  173. height: 200rpx;
  174. border-radius: 44rpx;
  175. background: rgba(255, 255, 255, 0.95);
  176. box-shadow: 0 20rpx 60rpx rgba(0, 0, 0, 0.15),
  177. 0 0 40rpx rgba(255, 255, 255, 0.3);
  178. display: flex;
  179. align-items: center;
  180. justify-content: center;
  181. animation: logoFloat 3s ease-in-out infinite;
  182. position: relative;
  183. z-index: 2;
  184. }
  185. }
  186. .app-name {
  187. font-size: 48rpx;
  188. font-weight: 600;
  189. color: #ffffff;
  190. margin-top: 48rpx;
  191. letter-spacing: 3rpx;
  192. text-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.15);
  193. }
  194. .app-slogan {
  195. font-size: 26rpx;
  196. color: rgba(255, 255, 255, 0.85);
  197. margin-top: 20rpx;
  198. letter-spacing: 1rpx;
  199. text-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.1);
  200. }
  201. }
  202. // 加载动画
  203. .loading-section {
  204. display: flex;
  205. flex-direction: column;
  206. align-items: center;
  207. position: relative;
  208. z-index: 10;
  209. .loading-text {
  210. font-size: 28rpx;
  211. color: rgba(255, 255, 255, 0.95);
  212. letter-spacing: 2rpx;
  213. text-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.1);
  214. display: flex;
  215. align-items: center;
  216. justify-content: center;
  217. background: rgba(255, 255, 255, 0.15);
  218. padding: 20rpx 40rpx;
  219. border-radius: 40rpx;
  220. backdrop-filter: blur(10rpx);
  221. box-shadow: 0 8rpx 32rpx rgba(0, 0, 0, 0.1);
  222. .loading-dots {
  223. display: flex;
  224. justify-content: center;
  225. align-items: center;
  226. margin-left: 8rpx;
  227. height: 20rpx;
  228. .dot {
  229. width: 12rpx;
  230. height: 12rpx;
  231. border-radius: 50%;
  232. background-color: #ffffff;
  233. margin: 0 4rpx;
  234. opacity: 0.4;
  235. box-shadow: 0 0 15rpx rgba(255, 255, 255, 0.5);
  236. }
  237. .dot1 {
  238. animation: loadingDot 1.4s ease-in-out infinite;
  239. }
  240. .dot2 {
  241. animation: loadingDot 1.4s ease-in-out 0.2s infinite;
  242. }
  243. .dot3 {
  244. animation: loadingDot 1.4s ease-in-out 0.4s infinite;
  245. }
  246. }
  247. }
  248. }
  249. // 版本信息
  250. .version-info {
  251. position: absolute;
  252. bottom: 80rpx;
  253. display: flex;
  254. flex-direction: column;
  255. align-items: center;
  256. justify-content: center;
  257. z-index: 10;
  258. background: rgba(255, 255, 255, 0.1);
  259. padding: 20rpx 40rpx;
  260. border-radius: 32rpx;
  261. backdrop-filter: blur(10rpx);
  262. box-shadow: 0 8rpx 32rpx rgba(0, 0, 0, 0.1);
  263. border: 1rpx solid rgba(255, 255, 255, 0.2);
  264. .version-text {
  265. font-size: 22rpx;
  266. color: rgba(255, 255, 255, 0.7);
  267. text-align: center;
  268. line-height: 1.6;
  269. text-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.1);
  270. }
  271. }
  272. // 动画
  273. @keyframes logoFloat {
  274. 0%,
  275. 100% {
  276. transform: translateY(0) scale(1);
  277. }
  278. 50% {
  279. transform: translateY(-15rpx) scale(1.02);
  280. }
  281. }
  282. @keyframes logoGlow {
  283. 0%,
  284. 100% {
  285. opacity: 0.5;
  286. transform: translate(-50%, -50%) scale(1);
  287. }
  288. 50% {
  289. opacity: 0.8;
  290. transform: translate(-50%, -50%) scale(1.1);
  291. }
  292. }
  293. @keyframes loadingDot {
  294. 0%,
  295. 80%,
  296. 100% {
  297. transform: scale(0.8);
  298. opacity: 0.4;
  299. }
  300. 40% {
  301. transform: scale(1.2);
  302. opacity: 1;
  303. }
  304. }
  305. @keyframes floatBg1 {
  306. 0%,
  307. 100% {
  308. transform: translate(0, 0) scale(1);
  309. }
  310. 50% {
  311. transform: translate(30rpx, -30rpx) scale(1.05);
  312. }
  313. }
  314. @keyframes floatBg2 {
  315. 0%,
  316. 100% {
  317. transform: translate(0, 0) scale(1);
  318. }
  319. 50% {
  320. transform: translate(-30rpx, 30rpx) scale(1.08);
  321. }
  322. }
  323. </style>