splash.vue 7.3 KB

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