search-result.vue 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  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(data) {
  120. // data now contains { product, quality, quantity } from the popup
  121. console.log('Added to cart:', data);
  122. uni.showToast({
  123. title: '已加入购物车',
  124. icon: 'success'
  125. });
  126. }
  127. }
  128. }
  129. </script>
  130. <style lang="scss" scoped>
  131. .search-result-page {
  132. min-height: 100vh;
  133. background-color: #F6F6F6;
  134. font-family: 'Source Han Sans SC', sans-serif;
  135. position: relative;
  136. }
  137. /* 顶部大背景图 */
  138. .top-bg-image {
  139. position: fixed;
  140. top: 0;
  141. left: 0;
  142. width: 100%;
  143. z-index: 0;
  144. display: block;
  145. }
  146. .search-bar-wrapper {
  147. position: relative;
  148. z-index: 100;
  149. display: flex;
  150. align-items: center;
  151. padding: 0 30rpx;
  152. height: 88rpx;
  153. width: 100%;
  154. }
  155. .banner-section {
  156. position: relative;
  157. width: 100%;
  158. z-index: 1;
  159. padding: 10rpx 30rpx;
  160. .top-banner {
  161. width: 100%;
  162. display: block;
  163. }
  164. }
  165. .content-area {
  166. position: relative;
  167. z-index: 2;
  168. padding: 30rpx 30rpx;
  169. border-radius: 30rpx 30rpx 0 0;
  170. min-height: 500rpx;
  171. .section-block {
  172. margin-bottom: 30rpx;
  173. background-color: #fff;
  174. padding: 30rpx 24rpx;
  175. border-radius: 20rpx;
  176. .section-title {
  177. font-size: 32rpx;
  178. font-weight: bold;
  179. color: #333;
  180. margin-bottom: 20rpx;
  181. display: block;
  182. }
  183. }
  184. }
  185. .filter-bar {
  186. display: flex;
  187. justify-content: space-between;
  188. align-items: center;
  189. margin-bottom: 20rpx;
  190. .filter-item {
  191. display: flex;
  192. align-items: center;
  193. font-size: 28rpx;
  194. color: #666;
  195. &.active {
  196. color: #333;
  197. font-weight: bold;
  198. .triangle-icon {
  199. border-top-color: #333;
  200. }
  201. }
  202. text {
  203. margin-right: 6rpx;
  204. }
  205. .triangle-icon {
  206. width: 0;
  207. height: 0;
  208. border-left: 8rpx solid transparent;
  209. border-right: 8rpx solid transparent;
  210. border-top: 10rpx solid #666;
  211. }
  212. .sort-icons {
  213. display: flex;
  214. flex-direction: column;
  215. margin-left: 4rpx;
  216. .icon-sort {
  217. width: 12rpx;
  218. height: 8rpx;
  219. margin: 2rpx 0;
  220. }
  221. }
  222. .icon-filter {
  223. width: 24rpx;
  224. height: 24rpx;
  225. margin-left: 4rpx;
  226. }
  227. }
  228. }
  229. .book-list {
  230. padding-bottom: 40rpx;
  231. background: #fff;
  232. border-radius: 20rpx;
  233. padding: 0 24rpx;
  234. }
  235. </style>