index.wxml 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. <!--pages/index/index.wxml-->
  2. <view class="container">
  3. <!-- 搜索栏(固定在顶部) -->
  4. <view class="search-bar">
  5. <view class="search-box" bindtap="toggleSearch">
  6. <icon type="search" size="16" color="#999"></icon>
  7. <text class="search-placeholder">搜索书籍或听书</text>
  8. </view>
  9. </view>
  10. <!-- 轮播图 -->
  11. <view class="swiper-section" style="margin-top: {{swiperMarginTop}};">
  12. <swiper
  13. class="swiper"
  14. indicator-dots="{{true}}"
  15. autoplay="{{true}}"
  16. interval="{{3000}}"
  17. duration="{{500}}"
  18. circular="{{true}}"
  19. indicator-color="rgba(255, 255, 255, 0.5)"
  20. indicator-active-color="#fff"
  21. >
  22. <swiper-item wx:for="{{bannerList}}" wx:key="contentId">
  23. <view class="swiper-item" bindtap="goToDetail" data-id="{{item.contentId}}">
  24. <image class="swiper-image" src="{{item.coverUrl}}" mode="aspectFill" lazy-load="{{true}}"></image>
  25. <view class="swiper-content">
  26. <view class="swiper-title">{{item.title}}</view>
  27. <view class="swiper-author">{{item.author || '未知作者'}}</view>
  28. </view>
  29. </view>
  30. </swiper-item>
  31. </swiper>
  32. </view>
  33. <!-- 搜索输入框 -->
  34. <view class="search-input-box" wx:if="{{showSearch}}">
  35. <input
  36. class="search-input"
  37. type="text"
  38. placeholder="请输入关键词"
  39. value="{{keyword}}"
  40. bindinput="onSearchInput"
  41. bindconfirm="onSearchConfirm"
  42. confirm-type="search"
  43. />
  44. <text class="search-cancel" bindtap="toggleSearch">取消</text>
  45. </view>
  46. <!-- 内容类型切换 -->
  47. <view class="type-tabs">
  48. <view
  49. class="type-tab {{contentType === null ? 'active' : ''}}"
  50. data-type="null"
  51. bindtap="onContentTypeTap"
  52. >
  53. 全部
  54. </view>
  55. <view
  56. class="type-tab {{contentType === 1 ? 'active' : ''}}"
  57. data-type="1"
  58. bindtap="onContentTypeTap"
  59. >
  60. 电子书
  61. </view>
  62. <view
  63. class="type-tab {{contentType === 2 ? 'active' : ''}}"
  64. data-type="2"
  65. bindtap="onContentTypeTap"
  66. >
  67. 听书
  68. </view>
  69. </view>
  70. <!-- 分类列表 -->
  71. <scroll-view class="category-scroll" scroll-x="true">
  72. <view class="category-list">
  73. <view
  74. class="category-item {{currentCategory === item.categoryId ? 'active' : ''}}"
  75. wx:for="{{categories}}"
  76. wx:key="categoryId"
  77. data-id="{{item.categoryId}}"
  78. bindtap="onCategoryTap"
  79. >
  80. {{item.categoryName}}
  81. </view>
  82. </view>
  83. </scroll-view>
  84. <!-- 今日推荐 -->
  85. <view class="recommended-section" wx:if="{{recommendedList.length > 0}}">
  86. <view class="section-header">
  87. <text class="section-title">今日推荐</text>
  88. <text class="section-more">更多 ></text>
  89. </view>
  90. <view class="recommended-grid {{recommendedColumns === 3 ? 'columns-3' : ''}}">
  91. <view
  92. class="recommended-item"
  93. wx:for="{{recommendedList}}"
  94. wx:key="contentId"
  95. data-id="{{item.contentId}}"
  96. bindtap="goToDetail"
  97. >
  98. <view class="recommended-cover-wrapper">
  99. <image
  100. class="recommended-cover"
  101. src="{{item.coverUrl}}"
  102. mode="aspectFill"
  103. lazy-load="{{true}}"
  104. wx:if="{{item.coverUrl}}"
  105. ></image>
  106. <view class="recommended-cover-placeholder" wx:else>
  107. <text class="recommended-cover-text">{{item.title}}</text>
  108. </view>
  109. </view>
  110. <view class="recommended-title">{{item.title}}</view>
  111. </view>
  112. </view>
  113. </view>
  114. <!-- 内容列表 -->
  115. <view class="content-list">
  116. <view
  117. class="content-item"
  118. wx:for="{{contentList}}"
  119. wx:key="contentId"
  120. data-id="{{item.contentId}}"
  121. bindtap="goToDetail"
  122. >
  123. <view class="cover-wrapper">
  124. <image
  125. class="cover"
  126. src="{{item.coverUrl}}"
  127. mode="aspectFill"
  128. lazy-load="{{true}}"
  129. wx:if="{{item.coverUrl}}"
  130. ></image>
  131. <view class="cover-placeholder" wx:else>
  132. <text class="cover-text">{{item.title}}</text>
  133. </view>
  134. </view>
  135. <view class="content-info">
  136. <view class="title">{{item.title}}</view>
  137. <view class="author">{{item.author || '未知作者'}}</view>
  138. <view class="meta">
  139. <text class="type">{{item.contentType === 1 ? '电子书' : '听书'}}</text>
  140. <text class="chapters">{{item.totalChapters || 0}}章</text>
  141. <text class="status">{{item.status === 1 ? '连载中' : '已完结'}}</text>
  142. </view>
  143. <view class="description">{{item.description || '暂无简介'}}</view>
  144. </view>
  145. </view>
  146. <!-- 加载状态 -->
  147. <view class="loading" wx:if="{{loading}}">
  148. <text>加载中...</text>
  149. </view>
  150. <view class="no-more" wx:if="{{!hasMore && !loading && contentList.length > 0}}">
  151. <text>没有更多了</text>
  152. </view>
  153. <view class="empty" wx:if="{{!loading && contentList.length === 0}}">
  154. <text>暂无内容</text>
  155. </view>
  156. </view>
  157. </view>