index.vue 2.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. <template>
  2. <div class="page pg-bg loading-pg" @click.prevent.stop="onClick" @touchmove.prevent @touchend.stop="onClick">
  3. <div class="header abs">
  4. <Bell />
  5. </div>
  6. <div class="content">
  7. <div class="loading-main">
  8. <div class="main-img">
  9. <Flower :percent="percent" />
  10. </div>
  11. <div class="txt">
  12. <LoadingTxt />
  13. <div>{{percent}}</div>
  14. </div>
  15. </div>
  16. </div>
  17. <DownArrow v-if="percent == '100%'" style="bottom: 120px" />
  18. <!-- <div class="footer abs txt">
  19. 主办单位:中共南京市委网信办、共青团南京市委员会、南京广播电视集团、侵华日军南京大屠杀遇难同胞纪念馆
  20. </div> -->
  21. </div>
  22. </template>
  23. <script setup>
  24. import { computed, onMounted, ref } from 'vue';
  25. import Bell from '@/components/Bell.vue';
  26. import DownArrow from '@/components/DownArrow.vue';
  27. import LoadingTxt from './LoadingTxt.vue';
  28. import Flower from './Flower.vue';
  29. import { preload } from '@/utils/preload';
  30. import throttle from '@/utils/throttle';
  31. const emit = defineEmits(['ready']);
  32. const percent = ref('0%');
  33. const finished = ref(false);
  34. const onClick = () => {
  35. if (!finished.value) return;
  36. const t = setTimeout(() => {
  37. emit('ready');
  38. clearTimeout(t);
  39. }, 100);
  40. }
  41. const callback = (val) => {
  42. console.log('------val----->', val)
  43. const p = Number(val * 100).toFixed(2);
  44. percent.value = `${p}%`
  45. }
  46. onMounted(() => {
  47. preload(throttle(callback, 0)).then(() => {
  48. percent.value = `${100}%`
  49. finished.value = true;
  50. // emit('ready');
  51. });
  52. });
  53. </script>
  54. <style lang="less" scoped>
  55. .loading-pg {
  56. width: 100%;
  57. height: 100%;
  58. overflow: hidden;
  59. background-image: url(/images/loading/bg.jpg);
  60. background-size: 100% 100%;
  61. background-repeat: no-repeat;
  62. .content {
  63. position: relative;
  64. width: 100%;
  65. height: 100%;
  66. display: flex;
  67. align-items: center;
  68. justify-content: center;
  69. .loading-main {
  70. position: relative;
  71. text-align: center;
  72. width: 80vw;
  73. flex: none;
  74. display: flex;
  75. align-items: center;
  76. justify-content: center;
  77. .main-img {
  78. flex: none;
  79. width: 20vw;
  80. position: relative;
  81. }
  82. }
  83. }
  84. .header {
  85. top: 24px;
  86. right: 24px;
  87. width: 40px;
  88. }
  89. .footer {
  90. font-size: 12px;
  91. text-align: center;
  92. bottom: 12px;
  93. left: 0;
  94. padding: 0 16px;
  95. }
  96. }
  97. </style>