index.nvue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. <template>
  2. <view class="page">
  3. <view class="status-bar" :style="{height: statusBarHeight + 'px'}"></view>
  4. <text class="page-title">推荐</text>
  5. <scroll-view class="scroll-content" scroll-y="true" @scrolltolower="onReachBottom">
  6. <view class="recommend-grid">
  7. <view class="recommend-card" v-for="(item, index) in recommends" :key="index" @click="onItemClick(item)">
  8. <image class="card-img" :src="item.img" mode="aspectFill"></image>
  9. <text class="card-title">{{item.title}}</text>
  10. <view class="card-footer">
  11. <view class="badge-circle">
  12. <text class="badge-text">研</text>
  13. </view>
  14. <text class="footer-name">研年健康贴士</text>
  15. <view class="badge-official">
  16. <text class="official-text">官方</text>
  17. </view>
  18. </view>
  19. </view>
  20. </view>
  21. <text class="load-tip" v-if="recommends.length > 0">{{loadMore ? '加载中...' : ''}}</text>
  22. </scroll-view>
  23. <ay-toast ref="ayToast" />
  24. </view>
  25. </template>
  26. <script>
  27. import ayToast from '@/components/ay-toast/ay-toast.nvue'
  28. export default {
  29. components: {
  30. ayToast
  31. },
  32. data() {
  33. return {
  34. statusBarHeight: 44,
  35. page: 1,
  36. loadMore: false,
  37. recommends: [
  38. { id: 1, img: '/static/home/banner.png', title: '春季艾灸养生:温补阳气祛湿寒' },
  39. { id: 2, img: '/static/home/detail.png', title: '失眠困扰?试试这几个穴位' },
  40. { id: 3, img: '/static/home/banner.png', title: '办公族必看:肩颈酸痛缓解方案' },
  41. { id: 4, img: '/static/home/detail.png', title: '女性调理:暖宫驱寒艾灸指南' },
  42. { id: 5, img: '/static/home/banner.png', title: '中老年腰膝酸软怎么办' },
  43. { id: 6, img: '/static/home/detail.png', title: '日常保健:提升免疫力的穴位' }
  44. ]
  45. }
  46. },
  47. onShow() {
  48. const sysInfo = uni.getSystemInfoSync()
  49. this.statusBarHeight = sysInfo.statusBarHeight || 44
  50. },
  51. onPullDownRefresh() {
  52. this.page = 1
  53. // TODO: 重新加载数据
  54. uni.stopPullDownRefresh()
  55. },
  56. methods: {
  57. onReachBottom() {
  58. if (this.loadMore) return
  59. this.page++
  60. // TODO: 加载更多数据
  61. },
  62. onItemClick(item) {
  63. // TODO: 跳转详情
  64. this.$toastRef.text(item.title)
  65. }
  66. }
  67. }
  68. </script>
  69. <style>
  70. .page {
  71. flex: 1;
  72. background-color: #F5F5F5;
  73. }
  74. .status-bar {
  75. background-color: #F5F5F5;
  76. }
  77. .page-title {
  78. font-weight: bold;
  79. font-size: 48rpx;
  80. color: #545F71;
  81. margin-left: 50rpx;
  82. margin-top: 40rpx;
  83. margin-bottom: 40rpx;
  84. }
  85. .scroll-content {
  86. flex: 1;
  87. }
  88. .recommend-grid {
  89. flex-direction: row;
  90. flex-wrap: wrap;
  91. justify-content: space-between;
  92. padding-left: 40rpx;
  93. padding-right: 40rpx;
  94. }
  95. .recommend-card {
  96. width: 324rpx;
  97. background-color: #FFFFFF;
  98. border-radius: 20rpx;
  99. margin-bottom: 28rpx;
  100. overflow: hidden;
  101. }
  102. .card-img {
  103. width: 324rpx;
  104. height: 340rpx;
  105. }
  106. .card-title {
  107. padding-left: 16rpx;
  108. padding-right: 16rpx;
  109. padding-top: 20rpx;
  110. padding-bottom: 16rpx;
  111. font-size: 32rpx;
  112. color: #545F71;
  113. lines: 2;
  114. text-overflow: ellipsis;
  115. }
  116. .card-footer {
  117. flex-direction: row;
  118. align-items: center;
  119. padding-left: 16rpx;
  120. padding-bottom: 20rpx;
  121. }
  122. .badge-circle {
  123. width: 32rpx;
  124. height: 32rpx;
  125. background-color: #389588;
  126. border-radius: 32rpx;
  127. justify-content: center;
  128. align-items: center;
  129. margin-right: 4rpx;
  130. }
  131. .badge-text {
  132. font-size: 20rpx;
  133. color: #FFFFFF;
  134. }
  135. .footer-name {
  136. font-size: 24rpx;
  137. color: #BBBDBF;
  138. }
  139. .badge-official {
  140. width: 60rpx;
  141. height: 32rpx;
  142. background-color: #000000;
  143. border-radius: 4rpx;
  144. justify-content: center;
  145. align-items: center;
  146. margin-left: 10rpx;
  147. }
  148. .official-text {
  149. font-size: 24rpx;
  150. color: #EAC384;
  151. }
  152. .load-tip {
  153. text-align: center;
  154. font-size: 24rpx;
  155. color: #999999;
  156. padding-top: 20rpx;
  157. padding-bottom: 40rpx;
  158. }
  159. </style>