type.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690
  1. <template>
  2. <view class="study-type">
  3. <!-- 导航栏 -->
  4. <zs-header :background="background" color="#000" :title="title"></zs-header>
  5. <image class="banner" :src="bg" mode=""></image>
  6. <view style="margin-bottom: 0;" class="type-title more-title">
  7. 推荐线路
  8. <view class="more-box" @click="jump('./community/goods?columnId='+ query.columnId)">
  9. <view>
  10. 更多
  11. </view>
  12. <image class="more" src="../static/jiantou-icon.png" mode=""></image>
  13. </view>
  14. </view>
  15. <zs-list class="store-recommend-box" mt="0">
  16. <view class="left">
  17. <view class="store-item" v-for="(item, index) in recommendList" :key="index"
  18. @click="goGoodsDetail(item.goodsId)">
  19. <zs-img :src="item.goodsPath" width="344rpx" height="344rpx" mode=""></zs-img>
  20. <view class="info">
  21. <view class="title">
  22. {{ item.goodsName }}
  23. </view>
  24. <view class="user-info">
  25. <!-- <image class="head" :src="item.goodsPath"></image> -->
  26. <view class="user-name">
  27. {{ item.goodsDescribe }}
  28. </view>
  29. </view>
  30. <view class="price-box">
  31. <view class="left">
  32. <view class="unit">
  33. </view>
  34. <view class="price">
  35. {{ item.realPrice }}
  36. </view>
  37. <view class="old-price">
  38. ¥{{ item.marketPrice }}
  39. </view>
  40. </view>
  41. <view class="right">
  42. {{ item.saleNum }}人已购
  43. </view>
  44. </view>
  45. </view>
  46. </view>
  47. </view>
  48. <view class="right">
  49. <view class="store-item" v-for="(item, index) in recommendList1" :key="index"
  50. @click="goGoodsDetail(item.goodsId)">
  51. <zs-img :src="item.goodsPath" width="344rpx" height="344rpx" mode=""></zs-img>
  52. <view class="info">
  53. <view class="title">
  54. {{ item.goodsName }}
  55. </view>
  56. <view class="user-info">
  57. <!-- <image class="head" :src="item.goodsPath" mode=""></image> -->
  58. <view class="user-name">
  59. {{ item.goodsDescribe }}
  60. </view>
  61. </view>
  62. <view class="price-box">
  63. <view class="left">
  64. <view class="unit">
  65. </view>
  66. <view class="price">
  67. {{ item.realPrice }}
  68. </view>
  69. <view class="old-price">
  70. ¥{{ item.marketPrice }}
  71. </view>
  72. </view>
  73. <view class="right">
  74. {{ item.saleNum }}人已购
  75. </view>
  76. </view>
  77. </view>
  78. </view>
  79. </view>
  80. </zs-list>
  81. <view class="type-title more-title">
  82. 互动社区
  83. <view class="more-box" @click="jump('./community/index?id=' + tab)">
  84. <view>
  85. 更多
  86. </view>
  87. <image class="more" src="../static/jiantou-icon.png" mode=""></image>
  88. </view>
  89. </view>
  90. <scroll-view class="tab-box" enable-flex scroll-x>
  91. <view class="tab" :class="[tab == item.id ? 'active' : '']" v-for="(item, index) in tabList" :key="index"
  92. @click="handleTab(item.id)">
  93. {{ item.communityName }}
  94. </view>
  95. </scroll-view>
  96. <template>
  97. <!-- 列表 -->
  98. <zs-list class="store-box" mt="0">
  99. <view class="left">
  100. <view class="store-item" v-for="(item, index) in communityList" :key="index" @click="goCommunity(item.tabId)">
  101. <!-- <image class="play-icon" src="../static/play.png" mode="widthFix"></image> -->
  102. <zs-img :src="item.coverImg" width="344rpx" height="256rpx"></zs-img>
  103. <view class="info">
  104. <view class="title">
  105. {{ item.communityTitle }}
  106. </view>
  107. <view class="user-info">
  108. <view class="head">
  109. {{ item.communityName }}
  110. </view>
  111. <view class="user-name">
  112. 观看 {{ item.viewedCount }}
  113. </view>
  114. </view>
  115. </view>
  116. </view>
  117. </view>
  118. <view class="right">
  119. <view class="store-item" v-for="(item, index) in communityList1" :key="index"
  120. @click="goCommunity(item.tabId)">
  121. <image class="play-icon" src="../static/play.png" mode=""></image>
  122. <zs-img :src="item.coverImg" width="344rpx" height="256rpx"></zs-img>
  123. <view class="info">
  124. <view class="title">
  125. {{ item.communityTitle }}
  126. </view>
  127. <view class="user-info">
  128. <view class="head">
  129. {{ item.communityName }}
  130. </view>
  131. <view class="user-name">
  132. 观看 {{ item.viewedCount }}
  133. </view>
  134. </view>
  135. </view>
  136. </view>
  137. </view>
  138. <view v-if="communityList.length == 0 && communityList1.length == 0" class="noneContent">
  139. <view>没有数据</view>
  140. </view>
  141. </zs-list>
  142. </template>
  143. <view class="type-title more-title">
  144. 科普视频
  145. <view class="more-box" @click="jump('./community/video?columnId=' + query.columnId)">
  146. <view>
  147. 更多
  148. </view>
  149. <image class="more" src="../static/jiantou-icon.png" mode=""></image>
  150. </view>
  151. </view>
  152. <template>
  153. <!-- 列表 -->
  154. <zs-list class="store-box" mt="0" @load="loadMore" :status="status">
  155. <view class="left">
  156. <view class="store-item" v-for="(item, index) in list" :key="index" @click="goCourse(item.id)">
  157. <image class="play-icon" src="../static/play.png" mode="widthFix"></image>
  158. <zs-img :src="item.courseImg" width="344rpx" height="256rpx"></zs-img>
  159. <view class="info">
  160. <view class="title">
  161. {{ item.courseName }}
  162. </view>
  163. <view class="user-info">
  164. <view class="head" mode=""> 科普视频</view>
  165. <view class="user-name">
  166. 观看{{ item.viewedCount }}
  167. </view>
  168. </view>
  169. </view>
  170. </view>
  171. </view>
  172. <view class="right">
  173. <view class="store-item" v-for="(item, index) in list1" :key="index" @click="goCourse(item.id)">
  174. <image class="play-icon" src="../static/play.png" mode=""></image>
  175. <zs-img :src="item.courseImg" width="344rpx" height="256rpx"></zs-img>
  176. <view class="info">
  177. <view class="title">
  178. {{ item.courseName }}
  179. </view>
  180. <view class="user-info">
  181. <view class="head">科普视频</view>
  182. <!-- <image class="head" src="../static/logo.png" mode=""></image> -->
  183. <view class="user-name">
  184. 观看{{ item.viewedCount }}
  185. </view>
  186. </view>
  187. </view>
  188. </view>
  189. </view>
  190. </zs-list>
  191. </template>
  192. </view>
  193. </template>
  194. <script>
  195. import { getPage, videoList, studyGoods, studyGoodsByUser, getCommunitys, getItem, } from '@/api/study.js';
  196. export default {
  197. data() {
  198. return {
  199. bg: '',
  200. title: '',
  201. background: false,
  202. pageContent: [],
  203. status: 'more',
  204. list: [],
  205. list1: [],
  206. recommendList: [],
  207. recommendList1: [],
  208. communityList: [],
  209. communityList1: [],
  210. tab: 0,
  211. tabList: [],
  212. query: {
  213. columnId: 0,
  214. currentPage: 1,
  215. pageSize: 10,
  216. }
  217. }
  218. },
  219. methods: {
  220. jump(url) {
  221. uni.navigateTo({
  222. url
  223. });
  224. },
  225. // 去商品详情
  226. goGoodsDetail(id) {
  227. uni.navigateTo({
  228. url: '/study/studyGoodsDetail?id=' + id
  229. })
  230. },
  231. goTypeList(id, title) {
  232. uni.navigateTo({
  233. url: `/study/studyList?id=${id}&title=${title}`
  234. })
  235. },
  236. goDetail() { },
  237. // 去课程详情页
  238. goCourse(id) {
  239. uni.navigateTo({
  240. url: './courseDetail?id=' + id
  241. })
  242. },
  243. goCommunity(id) {
  244. console.log(id)
  245. uni.navigateTo({
  246. url: './community/detail?id=' + id
  247. });
  248. },
  249. loadMore() {
  250. this.videoList()
  251. },
  252. // 获取顶部栏目
  253. getPage(columnId) {
  254. return new Promise((resolve, reject) => {
  255. getPage({ currentPage: 1, pageSize: 10, columnId, status: 1 }).then(res => {
  256. if (res.state == 'Success') {
  257. res.content.map(item => {
  258. let obj = {
  259. id: item.id,
  260. title: item.columnName,
  261. list: []
  262. }
  263. this.pageContent.push(obj)
  264. })
  265. console.log(this.pageContent);
  266. resolve()
  267. }
  268. })
  269. })
  270. },
  271. // 课程视频
  272. videoList() {
  273. this.status = 'loading'
  274. videoList(this.query).then(res => {
  275. if (res.state == 'Success') {
  276. let list = []
  277. let list1 = []
  278. res.content.records.map((item, index) => {
  279. if (index % 2) {
  280. list1.push(item)
  281. } else {
  282. list.push(item)
  283. }
  284. })
  285. this.list = this.list.concat(list)
  286. this.list1 = this.list1.concat(list1)
  287. let total = this.list.length + this.list1.length
  288. if (total >= res.content.total) {
  289. this.status = 'noMore'
  290. } else {
  291. this.status = 'more'
  292. this.query.currentPage++
  293. }
  294. }
  295. })
  296. },
  297. getStudyGoods() {
  298. this.pageContent.map(item => {
  299. studyGoods({ columnId: item.id, currentPage: 1, pageSize: 4 }).then(res => {
  300. if (res.state == 'Success') {
  301. item.list = res.content.records
  302. }
  303. })
  304. })
  305. },
  306. studyRecommendByUser() {
  307. studyGoodsByUser({
  308. columnId: this.query.columnId,
  309. currentPage: 1,
  310. pageSize: 4
  311. }).then(res => {
  312. if (res.state == 'Success') {
  313. let recommendList = []
  314. let recommendList1 = []
  315. res.content.records.map((item, index) => {
  316. if (index % 2) {
  317. recommendList1.push(item)
  318. } else {
  319. recommendList.push(item)
  320. }
  321. })
  322. this.recommendList = this.recommendList.concat(recommendList)
  323. this.recommendList1 = this.recommendList1.concat(recommendList1)
  324. }
  325. })
  326. },
  327. getColumnTabs() {
  328. getCommunitys({ columnId: this.query.columnId }).then(res => {
  329. if (res.state == 'Success') {
  330. this.tabList = res.content
  331. if (this.tabList.length > 0) {
  332. this.tab = this.tabList[0].id
  333. this.getItem(this.tab)
  334. }
  335. }
  336. })
  337. },
  338. // 点击社区tab
  339. handleTab(tab) {
  340. this.tab = tab
  341. this.communityList = []
  342. this.communityList1 = []
  343. this.getItem(tab)
  344. },
  345. //获取社区分类列表
  346. getItem(communityId) {
  347. getItem({ communityId, currentPage: 1, pageSize: 2, state: 2 }).then(res => {
  348. if (res.state == 'Success') {
  349. let communityList = []
  350. let communityList1 = []
  351. res.content.records.map((item, index) => {
  352. if (index % 2) {
  353. communityList1.push(item)
  354. } else {
  355. communityList.push(item)
  356. }
  357. })
  358. this.communityList = this.communityList.concat(communityList)
  359. this.communityList1 = this.communityList1.concat(communityList1)
  360. }
  361. })
  362. },
  363. },
  364. onLoad(options) {
  365. this.query.columnId = options.id
  366. // this.getPage(options.id).then(()=>{
  367. // this.getStudyGoods()
  368. // })
  369. this.getColumnTabs()
  370. this.studyRecommendByUser()
  371. let that = this
  372. const eventChannel = this.getOpenerEventChannel();
  373. if (JSON.stringify(eventChannel) !== '{}') {
  374. eventChannel.on('img', function (img, name) {
  375. that.bg = img
  376. that.title = name
  377. })
  378. }
  379. },
  380. onPageScroll(e) {
  381. if (e.scrollTop >= 30) {
  382. this.background = true
  383. } else {
  384. this.background = false
  385. }
  386. },
  387. }
  388. </script>
  389. <style lang="scss">
  390. .study-type {
  391. padding: 0 20rpx;
  392. background: #F9F9F9;
  393. .banner {
  394. width: 750rpx;
  395. height: 480rpx;
  396. vertical-align: bottom;
  397. position: relative;
  398. left: -20rpx;
  399. }
  400. .title-box {
  401. display: flex;
  402. align-items: center;
  403. justify-content: space-between;
  404. .more {
  405. font-size: 20rpx;
  406. color: #AAAAAA;
  407. }
  408. }
  409. .more-title {
  410. display: flex;
  411. justify-content: space-between;
  412. align-items: center;
  413. .more-box {
  414. display: flex;
  415. align-items: center;
  416. font-size: 24rpx;
  417. color: #AAAAAA;
  418. .more {
  419. width: 20rpx;
  420. height: 20rpx;
  421. display: block;
  422. margin-left: 6rpx;
  423. }
  424. }
  425. }
  426. .tab-box {
  427. display: flex;
  428. align-items: flex-start;
  429. .tab {
  430. flex-shrink: 0;
  431. padding: 10rpx 24rpx;
  432. // margin-top: 28rpx;
  433. color: #AAAAAA;
  434. background: #EEEEEE;
  435. font-size: 28rpx;
  436. margin-right: 20rpx;
  437. border-radius: 8rpx;
  438. }
  439. .tab.active {
  440. color: #222222;
  441. // background: #CEE0FF;
  442. }
  443. }
  444. .type-title {
  445. font-weight: bold;
  446. color: #222222;
  447. font-size: 32rpx;
  448. margin: 20rpx 0 20rpx;
  449. }
  450. .type-box {
  451. display: flex;
  452. justify-content: space-between;
  453. flex-wrap: wrap;
  454. .type-item {
  455. width: 340rpx;
  456. margin-bottom: 20rpx;
  457. // box-shadow: 0rpx 0rpx 24rpx 2rpx rgba(0, 0, 0, 0.08);
  458. border-radius: 16rpx;
  459. background: #fff;
  460. .icon {
  461. width: 100%;
  462. height: 300rpx;
  463. border-radius: 16rpx 16rpx 0 0;
  464. }
  465. .info {
  466. flex: 1;
  467. padding: 16rpx;
  468. display: flex;
  469. flex-direction: column;
  470. justify-content: space-between;
  471. position: relative;
  472. .title {
  473. font-size: 28rpx;
  474. font-weight: bold;
  475. width: 100%;
  476. white-space: nowrap;
  477. overflow: hidden;
  478. text-overflow: ellipsis;
  479. margin-top: 10rpx;
  480. }
  481. .desc {
  482. font-size: 24rpx;
  483. color: #AAAAAA;
  484. overflow: hidden;
  485. text-overflow: ellipsis;
  486. /* 弹性伸缩盒子模型显示 */
  487. display: -webkit-box;
  488. /* 限制在一个块元素显示的文本的行数 */
  489. -webkit-line-clamp: 2;
  490. /* 设置或检索伸缩盒对象的子元素的排列方式 */
  491. -webkit-box-orient: vertical;
  492. margin-top: 12rpx;
  493. }
  494. .price-box {
  495. display: flex;
  496. justify-content: space-between;
  497. align-items: center;
  498. margin-top: 12rpx;
  499. .left {
  500. display: flex;
  501. align-items: flex-end;
  502. .unit {
  503. font-size: 20rpx;
  504. color: $uni-color-primary;
  505. font-weight: bold;
  506. }
  507. .price {
  508. font-size: 32rpx;
  509. color: $uni-color-primary;
  510. font-weight: bold;
  511. }
  512. }
  513. .right {
  514. font-size: 24rpx;
  515. color: #AAAAAA;
  516. }
  517. }
  518. }
  519. }
  520. }
  521. .swiper {
  522. height: 272rpx;
  523. border-radius: 16rpx;
  524. margin-top: 28rpx;
  525. .swiper-item {
  526. width: 100%;
  527. height: 100%;
  528. border-radius: 16rpx;
  529. object-fit: cover;
  530. }
  531. }
  532. .noneContent {
  533. display: flex;
  534. justify-content: center;
  535. width: 100%;
  536. padding-top: 10rpx;
  537. color: #777777;
  538. font-size: 28rpx;
  539. }
  540. .zs-list {
  541. display: flex;
  542. flex-wrap: wrap;
  543. justify-content: space-between;
  544. .left {}
  545. .right {}
  546. .store-item {
  547. box-shadow: 0rpx 0rpx 24rpx 2rpx rgba(0, 0, 0, 0.08);
  548. border-radius: 16rpx;
  549. width: 344rpx;
  550. margin-top: 20rpx;
  551. position: relative;
  552. .play-icon {
  553. position: absolute;
  554. top: 20rpx;
  555. right: 30rpx;
  556. width: 30rpx;
  557. height: 30rpx;
  558. z-index: 2;
  559. }
  560. .info {
  561. padding: 20rpx;
  562. .title {
  563. color: #222222;
  564. height: 76rpx;
  565. font-size: 28rpx;
  566. font-weight: bold;
  567. width: 100%;
  568. display: -webkit-box;
  569. -webkit-box-orient: vertical;
  570. -webkit-line-clamp: 2;
  571. /* 显示的最大行数 */
  572. overflow: hidden;
  573. }
  574. .user-info {
  575. display: flex;
  576. align-items: center;
  577. justify-content: space-between;
  578. margin-top: 20rpx;
  579. font-size: 20rpx;
  580. color: #AAAAAA;
  581. .head {
  582. font-size: 20rpx;
  583. }
  584. .user-name {
  585. font-size: 20rpx;
  586. overflow: hidden;
  587. text-overflow: ellipsis;
  588. display: -webkit-box;
  589. -webkit-box-orient: vertical;
  590. -webkit-line-clamp: 1;
  591. }
  592. }
  593. .price-box {
  594. display: flex;
  595. justify-content: space-between;
  596. align-items: center;
  597. margin-top: 12rpx;
  598. .left {
  599. display: flex;
  600. align-items: flex-end;
  601. .unit {
  602. font-size: 24rpx;
  603. color: $uni-color-primary;
  604. font-weight: bold;
  605. }
  606. .price {
  607. font-size: 32rpx;
  608. color: $uni-color-primary;
  609. font-weight: bold;
  610. }
  611. .old-price {
  612. font-size: 20rpx;
  613. color: #AAAAAA;
  614. text-decoration: line-through;
  615. margin-left: 10rpx;
  616. }
  617. }
  618. .right {
  619. font-size: 20rpx;
  620. color: #AAAAAA;
  621. }
  622. }
  623. }
  624. }
  625. }
  626. }
  627. </style>