type.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370
  1. <template>
  2. <view class="study-type">
  3. <!-- 导航栏 -->
  4. <zs-header :background="background"></zs-header>
  5. <image class="banner" :src="bg" mode=""></image>
  6. <!-- 横向 -->
  7. <view v-for="(item,index) in pageContent" :key="item.id">
  8. <view class="type-title" v-if="item.pages.length">
  9. {{item.columnName}}
  10. </view>
  11. <!-- type-box横向 type-box1纵向 -->
  12. <view :class="item.templateType == 1?'type-box1':'type-box'">
  13. <view class="type-item" v-for="(i,d) in item.pages" :key="i.id" @click="goTypeList(i.id,i.columnName)">
  14. <view class="glass" :style="{'--bg':i.colour}">
  15. <view class="title">
  16. {{i.columnName}}
  17. </view>
  18. <view class="type">
  19. {{i.columnMsg}}
  20. </view>
  21. </view>
  22. <image class="icon" :src="i.columnImg" mode=""></image>
  23. </view>
  24. </view>
  25. <!-- 纵向 -->
  26. <!-- <view class="type-box1">
  27. <view class="type-item" v-for="(i,d) in item.pages" :key="i.id" @click="goTypeList(i.id,i.columnName)">
  28. <view class="glass">
  29. <view class="title">
  30. {{i.columnName}}
  31. </view>
  32. <view class="type">
  33. {{i.columnMsg}}
  34. </view>
  35. </view>
  36. <image class="icon" :src="i.columnImg" mode=""></image>
  37. </view>
  38. </view> -->
  39. </view>
  40. <template>
  41. <view class="type-title" v-if="list.length||list1.length">
  42. 科普视频
  43. </view>
  44. <!-- 列表 -->
  45. <zs-list class="store-box" mt="0" @load="loadMore" :status="status">
  46. <view class="left">
  47. <view class="store-item" v-for="(item,index) in list" :key="index" @click="goCourse(item.id)">
  48. <image class="play-icon" src="../static/play.png" mode="widthFix"></image>
  49. <zs-img :src="item.courseImg" width="344rpx" height="256rpx"></zs-img>
  50. <view class="info">
  51. <view class="title">
  52. {{item.courseName}}
  53. </view>
  54. <view class="user-info">
  55. <image class="head" src="../static/logo.png" mode=""></image>
  56. <view class="user-name">
  57. 研学官方账号
  58. </view>
  59. </view>
  60. </view>
  61. </view>
  62. </view>
  63. <view class="right">
  64. <view class="store-item" v-for="(item,index) in list1" :key="index" @click="goCourse(item.id)">
  65. <image class="play-icon" src="../static/play.png" mode=""></image>
  66. <zs-img :src="item.courseImg" width="344rpx" height="256rpx"></zs-img>
  67. <view class="info">
  68. <view class="title">
  69. {{item.courseName}}
  70. </view>
  71. <view class="user-info">
  72. <image class="head" src="../static/logo.png" mode=""></image>
  73. <view class="user-name">
  74. 研学官方账号
  75. </view>
  76. </view>
  77. </view>
  78. </view>
  79. </view>
  80. </zs-list>
  81. </template>
  82. </view>
  83. </template>
  84. <script>
  85. import {getMenu,getPage,videoList,studyGoods} from '@/api/study.js';
  86. export default {
  87. data() {
  88. return {
  89. bg:'',
  90. background:false,
  91. pageContent:[],
  92. status: 'more',
  93. list: [],
  94. list1: [],
  95. query:{
  96. columnId:0,
  97. currentPage:1,
  98. pageSize:10,
  99. }
  100. }
  101. },
  102. methods: {
  103. goTypeList(id,title){
  104. uni.navigateTo({
  105. url:`/study/studyList?id=${id}&title=${title}`
  106. })
  107. },
  108. goDetail(){},
  109. // 去课程详情页
  110. goCourse(id){
  111. uni.navigateTo({
  112. url:'./courseDetail?id='+id
  113. })
  114. },
  115. loadMore() {
  116. this.videoList()
  117. },
  118. // 获取顶部栏目
  119. getPage(columnId){
  120. getPage({currentPage:1,pageSize:10,columnId,status:1}).then(res=>{
  121. if(res.state == 'Success'){
  122. this.pageContent = res.content
  123. this.studyGoods(50)
  124. }
  125. })
  126. },
  127. // 课程视频
  128. videoList(){
  129. this.status = 'loading'
  130. videoList(this.query).then(res=>{
  131. if(res.state == 'Success'){
  132. let list = []
  133. let list1 = []
  134. res.content.records.map((item,index)=>{
  135. if(index%2){
  136. list1.push(item)
  137. }else{
  138. list.push(item)
  139. }
  140. })
  141. this.list = this.list.concat(list)
  142. this.list1 = this.list1.concat(list1)
  143. let total = this.list.length+this.list1.length
  144. if(total>=res.content.total){
  145. this.status = 'noMore'
  146. }else{
  147. this.status = 'more'
  148. this.query.currentPage++
  149. }
  150. }
  151. })
  152. },
  153. studyGoods(columnId){
  154. studyGoods({columnId,currentPage:1,pageSize:4}).then(res=>{
  155. if(res.state == 'Success'){
  156. }
  157. })
  158. }
  159. },
  160. onLoad(options) {
  161. this.query.columnId = options.id
  162. this.getPage(options.id)
  163. let that = this
  164. const eventChannel = this.getOpenerEventChannel();
  165. if(JSON.stringify(eventChannel) !=='{}'){
  166. eventChannel.on('img', function(data) {
  167. that.bg = data
  168. })
  169. }
  170. },
  171. onPageScroll(e) {
  172. if(e.scrollTop >= 30){
  173. this.background = true
  174. }else{
  175. this.background = false
  176. }
  177. },
  178. }
  179. </script>
  180. <style lang="scss" >
  181. .study-type{
  182. padding: 0 20rpx;
  183. .banner{
  184. width: 750rpx;
  185. height: 420rpx;
  186. vertical-align: bottom;
  187. position: relative;
  188. left: -20rpx;
  189. }
  190. .type-title{
  191. font-weight: bold;
  192. color: #222222;
  193. font-size: 32rpx;
  194. margin: 30rpx 0 20rpx;
  195. }
  196. .type-box{
  197. display: flex;
  198. justify-content: space-between;
  199. flex-wrap: wrap;
  200. .type-item{
  201. position: relative;
  202. margin-bottom: 16rpx;
  203. .glass{
  204. position: absolute;
  205. bottom: 0%;
  206. left: 0%;
  207. width: 100%;
  208. height: 72rpx;
  209. padding-left: 16rpx;
  210. box-sizing: border-box;
  211. border-radius:0 0 16rpx 16rpx;
  212. background: linear-gradient(180deg, rgba(0,188,255,0) 0%, var(--bg) 100%);
  213. .title{
  214. font-weight: bold;
  215. color: #FFFFFF;
  216. font-size: 24rpx;
  217. margin-top: 8rpx;
  218. width: 100%;
  219. white-space: nowrap;
  220. overflow: hidden;
  221. text-overflow: ellipsis;
  222. }
  223. .type{
  224. font-weight: 400;
  225. color: #FFFFFF;
  226. font-size: 16rpx;
  227. margin-top: 8rpx;
  228. width: 100%;
  229. white-space: nowrap;
  230. overflow: hidden;
  231. text-overflow: ellipsis;
  232. }
  233. }
  234. .icon{
  235. width: 224rpx;
  236. height: 124rpx;
  237. border-radius: 16rpx;
  238. vertical-align: bottom;
  239. }
  240. }
  241. }
  242. .type-box1{
  243. display: flex;
  244. justify-content: space-between;
  245. flex-wrap: wrap;
  246. .type-item{
  247. position: relative;
  248. margin-bottom: 16rpx;
  249. .glass{
  250. position: absolute;
  251. bottom: 0%;
  252. left: 0%;
  253. width: 100%;
  254. height: 72rpx;
  255. padding-left: 16rpx;
  256. box-sizing: border-box;
  257. border-radius:0 0 16rpx 16rpx;
  258. backdrop-filter: blur(6px);
  259. .title{
  260. font-weight: bold;
  261. color: #FFFFFF;
  262. font-size: 24rpx;
  263. margin-top: 8rpx;
  264. width: 100%;
  265. white-space: nowrap;
  266. overflow: hidden;
  267. text-overflow: ellipsis;
  268. }
  269. .type{
  270. font-weight: 400;
  271. color: #FFFFFF;
  272. font-size: 16rpx;
  273. margin-top: 8rpx;
  274. width: 100%;
  275. white-space: nowrap;
  276. overflow: hidden;
  277. text-overflow: ellipsis;
  278. }
  279. }
  280. .icon{
  281. width: 224rpx;
  282. height: 298rpx;
  283. border-radius: 16rpx;
  284. vertical-align: bottom;
  285. }
  286. }
  287. }
  288. .swiper {
  289. height: 272rpx;
  290. border-radius: 16rpx;
  291. margin-top: 28rpx;
  292. .swiper-item {
  293. width: 100%;
  294. height: 100%;
  295. border-radius: 16rpx;
  296. object-fit: cover;
  297. }
  298. }
  299. .zs-list {
  300. display: flex;
  301. flex-wrap: wrap;
  302. justify-content: space-between;
  303. .left {
  304. }
  305. .right {
  306. }
  307. .store-item{
  308. box-shadow: 0rpx 0rpx 24rpx 2rpx rgba(0,0,0,0.08);
  309. border-radius: 16rpx;
  310. width: 344rpx;
  311. margin-top: 20rpx;
  312. position: relative;
  313. .play-icon{
  314. position: absolute;
  315. top: 20rpx;
  316. right: 30rpx;
  317. width: 30rpx;
  318. height: 30rpx;
  319. z-index: 2;
  320. }
  321. .info{
  322. padding: 20rpx;
  323. .title{
  324. color: #222222;
  325. font-size: 24rpx;
  326. width: 100%;
  327. display: -webkit-box;
  328. -webkit-box-orient: vertical;
  329. -webkit-line-clamp: 2; /* 显示的最大行数 */
  330. overflow: hidden;
  331. }
  332. .user-info{
  333. display: flex;
  334. align-items: center;
  335. margin-top: 20rpx;
  336. .head{
  337. width: 40rpx;
  338. height: 40rpx;
  339. border-radius: 50%;
  340. }
  341. .user-name{
  342. color: #AAAAAA;
  343. font-size: 20rpx;
  344. margin-left: 12rpx;
  345. }
  346. }
  347. }
  348. }
  349. }
  350. }
  351. </style>