topic.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. <template>
  2. <view class="feature-page">
  3. <!-- Header Background -->
  4. <image class="header-bg" src="/pages-sell/static/topic/top-bg-2.png" mode="widthFix"></image>
  5. <!-- Custom Navbar -->
  6. <Navbar title="图书专题" :titleSize="32" title-color="#ffffff" back-icon-color="#ffffff"></Navbar>
  7. <!-- Header Content -->
  8. <view class="header-content">
  9. <view class="title-area">
  10. <text class="main-title">【考试】大学英语四六级</text>
  11. </view>
  12. </view>
  13. <!-- List Content -->
  14. <view class="list-container">
  15. <RecommendItem v-for="(item, index) in bookList" :key="index" :item="item" :show-desc="false"
  16. @add-cart="handleAddToCart"></RecommendItem>
  17. <!-- Change Batch Button -->
  18. <view class="refresh-fab" @click="changeBatch">
  19. <view class="refresh-bg"></view>
  20. <view class="refresh-content">
  21. <image src="/pages-sell/static/topic/icon-refresh.png" class="refresh-icon" mode="widthFix" style="width: 32rpx"></image>
  22. <text class="refresh-text">换一批</text>
  23. </view>
  24. </view>
  25. </view>
  26. </view>
  27. </template>
  28. <script>
  29. import RecommendItem from '../components/recommend-item/index.vue'
  30. import Navbar from '@/components/navbar/navbar.vue'
  31. export default {
  32. components: {
  33. RecommendItem,
  34. Navbar
  35. },
  36. data() {
  37. return {
  38. currentIndex: 0,
  39. pageSize: 5,
  40. allBooks: [],
  41. bookList: []
  42. }
  43. },
  44. created() {
  45. this.initBooks();
  46. this.updateBookList();
  47. },
  48. methods: {
  49. initBooks() {
  50. const baseBooks = [
  51. {
  52. title: '山河岁月',
  53. author: '本书编写组',
  54. price: '6.80',
  55. originalPrice: '36.80',
  56. cover: '/static/img/1.png',
  57. desc: '“山河岁月”以宏大的历史视野,讲述了...'
  58. },
  59. {
  60. title: '平凡的世界',
  61. author: '路遥',
  62. price: '12.80',
  63. originalPrice: '45.00',
  64. cover: '/static/img/1.png',
  65. desc: '中国当代城乡社会生活的巨大变迁...'
  66. },
  67. {
  68. title: '活着',
  69. author: '余华',
  70. price: '9.90',
  71. originalPrice: '28.00',
  72. cover: '/static/img/1.png',
  73. desc: '讲述了人如何去承受巨大的苦难...'
  74. },
  75. {
  76. title: '三体',
  77. author: '刘慈欣',
  78. price: '15.50',
  79. originalPrice: '38.00',
  80. cover: '/static/img/1.png',
  81. desc: '地球文明在宇宙中的兴衰历程...'
  82. },
  83. {
  84. title: '百年孤独',
  85. author: '马尔克斯',
  86. price: '18.00',
  87. originalPrice: '55.00',
  88. cover: '/static/img/1.png',
  89. desc: '布恩迪亚家族七代人的传奇故事...'
  90. }
  91. ];
  92. // Generate more data for demonstration
  93. this.allBooks = [];
  94. for (let i = 0; i < 4; i++) {
  95. this.allBooks.push(...baseBooks.map((b, idx) => ({
  96. ...b,
  97. id: i * 10 + idx + 1,
  98. title: `${b.title} ${i > 0 ? i + 1 : ''}`
  99. })));
  100. }
  101. },
  102. updateBookList() {
  103. const start = this.currentIndex * this.pageSize;
  104. const end = start + this.pageSize;
  105. this.bookList = this.allBooks.slice(start, end);
  106. uni.pageScrollTo({
  107. scrollTop: 0,
  108. duration: 300
  109. });
  110. },
  111. changeBatch() {
  112. const maxIndex = Math.ceil(this.allBooks.length / this.pageSize) - 1;
  113. if (this.currentIndex < maxIndex) {
  114. this.currentIndex++;
  115. } else {
  116. this.currentIndex = 0;
  117. }
  118. // Simple loading effect
  119. uni.showLoading({ title: '加载中' });
  120. setTimeout(() => {
  121. this.updateBookList();
  122. uni.hideLoading();
  123. }, 300);
  124. },
  125. handleAddToCart(data) {
  126. console.log('Add to cart:', data);
  127. uni.showToast({
  128. title: '已加入购物车',
  129. icon: 'success'
  130. });
  131. }
  132. }
  133. }
  134. </script>
  135. <style lang="scss" scoped>
  136. .feature-page {
  137. min-height: 100vh;
  138. background-color: #F8F8F8;
  139. position: relative;
  140. }
  141. .header-bg {
  142. position: fixed;
  143. top: 0;
  144. left: 0;
  145. width: 100%;
  146. z-index: 0;
  147. }
  148. .header-content {
  149. position: relative;
  150. z-index: 1;
  151. padding: 0 40rpx;
  152. display: flex;
  153. flex-direction: column;
  154. align-items: center;
  155. justify-content: center;
  156. min-height: 200rpx;
  157. .title-area {
  158. width: 100%;
  159. .main-title {
  160. font-family: YouSheBiaoTiHei;
  161. font-weight: 400;
  162. font-size: 60rpx;
  163. color: #FFFFFF;
  164. text-shadow: 2px 2px 4px #0C256D;
  165. text-align: center;
  166. }
  167. }
  168. }
  169. .list-container {
  170. position: relative;
  171. z-index: 1;
  172. background-color: #fff;
  173. border-radius: 40rpx 40rpx 0 0;
  174. padding: 10rpx 40rpx 40rpx;
  175. min-height: calc(100vh - 360rpx);
  176. }
  177. .refresh-fab {
  178. position: fixed;
  179. right: 30rpx;
  180. bottom: 30%;
  181. width: 108rpx;
  182. height: 108rpx;
  183. border-radius: 50%;
  184. z-index: 100;
  185. display: flex;
  186. align-items: center;
  187. justify-content: center;
  188. overflow: hidden;
  189. .refresh-bg {
  190. position: absolute;
  191. top: 0;
  192. left: 0;
  193. width: 100%;
  194. height: 100%;
  195. background-color: #000000;
  196. opacity: 0.2; /* Adjusted for visibility, user said 0.1 but that might be too faint for white text bg */
  197. z-index: 1;
  198. }
  199. .refresh-content {
  200. position: relative;
  201. z-index: 2;
  202. display: flex;
  203. flex-direction: column;
  204. align-items: center;
  205. justify-content: center;
  206. .refresh-text {
  207. font-size: 20rpx;
  208. color: #FFFFFF;
  209. margin-top: 4rpx;
  210. }
  211. }
  212. }
  213. </style>