search-result.vue 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  1. <template>
  2. <view class="search-result-page">
  3. <image class="top-bg-image" src="/pages-sell/static/top-bg.png" mode="widthFix"></image>
  4. <Navbar title="书嗨" :titleSize="36" title-color="#ffffff" back-icon-color="#ffffff"></Navbar>
  5. <!-- Custom Header -->
  6. <view class="search-bar-wrapper">
  7. <u-search style="width: 100%;" v-model="keyword" placeholder="书名/作者/ISBN" :show-action="true" action-text="取消"
  8. :action-style="{ color: '#fff' }" bg-color="#fff" shape="round" :clearabled="true"
  9. search-icon="/pages-sell/static/search-icon.png" @custom="goBack" @search="onSearch"></u-search>
  10. </view>
  11. <!-- Banner -->
  12. <view class="banner-section">
  13. <image src="/pages-sell/static/top-banner.png" class="top-banner" mode="widthFix"></image>
  14. </view>
  15. <!-- Content Area -->
  16. <view class="content-area">
  17. <!-- Everyone is watching -->
  18. <view class="section-block">
  19. <text class="section-title">大家都在看</text>
  20. <HotRecommendItem :item="hotBook" @add-cart="addToCart"></HotRecommendItem>
  21. </view>
  22. <!-- Filter Bar -->
  23. <view class="filter-bar">
  24. <view class="filter-item active">
  25. <text>综合</text>
  26. <view class="triangle-icon"></view>
  27. </view>
  28. <view class="filter-item">
  29. <text>销量</text>
  30. </view>
  31. <view class="filter-item">
  32. <text>价格</text>
  33. <view class="sort-icons">
  34. <image src="/pages-sell/static/search-result/icon-top.png" class="icon-sort"></image>
  35. <image src="/pages-sell/static/search-result/icon-bottom.png" class="icon-sort"></image>
  36. </view>
  37. </view>
  38. <view class="filter-item">
  39. <text>筛选</text>
  40. <image src="/pages-sell/static/search-result/icon-filter.png" class="icon-filter"></image>
  41. </view>
  42. </view>
  43. <!-- Book List -->
  44. <view class="book-list">
  45. <RecommendItem v-for="(item, index) in bookList" :key="index" :item="item" @add-cart="addToCart" :show-desc="false">
  46. </RecommendItem>
  47. </view>
  48. </view>
  49. </view>
  50. </template>
  51. <script>
  52. import RecommendItem from '../components/recommend-item/index.vue';
  53. import HotRecommendItem from '../components/hot-recommend-item/index.vue';
  54. import Navbar from '@/components/navbar/navbar.vue';
  55. export default {
  56. components: {
  57. RecommendItem,
  58. HotRecommendItem,
  59. Navbar
  60. },
  61. data() {
  62. return {
  63. keyword: '习近平新时代思想',
  64. hotBook: {
  65. id: 1,
  66. title: '山河岁月',
  67. cover: '/static/img/1.png', // Assuming a placeholder or from static
  68. price: '6.80',
  69. discount: '5.3折',
  70. discountDesc: '省9.8元'
  71. },
  72. bookList: [
  73. {
  74. id: 2,
  75. title: '山河岁月',
  76. author: '本书编写组',
  77. cover: '/static/img/1.png',
  78. price: '6.80',
  79. originalPrice: '36.80',
  80. desc: '“山河岁月”以宏大的历史视野,讲述了... '
  81. },
  82. {
  83. id: 3,
  84. title: '山河岁月',
  85. author: '本书编写组',
  86. cover: '/static/img/1.png',
  87. price: '6.80',
  88. originalPrice: '36.80',
  89. desc: '“山河岁月”以宏大的历史视野,讲述了... '
  90. },
  91. {
  92. id: 4,
  93. title: '山河岁月',
  94. author: '本书编写组',
  95. cover: '/static/img/1.png',
  96. price: '6.80',
  97. originalPrice: '36.80',
  98. desc: '“山河岁月”以宏大的历史视野,讲述了... '
  99. },
  100. {
  101. id: 5,
  102. title: '山河岁月',
  103. author: '本书编写组',
  104. cover: '/static/img/1.png',
  105. price: '6.80',
  106. originalPrice: '36.80',
  107. desc: '“山河岁月”以宏大的历史视野,讲述了... '
  108. }
  109. ]
  110. }
  111. },
  112. methods: {
  113. goBack() {
  114. uni.navigateBack();
  115. },
  116. onSearch(val) {
  117. console.log('Search:', val);
  118. },
  119. addToCart(item) {
  120. uni.showToast({
  121. title: '已加入购物车',
  122. icon: 'success'
  123. });
  124. }
  125. }
  126. }
  127. </script>
  128. <style lang="scss" scoped>
  129. .search-result-page {
  130. min-height: 100vh;
  131. background-color: #F6F6F6;
  132. font-family: 'Source Han Sans SC', sans-serif;
  133. position: relative;
  134. }
  135. /* 顶部大背景图 */
  136. .top-bg-image {
  137. position: fixed;
  138. top: 0;
  139. left: 0;
  140. width: 100%;
  141. z-index: 0;
  142. display: block;
  143. }
  144. .search-bar-wrapper {
  145. position: relative;
  146. z-index: 100;
  147. display: flex;
  148. align-items: center;
  149. padding: 0 30rpx;
  150. height: 88rpx;
  151. width: 100%;
  152. }
  153. .banner-section {
  154. position: relative;
  155. width: 100%;
  156. z-index: 1;
  157. padding: 10rpx 30rpx;
  158. .top-banner {
  159. width: 100%;
  160. display: block;
  161. }
  162. }
  163. .content-area {
  164. position: relative;
  165. z-index: 2;
  166. padding: 30rpx 30rpx;
  167. border-radius: 30rpx 30rpx 0 0;
  168. min-height: 500rpx;
  169. .section-block {
  170. margin-bottom: 30rpx;
  171. background-color: #fff;
  172. padding: 30rpx 24rpx;
  173. border-radius: 20rpx;
  174. .section-title {
  175. font-size: 32rpx;
  176. font-weight: bold;
  177. color: #333;
  178. margin-bottom: 20rpx;
  179. display: block;
  180. }
  181. }
  182. }
  183. .filter-bar {
  184. display: flex;
  185. justify-content: space-between;
  186. align-items: center;
  187. margin-bottom: 20rpx;
  188. .filter-item {
  189. display: flex;
  190. align-items: center;
  191. font-size: 28rpx;
  192. color: #666;
  193. &.active {
  194. color: #333;
  195. font-weight: bold;
  196. .triangle-icon {
  197. border-top-color: #333;
  198. }
  199. }
  200. text {
  201. margin-right: 6rpx;
  202. }
  203. .triangle-icon {
  204. width: 0;
  205. height: 0;
  206. border-left: 8rpx solid transparent;
  207. border-right: 8rpx solid transparent;
  208. border-top: 10rpx solid #666;
  209. }
  210. .sort-icons {
  211. display: flex;
  212. flex-direction: column;
  213. margin-left: 4rpx;
  214. .icon-sort {
  215. width: 12rpx;
  216. height: 8rpx;
  217. margin: 2rpx 0;
  218. }
  219. }
  220. .icon-filter {
  221. width: 24rpx;
  222. height: 24rpx;
  223. margin-left: 4rpx;
  224. }
  225. }
  226. }
  227. .book-list {
  228. padding-bottom: 40rpx;
  229. background: #fff;
  230. border-radius: 20rpx;
  231. padding: 0 24rpx;
  232. }
  233. </style>