living.vue 11 KB

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