hot-sell.vue 2.5 KB

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