type.vue 15 KB

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