liveCourse.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472
  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:443/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:443/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:443/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. // name: '课程状态',
  90. // value: 1,
  91. // },
  92. ],
  93. contentH: 0,
  94. activeTab: 1,
  95. courseList: [],
  96. courseId: '',
  97. searchbarNav: 0,
  98. courserIndex: '',
  99. searchbar: [{
  100. name: '训练营-营期'
  101. },
  102. {
  103. name: '课程状态'
  104. }
  105. ],
  106. mescroll: null,
  107. downOption: {
  108. use: true,
  109. auto: false
  110. },
  111. upOption: {
  112. onScroll: false,
  113. use: true, // 是否启用上拉加载; 默认true
  114. auto: true,
  115. page: {
  116. pae: 0, // 当前页码,默认0,回调之前会加1,即callback(page)会从1开始
  117. size: 10 // 每页数据的数量,默认10
  118. },
  119. noMoreSize: 10, // 配置列表的总数量要大于等于5条才显示'-- END --'的提示
  120. textNoMore: "已经到底了",
  121. empty: {
  122. icon: 'https://cos.his.cdwjyyh.com/fs/20240423/cf4a86b913a04341bb44e34bb4d37aa2.png',
  123. tip: '暂无数据'
  124. }
  125. },
  126. dataList: [],
  127. params: {
  128. pageNum: 1,
  129. pageSize: 10
  130. },
  131. triggered: false,
  132. loadStatus: 'loadmore',
  133. //课程选择列表
  134. pageNum:1,
  135. pageSize: 10,
  136. triggereds: false,
  137. status: 'loadmore',
  138. keyword:'',
  139. isEnableds:true,
  140. keywordlist:'',
  141. actid:'',
  142. scrollTop: 0,
  143. old: {
  144. scrollTop: 0
  145. },
  146. shareConfig:''
  147. }
  148. },
  149. mounted() {
  150. const windowHeight = uni.getSystemInfoSync().windowHeight
  151. this.contentH = `calc(${windowHeight}px - 132px - 56px)`
  152. this.user = uni.getStorageSync("companyUserInfo") ? JSON.parse(uni.getStorageSync("companyUserInfo")) : {}
  153. this.getFsCourseList()
  154. },
  155. methods: {
  156. handleShare(config) {
  157. // 保存分享配置到父页面数据
  158. this.shareConfig = config;
  159. this.$emit('child-data-update', this.shareConfig);
  160. // 调起分享面板(微信小程序需主动调用)
  161. // #ifdef MP-WEIXIN
  162. uni.showShareMenu();
  163. // #endif
  164. },
  165. scroll: function(e) {
  166. // console.log(e)
  167. this.old.scrollTop = e.detail.scrollTop
  168. },
  169. onChange(index) {
  170. this.searchbarNav = index
  171. },
  172. reset() {
  173. this.courseId = ''
  174. this.keyword=''
  175. this.courseList=[]
  176. this.getFsCourseList()
  177. },
  178. handleCourse(item,index) {
  179. this.courserIndex = index
  180. this.actid=item.periodId
  181. },
  182. confirm() {
  183. this.courseId = this.actid
  184. console.log(this.courseId)
  185. this.params.pageNum=1
  186. this.getListData()
  187. },
  188. searchKeyword(value){
  189. this.courseList=[]
  190. this.keyword = value
  191. this.getFsCourseList()
  192. },
  193. searchKeywordlist(value){
  194. this.dataList=[]
  195. this.keywordlist = value
  196. this.getListData()
  197. },
  198. pullDownRefreshs() {
  199. // 下拉
  200. this.triggereds = true; //下拉了状态为true
  201. setTimeout(() => {
  202. this.triggereds = false;
  203. uni.stopPullDownRefresh()
  204. this.pageNum = 1;
  205. this.getFsCourseList('refresh') //触底 不穿执行else
  206. // 请求接口里面需要判断是不是最后一页 是最后一页 status赋值为‘loadmore’没有更多了
  207. // 请求接口
  208. }, 1000)
  209. },
  210. reachBottoms() {
  211. // status这个是加载状态
  212. if (this.status === 'loadmore') {
  213. this.status = 'loading'
  214. uni.showNavigationBarLoading()
  215. setTimeout(() => {
  216. this.pageNum++
  217. this.getFsCourseList() //触底 不穿执行else
  218. uni.hideNavigationBarLoading()
  219. }, 1000);
  220. }
  221. },
  222. // 训练营
  223. getFsCourseList(type) {
  224. const day = uni.$u.timeFormat(new Date(), 'yyyy-mm-dd')
  225. const param = {
  226. pageNum:this.pageNum,
  227. pageSize:this.pageSize,
  228. keyword:this.keyword
  229. }
  230. getFsCourseList(param).then(res => {
  231. if (res.code == 200) {
  232. if (type == 'refresh') {
  233. this.courseList = res.data.list
  234. } else {
  235. // 加载更多 当前页和下一页合并
  236. this.courseList = [...this.courseList, ...res.data.list]
  237. }
  238. if ( res.data.isLastPage) {
  239. this.status = 'nomore'
  240. } else {
  241. this.status = 'loadmore'
  242. }
  243. this.searchbar[0].name = this.courseList && this.courseList.length > 0 ? this.courseList[0]
  244. .courseName : '训练营-营期'
  245. console.log(this.courseId)
  246. // this.mescroll.resetUpScroll()
  247. this.getListInit()
  248. } else {
  249. uni.showToast({
  250. icon: 'none',
  251. title: res.msg,
  252. });
  253. }
  254. })
  255. },
  256. handleNav(type) {
  257. this.activeTab = type
  258. },
  259. clickSearchbar(type) {
  260. this.searchbarNav = type == this.searchbarNav ? 'colse' : type
  261. },
  262. mescrollInit(mescroll) {
  263. this.mescroll = mescroll;
  264. },
  265. getListInit() {
  266. this.params.pageNum = 1
  267. this.getListData('refresh')
  268. },
  269. async getListData(type = 'refresh') {
  270. uni.showLoading({
  271. title: "加载中..."
  272. })
  273. this.loadStatus = 'loading'
  274. const result = await getCourseVdieoList({
  275. periodId: this.courseId,
  276. keyword:this.keywordlist,
  277. ...this.params
  278. })
  279. if (result) {
  280. const {
  281. isLastPage,
  282. total,
  283. list,
  284. } = result.data
  285. if (type == 'refresh') {
  286. this.dataList = list
  287. } else {
  288. this.dataList = [...this.dataList, ...list]
  289. }
  290. if (isLastPage) {
  291. this.loadStatus = 'nomore';
  292. } else {
  293. this.loadStatus = 'loadmore';
  294. }
  295. // 当页数为1时,重置滚动位置
  296. if (this.params.pageNum === 1) {
  297. console.log(this.scrollTop)
  298. this.scrollTop = this.old.scrollTop
  299. this.$nextTick(function() {
  300. this.scrollTop = 0
  301. });
  302. }
  303. uni.hideLoading()
  304. } else {
  305. uni.showToast({
  306. icon: 'none',
  307. title: "请求失败",
  308. });
  309. this.dataList = []
  310. }
  311. },
  312. /**
  313. * 触底添加下一页
  314. */
  315. reachBottom(options) {
  316. if (this.loadStatus === 'loadmore') {
  317. this.loadStatus = 'loading'
  318. uni.showNavigationBarLoading()
  319. setTimeout(() => {
  320. this.params.pageNum += 1;
  321. this.getListData('more')
  322. uni.hideNavigationBarLoading()
  323. }, 500);
  324. }
  325. },
  326. /**
  327. * 下拉列表页
  328. */
  329. pullDownRefresh(options) {
  330. this.triggered = true;
  331. setTimeout(() => {
  332. this.triggered = false;
  333. uni.stopPullDownRefresh()
  334. this.params.pageNum = 1;
  335. this.getListData('refresh')
  336. }, 500)
  337. }
  338. }
  339. }
  340. </script>
  341. <style lang="scss">
  342. .container {
  343. font-family: PingFang SC, PingFang SC;
  344. font-weight: 400;
  345. font-size: 14px;
  346. color: #222;
  347. display: flex;
  348. flex-direction: column;
  349. height: 100vh;
  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>