Commit 391cecd1 authored by jyx's avatar jyx

代码优化

parent 75db8e75
<template> <template>
<view> <z-paging style="height: 100%;">
<c-navi id='navi'></c-navi> <c-navi id='navi'></c-navi>
<book-search-box id='search' :searchType='searchType'></book-search-box> <book-search-box id='search' :searchType='searchType'></book-search-box>
<read-time-count-row id='count' ref='timeCount' @resize='resizeTimeCount'></read-time-count-row> <read-time-count-row id='count' ref='timeCount' @resize='resizeTimeCount'></read-time-count-row>
<BookshelfList ref='bookList' :height='listHeight'></BookshelfList> <BookshelfList ref='bookList' :height='listHeight'></BookshelfList>
<c-login></c-login> <c-login></c-login>
</view> </z-paging>
</template> </template>
<script> <script>
...@@ -45,12 +45,6 @@ ...@@ -45,12 +45,6 @@
watchCollectionChange(() => { watchCollectionChange(() => {
this.refreshList(); this.refreshList();
}, this); }, this);
},
show(){
},
hide(){
}, },
onShow() { onShow() {
// 更新阅读时间统计 // 更新阅读时间统计
...@@ -62,6 +56,22 @@ ...@@ -62,6 +56,22 @@
removeCollectionChangeWatch(this); removeCollectionChangeWatch(this);
}, },
methods: { methods: {
show() {
this.initHeight();
// 监听用户变动
watchUserInfoChange((info) => {
if (info.userInfo) {
this.initData();
}
}, this)
// 监听收藏变动
watchCollectionChange(() => {
this.refreshList();
}, this);
},
hide() {
},
resizeTimeCount() { resizeTimeCount() {
this.initHeight(); this.initHeight();
}, },
......
<template> <template>
<view> <z-paging style="height: 100%;">
<c-navi id='navi'></c-navi> <c-navi id='navi'></c-navi>
<book-search-box id='search'></book-search-box> <book-search-box id='search'></book-search-box>
<CategoryBar id='category' :range='categorys' :current='currentIndex' @change='changeCategory' <CategoryBar id='category' :range='categorys' :current='currentIndex' @change='changeCategory'
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
</swiper> </swiper>
</view> </view>
<c-login></c-login> <c-login></c-login>
</view> </z-paging>
</template> </template>
<script> <script>
...@@ -50,23 +50,8 @@ ...@@ -50,23 +50,8 @@
}; };
}, },
onLoad(options) { onLoad(options) {
setTimeout(() => {
// 匹配用户直接跳转小说
if (options.bookId != '' && options.bookId != undefined) {
gotoBookContentPage(options.bookId);
}
}, 800);
this.getCategoryData();
if(wx.setVisualEffectOnCapture){
wx.setVisualEffectOnCapture({
visualEffect: 'hidden',
success:(res) => {
}, },
})
}
},
computed: { computed: {
showEmpty: function() { showEmpty: function() {
return isEmpty(this.categorys); return isEmpty(this.categorys);
...@@ -101,10 +86,25 @@ ...@@ -101,10 +86,25 @@
} }
}, },
methods: { methods: {
show(){ show() {
setTimeout(() => {
// 匹配用户直接跳转小说
if (options.bookId != '' && options.bookId != undefined) {
gotoBookContentPage(options.bookId);
}
}, 800);
this.getCategoryData();
if (wx.setVisualEffectOnCapture) {
wx.setVisualEffectOnCapture({
visualEffect: 'hidden',
success: (res) => {
},
})
}
}, },
hide(){ hide() {
}, },
readyCategory() { readyCategory() {
......
...@@ -97,15 +97,9 @@ ...@@ -97,15 +97,9 @@
loadComponentData() { loadComponentData() {
if (this.currentPage == 0) { if (this.currentPage == 0) {
this.$refs.index.show(); this.$refs.index.show();
this.$refs.recommend.hide();
this.$refs.user.hide();
} else if (this.currentPage == 1) { } else if (this.currentPage == 1) {
this.$refs.index.hide();
this.$refs.recommend.show(); this.$refs.recommend.show();
this.$refs.user.hide();
} else if (this.currentPage == 2) { } else if (this.currentPage == 2) {
this.$refs.index.hide();
this.$refs.recommend.hide();
this.$refs.user.show(); this.$refs.user.show();
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment