type.vue 8.3 KB

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