splash.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  1. <template>
  2. <view class="splash-container">
  3. <view class="logo-section">
  4. <view class="logo-wrapper">
  5. <image class="logo-icon" src="/static/image/public/logo.png" mode="aspectFit"></image>
  6. <view class="shine"></view>
  7. <view class="spin-dot"></view>
  8. </view>
  9. <text class="app-name">{{appName}}</text>
  10. </view>
  11. <!-- 隐藏的 Canvas 用于生成名片快照 -->
  12. <canvas id="posterCanvas" type="2d"
  13. style="position: fixed; left: -9999px; top: -9999px; width: 750px; height: 780px;"></canvas>
  14. <!-- 隐藏的 Canvas 用于生成二维码海报 -->
  15. <view class="hidden-canvas-box">
  16. <canvas id="qrPosterCanvas" type="2d" style="width: 600px; height: 700px;"></canvas>
  17. </view>
  18. </view>
  19. </template>
  20. <script setup>
  21. import {
  22. ref,
  23. onMounted,
  24. } from 'vue'
  25. import {
  26. isLogin
  27. } from '@/utils/userCache.js'
  28. import {
  29. useUserStore
  30. } from '@/store/modules/user.js'
  31. import {
  32. onLoad,
  33. } from "@dcloudio/uni-app";
  34. const userStore = useUserStore() || null
  35. import {
  36. getCurrentConfig
  37. } from '@/config/index.js'
  38. let appName = ref('')
  39. // 页面加载
  40. onMounted(async () => {
  41. const config = await getCurrentConfig()
  42. appName.value = config.appName
  43. })
  44. onLoad((options) => {
  45. initApp(options?.userId, options?.currentId)
  46. })
  47. /**
  48. * 初始化应用
  49. */
  50. const initApp = async (userId = null, currentId = null) => {
  51. try {
  52. const loginToggle = isLogin() || !!userId
  53. if (!loginToggle) {
  54. console.log('未登录,token 不存在')
  55. uni.reLaunch({
  56. url: '/pages/login/login'
  57. })
  58. return
  59. }
  60. if (loginToggle) {
  61. let userList = await userStore.queryCardInfo(userId)
  62. // 如果有 currentId 参数,在数据加载完成后设置索引
  63. if (!!currentId) {
  64. let num = 0
  65. try {
  66. num = userList.findLastIndex(item => item.companyDTO.id == currentId) || 0
  67. } catch (err) {
  68. num = 0
  69. }
  70. userStore.setCurrentIndex(num)
  71. }
  72. await userStore.queryCardPoster()
  73. uni.reLaunch({
  74. url: !!userId ? '/pages/mine/userCard' : '/pages/index/index'
  75. })
  76. } else {
  77. clearUserInfo()
  78. uni.reLaunch({
  79. url: '/pages/login/login'
  80. })
  81. }
  82. } catch (error) {
  83. console.error('验证登录态失败:', error)
  84. clearUserInfo()
  85. uni.reLaunch({
  86. url: '/pages/login/login'
  87. })
  88. }
  89. }
  90. /**
  91. * 延时函数
  92. * @param {number} ms - 毫秒数
  93. */
  94. const sleep = (ms) => {
  95. return new Promise(resolve => setTimeout(resolve, ms))
  96. }
  97. </script>
  98. <style lang="scss" scoped>
  99. .splash-container {
  100. min-height: 100vh;
  101. background-color: #ffffff;
  102. display: flex;
  103. flex-direction: column;
  104. align-items: center;
  105. padding-top: 35vh;
  106. }
  107. // Logo 区域
  108. .logo-section {
  109. display: flex;
  110. flex-direction: column;
  111. align-items: center;
  112. .logo-wrapper {
  113. position: relative;
  114. width: 125rpx;
  115. height: 125rpx;
  116. border-radius: 50%;
  117. display: flex;
  118. align-items: center;
  119. justify-content: center;
  120. border: 1px solid #F1F1F1;
  121. &::after {
  122. content: '';
  123. position: absolute;
  124. top: -6rpx;
  125. left: -6rpx;
  126. right: -6rpx;
  127. bottom: -6rpx;
  128. border-radius: 50%;
  129. background: linear-gradient(135deg,
  130. rgba(255, 255, 255, 0.6) 0%,
  131. rgba(255, 255, 255, 0) 40%,
  132. rgba(255, 255, 255, 0) 60%,
  133. rgba(255, 255, 255, 0.2) 100%);
  134. pointer-events: none;
  135. z-index: 2;
  136. }
  137. // 亮光扫过动效
  138. .shine {
  139. position: absolute;
  140. top: 0;
  141. left: 0;
  142. width: 100%;
  143. height: 100%;
  144. border-radius: 50%;
  145. overflow: hidden;
  146. z-index: 3;
  147. pointer-events: none;
  148. &::before {
  149. content: '';
  150. position: absolute;
  151. top: -50%;
  152. left: -50%;
  153. width: 200%;
  154. height: 200%;
  155. background: linear-gradient(135deg,
  156. transparent 0%,
  157. transparent 35%,
  158. rgba(255, 255, 255, 0.5) 45%,
  159. transparent 55%,
  160. transparent 100%);
  161. animation: shineSweep 2s ease-in-out infinite;
  162. }
  163. }
  164. // 小圆点沿边框转圈
  165. .spin-dot {
  166. position: absolute;
  167. top: 0;
  168. left: 0;
  169. width: 100%;
  170. height: 100%;
  171. border-radius: 50%;
  172. z-index: 4;
  173. pointer-events: none;
  174. animation: spinDotRotate 2s linear infinite;
  175. &::before {
  176. content: '';
  177. position: absolute;
  178. top: -8rpx;
  179. left: 50%;
  180. width: 12rpx;
  181. height: 12rpx;
  182. background: #4080FF;
  183. border-radius: 50%;
  184. transform: translateX(-50%);
  185. }
  186. }
  187. .logo-icon {
  188. border-radius: 50%;
  189. width: 88rpx;
  190. height: 88rpx;
  191. position: relative;
  192. z-index: 1;
  193. }
  194. }
  195. .app-name {
  196. font-size: 28rpx;
  197. color: #333333;
  198. margin-top: 28rpx;
  199. }
  200. }
  201. // 亮光扫过动效
  202. // 小圆点沿圆边旋转
  203. @keyframes spinDotRotate {
  204. 0% {
  205. transform: rotate(0deg);
  206. }
  207. 100% {
  208. transform: rotate(360deg);
  209. }
  210. }
  211. @keyframes shineSweep {
  212. 0% {
  213. transform: translateX(-100%) translateY(-100%) rotate(-20deg);
  214. }
  215. 20% {
  216. transform: translateX(0%) translateY(0%) rotate(-20deg);
  217. }
  218. 40% {
  219. transform: translateX(100%) translateY(100%) rotate(-20deg);
  220. }
  221. 100% {
  222. transform: translateX(100%) translateY(100%) rotate(-20deg);
  223. }
  224. }
  225. // 隐藏的 canvas 容器
  226. .hidden-canvas-box {
  227. position: fixed;
  228. left: -9999px;
  229. top: -9999px;
  230. width: 1px;
  231. height: 1px;
  232. overflow: hidden;
  233. }
  234. </style>