hot-sell.vue 2.8 KB

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