search.wxml 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <!--pages/search/search.wxml-->
  2. <view class="container">
  3. <!-- 顶部标题栏 -->
  4. <view class="header">
  5. <view class="back-btn" bindtap="goBack">
  6. <view class="icon-back">
  7. <view class="icon-back-arrow"></view>
  8. </view>
  9. </view>
  10. <text class="title">搜索</text>
  11. </view>
  12. <!-- 搜索框 -->
  13. <view class="search-box">
  14. <icon type="search" size="20" color="#999"/>
  15. <input
  16. type="text"
  17. placeholder="请输入书名/口令搜索"
  18. placeholder-class="placeholder"
  19. value="{{keyword}}"
  20. bindinput="handleInput"
  21. bindconfirm="search"
  22. confirm-type="search"
  23. focus="true"
  24. />
  25. <icon wx:if="{{keyword}}" type="clear" size="20" color="#999" catchtap="clearSearch"/>
  26. <view wx:if="{{keyword}}" bindtap="search" class="search-btn">搜索</view>
  27. </view>
  28. <!-- 搜索结果 -->
  29. <scroll-view
  30. scroll-y
  31. class="search-result"
  32. bindscrolltolower="onScrollToLower"
  33. lower-threshold="50"
  34. >
  35. <!-- 书籍列表 -->
  36. <view class="book-list">
  37. <view class="book-item"
  38. wx:for="{{bookList}}"
  39. wx:key="id"
  40. bindtap="handleBookTap"
  41. data-id="{{item.id}}"
  42. data-wxbookid="{{item.wxBookId}}"
  43. >
  44. <image class="book-cover" src="{{item.cover}}" mode="aspectFill"/>
  45. <view class="book-info">
  46. <!-- 标题显示,带关键字高亮 -->
  47. <view class="book-title">
  48. <block wx:if="{{item.titleContainsKeyword}}">
  49. <text>{{item.titleBeforeKeyword}}</text>
  50. <text class="highlight">{{item.titleKeyword}}</text>
  51. <text>{{item.titleAfterKeyword}}</text>
  52. </block>
  53. <block wx:else>
  54. <text>{{item.title}}</text>
  55. </block>
  56. </view>
  57. <text class="book-desc">{{item.brief}}</text>
  58. <text class="book-author">{{item.author || '未知作者'}}</text>
  59. </view>
  60. </view>
  61. </view>
  62. <!-- 加载状态 -->
  63. <view class="loading" wx:if="{{loading}}">
  64. <text>加载中...</text>
  65. </view>
  66. <!-- 没有更多数据 -->
  67. <view class="no-more" wx:if="{{!loading && !hasMore && bookList.length > 0}}">
  68. <text>没有更多了</text>
  69. </view>
  70. <!-- 搜索结果为空 -->
  71. <view class="empty" wx:if="{{!loading && bookList.length === 0 && keyword}}">
  72. <text>未找到相关结果</text>
  73. </view>
  74. </scroll-view>
  75. </view>