splash.vue 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375
  1. <template>
  2. <view class="splash-container">
  3. <view class="splash-bg-1"></view>
  4. <view class="splash-bg-2"></view>
  5. <view class="logo-section">
  6. <view class="logo-wrapper">
  7. <view class="logo-glow"></view>
  8. <image class="logo-icon" src="/static/image/public/logo.png" mode="aspectFit"></image>
  9. </view>
  10. <text class="app-name">{{appName}}</text>
  11. <text class="app-slogan">您的客户关系管理助手</text>
  12. </view>
  13. <view class="loading-section">
  14. <text class="loading-text">
  15. 正在加载
  16. <view class="loading-dots">
  17. <view class="dot dot1"></view>
  18. <view class="dot dot2"></view>
  19. <view class="dot dot3"></view>
  20. </view>
  21. </text>
  22. </view>
  23. <view class="version-info">
  24. <text class="version-text">{{version}}</text>
  25. <view class="version-text">
  26. 浙江舒博特网络科技有限公司提供技术支持
  27. </view>
  28. </view>
  29. <!-- 隐藏的 Canvas 用于生成名片快照 -->
  30. <canvas id="posterCanvas" type="2d"
  31. style="position: fixed; left: -9999px; top: -9999px; width: 750px; height: 780px;"></canvas>
  32. <!-- 隐藏的 Canvas 用于生成二维码海报 -->
  33. <view class="hidden-canvas-box">
  34. <canvas id="qrPosterCanvas" type="2d" style="width: 600px; height: 700px;"></canvas>
  35. </view>
  36. </view>
  37. </template>
  38. <script setup>
  39. import {
  40. ref,
  41. onMounted,
  42. } from 'vue'
  43. import {
  44. isLogin
  45. } from '@/utils/userCache.js'
  46. import {
  47. useUserStore
  48. } from '@/store/modules/user.js'
  49. import {
  50. onLoad,
  51. } from "@dcloudio/uni-app";
  52. const userStore = useUserStore() || null
  53. import {
  54. getCurrentConfig
  55. } from '@/config/index.js'
  56. const loadingText = ref('正在加载...')
  57. let appName = ref('')
  58. let version = ref('')
  59. // 页面加载
  60. onMounted(async () => {
  61. const config = await getCurrentConfig()
  62. appName.value = config.appName
  63. version.value = config.appVersion
  64. })
  65. onLoad((options) => {
  66. initApp(options?.userId)
  67. })
  68. /**
  69. * 初始化应用
  70. */
  71. const initApp = async (userId = null) => {
  72. try {
  73. loadingText.value = '检查登录状态...'
  74. const loginToggle = isLogin() || !!userId
  75. if (!loginToggle) {
  76. console.log('未登录,token 不存在')
  77. uni.reLaunch({
  78. url: '/pages/login/login'
  79. })
  80. return
  81. }
  82. if (loginToggle) {
  83. await userStore.queryCardInfo(userId)
  84. await userStore.queryCompanyInfo(userId)
  85. await userStore.queryCardPoster()
  86. uni.reLaunch({
  87. url: !!userId ? '/pages/mine/userCard' : '/pages/index/index'
  88. })
  89. // await userStore.queryCardQrcode(userId)
  90. } else {
  91. clearUserInfo()
  92. uni.reLaunch({
  93. url: '/pages/login/login'
  94. })
  95. }
  96. } catch (error) {
  97. console.error('验证登录态失败:', error)
  98. clearUserInfo()
  99. uni.reLaunch({
  100. url: '/pages/login/login'
  101. })
  102. }
  103. }
  104. /**
  105. * 延时函数
  106. * @param {number} ms - 毫秒数
  107. */
  108. const sleep = (ms) => {
  109. return new Promise(resolve => setTimeout(resolve, ms))
  110. }
  111. </script>
  112. <style lang="scss" scoped>
  113. .splash-container {
  114. min-height: 100vh;
  115. background: linear-gradient(135deg, #4A90E2 0%, #6FB3F2 50%, #87CEEB 100%);
  116. // background-color: #fff;
  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. // 隐藏的 canvas 容器
  324. .hidden-canvas-box {
  325. position: fixed;
  326. left: -9999px;
  327. top: -9999px;
  328. width: 1px;
  329. height: 1px;
  330. overflow: hidden;
  331. }
  332. </style>