提交 cb3411c9 编写于 作者: H hdx

long-list: 提前请求网络数据

上级 fe2bcdb6
...@@ -56,6 +56,10 @@ ...@@ -56,6 +56,10 @@
type: { type: {
type: String, type: String,
default: '' default: ''
},
preload: {
type: Boolean,
default: false
} }
}, },
data() { data() {
...@@ -80,19 +84,18 @@ ...@@ -80,19 +84,18 @@
} }
} }
}, },
mounted() { created() {
uni.loadFontFace({ uni.loadFontFace({
global: false, global: false,
family: 'UtsIconsFontFamily', family: 'UtsIconsFontFamily',
source: '/static/fonts/icon-star.ttf' source: '/static/fonts/icon-star.ttf'
}) })
if (this.preload) {
this.loadData()
}
}, },
methods: { methods: {
init() {
if (this.dataList.length == 0) {
this.loadData()
}
},
loadData() { loadData() {
if (this.loading || this.isEnded) { if (this.loading || this.isEnded) {
return return
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
<swiper class="swiper-view" ref="swiper" :current="swiperIndex" @change="onSwiperChange" <swiper class="swiper-view" ref="swiper" :current="swiperIndex" @change="onSwiperChange"
@transition="onSwiperTransition" @animationfinish="onSwiperAnimationfinish"> @transition="onSwiperTransition" @animationfinish="onSwiperAnimationfinish">
<swiper-item class="swiper-item" v-for="(item, index) in swiperList" :key="index"> <swiper-item class="swiper-item" v-for="(item, index) in swiperList" :key="index">
<long-page ref="longPage" :type="item.type"></long-page> <long-page ref="longPage" :type="item.type" :preload="item.preload"></long-page>
</swiper-item> </swiper-item>
</swiper> </swiper>
</view> </view>
...@@ -40,7 +40,7 @@ ...@@ -40,7 +40,7 @@
type SwiperViewItem = { type SwiperViewItem = {
type : string, type : string,
name : string, name : string,
init : Boolean, preload : Boolean,
} }
export default { export default {
...@@ -53,7 +53,8 @@ ...@@ -53,7 +53,8 @@
swiperList: [ swiperList: [
{ {
type: 'UpdatedDate', type: 'UpdatedDate',
name: '最新上架' name: '最新上架',
preload: true
} as SwiperViewItem, } as SwiperViewItem,
{ {
type: 'FreeHot', type: 'FreeHot',
...@@ -139,9 +140,9 @@ ...@@ -139,9 +140,9 @@
} }
}, },
initSwiperItemPage(index : Number) { initSwiperItemPage(index : Number) {
if (!this.swiperList[index].init) { if (!this.swiperList[index].preload) {
this.swiperList[index].init = true; this.swiperList[index].preload = true;
(this.$refs["longPage"] as ComponentPublicInstance[])[index].$callMethod('init') (this.$refs["longPage"] as ComponentPublicInstance[])[index].$callMethod('loadData')
} }
}, },
updateTabIndicator(left : Number, width : Number) { updateTabIndicator(left : Number, width : Number) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册