1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- <template>
- <div>
- <TopSwiper :tops='tops'></TopSwiper>
-
- <Card v-for="book in books" :key="book.openid" :book='book'></Card>
- <p class="text-footer" v-if="!more">
- 没有更多数据
- </p>
- </div>
- </template>
- <script>
- import {get} from '@/util'
- import Card from '@/components/Card'
- import TopSwiper from '@/components/TopSwiper'
- export default {
- components: {
- Card,
- TopSwiper
- },
- data () {
- return {
- books: [],
- page: 0,
- more: true,
- tops: []
- }
- },
- methods: {
- async getList (init) {
- if (init) {
- this.page = 0
- this.more = true
- }
- wx.showNavigationBarLoading()
- const books = await get('/weapp/booklist', {page: this.page})
- if (books.list.length < 10 && this.page > 0) {
- this.more = false
-
- }
- if (init) {
- this.books = books.list
- wx.stopPullDownRefresh()
- } else {
-
- this.books = this.books.concat(books.list)
- }
- wx.hideNavigationBarLoading()
- },
- async getTop () {
- const tops = await get('/weapp/top')
- this.tops = tops.list
- }
- },
- onPullDownRefresh () {
- this.getList(true)
-
- this.getTop()
- },
- onReachBottom () {
-
- if (!this.more) {
-
- return false
- }
- this.page++
-
- this.getList()
- },
- mounted () {
- this.getList(true)
- this.getTop()
- }
- }
- </script>
- <style lang='scss'>
- </style>
|