discover.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432
  1. <template>
  2. <view class="discover-container">
  3. <!-- 搜索框 -->
  4. <view class="search-section">
  5. <view class="search-box">
  6. <uni-icons type="search" size="18" color="#999"></uni-icons>
  7. <input class="search-input" placeholder="python · html · java..." />
  8. </view>
  9. </view>
  10. <!-- 轮播图 -->
  11. <view class="banner-section">
  12. <swiper class="banner-swiper" :indicator-dots="true" :autoplay="true" :interval="3000" :duration="1000">
  13. <swiper-item v-for="(item, index) in bannerList" :key="index">
  14. <view class="banner-item" :style="{ backgroundColor: item.bgColor }">
  15. <view class="banner-content">
  16. <view class="banner-text">
  17. <text class="banner-title">{{ item.title }}</text>
  18. <text class="banner-subtitle">{{ item.subtitle }}</text>
  19. <view class="banner-btn">{{ item.btnText }}</view>
  20. </view>
  21. <image class="banner-image" :src="item.image" mode="aspectFit"></image>
  22. </view>
  23. </view>
  24. </swiper-item>
  25. </swiper>
  26. </view>
  27. <!-- 功能模块 -->
  28. <view class="function-section">
  29. <view class="function-row">
  30. <view class="function-item" v-for="(item, index) in functionList.slice(0, 5)" :key="index" @click="handleFunctionClick(item)">
  31. <view class="function-icon">
  32. <image :src="item.icon" mode="aspectFit"></image>
  33. </view>
  34. <text class="function-text">{{ item.name }}</text>
  35. <view v-if="item.badge" class="function-badge">{{ item.badge }}</view>
  36. </view>
  37. </view>
  38. <view class="function-row">
  39. <view class="function-item" v-for="(item, index) in functionList.slice(5, 10)" :key="index" @click="handleFunctionClick(item)">
  40. <view class="function-icon" :style="{ backgroundColor: item.bgColor }">
  41. <image :src="item.icon" mode="aspectFit"></image>
  42. </view>
  43. <text class="function-text">{{ item.name }}</text>
  44. </view>
  45. </view>
  46. </view>
  47. <!-- 课程推荐卡片 -->
  48. <view class="course-cards">
  49. <view class="course-card" v-for="(card, index) in courseCards" :key="index" :style="{ backgroundColor: card.bgColor }">
  50. <view class="card-content">
  51. <text class="card-title">{{ card.title }}</text>
  52. <text class="card-subtitle">{{ card.subtitle }}</text>
  53. </view>
  54. <image class="card-image" :src="card.image" mode="aspectFit"></image>
  55. </view>
  56. </view>
  57. <!-- 课程列表 -->
  58. <view class="course-section">
  59. <view class="section-header">
  60. <text class="section-title">大家都在学</text>
  61. <view class="more-btn">
  62. <text>更多课程</text>
  63. <uni-icons type="right" size="14" color="#999"></uni-icons>
  64. </view>
  65. </view>
  66. <view class="course-list">
  67. <view class="course-item" v-for="(course, index) in courseList" :key="index" @click="handleCourseClick(course)">
  68. <image class="course-cover" :src="course.cover" mode="aspectFill"></image>
  69. <view class="course-info">
  70. <text class="course-title">{{ course.title }}</text>
  71. <view class="course-stats">
  72. <text class="course-students">{{ course.students }}人学习</text>
  73. <text class="course-type">{{ course.type }}</text>
  74. </view>
  75. <text class="course-desc">{{ course.description }}</text>
  76. </view>
  77. </view>
  78. </view>
  79. </view>
  80. </view>
  81. </template>
  82. <script setup>
  83. import { ref, onMounted } from 'vue'
  84. // 轮播图数据
  85. const bannerList = ref([
  86. {
  87. title: 'Python编程班',
  88. subtitle: '产品体验有奖用户调研',
  89. btnText: '立即参与 >>',
  90. bgColor: 'linear-gradient(135deg, #667eea 0%, #764ba2 100%)',
  91. image: '/static/banner/python-banner.png'
  92. }
  93. ])
  94. // 功能模块数据
  95. const functionList = ref([
  96. { name: '学练课', icon: '/static/icons/study.png', bgColor: '#FF6B6B', badge: '好课' },
  97. { name: '视频课', icon: '/static/icons/video.png', bgColor: '#9B59B6' },
  98. { name: '题库', icon: '/static/icons/question.png', bgColor: '#F39C12' },
  99. { name: '教程', icon: '/static/icons/tutorial.png', bgColor: '#2ECC71' },
  100. { name: 'VIP会员', icon: '/static/icons/vip.png', bgColor: '#E74C3C', badge: '16周年' },
  101. { name: '基础入门', icon: '/static/icons/basic.png', bgColor: '#3498DB' },
  102. { name: '数据分析', icon: '/static/icons/data.png', bgColor: '#1ABC9C' },
  103. { name: '人工智能', icon: '/static/icons/ai.png', bgColor: '#95A5A6' },
  104. { name: '爬虫', icon: '/static/icons/spider.png', bgColor: '#34495E' },
  105. { name: '办公自动化', icon: '/static/icons/office.png', bgColor: '#16A085' }
  106. ])
  107. // 课程推荐卡片
  108. const courseCards = ref([
  109. {
  110. title: 'Python高薪就业课',
  111. subtitle: '面向大学、职场就业提效',
  112. bgColor: 'linear-gradient(135deg, #667eea 0%, #764ba2 100%)',
  113. image: '/static/cards/job-card.png'
  114. },
  115. {
  116. title: 'Python少儿编程',
  117. subtitle: '面向小学、初高中学习',
  118. bgColor: 'linear-gradient(135deg, #f093fb 0%, #f5576c 100%)',
  119. image: '/static/cards/kids-card.png'
  120. }
  121. ])
  122. // 课程列表数据
  123. const courseList = ref([
  124. {
  125. cover: '/static/courses/python-basic.png',
  126. title: 'Python3 入门课程',
  127. students: '5037',
  128. type: '学练课',
  129. description: '爬虫+机器学习? Python无所不能...'
  130. },
  131. {
  132. cover: '/static/courses/python-zero.png',
  133. title: '零基础入门学Python',
  134. students: '619',
  135. type: '视频课',
  136. description: '通过Python入门到实战全套教程...'
  137. },
  138. {
  139. cover: '/static/courses/python-guide.png',
  140. title: 'Python3零基础入门先导课',
  141. students: '5847',
  142. type: '学练课',
  143. description: '0基础的python入门先导课程...'
  144. }
  145. ])
  146. // 方法
  147. const handleFunctionClick = (item) => {
  148. console.log('点击功能:', item.name)
  149. // 这里可以添加跳转逻辑
  150. }
  151. const handleCourseClick = (course) => {
  152. console.log('点击课程:', course.title)
  153. // 这里可以添加跳转到课程详情的逻辑
  154. }
  155. onMounted(() => {
  156. console.log('发现页面加载完成')
  157. })
  158. </script>
  159. <style lang="scss" scoped>
  160. .discover-container {
  161. background-color: #f5f5f5;
  162. min-height: 100vh;
  163. }
  164. // 搜索框样式
  165. .search-section {
  166. background-color: #fff;
  167. padding: 20rpx 30rpx;
  168. .search-box {
  169. display: flex;
  170. align-items: center;
  171. background-color: #f8f8f8;
  172. border-radius: 50rpx;
  173. padding: 20rpx 30rpx;
  174. .search-input {
  175. flex: 1;
  176. margin-left: 20rpx;
  177. font-size: 28rpx;
  178. color: #333;
  179. }
  180. }
  181. }
  182. // 轮播图样式
  183. .banner-section {
  184. margin: 20rpx 30rpx;
  185. .banner-swiper {
  186. height: 300rpx;
  187. border-radius: 20rpx;
  188. overflow: hidden;
  189. }
  190. .banner-item {
  191. height: 100%;
  192. border-radius: 20rpx;
  193. background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  194. }
  195. .banner-content {
  196. display: flex;
  197. align-items: center;
  198. justify-content: space-between;
  199. height: 100%;
  200. padding: 40rpx;
  201. }
  202. .banner-text {
  203. flex: 1;
  204. .banner-title {
  205. display: block;
  206. color: #fff;
  207. font-size: 32rpx;
  208. font-weight: bold;
  209. margin-bottom: 10rpx;
  210. }
  211. .banner-subtitle {
  212. display: block;
  213. color: #fff;
  214. font-size: 28rpx;
  215. margin-bottom: 30rpx;
  216. }
  217. .banner-btn {
  218. background-color: #FF6B35;
  219. color: #fff;
  220. padding: 12rpx 24rpx;
  221. border-radius: 30rpx;
  222. font-size: 24rpx;
  223. display: inline-block;
  224. }
  225. }
  226. .banner-image {
  227. width: 120rpx;
  228. height: 120rpx;
  229. }
  230. }
  231. // 功能模块样式
  232. .function-section {
  233. background-color: #fff;
  234. margin: 20rpx 30rpx;
  235. border-radius: 20rpx;
  236. padding: 40rpx 20rpx;
  237. .function-row {
  238. display: flex;
  239. justify-content: space-around;
  240. margin-bottom: 40rpx;
  241. &:last-child {
  242. margin-bottom: 0;
  243. }
  244. }
  245. .function-item {
  246. display: flex;
  247. flex-direction: column;
  248. align-items: center;
  249. position: relative;
  250. .function-icon {
  251. width: 80rpx;
  252. height: 80rpx;
  253. border-radius: 20rpx;
  254. display: flex;
  255. align-items: center;
  256. justify-content: center;
  257. margin-bottom: 15rpx;
  258. }
  259. .function-text {
  260. font-size: 24rpx;
  261. color: #333;
  262. }
  263. .function-badge {
  264. position: absolute;
  265. top: -10rpx;
  266. right: -10rpx;
  267. background-color: #FF4757;
  268. color: #fff;
  269. font-size: 18rpx;
  270. padding: 4rpx 8rpx;
  271. border-radius: 20rpx;
  272. transform: scale(0.8);
  273. }
  274. }
  275. }
  276. // 课程推荐卡片样式
  277. .course-cards {
  278. margin: 20rpx 30rpx;
  279. display: flex;
  280. gap: 20rpx;
  281. .course-card {
  282. flex: 1;
  283. height: 200rpx;
  284. border-radius: 20rpx;
  285. padding: 30rpx;
  286. display: flex;
  287. align-items: center;
  288. justify-content: space-between;
  289. background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  290. .card-content {
  291. flex: 1;
  292. .card-title {
  293. display: block;
  294. color: #fff;
  295. font-size: 28rpx;
  296. font-weight: bold;
  297. margin-bottom: 10rpx;
  298. }
  299. .card-subtitle {
  300. display: block;
  301. color: #fff;
  302. font-size: 22rpx;
  303. opacity: 0.9;
  304. }
  305. }
  306. .card-image {
  307. width: 80rpx;
  308. height: 80rpx;
  309. }
  310. }
  311. }
  312. // 课程列表样式
  313. .course-section {
  314. background-color: #fff;
  315. margin: 20rpx 30rpx;
  316. border-radius: 20rpx;
  317. padding: 30rpx;
  318. .section-header {
  319. display: flex;
  320. align-items: center;
  321. justify-content: space-between;
  322. margin-bottom: 30rpx;
  323. .section-title {
  324. font-size: 32rpx;
  325. font-weight: bold;
  326. color: #333;
  327. }
  328. .more-btn {
  329. display: flex;
  330. align-items: center;
  331. color: #999;
  332. font-size: 24rpx;
  333. }
  334. }
  335. .course-list {
  336. .course-item {
  337. display: flex;
  338. margin-bottom: 30rpx;
  339. &:last-child {
  340. margin-bottom: 0;
  341. }
  342. .course-cover {
  343. width: 160rpx;
  344. height: 120rpx;
  345. border-radius: 12rpx;
  346. margin-right: 20rpx;
  347. }
  348. .course-info {
  349. flex: 1;
  350. .course-title {
  351. display: block;
  352. font-size: 28rpx;
  353. font-weight: bold;
  354. color: #333;
  355. margin-bottom: 10rpx;
  356. }
  357. .course-stats {
  358. display: flex;
  359. align-items: center;
  360. margin-bottom: 10rpx;
  361. .course-students {
  362. font-size: 22rpx;
  363. color: #999;
  364. margin-right: 20rpx;
  365. }
  366. .course-type {
  367. font-size: 22rpx;
  368. color: #999;
  369. }
  370. }
  371. .course-desc {
  372. font-size: 24rpx;
  373. color: #666;
  374. line-height: 1.4;
  375. }
  376. }
  377. }
  378. }
  379. }
  380. </style>