hot-sell.vue 2.6 KB

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