liveCourse.vue 14 KB

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