hot-sell.vue 2.8 KB

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