hot-sell.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. <template>
  2. <view class="hot-sell-page">
  3. <!-- Header Background -->
  4. <image class="header-bg" src="/pages-sell/static/hot/top-bg.png" mode="widthFix"></image>
  5. <!-- Custom Navbar -->
  6. <Navbar :background="scrollTop > 0 ? '#ffffff' : 'transparent'"></Navbar>
  7. <!-- Header Content -->
  8. <view class="header-content">
  9. <view class="title-area">
  10. <text class="main-title">热销榜单</text>
  11. <text class="sub-title">Best Sellers</text>
  12. </view>
  13. </view>
  14. <!-- List Content -->
  15. <view class="list-container">
  16. <page-scroll ref="pageRef" class="hot-scroll" slotEmpty
  17. url="/token/shop/showIndex/getHotBookList"
  18. :page-size="20"
  19. :params="listParams"
  20. bgColor="#ffffff"
  21. height="calc(100vh - 432rpx)"
  22. @updateList="handleUpdateList">
  23. <hot-sell-item
  24. v-for="(item, index) in bookList"
  25. :key="index"
  26. :rank="index + 1"
  27. :item="item"
  28. @add-cart="addToCart"
  29. @update-item="updateBookItem($event, index)"
  30. ></hot-sell-item>
  31. </page-scroll>
  32. </view>
  33. <select-good-popup-host />
  34. </view>
  35. </template>
  36. <script>
  37. import HotSellItem from '../components/hot-sell-item/index.vue'
  38. import Navbar from '@/components/navbar/navbar.vue'
  39. import pageScroll from '@/components/pageScroll/index.vue'
  40. import SelectGoodPopupHost from '@/components/select-good-popup-host.vue'
  41. export default {
  42. components: {
  43. HotSellItem,
  44. Navbar,
  45. pageScroll,
  46. SelectGoodPopupHost,
  47. },
  48. data() {
  49. return {
  50. statusBarHeight: 20,
  51. bookList: [],
  52. scrollTop: 0,
  53. listParams: {}
  54. }
  55. },
  56. created() {
  57. const systemInfo = uni.getSystemInfoSync();
  58. this.statusBarHeight = systemInfo.statusBarHeight || 20;
  59. },
  60. onPageScroll(e) {
  61. this.scrollTop = e.scrollTop;
  62. },
  63. methods: {
  64. goBack() {
  65. uni.navigateBack();
  66. },
  67. handleUpdateList(list) {
  68. this.bookList = list || [];
  69. },
  70. updateBookItem(updatedItem, index) {
  71. this.$set(this.bookList, index, { ...this.bookList[index], ...updatedItem });
  72. },
  73. addToCart(data) {
  74. console.log('add to cart:', data);
  75. }
  76. }
  77. }
  78. </script>
  79. <style lang="scss" scoped>
  80. .hot-sell-page {
  81. min-height: 100vh;
  82. background-color: #fff;
  83. position: relative;
  84. }
  85. .header-bg {
  86. position: fixed;
  87. top: 0;
  88. left: 0;
  89. width: 100%;
  90. height: 458rpx;
  91. z-index: 0;
  92. }
  93. .custom-navbar {
  94. position: fixed;
  95. top: 0;
  96. left: 0;
  97. width: 100%;
  98. z-index: 100;
  99. .navbar-content {
  100. height: 44px;
  101. display: flex;
  102. align-items: center;
  103. padding-left: 40rpx;
  104. .back-icon {
  105. width: 16rpx;
  106. height: 26rpx;
  107. }
  108. }
  109. }
  110. .header-content {
  111. position: relative;
  112. z-index: 1;
  113. padding: 0 40rpx;
  114. height: 200rpx; /* Adjust based on bg image height */
  115. display: flex;
  116. flex-direction: column;
  117. justify-content: center;
  118. margin-top: -20rpx;
  119. .title-area {
  120. .main-title {
  121. font-size: 60rpx;
  122. font-weight: bold;
  123. color: #0B2E16;
  124. display: block;
  125. }
  126. .sub-title {
  127. font-size: 36rpx;
  128. color: #72967D;
  129. }
  130. }
  131. }
  132. .list-container {
  133. position: relative;
  134. z-index: 1;
  135. background-color: #fff;
  136. border-radius: 40rpx 40rpx 0 0; /* Rounded top corners for list area */
  137. padding: 30rpx 40rpx;
  138. min-height: 500rpx;
  139. }
  140. </style>