splash.vue 7.6 KB

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