liveCourse.vue 13 KB

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