hot-sell.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  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. </view>
  34. </template>
  35. <script>
  36. import HotSellItem from '../components/hot-sell-item/index.vue'
  37. import Navbar from '@/components/navbar/navbar.vue'
  38. import pageScroll from '@/components/pageScroll/index.vue'
  39. export default {
  40. components: {
  41. HotSellItem,
  42. Navbar,
  43. pageScroll
  44. },
  45. data() {
  46. return {
  47. statusBarHeight: 20,
  48. bookList: [],
  49. scrollTop: 0,
  50. listParams: {}
  51. }
  52. },
  53. created() {
  54. const systemInfo = uni.getSystemInfoSync();
  55. this.statusBarHeight = systemInfo.statusBarHeight || 20;
  56. },
  57. onPageScroll(e) {
  58. this.scrollTop = e.scrollTop;
  59. },
  60. methods: {
  61. goBack() {
  62. uni.navigateBack();
  63. },
  64. handleUpdateList(list) {
  65. this.bookList = list || [];
  66. },
  67. updateBookItem(updatedItem, index) {
  68. this.$set(this.bookList, index, { ...this.bookList[index], ...updatedItem });
  69. },
  70. addToCart(data) {
  71. console.log('add to cart:', data);
  72. }
  73. }
  74. }
  75. </script>
  76. <style lang="scss" scoped>
  77. .hot-sell-page {
  78. min-height: 100vh;
  79. background-color: #fff;
  80. position: relative;
  81. }
  82. .header-bg {
  83. position: fixed;
  84. top: 0;
  85. left: 0;
  86. width: 100%;
  87. height: 458rpx;
  88. z-index: 0;
  89. }
  90. .custom-navbar {
  91. position: fixed;
  92. top: 0;
  93. left: 0;
  94. width: 100%;
  95. z-index: 100;
  96. .navbar-content {
  97. height: 44px;
  98. display: flex;
  99. align-items: center;
  100. padding-left: 40rpx;
  101. .back-icon {
  102. width: 16rpx;
  103. height: 26rpx;
  104. }
  105. }
  106. }
  107. .header-content {
  108. position: relative;
  109. z-index: 1;
  110. padding: 0 40rpx;
  111. height: 200rpx; /* Adjust based on bg image height */
  112. display: flex;
  113. flex-direction: column;
  114. justify-content: center;
  115. margin-top: -20rpx;
  116. .title-area {
  117. .main-title {
  118. font-size: 60rpx;
  119. font-weight: bold;
  120. color: #0B2E16;
  121. display: block;
  122. }
  123. .sub-title {
  124. font-size: 36rpx;
  125. color: #72967D;
  126. }
  127. }
  128. }
  129. .list-container {
  130. position: relative;
  131. z-index: 1;
  132. background-color: #fff;
  133. border-radius: 40rpx 40rpx 0 0; /* Rounded top corners for list area */
  134. padding: 30rpx 40rpx;
  135. min-height: 500rpx;
  136. }
  137. </style>