liveCourse.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468
  1. <template>
  2. <view class="container">
  3. <view class="headbox">
  4. <!-- <view class="headnav x-bc">
  5. <view :class="activeTab == 0 ? 'headnav-item headnav-active':'headnav-item'" @click="handleNav(0)">
  6. <view>直播计划</view>
  7. <view class="headnav-num">3</view>
  8. <image src="https://fbylive.obs.cn-southwest-2.myhuaweicloud.com/app/images/idle.png" mode="aspectFill"></image>
  9. </view>
  10. <view :class="activeTab == 1? 'headnav-item headnav-active':'headnav-item'" @click="handleNav(1)">
  11. <view>今日直播</view>
  12. <view class="headnav-num">3</view>
  13. <image src="https://fbylive.obs.cn-southwest-2.myhuaweicloud.com/app/images/streaming.png" mode="aspectFill"></image>
  14. </view>
  15. <view :class="activeTab == 2 ? 'headnav-item headnav-active':'headnav-item'" @click="handleNav(2)">
  16. <view>往日直播</view>
  17. <view class="headnav-num">3</view>
  18. <image src="https://fbylive.obs.cn-southwest-2.myhuaweicloud.com/app/images/finished.png" mode="aspectFill"></image>
  19. </view>
  20. </view> -->
  21. <!-- <view class="x-bc">
  22. <view :class="searchbarNav == index ? 'searchbar x-c searchbar-active':'searchbar x-c'" v-for="(item,index) in searchbar" :key="index" @click="clickSearchbar(index)">
  23. <text>{{item.name}}</text><u-icon class="arrow-down" name="arrow-down" :color="searchbarNav == index ?'#1677ff':'#999'" size="12"></u-icon>
  24. </view>
  25. </view> -->
  26. <dropdownPanel :filterData='filterData' @onChange="onChange" @confirm="confirm" @reset="reset">
  27. <scroll-view scroll-y="true" class="hb" :refresher-enabled="isEnableds"
  28. :refresher-triggered="triggereds" refresher-background="rgba(0,0,0,0)"
  29. @refresherrefresh="pullDownRefreshs" @refresherrestore="triggereds = false"
  30. :upper-threshold="100" :lower-threshold="100" @refresherabort="triggereds = false"
  31. @scrolltolower="reachBottoms">
  32. <view class="justify-between align-center mb20 mlr20 ">
  33. <u-search placeholder="搜索训练营" v-model="keyword" :showAction="false" height="30px"
  34. @search='searchKeyword'></u-search>
  35. </view>
  36. <view v-if="searchbarNav == 0">
  37. <view class="boxnav x-bc">
  38. <view class="boxnav-item" v-for="(item,index) in courseList" :key="index">
  39. <view class="boxnav-item-info one-t"
  40. :class="courserIndex == index ? 'boxnav-active':''"
  41. @click="handleCourse(item,index)">{{item.periodName}}</view>
  42. </view>
  43. </view>
  44. </view>
  45. <u-loadmore :status="status" />
  46. </scroll-view>
  47. </dropdownPanel>
  48. </view>
  49. <view class="justify-between align-center mb20 mlr20 mt20 ">
  50. <u-search placeholder="请输入课程名称" v-model="keywordlist" :showAction="false" height="30px"
  51. @search='searchKeywordlist' bgColor='#fff'></u-search>
  52. </view>
  53. <view class="container-right" >
  54. <scroll-view style="height:100%" :scroll-y="true" :refresher-enabled="true" :refresher-triggered="triggered"
  55. refresher-background="rgba(0,0,0,0)" @refresherrefresh="pullDownRefresh" :scroll-top='scrollTop'
  56. @refresherrestore="triggered = false" :upper-threshold="100" :lower-threshold="100"
  57. @refresherabort="triggered = false" @scrolltolower="reachBottom" @scroll="scroll">
  58. <view class="list">
  59. <courseItem :from="'course'" :activeTab="1" v-for="(item,index) in dataList" :key="index"
  60. :info="item" @trigger-share="handleShare" :parent-method="parentMethod"/>
  61. <u-loadmore :status="loadStatus" />
  62. </view>
  63. </scroll-view>
  64. </view>
  65. </view>
  66. </template>
  67. <script>
  68. import {
  69. getFsCourseList,
  70. getCourseVdieoList
  71. } from "@/api/courseManage.js"
  72. import dropdownPanel from "@/components/dropdownPanel.vue"
  73. import courseItem from "@/components/courseItem.vue"
  74. export default {
  75. name:"liveCourse",
  76. components: {
  77. courseItem,
  78. dropdownPanel
  79. },
  80. props: ['parentMethod'],
  81. data() {
  82. return {
  83. user: {},
  84. filterData: [{
  85. name: '训练营-营期',
  86. value: 0,
  87. },
  88. ],
  89. contentH: 0,
  90. activeTab: 1,
  91. courseList: [],
  92. courseId: '',
  93. searchbarNav: 0,
  94. courserIndex: '',
  95. searchbar: [{
  96. name: '训练营-营期'
  97. },
  98. {
  99. name: '课程状态'
  100. }
  101. ],
  102. mescroll: null,
  103. downOption: {
  104. use: true,
  105. auto: false
  106. },
  107. upOption: {
  108. onScroll: false,
  109. use: true, // 是否启用上拉加载; 默认true
  110. auto: true,
  111. page: {
  112. pae: 0, // 当前页码,默认0,回调之前会加1,即callback(page)会从1开始
  113. size: 10 // 每页数据的数量,默认10
  114. },
  115. noMoreSize: 10, // 配置列表的总数量要大于等于5条才显示'-- END --'的提示
  116. textNoMore: "已经到底了",
  117. empty: {
  118. icon: 'https://cos.his.cdwjyyh.com/fs/20240423/cf4a86b913a04341bb44e34bb4d37aa2.png',
  119. tip: '暂无数据'
  120. }
  121. },
  122. dataList: [],
  123. params: {
  124. pageNum: 1,
  125. pageSize: 10
  126. },
  127. triggered: false,
  128. loadStatus: 'loadmore',
  129. //课程选择列表
  130. pageNum:1,
  131. pageSize: 10,
  132. triggereds: false,
  133. status: 'loadmore',
  134. keyword:'',
  135. isEnableds:true,
  136. keywordlist:'',
  137. actid:'',
  138. scrollTop: 0,
  139. old: {
  140. scrollTop: 0
  141. },
  142. shareConfig:'',
  143. titleName:''
  144. }
  145. },
  146. mounted() {
  147. const windowHeight = uni.getSystemInfoSync().windowHeight
  148. this.contentH = `calc(${windowHeight}px - 132px - 56px)`
  149. this.user = uni.getStorageSync("companyUserInfo") ? JSON.parse(uni.getStorageSync("companyUserInfo")) : {}
  150. this.getFsCourseList()
  151. },
  152. methods: {
  153. handleShare(config) {
  154. // 保存分享配置到父页面数据
  155. this.shareConfig = config;
  156. this.$emit('child-data-update', this.shareConfig);
  157. // 调起分享面板(微信小程序需主动调用)
  158. // #ifdef MP-WEIXIN
  159. uni.showShareMenu();
  160. // #endif
  161. },
  162. scroll: function(e) {
  163. this.old.scrollTop = e.detail.scrollTop
  164. },
  165. onChange(index) {
  166. this.searchbarNav = index
  167. },
  168. reset() {
  169. this.courseId = ''
  170. this.keyword =''
  171. this.courseList=[]
  172. this.getFsCourseList()
  173. },
  174. handleCourse(item,index) {
  175. this.courserIndex = index
  176. this.titleName=item.periodName
  177. this.actid=item.periodId
  178. },
  179. confirm() {
  180. this.courseId = this.actid
  181. this.filterData[0].name=this.titleName
  182. console.log(this.filterData[0].name)
  183. this.params.pageNum=1
  184. this.getListData('refresh')
  185. },
  186. searchKeyword(value){
  187. this.courseList=[]
  188. this.keyword = value
  189. this.params.pageNum=1
  190. this.getFsCourseList('refresh')
  191. },
  192. searchKeywordlist(value){
  193. this.dataList = []
  194. this.keywordlist = value
  195. this.getListData()
  196. },
  197. pullDownRefreshs() {
  198. // 下拉
  199. this.triggereds = true; //下拉了状态为true
  200. setTimeout(() => {
  201. this.triggereds = false;
  202. uni.stopPullDownRefresh()
  203. this.pageNum = 1;
  204. this.getFsCourseList('refresh') //触底 不穿执行else
  205. // 请求接口里面需要判断是不是最后一页 是最后一页 status赋值为‘loadmore’没有更多了
  206. // 请求接口
  207. }, 1000)
  208. },
  209. reachBottoms() {
  210. // status这个是加载状态
  211. if (this.status === 'loadmore') {
  212. this.status = 'loading'
  213. uni.showNavigationBarLoading()
  214. setTimeout(() => {
  215. this.pageNum++
  216. this.getFsCourseList() //触底 不穿执行else
  217. uni.hideNavigationBarLoading()
  218. }, 1000);
  219. }
  220. },
  221. // 训练营
  222. getFsCourseList(type) {
  223. const day = uni.$u.timeFormat(new Date(), 'yyyy-mm-dd')
  224. const param = {
  225. pageNum:this.pageNum,
  226. pageSize:this.pageSize,
  227. keyword:this.keyword
  228. }
  229. getFsCourseList(param).then(res => {
  230. if (res.code == 200) {
  231. if (type == 'refresh') {
  232. this.courseList = res.data.list
  233. } else {
  234. // 加载更多 当前页和下一页合并
  235. this.courseList = [...this.courseList, ...res.data.list]
  236. }
  237. if ( res.data.isLastPage) {
  238. this.status = 'nomore'
  239. } else {
  240. this.status = 'loadmore'
  241. }
  242. this.courseId=this.courseList[0].periodId
  243. this.filterData[0].name=this.courseList[0].periodName
  244. this.getListInit()
  245. } else {
  246. uni.showToast({
  247. icon: 'none',
  248. title: res.msg,
  249. });
  250. }
  251. })
  252. },
  253. handleNav(type) {
  254. this.activeTab = type
  255. },
  256. clickSearchbar(type) {
  257. this.searchbarNav = type == this.searchbarNav ? 'colse' : type
  258. },
  259. mescrollInit(mescroll) {
  260. this.mescroll = mescroll;
  261. },
  262. getListInit() {
  263. this.params.pageNum = 1
  264. this.getListData('refresh')
  265. },
  266. async getListData(type) {
  267. console.log(type)
  268. uni.showLoading({
  269. title: "加载中..."
  270. })
  271. this.loadStatus = 'loading'
  272. const result = await getCourseVdieoList({
  273. periodId: this.courseId,
  274. keyword:this.keywordlist,
  275. ...this.params
  276. })
  277. if (result) {
  278. const {
  279. isLastPage,
  280. total,
  281. list,
  282. } = result.data
  283. if (type == 'refresh') {
  284. this.dataList = list
  285. } else {
  286. this.dataList = [...this.dataList, ...list]
  287. }
  288. if (isLastPage) {
  289. this.loadStatus = 'nomore';
  290. } else {
  291. this.loadStatus = 'loadmore';
  292. }
  293. // 当页数为1时,重置滚动位置
  294. if (this.params.pageNum === 1) {
  295. console.log(this.scrollTop)
  296. this.scrollTop = this.old.scrollTop
  297. this.$nextTick(function() {
  298. this.scrollTop = 0
  299. });
  300. }
  301. uni.hideLoading()
  302. } else {
  303. uni.showToast({
  304. icon: 'none',
  305. title: "请求失败",
  306. });
  307. this.dataList = []
  308. }
  309. },
  310. /**
  311. * 触底添加下一页
  312. */
  313. reachBottom(options) {
  314. if (this.loadStatus === 'loadmore') {
  315. this.loadStatus = 'loading'
  316. uni.showNavigationBarLoading()
  317. setTimeout(() => {
  318. this.params.pageNum += 1;
  319. this.getListData('more')
  320. uni.hideNavigationBarLoading()
  321. }, 500);
  322. }
  323. },
  324. /**
  325. * 下拉列表页
  326. */
  327. pullDownRefresh(options) {
  328. this.triggered = true;
  329. setTimeout(() => {
  330. this.triggered = false;
  331. uni.stopPullDownRefresh()
  332. this.params.pageNum = 1;
  333. this.getListData('refresh')
  334. }, 500)
  335. }
  336. }
  337. }
  338. </script>
  339. <style lang="scss">
  340. .container {
  341. font-family: PingFang SC, PingFang SC;
  342. font-weight: 400;
  343. font-size: 14px;
  344. color: #222;
  345. display: flex;
  346. flex-direction: column;
  347. /* #ifdef MP-WEIXIN */
  348. height: 100vh;
  349. /* #endif */
  350. }
  351. .boxnav {
  352. flex-wrap: wrap;
  353. padding: 0 0 0 10px;
  354. &-item {
  355. width: 50%;
  356. overflow: hidden;
  357. }
  358. &-item-info {
  359. border: 1px solid #f5f5f5;
  360. text-align: center;
  361. color: #222;
  362. background-color: #f5f5f5;
  363. border-radius: 3px;
  364. padding: 5px;
  365. margin: 0 10px 10px 0;
  366. }
  367. &-active {
  368. border: 1px solid #1677ff !important;
  369. color: #1677ff !important;
  370. background-color: #e7f1fe !important;
  371. }
  372. }
  373. .headbox {
  374. background-color: #fff;
  375. }
  376. .headnav {
  377. padding: 15px 12px;
  378. margin: 0 -10px -10px 0;
  379. box-sizing: border-box;
  380. image {
  381. height: 60px;
  382. width: 50px;
  383. position: absolute;
  384. z-index: 0;
  385. bottom: 0;
  386. right: 0;
  387. display: none;
  388. }
  389. &-item {
  390. flex: 1;
  391. font-size: 16px;
  392. padding: 10px;
  393. border-radius: 10px;
  394. background: #f5f5f5;
  395. margin: 0 10px 10px 0;
  396. position: relative;
  397. z-index: 1;
  398. overflow: hidden;
  399. color: #555;
  400. }
  401. &-active {
  402. background-color: rgb(231, 241, 255) !important;
  403. .headnav-num {
  404. color: #1677ff !important;
  405. }
  406. image {
  407. display: block !important;
  408. }
  409. }
  410. &-num {
  411. font-family: DIN, DIN;
  412. font-weight: bold;
  413. font-size: 25px;
  414. margin: 5px 0;
  415. }
  416. }
  417. .searchbar {
  418. flex: 1;
  419. padding-bottom: 10px;
  420. .arrow-down {
  421. margin-left: 5px;
  422. }
  423. &-active {
  424. color: #1677ff !important;
  425. .arrow-down {
  426. transform: rotate(180deg);
  427. }
  428. }
  429. }
  430. // .coursebox {
  431. // position: relative;
  432. // overflow-y: auto;
  433. // box-sizing: border-box;
  434. // }
  435. // .courselist {
  436. // padding: 12px;
  437. // box-sizing: border-box;
  438. // }
  439. .container-right {
  440. flex: 1;
  441. height: calc(100% - 80rpx);
  442. overflow-y: scroll;
  443. // padding-bottom: 80rpx;
  444. .list {
  445. padding: 10px;
  446. box-sizing: border-box;
  447. width: 100%;
  448. }
  449. }
  450. </style>