hookehuyr

页面载入显示优化

1 <!-- 1 <!--
2 * @Date: 2022-09-19 14:11:06 2 * @Date: 2022-09-19 14:11:06
3 * @LastEditors: hookehuyr hookehuyr@gmail.com 3 * @LastEditors: hookehuyr hookehuyr@gmail.com
4 - * @LastEditTime: 2023-12-18 10:16:03 4 + * @LastEditTime: 2023-12-19 11:19:03
5 * @FilePath: /meihuaApp/src/pages/book/index.vue 5 * @FilePath: /meihuaApp/src/pages/book/index.vue
6 * @Description: 文件描述 6 * @Description: 文件描述
7 --> 7 -->
8 <template> 8 <template>
9 <view class="book-page"> 9 <view class="book-page">
10 - <view v-if="showContent" id="book-content" class="book-content"> 10 + <view id="book-content" class="book-content">
11 <view id="book-cal" class="book-cal"> 11 <view id="book-cal" class="book-cal">
12 <calendar-select @on-dates-change="onDatesChange"></calendar-select> 12 <calendar-select @on-dates-change="onDatesChange"></calendar-select>
13 </view> 13 </view>
14 <view class="book-type"> 14 <view class="book-type">
15 <nut-tabs v-model="value" title-scroll title-gutter="10" name="tabName" background="#FFF" color="#4C2E08" animated-time="0"> 15 <nut-tabs v-model="value" title-scroll title-gutter="10" name="tabName" background="#FFF" color="#4C2E08" animated-time="0">
16 <nut-tab-pane v-for="item in list" :title="'Tab ' + item" :pane-key="item"> 16 <nut-tab-pane v-for="item in list" :title="'Tab ' + item" :pane-key="item">
17 - <view class="book-list"> 17 + <view v-if="showContent" class="book-list">
18 - <scroll-view :style="scrollStyle" :scroll-y="true" :scroll-with-animation="true" @scrolltolower="onScrollToLower"> 18 + <scroll-view ref="refScrollView" :style="scrollStyle" :scroll-y="true" :scroll-with-animation="true" @scrolltolower="onScrollToLower">
19 <view v-for="(item, index) in 10" :key="index"> 19 <view v-for="(item, index) in 10" :key="index">
20 <room-card :key="index"></room-card> 20 <room-card :key="index"></room-card>
21 <view v-if="index === 9" style="height: 2rem;"></view> 21 <view v-if="index === 9" style="height: 2rem;"></view>
...@@ -54,23 +54,36 @@ export default { ...@@ -54,23 +54,36 @@ export default {
54 computed: { 54 computed: {
55 scrollStyle() { 55 scrollStyle() {
56 return { 56 return {
57 + refScrollView: null,
57 height: this.indexCoverHeight + 'px', 58 height: this.indexCoverHeight + 'px',
58 // paddingBottom: 50 + 'px', 59 // paddingBottom: 50 + 'px',
59 }; 60 };
60 }, 61 },
61 }, 62 },
62 mounted () { 63 mounted () {
64 + Taro.showLoading({
65 + title: '加载中',
66 + });
63 // 设置首页封面高度 67 // 设置首页封面高度
64 const windowHeight = wx.getSystemInfoSync().windowHeight; 68 const windowHeight = wx.getSystemInfoSync().windowHeight;
65 // 处理切换显示白屏问题 69 // 处理切换显示白屏问题
66 setTimeout(() => { 70 setTimeout(() => {
67 this.showContent = true; 71 this.showContent = true;
68 }, 100); 72 }, 100);
69 - setTimeout(async () => { 73 + // setTimeout(async () => {
74 + // const navHeight = await $('#navbar-page').height();
75 + // const calHeight = await $('#book-cal').height();
76 + // this.indexCoverHeight = windowHeight - navHeight - calHeight - 50;
77 + // }, 500);
78 + this.$nextTick(async () => {
70 const navHeight = await $('#navbar-page').height(); 79 const navHeight = await $('#navbar-page').height();
71 const calHeight = await $('#book-cal').height(); 80 const calHeight = await $('#book-cal').height();
72 this.indexCoverHeight = windowHeight - navHeight - calHeight - 50; 81 this.indexCoverHeight = windowHeight - navHeight - calHeight - 50;
73 - }, 500); 82 + if (this.$refs.refScrollView) {
83 + Taro.hideLoading();
84 + console.warn('加载完成');
85 + }
86 + });
74 }, 87 },
75 data() { 88 data() {
76 return { 89 return {
......
1 <!-- 1 <!--
2 * @Date: 2023-12-13 11:13:13 2 * @Date: 2023-12-13 11:13:13
3 * @LastEditors: hookehuyr hookehuyr@gmail.com 3 * @LastEditors: hookehuyr hookehuyr@gmail.com
4 - * @LastEditTime: 2023-12-19 10:46:04 4 + * @LastEditTime: 2023-12-19 11:22:24
5 * @FilePath: /meihuaApp/src/pages/my/index.vue 5 * @FilePath: /meihuaApp/src/pages/my/index.vue
6 * @Description: 文件描述 6 * @Description: 文件描述
7 --> 7 -->
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
25 <nut-tabs v-model="value" title-scroll title-gutter="0" name="tabName" background="#FFF" color="#6A4925" animated-time="0"> 25 <nut-tabs v-model="value" title-scroll title-gutter="0" name="tabName" background="#FFF" color="#6A4925" animated-time="0">
26 <nut-tab-pane v-for="item in tabList" :title="item.title" :pane-key="item.key"> 26 <nut-tab-pane v-for="item in tabList" :title="item.title" :pane-key="item.key">
27 <view v-if="showContent" class="book-list"> 27 <view v-if="showContent" class="book-list">
28 - <scroll-view :style="scrollStyle" :scroll-y="true" :scroll-with-animation="true" @scrolltolower="onScrollToLower"> 28 + <scroll-view ref="refScrollView" :style="scrollStyle" :scroll-y="true" :scroll-with-animation="true" @scrolltolower="onScrollToLower">
29 <view v-for="(item, index) in 10" :key="index"> 29 <view v-for="(item, index) in 10" :key="index">
30 <order-card :key="index" @onPay="onPay"></order-card> 30 <order-card :key="index" @onPay="onPay"></order-card>
31 <view v-if="index === 9" style="height: 2rem;"></view> 31 <view v-if="index === 9" style="height: 2rem;"></view>
...@@ -55,6 +55,8 @@ import { IconFont } from '@nutui/icons-vue-taro'; ...@@ -55,6 +55,8 @@ import { IconFont } from '@nutui/icons-vue-taro';
55 import navBar from '@/components/navBar.vue' 55 import navBar from '@/components/navBar.vue'
56 import orderCard from '@/components/orderCard.vue' 56 import orderCard from '@/components/orderCard.vue'
57 57
58 +const refScrollView = ref(null);
59 +
58 const value = ref('0'); 60 const value = ref('0');
59 const tabList = ref([{ 61 const tabList = ref([{
60 title: '全部订单', 62 title: '全部订单',
...@@ -103,18 +105,31 @@ export default { ...@@ -103,18 +105,31 @@ export default {
103 }, 105 },
104 }, 106 },
105 mounted () { 107 mounted () {
108 + Taro.showLoading({
109 + title: '加载中',
110 + });
106 // 设置首页封面高度 111 // 设置首页封面高度
107 const windowHeight = wx.getSystemInfoSync().windowHeight; 112 const windowHeight = wx.getSystemInfoSync().windowHeight;
108 // 处理切换显示白屏问题 113 // 处理切换显示白屏问题
109 setTimeout(() => { 114 setTimeout(() => {
110 this.showContent = true; 115 this.showContent = true;
111 }, 100); 116 }, 100);
112 - setTimeout(async () => { 117 + // setTimeout(async () => {
118 + // const navHeight = await $('#navbar-page').height();
119 + // const avatorHeight = await $('#avator').height();
120 + // const titleHeight = await $('#title').height();
121 + // this.indexCoverHeight = windowHeight - navHeight - avatorHeight - titleHeight - 50;
122 + // }, 500);
123 + this.$nextTick(async () => {
113 const navHeight = await $('#navbar-page').height(); 124 const navHeight = await $('#navbar-page').height();
114 const avatorHeight = await $('#avator').height(); 125 const avatorHeight = await $('#avator').height();
115 const titleHeight = await $('#title').height(); 126 const titleHeight = await $('#title').height();
116 this.indexCoverHeight = windowHeight - navHeight - avatorHeight - titleHeight - 50; 127 this.indexCoverHeight = windowHeight - navHeight - avatorHeight - titleHeight - 50;
117 - }, 500); 128 + if (this.$refs.refScrollView) {
129 + Taro.hideLoading();
130 + console.warn('加载完成');
131 + }
132 + });
118 }, 133 },
119 data() { 134 data() {
120 return { 135 return {
......