search-result.vue 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  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. <!-- Service Popup -->
  49. <ServicePopup ref="servicePopup"></ServicePopup>
  50. </view>
  51. </view>
  52. </template>
  53. <script>
  54. import RecommendItem from '../components/recommend-item/index.vue';
  55. import HotRecommendItem from '../components/hot-recommend-item/index.vue';
  56. import Navbar from '@/components/navbar/navbar.vue';
  57. import ServicePopup from '../components/service-popup/index.vue';
  58. export default {
  59. components: {
  60. RecommendItem,
  61. HotRecommendItem,
  62. Navbar,
  63. ServicePopup
  64. },
  65. data() {
  66. return {
  67. keyword: '习近平新时代思想',
  68. hotBook: {
  69. id: 1,
  70. title: '山河岁月',
  71. cover: '/static/img/1.png', // Assuming a placeholder or from static
  72. price: '6.80',
  73. discount: '5.3折',
  74. discountDesc: '省9.8元'
  75. },
  76. bookList: [
  77. {
  78. id: 2,
  79. title: '山河岁月',
  80. author: '本书编写组',
  81. cover: '/static/img/1.png',
  82. price: '6.80',
  83. originalPrice: '36.80',
  84. desc: '“山河岁月”以宏大的历史视野,讲述了... '
  85. },
  86. {
  87. id: 3,
  88. title: '山河岁月',
  89. author: '本书编写组',
  90. cover: '/static/img/1.png',
  91. price: '6.80',
  92. originalPrice: '36.80',
  93. desc: '“山河岁月”以宏大的历史视野,讲述了... '
  94. },
  95. {
  96. id: 4,
  97. title: '山河岁月',
  98. author: '本书编写组',
  99. cover: '/static/img/1.png',
  100. price: '6.80',
  101. originalPrice: '36.80',
  102. desc: '“山河岁月”以宏大的历史视野,讲述了... '
  103. },
  104. {
  105. id: 5,
  106. title: '山河岁月',
  107. author: '本书编写组',
  108. cover: '/static/img/1.png',
  109. price: '6.80',
  110. originalPrice: '36.80',
  111. desc: '“山河岁月”以宏大的历史视野,讲述了... '
  112. }
  113. ]
  114. }
  115. },
  116. mounted() {
  117. // Open service popup by default for testing
  118. this.$nextTick(() => {
  119. this.$refs.servicePopup.open();
  120. });
  121. },
  122. methods: {
  123. goBack() {
  124. uni.navigateBack();
  125. },
  126. onSearch(val) {
  127. console.log('Search:', val);
  128. },
  129. addToCart(data) {
  130. // data now contains { product, quality, quantity } from the popup
  131. console.log('Added to cart:', data);
  132. uni.showToast({
  133. title: '已加入购物车',
  134. icon: 'success'
  135. });
  136. }
  137. }
  138. }
  139. </script>
  140. <style lang="scss" scoped>
  141. .search-result-page {
  142. min-height: 100vh;
  143. background-color: #F6F6F6;
  144. font-family: 'Source Han Sans SC', sans-serif;
  145. position: relative;
  146. }
  147. /* 顶部大背景图 */
  148. .top-bg-image {
  149. position: fixed;
  150. top: 0;
  151. left: 0;
  152. width: 100%;
  153. z-index: 0;
  154. display: block;
  155. }
  156. .search-bar-wrapper {
  157. position: relative;
  158. z-index: 2;
  159. display: flex;
  160. align-items: center;
  161. padding: 0 30rpx;
  162. height: 88rpx;
  163. width: 100%;
  164. }
  165. .banner-section {
  166. position: relative;
  167. width: 100%;
  168. z-index: 1;
  169. padding: 10rpx 30rpx;
  170. .top-banner {
  171. width: 100%;
  172. display: block;
  173. }
  174. }
  175. .content-area {
  176. position: relative;
  177. z-index: 2;
  178. padding: 30rpx 30rpx;
  179. border-radius: 30rpx 30rpx 0 0;
  180. min-height: 500rpx;
  181. .section-block {
  182. margin-bottom: 30rpx;
  183. background-color: #fff;
  184. padding: 30rpx 24rpx;
  185. border-radius: 20rpx;
  186. .section-title {
  187. font-size: 32rpx;
  188. font-weight: bold;
  189. color: #333;
  190. margin-bottom: 20rpx;
  191. display: block;
  192. }
  193. }
  194. }
  195. .filter-bar {
  196. display: flex;
  197. justify-content: space-between;
  198. align-items: center;
  199. margin-bottom: 20rpx;
  200. .filter-item {
  201. display: flex;
  202. align-items: center;
  203. font-size: 28rpx;
  204. color: #666;
  205. &.active {
  206. color: #333;
  207. font-weight: bold;
  208. .triangle-icon {
  209. border-top-color: #333;
  210. }
  211. }
  212. text {
  213. margin-right: 6rpx;
  214. }
  215. .triangle-icon {
  216. width: 0;
  217. height: 0;
  218. border-left: 8rpx solid transparent;
  219. border-right: 8rpx solid transparent;
  220. border-top: 10rpx solid #666;
  221. }
  222. .sort-icons {
  223. display: flex;
  224. flex-direction: column;
  225. margin-left: 4rpx;
  226. .icon-sort {
  227. width: 12rpx;
  228. height: 8rpx;
  229. margin: 2rpx 0;
  230. }
  231. }
  232. .icon-filter {
  233. width: 24rpx;
  234. height: 24rpx;
  235. margin-left: 4rpx;
  236. }
  237. }
  238. }
  239. .book-list {
  240. padding-bottom: 40rpx;
  241. background: #fff;
  242. border-radius: 20rpx;
  243. padding: 0 24rpx;
  244. }
  245. </style>