123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110 |
- <template>
- <div class="page pg-bg loading-pg" @click.prevent.stop="onClick" @touchmove.prevent @touchend.stop="onClick">
- <div class="header abs">
- <Bell />
- </div>
- <div class="content">
- <div class="loading-main">
- <div class="main-img">
- <Flower :percent="percent" />
- </div>
- <div class="txt">
- <LoadingTxt />
- <div>{{percent}}</div>
- </div>
- </div>
- </div>
- <DownArrow v-if="percent == '100%'" style="bottom: 120px" />
-
-
- </div>
- </template>
-
- <script setup>
- import { computed, onMounted, ref } from 'vue';
- import Bell from '@/components/Bell.vue';
- import DownArrow from '@/components/DownArrow.vue';
- import LoadingTxt from './LoadingTxt.vue';
- import Flower from './Flower.vue';
- import { preload } from '@/utils/preload';
- import throttle from '@/utils/throttle';
-
- const emit = defineEmits(['ready']);
-
- const percent = ref('0%');
- const finished = ref(false);
-
- const onClick = () => {
- if (!finished.value) return;
-
- const t = setTimeout(() => {
- emit('ready');
- clearTimeout(t);
- }, 100);
- }
-
- const callback = (val) => {
- console.log('------val----->', val)
- const p = Number(val * 100).toFixed(2);
- percent.value = `${p}%`
- }
-
- onMounted(() => {
- preload(throttle(callback, 0)).then(() => {
- percent.value = `${100}%`
- finished.value = true;
-
- });
- });
- </script>
-
- <style lang="less" scoped>
- .loading-pg {
- width: 100%;
- height: 100%;
- overflow: hidden;
- background-image: url(/images/loading/bg.jpg);
- background-size: 100% 100%;
- background-repeat: no-repeat;
-
- .content {
- position: relative;
- width: 100%;
- height: 100%;
- display: flex;
- align-items: center;
- justify-content: center;
-
- .loading-main {
- position: relative;
- text-align: center;
- width: 80vw;
- flex: none;
- display: flex;
- align-items: center;
- justify-content: center;
-
- .main-img {
- flex: none;
- width: 20vw;
- position: relative;
- }
- }
- }
-
- .header {
- top: 24px;
- right: 24px;
- width: 40px;
- }
-
- .footer {
- font-size: 12px;
- text-align: center;
- bottom: 12px;
- left: 0;
- padding: 0 16px;
- }
- }
- </style>
|