type.vue 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362
  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} 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. }
  124. })
  125. },
  126. // 课程视频
  127. videoList(){
  128. this.status = 'loading'
  129. videoList(this.query).then(res=>{
  130. if(res.state == 'Success'){
  131. let list = []
  132. let list1 = []
  133. res.content.records.map((item,index)=>{
  134. if(index%2){
  135. list1.push(item)
  136. }else{
  137. list.push(item)
  138. }
  139. })
  140. this.list = this.list.concat(list)
  141. this.list1 = this.list1.concat(list1)
  142. let total = this.list.length+this.list1.length
  143. if(total>=res.content.total){
  144. this.status = 'noMore'
  145. }else{
  146. this.status = 'more'
  147. this.query.currentPage++
  148. }
  149. }
  150. })
  151. }
  152. },
  153. onLoad(options) {
  154. this.query.columnId = options.id
  155. this.getPage(options.id)
  156. let that = this
  157. const eventChannel = this.getOpenerEventChannel();
  158. if(JSON.stringify(eventChannel) !=='{}'){
  159. eventChannel.on('img', function(data) {
  160. that.bg = data
  161. })
  162. }
  163. },
  164. onPageScroll(e) {
  165. if(e.scrollTop >= 30){
  166. this.background = true
  167. }else{
  168. this.background = false
  169. }
  170. },
  171. }
  172. </script>
  173. <style lang="scss" >
  174. .study-type{
  175. padding: 0 20rpx;
  176. .banner{
  177. width: 750rpx;
  178. height: 420rpx;
  179. vertical-align: bottom;
  180. position: relative;
  181. left: -20rpx;
  182. }
  183. .type-title{
  184. font-weight: bold;
  185. color: #222222;
  186. font-size: 32rpx;
  187. margin: 30rpx 0 20rpx;
  188. }
  189. .type-box{
  190. display: flex;
  191. justify-content: space-between;
  192. flex-wrap: wrap;
  193. .type-item{
  194. position: relative;
  195. margin-bottom: 16rpx;
  196. .glass{
  197. position: absolute;
  198. bottom: 0%;
  199. left: 0%;
  200. width: 100%;
  201. height: 72rpx;
  202. padding-left: 16rpx;
  203. box-sizing: border-box;
  204. border-radius:0 0 16rpx 16rpx;
  205. background: linear-gradient(180deg, rgba(0,188,255,0) 0%, var(--bg) 100%);
  206. .title{
  207. font-weight: bold;
  208. color: #FFFFFF;
  209. font-size: 24rpx;
  210. margin-top: 8rpx;
  211. width: 100%;
  212. white-space: nowrap;
  213. overflow: hidden;
  214. text-overflow: ellipsis;
  215. }
  216. .type{
  217. font-weight: 400;
  218. color: #FFFFFF;
  219. font-size: 16rpx;
  220. margin-top: 8rpx;
  221. width: 100%;
  222. white-space: nowrap;
  223. overflow: hidden;
  224. text-overflow: ellipsis;
  225. }
  226. }
  227. .icon{
  228. width: 224rpx;
  229. height: 124rpx;
  230. border-radius: 16rpx;
  231. vertical-align: bottom;
  232. }
  233. }
  234. }
  235. .type-box1{
  236. display: flex;
  237. justify-content: space-between;
  238. flex-wrap: wrap;
  239. .type-item{
  240. position: relative;
  241. margin-bottom: 16rpx;
  242. .glass{
  243. position: absolute;
  244. bottom: 0%;
  245. left: 0%;
  246. width: 100%;
  247. height: 72rpx;
  248. padding-left: 16rpx;
  249. box-sizing: border-box;
  250. border-radius:0 0 16rpx 16rpx;
  251. backdrop-filter: blur(6px);
  252. .title{
  253. font-weight: bold;
  254. color: #FFFFFF;
  255. font-size: 24rpx;
  256. margin-top: 8rpx;
  257. width: 100%;
  258. white-space: nowrap;
  259. overflow: hidden;
  260. text-overflow: ellipsis;
  261. }
  262. .type{
  263. font-weight: 400;
  264. color: #FFFFFF;
  265. font-size: 16rpx;
  266. margin-top: 8rpx;
  267. width: 100%;
  268. white-space: nowrap;
  269. overflow: hidden;
  270. text-overflow: ellipsis;
  271. }
  272. }
  273. .icon{
  274. width: 224rpx;
  275. height: 298rpx;
  276. border-radius: 16rpx;
  277. vertical-align: bottom;
  278. }
  279. }
  280. }
  281. .swiper {
  282. height: 272rpx;
  283. border-radius: 16rpx;
  284. margin-top: 28rpx;
  285. .swiper-item {
  286. width: 100%;
  287. height: 100%;
  288. border-radius: 16rpx;
  289. object-fit: cover;
  290. }
  291. }
  292. .zs-list {
  293. display: flex;
  294. flex-wrap: wrap;
  295. justify-content: space-between;
  296. .left {
  297. }
  298. .right {
  299. }
  300. .store-item{
  301. box-shadow: 0rpx 0rpx 24rpx 2rpx rgba(0,0,0,0.08);
  302. border-radius: 16rpx;
  303. width: 344rpx;
  304. margin-top: 20rpx;
  305. position: relative;
  306. .play-icon{
  307. position: absolute;
  308. top: 20rpx;
  309. right: 30rpx;
  310. width: 30rpx;
  311. height: 30rpx;
  312. z-index: 2;
  313. }
  314. .info{
  315. padding: 20rpx;
  316. .title{
  317. color: #222222;
  318. font-size: 24rpx;
  319. width: 100%;
  320. display: -webkit-box;
  321. -webkit-box-orient: vertical;
  322. -webkit-line-clamp: 2; /* 显示的最大行数 */
  323. overflow: hidden;
  324. }
  325. .user-info{
  326. display: flex;
  327. align-items: center;
  328. margin-top: 20rpx;
  329. .head{
  330. width: 40rpx;
  331. height: 40rpx;
  332. border-radius: 50%;
  333. }
  334. .user-name{
  335. color: #AAAAAA;
  336. font-size: 20rpx;
  337. margin-left: 12rpx;
  338. }
  339. }
  340. }
  341. }
  342. }
  343. }
  344. </style>