liveCourse.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473
  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. console.log(config)
  160. this.$emit('child-data-update', this.shareConfig);
  161. // 调起分享面板(微信小程序需主动调用)
  162. // #ifdef MP-WEIXIN
  163. uni.showShareMenu();
  164. // #endif
  165. },
  166. scroll: function(e) {
  167. // console.log(e)
  168. this.old.scrollTop = e.detail.scrollTop
  169. },
  170. onChange(index) {
  171. this.searchbarNav = index
  172. },
  173. reset() {
  174. this.courseId = ''
  175. this.keyword=''
  176. this.courseList=[]
  177. this.getFsCourseList()
  178. },
  179. handleCourse(item,index) {
  180. this.courserIndex = index
  181. this.actid=item.periodId
  182. },
  183. confirm() {
  184. this.courseId = this.actid
  185. console.log(this.courseId)
  186. this.params.pageNum=1
  187. this.getListData()
  188. },
  189. searchKeyword(value){
  190. this.courseList=[]
  191. this.keyword = value
  192. this.getFsCourseList()
  193. },
  194. searchKeywordlist(value){
  195. this.dataList=[]
  196. this.keywordlist = value
  197. this.getListData()
  198. },
  199. pullDownRefreshs() {
  200. // 下拉
  201. this.triggereds = true; //下拉了状态为true
  202. setTimeout(() => {
  203. this.triggereds = false;
  204. uni.stopPullDownRefresh()
  205. this.pageNum = 1;
  206. this.getFsCourseList('refresh') //触底 不穿执行else
  207. // 请求接口里面需要判断是不是最后一页 是最后一页 status赋值为‘loadmore’没有更多了
  208. // 请求接口
  209. }, 1000)
  210. },
  211. reachBottoms() {
  212. // status这个是加载状态
  213. if (this.status === 'loadmore') {
  214. this.status = 'loading'
  215. uni.showNavigationBarLoading()
  216. setTimeout(() => {
  217. this.pageNum++
  218. this.getFsCourseList() //触底 不穿执行else
  219. uni.hideNavigationBarLoading()
  220. }, 1000);
  221. }
  222. },
  223. // 训练营
  224. getFsCourseList(type) {
  225. const day = uni.$u.timeFormat(new Date(), 'yyyy-mm-dd')
  226. const param = {
  227. pageNum:this.pageNum,
  228. pageSize:this.pageSize,
  229. keyword:this.keyword
  230. }
  231. getFsCourseList(param).then(res => {
  232. if (res.code == 200) {
  233. if (type == 'refresh') {
  234. this.courseList = res.data.list
  235. } else {
  236. // 加载更多 当前页和下一页合并
  237. this.courseList = [...this.courseList, ...res.data.list]
  238. }
  239. if ( res.data.isLastPage) {
  240. this.status = 'nomore'
  241. } else {
  242. this.status = 'loadmore'
  243. }
  244. this.searchbar[0].name = this.courseList && this.courseList.length > 0 ? this.courseList[0]
  245. .courseName : '训练营-营期'
  246. console.log(this.courseId)
  247. // this.mescroll.resetUpScroll()
  248. this.getListInit()
  249. } else {
  250. uni.showToast({
  251. icon: 'none',
  252. title: res.msg,
  253. });
  254. }
  255. })
  256. },
  257. handleNav(type) {
  258. this.activeTab = type
  259. },
  260. clickSearchbar(type) {
  261. this.searchbarNav = type == this.searchbarNav ? 'colse' : type
  262. },
  263. mescrollInit(mescroll) {
  264. this.mescroll = mescroll;
  265. },
  266. getListInit() {
  267. this.params.pageNum = 1
  268. this.getListData('refresh')
  269. },
  270. async getListData(type = 'refresh') {
  271. uni.showLoading({
  272. title: "加载中..."
  273. })
  274. this.loadStatus = 'loading'
  275. const result = await getCourseVdieoList({
  276. periodId: this.courseId,
  277. keyword:this.keywordlist,
  278. ...this.params
  279. })
  280. if (result) {
  281. const {
  282. isLastPage,
  283. total,
  284. list,
  285. } = result.data
  286. if (type == 'refresh') {
  287. this.dataList = list
  288. } else {
  289. this.dataList = [...this.dataList, ...list]
  290. }
  291. if (isLastPage) {
  292. this.loadStatus = 'nomore';
  293. } else {
  294. this.loadStatus = 'loadmore';
  295. }
  296. // 当页数为1时,重置滚动位置
  297. if (this.params.pageNum === 1) {
  298. console.log(this.scrollTop)
  299. this.scrollTop = this.old.scrollTop
  300. this.$nextTick(function() {
  301. this.scrollTop = 0
  302. });
  303. }
  304. uni.hideLoading()
  305. } else {
  306. uni.showToast({
  307. icon: 'none',
  308. title: "请求失败",
  309. });
  310. this.dataList = []
  311. }
  312. },
  313. /**
  314. * 触底添加下一页
  315. */
  316. reachBottom(options) {
  317. if (this.loadStatus === 'loadmore') {
  318. this.loadStatus = 'loading'
  319. uni.showNavigationBarLoading()
  320. setTimeout(() => {
  321. this.params.pageNum += 1;
  322. this.getListData('more')
  323. uni.hideNavigationBarLoading()
  324. }, 500);
  325. }
  326. },
  327. /**
  328. * 下拉列表页
  329. */
  330. pullDownRefresh(options) {
  331. this.triggered = true;
  332. setTimeout(() => {
  333. this.triggered = false;
  334. uni.stopPullDownRefresh()
  335. this.params.pageNum = 1;
  336. this.getListData('refresh')
  337. }, 500)
  338. }
  339. }
  340. }
  341. </script>
  342. <style lang="scss">
  343. .container {
  344. font-family: PingFang SC, PingFang SC;
  345. font-weight: 400;
  346. font-size: 14px;
  347. color: #222;
  348. display: flex;
  349. flex-direction: column;
  350. height: 100vh;
  351. }
  352. .boxnav {
  353. flex-wrap: wrap;
  354. padding: 0 0 0 10px;
  355. &-item {
  356. width: 50%;
  357. overflow: hidden;
  358. }
  359. &-item-info {
  360. border: 1px solid #f5f5f5;
  361. text-align: center;
  362. color: #222;
  363. background-color: #f5f5f5;
  364. border-radius: 3px;
  365. padding: 5px;
  366. margin: 0 10px 10px 0;
  367. }
  368. &-active {
  369. border: 1px solid #1677ff !important;
  370. color: #1677ff !important;
  371. background-color: #e7f1fe !important;
  372. }
  373. }
  374. .headbox {
  375. background-color: #fff;
  376. }
  377. .headnav {
  378. padding: 15px 12px;
  379. margin: 0 -10px -10px 0;
  380. box-sizing: border-box;
  381. image {
  382. height: 60px;
  383. width: 50px;
  384. position: absolute;
  385. z-index: 0;
  386. bottom: 0;
  387. right: 0;
  388. display: none;
  389. }
  390. &-item {
  391. flex: 1;
  392. font-size: 16px;
  393. padding: 10px;
  394. border-radius: 10px;
  395. background: #f5f5f5;
  396. margin: 0 10px 10px 0;
  397. position: relative;
  398. z-index: 1;
  399. overflow: hidden;
  400. color: #555;
  401. }
  402. &-active {
  403. background-color: rgb(231, 241, 255) !important;
  404. .headnav-num {
  405. color: #1677ff !important;
  406. }
  407. image {
  408. display: block !important;
  409. }
  410. }
  411. &-num {
  412. font-family: DIN, DIN;
  413. font-weight: bold;
  414. font-size: 25px;
  415. margin: 5px 0;
  416. }
  417. }
  418. .searchbar {
  419. flex: 1;
  420. padding-bottom: 10px;
  421. .arrow-down {
  422. margin-left: 5px;
  423. }
  424. &-active {
  425. color: #1677ff !important;
  426. .arrow-down {
  427. transform: rotate(180deg);
  428. }
  429. }
  430. }
  431. .coursebox {
  432. position: relative;
  433. overflow-y: auto;
  434. box-sizing: border-box;
  435. }
  436. .courselist {
  437. padding: 12px;
  438. box-sizing: border-box;
  439. }
  440. .container-right {
  441. flex: 1;
  442. height: calc(100% - 80rpx);
  443. overflow-y: scroll;
  444. // padding-bottom: 80rpx;
  445. .list {
  446. padding: 10px;
  447. box-sizing: border-box;
  448. width: 100%;
  449. }
  450. }
  451. </style>