| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- import { getCardNovelsMore } from '../../api/api'
- import { goToBookDetail } from '../../utils/util'
- Page({
- data: {
- pageTitle: '',
- bookList: [],
- loading: false,
- id: ''
- },
- onLoad(options) {
- const pageTitle = options.name || '书籍列表'
-
- this.setData({
- pageTitle,
- id: options.id
- })
- // 加载数据
- this.loadBookList()
- },
- // 加载书籍列表
- async loadBookList() {
- if (this.data.loading) return
- this.setData({ loading: true })
- try {
- const result = await getCardNovelsMore(this.data.id)
-
- this.setData({
- bookList: result || [],
- loading: false
- })
- } catch (error) {
- console.error('加载书籍列表失败:', error)
- this.setData({ loading: false })
- wx.showToast({
- title: '加载失败,请重试',
- icon: 'none'
- })
- }
- },
- // 点击书籍项
- onBookTap(e) {
- const bookId = e.currentTarget.dataset.bookId;
- const wxBookId = e.currentTarget.dataset.wxBookId;
- const chapterId = e.currentTarget.dataset.chapterId;
- console.log('bookId',bookId);
- console.log('wxBookId',wxBookId);
- console.log('chapterId',chapterId);
-
- goToBookDetail({
- bookId,
- wxBookId,
- chapterId
- });
- },
- // 返回上一页
- goBack() {
- wx.navigateBack({
- delta: 1
- });
- }
- })
|