living.vue 11 KB

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