index.vue 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304
  1. <template>
  2. <view class="learn-container">
  3. <image class="learn-bg" src="/static/home_top_bg.png" mode="aspectFill"></image>
  4. <!-- 顶部导航栏 -->
  5. <view class="custom-navbar" :style="{ paddingTop: statusBarHeight + 'px' }">
  6. <view class="navbar-content">
  7. <text class="page-title">热门文章</text>
  8. <view class="search-box">
  9. <image class="search-icon" src="/static/icon_search_org.png" mode="aspectFit"></image>
  10. <input class="search-input" type="text" placeholder="搜索文章" placeholder-class="search-placeholder" />
  11. <button class="search-btn">搜索</button>
  12. </view>
  13. </view>
  14. </view>
  15. <!-- 分类标签栏 - 悬浮在导航栏下方 -->
  16. <view class="category-tabs-wrap" :style="{ top: (statusBarHeight + 44) + 'px' }">
  17. <scroll-view scroll-x class="category-tabs">
  18. <view class="tab-item" :class="{ active: activeCategory === index }" v-for="(category, index) in categories" :key="index" @click="selectCategory(index)">
  19. <text>{{ category }}</text>
  20. </view>
  21. </scroll-view>
  22. </view>
  23. <!-- 页面内容区域 - 可滚动 -->
  24. <scroll-view scroll-y class="page-content-scroll" :style="{ paddingTop: (statusBarHeight + 80) + 'px' }">
  25. <!-- 文章列表 -->
  26. <view class="article-list">
  27. <view class="article-card" v-for="(article, index) in articles" :key="index">
  28. <view class="article-header">
  29. <text class="article-main-title">{{ article.mainTitle }}</text>
  30. <text class="article-sub-title">{{ article.subTitle }}</text>
  31. </view>
  32. <view class="article-content">
  33. <image class="article-cover" :src="article.cover" mode="aspectFill"></image>
  34. <view class="article-info">
  35. <text class="article-description">{{ article.description }}</text>
  36. <view class="article-meta">
  37. <text class="category-tag">{{ article.category }}</text>
  38. <text class="category-line">|</text>
  39. <text class="play-count">{{ article.playCount }}次播放</text>
  40. </view>
  41. </view>
  42. </view>
  43. </view>
  44. </view>
  45. </scroll-view>
  46. </view>
  47. </template>
  48. <script>
  49. export default {
  50. data() {
  51. return {
  52. statusBarHeight: uni.getSystemInfoSync().statusBarHeight,
  53. categories: ['推荐', '科普', '养生', '中医', '自然', '饮食', '运动'],
  54. activeCategory: 0,
  55. articles: [{
  56. mainTitle: '熬夜党必看:养肝护肾,修复身体的夜间自愈课',
  57. subTitle: '',
  58. cover: '/static/course_img.png',
  59. description: '睡眠是藏在夜里的养生良方。子时入睡,胆经得养;丑时安睡,肝经舒通。一夜好眠,能补气...',
  60. category: '科普',
  61. playCount: '2468'
  62. }, {
  63. mainTitle: '科学饮食,稳糖稳脂不复发',
  64. subTitle: '',
  65. cover: '/static/course_img.png',
  66. description: '睡眠是藏在夜里的养生良方。子时入睡,胆经得养;丑时安睡,肝经舒通。一夜好眠,能补气...',
  67. category: '科普',
  68. playCount: '2468'
  69. }, {
  70. mainTitle: '护腰护颈,远离颈椎腰椎病',
  71. subTitle: '',
  72. cover: '/static/course_img.png',
  73. description: '睡眠是藏在夜里的养生良方。子时入睡,胆经得养;丑时安睡,肝经舒通。一夜好眠,能补气...',
  74. category: '科普',
  75. playCount: '2468'
  76. }, {
  77. mainTitle: '好睡眠,是成年人最高级的养生',
  78. subTitle: '',
  79. cover: '/static/course_img.png',
  80. description: '睡眠是藏在夜里的养生良方。子时入睡,胆经得养;丑时安睡,肝经舒通。一夜好眠,能补气...',
  81. category: '科普',
  82. playCount: '2468'
  83. },{
  84. mainTitle: '护腰护颈,远离颈椎腰椎病',
  85. subTitle: '',
  86. cover: '/static/course_img.png',
  87. description: '睡眠是藏在夜里的养生良方。子时入睡,胆经得养;丑时安睡,肝经舒通。一夜好眠,能补气...',
  88. category: '科普',
  89. playCount: '2468'
  90. }, {
  91. mainTitle: '好睡眠,是成年人最高级的养生',
  92. subTitle: '',
  93. cover: '/static/course_img.png',
  94. description: '睡眠是藏在夜里的养生良方。子时入睡,胆经得养;丑时安睡,肝经舒通。一夜好眠,能补气...',
  95. category: '科普',
  96. playCount: '2468'
  97. }]
  98. };
  99. },
  100. methods: {
  101. selectCategory(index) {
  102. this.activeCategory = index;
  103. }
  104. }
  105. }
  106. </script>
  107. <style lang="scss" scoped>
  108. .learn-container {
  109. min-height: 100vh;
  110. background-color: #F8F8F8;
  111. position: relative;
  112. .learn-bg{
  113. position: absolute;
  114. top: 0;
  115. left: 0;
  116. width: 100%;
  117. height: 380rpx;
  118. }
  119. }
  120. .custom-navbar {
  121. position: fixed;
  122. top: 0;
  123. left: 0;
  124. width: 100%;
  125. z-index: 100;
  126. .navbar-content {
  127. height: 44px;
  128. display: flex;
  129. align-items: center;
  130. padding: 0 30rpx;
  131. .page-title {
  132. font-size: 36rpx;
  133. font-weight: bold;
  134. color: #333333;
  135. }
  136. .search-box {
  137. display: flex;
  138. align-items: center;
  139. background-color: #fff;
  140. padding: 8rpx 8rpx 8rpx 24rpx;
  141. width: 324rpx;
  142. margin-left: 30rpx;
  143. border-radius: 36rpx;
  144. border: 2rpx solid #F5723A;
  145. .search-icon {
  146. width: 32rpx;
  147. height: 32rpx;
  148. margin-right: 10rpx;
  149. }
  150. .search-input {
  151. flex: 1;
  152. font-size: 28rpx;
  153. color: #333333;
  154. height: 100%;
  155. }
  156. .search-placeholder {
  157. color: #999999;
  158. }
  159. .search-btn {
  160. background: linear-gradient( 180deg, #FFA33B 0%, #F5723A 100%);
  161. border-radius: 58rpx 58rpx 58rpx 58rpx;
  162. color: #FFFFFF;
  163. font-size: 28rpx;
  164. padding: 16rpx 24rpx;
  165. margin-left: 20rpx;
  166. line-height: 1;
  167. height: auto;
  168. }
  169. }
  170. }
  171. }
  172. .category-tabs-wrap {
  173. position: fixed;
  174. left: 0;
  175. width: 100%;
  176. z-index: 99;
  177. padding: 20rpx 0;
  178. .category-tabs {
  179. white-space: nowrap;
  180. padding: 0 30rpx;
  181. .tab-item {
  182. display: inline-block;
  183. margin-right: 68rpx;
  184. font-size: 30rpx;
  185. color: #666666;
  186. position: relative;
  187. padding-bottom: 10rpx;
  188. &.active {
  189. color: #333333;
  190. font-weight: bold;
  191. &::after {
  192. content: '';
  193. position: absolute;
  194. bottom: 0;
  195. left: 50%;
  196. transform: translateX(-50%);
  197. width: 40rpx;
  198. height: 6rpx;
  199. background-color: #FF8D4D;
  200. border-radius: 3rpx;
  201. }
  202. }
  203. }
  204. }
  205. }
  206. .page-content-scroll {
  207. height: 100vh;
  208. box-sizing: border-box;
  209. .article-list {
  210. padding: 20rpx 24rpx;
  211. .article-card {
  212. background-color: #FFFFFF;
  213. border-radius: 20rpx;
  214. margin-bottom: 20rpx;
  215. padding: 24rpx;
  216. .article-header {
  217. margin-bottom: 20rpx;
  218. .article-main-title {
  219. font-size: 32rpx;
  220. font-weight: bold;
  221. color: #333333;
  222. line-height: 1.4;
  223. }
  224. .article-sub-title {
  225. font-size: 28rpx;
  226. color: #666666;
  227. margin-top: 8rpx;
  228. }
  229. }
  230. .article-content {
  231. display: flex;
  232. align-items: flex-start;
  233. .article-cover {
  234. width: 200rpx;
  235. height: 140rpx;
  236. border-radius: 12rpx;
  237. margin-right: 24rpx;
  238. flex-shrink: 0;
  239. }
  240. .article-info {
  241. flex: 1;
  242. display: flex;
  243. flex-direction: column;
  244. justify-content: space-between;
  245. height: 140rpx;
  246. .article-description {
  247. font-size: 28rpx;
  248. color: #666666;
  249. line-height: 1.5;
  250. display: -webkit-box;
  251. -webkit-box-orient: vertical;
  252. -webkit-line-clamp: 2;
  253. overflow: hidden;
  254. }
  255. .article-meta {
  256. display: flex;
  257. align-items: center;
  258. margin-top: 10rpx;
  259. color: #999999;
  260. font-size: 24rpx;
  261. .category-tag {
  262. padding: 4rpx 12rpx;
  263. border-radius: 8rpx;
  264. }
  265. .category-line {
  266. margin:0 16rpx;
  267. }
  268. .play-count {
  269. }
  270. }
  271. }
  272. }
  273. }
  274. }
  275. }
  276. </style>