courseIndex.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627
  1. <template>
  2. <view class="container">
  3. <view class="headbox">
  4. <dropdownPanel :filterData='filterData' @onChange="onChange" @confirm="confirm" @reset="reset"
  5. @onClick="selindex">
  6. <view class="justify-start align-center ptb20">
  7. <view class="pl20" @click="showtrain=false" v-if="showtrain">
  8. <u-icon name="arrow-left" color="#919191" size="20"></u-icon>
  9. </view>
  10. <view class="ml20">{{traintext}}</view>
  11. </view>
  12. <scroll-view scroll-y="true" class="hb" :refresher-enabled="isEnableds" @refresherrefresh="pullDownRefreshst"
  13. :refresher-triggered="triggeredst" refresher-background="rgba(0,0,0,0)" @refresherrestore="triggeredst = false"
  14. :upper-threshold="100" :lower-threshold="100" @refresherabort="triggeredst = false"
  15. @scrolltolower="reachBottomst" v-if="searchbarNav == 1&&!showtrain">
  16. <view >
  17. <view class="boxnav x-bc">
  18. <view class="boxnav-item" v-for="(item,index) in trainingList" :key="index">
  19. <view class="boxnav-item-info one-t"
  20. :class="trainingindex == index ? 'boxnav-active':''"
  21. @click="seltrainingid(item,index)">{{item.trainingCampName}}</view>
  22. </view>
  23. </view>
  24. </view>
  25. <u-loadmore :status="loadStatust" />
  26. </scroll-view>
  27. <scroll-view scroll-y="true" class="hb" :refresher-enabled="isEnableds" @refresherrefresh="pullDownRefreshs"
  28. :refresher-triggered="triggereds" refresher-background="rgba(0,0,0,0)" @refresherrestore="triggereds = false"
  29. :upper-threshold="100" :lower-threshold="100" @refresherabort="triggereds = false"
  30. @scrolltolower="reachBottoms" v-if="showtrain">
  31. <view class="justify-between align-center mb20 mlr20 ">
  32. <u-search placeholder="搜索课程" v-model="keyword" :showAction="false" height="30px"
  33. @search='searchKeyword'></u-search>
  34. </view>
  35. <view >
  36. <view class="boxnav x-bc">
  37. <view class="boxnav-item" v-for="(item,index) in courseList" :key="index">
  38. <view class="boxnav-item-info one-t"
  39. :class="courserIndex == index ? 'boxnav-active':''"
  40. @click="handleCourse(item,index)">{{item.periodName}}</view>
  41. </view>
  42. </view>
  43. </view>
  44. <u-loadmore :status="status" />
  45. </scroll-view>
  46. </dropdownPanel>
  47. </view>
  48. <view class="justify-between align-center mb20 mlr20 mt20 ">
  49. <u-search placeholder="请输入课程名称" v-model="keywordlist" :showAction="false" height="30px"
  50. @search='searchKeywordlist' bgColor='#fff'></u-search>
  51. </view>
  52. <view class="container-right" >
  53. <scroll-view style="height:100%" :scroll-y="true" :refresher-enabled="isEnableds" :refresher-triggered="triggered"
  54. refresher-background="rgba(0,0,0,0)" @refresherrefresh="pullDownRefresh" :scroll-top='scrollTop'
  55. @refresherrestore="triggered = false" :upper-threshold="100" :lower-threshold="100"
  56. @refresherabort="triggered = false" @scrolltolower="reachBottom" @scroll="scroll">
  57. <view class="list">
  58. <courseItem :from="'course'" :activeTab="1" v-for="(item,index) in dataList" :key="index"
  59. :info="item" @trigger-share="handleShare" :parent-method="parentMethod" @retime='reflashtime'/>
  60. <u-loadmore :status="loadStatus" />
  61. <view class="h120"></view>
  62. </view>
  63. </scroll-view>
  64. </view>
  65. <u-loading-page :loading="viewload" iconSize="32" loadingColor="#3c9cff" fontSize="24"
  66. :loading-text="loadingtext"></u-loading-page>
  67. </view>
  68. </template>
  69. <script>
  70. import {
  71. getFsCourseList,
  72. getCourseVdieoList,
  73. getTodayCourse,
  74. trainingCampList,
  75. courseList
  76. } from "@/api/manageCompany.js"
  77. import dropdownPanel from "../components/dropdownPanel.vue"
  78. import courseItem from "../components/courseItem.vue"
  79. export default {
  80. name:"liveCourse",
  81. components: {
  82. courseItem,
  83. dropdownPanel
  84. },
  85. props: ['parentMethod'],
  86. data() {
  87. return {
  88. viewload:true,
  89. loadingtext:"数据加载中...",
  90. user: {},
  91. filterData: [{
  92. name: '今日课程',
  93. value: 0,
  94. type: 'click',
  95. },{
  96. name: ' 我的课程',
  97. value: 1,
  98. },
  99. ],
  100. contentH: 0,
  101. activeTab: 1,
  102. courseList: [],
  103. courseId: '',
  104. searchbarNav: 0,
  105. courserIndex: null,
  106. searchbar: [{
  107. name: '我的课程'
  108. },
  109. {
  110. name: '课程状态'
  111. }
  112. ],
  113. mescroll: null,
  114. downOption: {
  115. use: true,
  116. auto: false
  117. },
  118. upOption: {
  119. onScroll: false,
  120. use: true, // 是否启用上拉加载; 默认true
  121. auto: true,
  122. page: {
  123. pae: 0, // 当前页码,默认0,回调之前会加1,即callback(page)会从1开始
  124. size: 10 // 每页数据的数量,默认10
  125. },
  126. noMoreSize: 10, // 配置列表的总数量要大于等于5条才显示'-- END --'的提示
  127. textNoMore: "已经到底了",
  128. empty: {
  129. icon: 'https://cos.his.cdwjyyh.com/fs/20240423/cf4a86b913a04341bb44e34bb4d37aa2.png',
  130. tip: '暂无数据'
  131. }
  132. },
  133. dataList: [],
  134. params: {
  135. pageNum: 1,
  136. pageSize: 10
  137. },
  138. triggered: false,
  139. loadStatus: 'loadmore',
  140. //课程选择列表
  141. pageNum:1,
  142. pageSize: 10,
  143. triggereds: false,
  144. status: 'loadmore',
  145. keyword:'',
  146. isEnableds:true,
  147. keywordlist:'',
  148. actid:'',
  149. scrollTop: 0,
  150. old: {
  151. scrollTop: 0
  152. },
  153. shareConfig:'',
  154. titleName:'',
  155. seltoday:0,
  156. trainingId:0,
  157. trainingindex:0,
  158. trainingList:[],
  159. traintext:'训练营',
  160. loadStatust:'loadmore',
  161. pageNumt:1,
  162. pageSizet: 10,
  163. triggeredst:false,
  164. showtrain:false
  165. }
  166. },
  167. computed: {
  168. imgPath() {
  169. return this.$store.state.imgpath
  170. }
  171. },
  172. mounted() {
  173. const windowHeight = uni.getSystemInfoSync().windowHeight
  174. this.contentH = `calc(${windowHeight}px - 132px - 56px)`
  175. this.user = uni.getStorageSync("companyUserInfo") ? JSON.parse(uni.getStorageSync("companyUserInfo")) : {}
  176. this.gettodaylist()
  177. this.trainingCampLists()
  178. console.log(this.courserIndex)
  179. },
  180. methods: {
  181. pullDownRefreshst() {
  182. // 下拉
  183. this.triggeredst = true; //下拉了状态为true
  184. setTimeout(() => {
  185. this.triggeredst = false;
  186. uni.stopPullDownRefresh()
  187. this.pageNumt = 1;
  188. this.trainingCampLists('refresh') //触底 不穿执行else
  189. // 请求接口里面需要判断是不是最后一页 是最后一页 status赋值为‘loadmore’没有更多了
  190. // 请求接口
  191. }, 1000)
  192. },
  193. reachBottomst() {
  194. // status这个是加载状态
  195. if (this.loadStatust === 'loadmore') {
  196. this.loadStatust = 'loading'
  197. uni.showNavigationBarLoading()
  198. setTimeout(() => {
  199. this.pageNumt++
  200. this.trainingCampLists() //触底 不穿执行else
  201. uni.hideNavigationBarLoading()
  202. }, 1000);
  203. }
  204. },
  205. seltrainingid(item,index){
  206. console.log(index)
  207. this.trainingindex = index
  208. this.traintext=item.trainingCampName
  209. this.trainingId=item.trainingCampId
  210. setTimeout(()=>{
  211. this.showtrain=true
  212. this.courseList=[]
  213. this.getFsCourseList('refresh')
  214. },800)
  215. },
  216. trainingCampLists(type){
  217. const data={
  218. pageNum:this.pageNumt,
  219. pageSize:this.pageSizet,
  220. }
  221. trainingCampList(data).then(res=>{
  222. if(res.code==200){
  223. const list=res.data.list
  224. if (type == 'refresh') {
  225. this.trainingList = list
  226. } else {
  227. this.trainingList = [...this.trainingList, ...list]
  228. }
  229. if ( res.data.isLastPage) {
  230. this.loadStatust = 'nomore'
  231. } else {
  232. this.loadStatust = 'loadmore'
  233. }
  234. }else{
  235. uni.showToast({
  236. icon: 'none',
  237. title: res.msg,
  238. });
  239. }
  240. })
  241. },
  242. onChildDataUpdate(data) {
  243. this.childdata = data
  244. this.showShare = this.childdata.onshow
  245. console.log(this.childdata);
  246. console.log('父组件', this.childdata.path + "?course=" +JSON.stringify(this.childdata.params) )
  247. },
  248. reflashtime(){
  249. this.keywordlist=''
  250. this.params.pageNum=1
  251. this.dataList=[]
  252. this.gettodaylist()
  253. this.getFsCourseList('refresh')
  254. },
  255. gettodaylist(type){
  256. const data={
  257. pageNum:this.params.pageNum,
  258. pageSize:this.params.pageSize,
  259. keyword:this.keywordlist,
  260. }
  261. getTodayCourse(data).then(res=>{
  262. console.log(res)
  263. if(res.code==200){
  264. this.viewload=false
  265. const list=res.data.list
  266. // this.dataList=res.data.list
  267. if (type == 'refresh') {
  268. this.dataList = list
  269. } else {
  270. this.dataList = [...this.dataList, ...list]
  271. }
  272. if ( res.data.isLastPage) {
  273. this.loadStatus = 'nomore'
  274. } else {
  275. this.loadStatus = 'loadmore'
  276. }
  277. }else{
  278. uni.showToast({
  279. icon: 'none',
  280. title: res.msg,
  281. });
  282. }
  283. })
  284. },
  285. selindex(e){
  286. this.seltoday=e.value
  287. if(e.value==0){
  288. this.params.pageNum = 1
  289. this.gettodaylist('refresh')
  290. }else{
  291. // this.params.pageNum = 1
  292. // this.keywordlist=''
  293. // this.getFsCourseList('refresh')
  294. this.pageNumt=1
  295. this.trainingCampLists('refresh')
  296. }
  297. console.log(e)
  298. },
  299. handleShare(config) {
  300. // 保存分享配置到父页面数据
  301. this.shareConfig = config;
  302. this.$emit('child-data-update', this.shareConfig);
  303. // 调起分享面板(微信小程序需主动调用)
  304. // #ifdef MP-WEIXIN
  305. uni.showShareMenu();
  306. // #endif
  307. },
  308. scroll: function(e) {
  309. this.old.scrollTop = e.detail.scrollTop
  310. },
  311. onChange(index) {
  312. this.searchbarNav = index
  313. },
  314. reset() {
  315. this.courseId = ''
  316. this.keyword =''
  317. this.courseList=[]
  318. this.getFsCourseList()
  319. },
  320. handleCourse(item,index) {
  321. console.log(index)
  322. this.courserIndex = index
  323. this.titleName=item.periodName
  324. this.actid=item.periodId
  325. },
  326. confirm() {
  327. if(this.actid==''){
  328. uni.showToast({
  329. icon: 'none',
  330. title: '请选择课程',
  331. });
  332. return
  333. }
  334. // this.showtrain=false
  335. this.courseId = this.actid
  336. this.filterData[1].name=this.titleName
  337. console.log(this.filterData[1].name)
  338. this.params.pageNum=1
  339. // this.getListInit()
  340. this.getListData('refresh')
  341. },
  342. searchKeyword(value){
  343. this.courseList=[]
  344. this.keyword = value
  345. this.params.pageNum=1
  346. this.getFsCourseList('refresh')
  347. },
  348. searchKeywordlist(value){
  349. this.dataList = []
  350. this.keywordlist = value
  351. if(this.seltoday==0){
  352. this.gettodaylist()
  353. }else{
  354. this.getListData()
  355. }
  356. },
  357. pullDownRefreshs() {
  358. // 下拉
  359. this.triggereds = true; //下拉了状态为true
  360. setTimeout(() => {
  361. this.triggereds = false;
  362. uni.stopPullDownRefresh()
  363. this.pageNum = 1;
  364. this.getFsCourseList('refresh') //触底 不穿执行else
  365. // 请求接口里面需要判断是不是最后一页 是最后一页 status赋值为‘loadmore’没有更多了
  366. // 请求接口
  367. }, 1000)
  368. },
  369. reachBottoms() {
  370. // status这个是加载状态
  371. if (this.status === 'loadmore') {
  372. this.status = 'loading'
  373. uni.showNavigationBarLoading()
  374. setTimeout(() => {
  375. this.pageNum++
  376. this.getFsCourseList() //触底 不穿执行else
  377. uni.hideNavigationBarLoading()
  378. }, 1000);
  379. }
  380. },
  381. // 训练营
  382. getFsCourseList(type) {
  383. const day = uni.$u.timeFormat(new Date(), 'yyyy-mm-dd')
  384. const param = {
  385. pageNum:this.pageNum,
  386. pageSize:this.pageSize,
  387. keyword:this.keyword,
  388. trainingCampId:this.trainingId
  389. }
  390. courseList(param).then(res => {
  391. if (res.code == 200) {
  392. if (type == 'refresh') {
  393. this.courseList = res.data.list
  394. } else {
  395. // 加载更多 当前页和下一页合并
  396. this.courseList = [...this.courseList, ...res.data.list]
  397. }
  398. if ( res.data.isLastPage) {
  399. this.status = 'nomore'
  400. } else {
  401. this.status = 'loadmore'
  402. }
  403. // this.courseId=this.courseList[0].periodId
  404. // this.filterData[1].name=this.courseList[0].periodName
  405. // this.getListInit()
  406. } else {
  407. uni.showToast({
  408. icon: 'none',
  409. title: res.msg,
  410. });
  411. }
  412. })
  413. },
  414. handleNav(type) {
  415. this.activeTab = type
  416. },
  417. clickSearchbar(type) {
  418. this.searchbarNav = type == this.searchbarNav ? 'colse' : type
  419. },
  420. getListInit() {
  421. this.params.pageNum = 1
  422. this.getListData('refresh')
  423. },
  424. async getListData(type) {
  425. console.log(type)
  426. uni.showLoading({
  427. title: "加载中..."
  428. })
  429. this.loadStatus = 'loading'
  430. const result = await getCourseVdieoList({
  431. periodId: this.courseId,
  432. keyword:this.keywordlist,
  433. ...this.params
  434. })
  435. if (result) {
  436. const {
  437. isLastPage,
  438. total,
  439. list,
  440. } = result.data
  441. if (type == 'refresh') {
  442. this.dataList = list
  443. } else {
  444. this.dataList = [...this.dataList, ...list]
  445. }
  446. if (isLastPage) {
  447. this.loadStatus = 'nomore';
  448. } else {
  449. this.loadStatus = 'loadmore';
  450. }
  451. // 当页数为1时,重置滚动位置
  452. if (this.params.pageNum === 1) {
  453. console.log(this.scrollTop)
  454. this.scrollTop = this.old.scrollTop
  455. this.$nextTick(function() {
  456. this.scrollTop = 0
  457. });
  458. }
  459. uni.hideLoading()
  460. } else {
  461. uni.showToast({
  462. icon: 'none',
  463. title: "请求失败",
  464. });
  465. this.dataList = []
  466. }
  467. },
  468. /**
  469. * 触底添加下一页
  470. */
  471. reachBottom(options) {
  472. if (this.loadStatus === 'loadmore') {
  473. this.loadStatus = 'loading'
  474. uni.showNavigationBarLoading()
  475. setTimeout(() => {
  476. this.params.pageNum += 1;
  477. // this.getListData('more')
  478. if(this.seltoday==0){
  479. this.gettodaylist('more')
  480. }else{
  481. this.getListData('more')
  482. }
  483. uni.hideNavigationBarLoading()
  484. }, 500);
  485. }
  486. },
  487. /**
  488. * 下拉列表页
  489. */
  490. pullDownRefresh(options) {
  491. this.triggered = true;
  492. setTimeout(() => {
  493. this.triggered = false;
  494. uni.stopPullDownRefresh()
  495. this.params.pageNum = 1;
  496. if(this.seltoday==0){
  497. this.gettodaylist()
  498. }else{
  499. this.getListData('refresh')
  500. }
  501. }, 500)
  502. }
  503. }
  504. }
  505. </script>
  506. <style lang="scss">
  507. .container {
  508. font-family: PingFang SC, PingFang SC;
  509. font-weight: 400;
  510. font-size: 14px;
  511. color: #222;
  512. display: flex;
  513. flex-direction: column;
  514. /* #ifdef MP-WEIXIN */
  515. height: 100vh;
  516. /* #endif */
  517. }
  518. .boxnav {
  519. flex-wrap: wrap;
  520. padding: 0 0 0 10px;
  521. &-item {
  522. width: 50%;
  523. overflow: hidden;
  524. }
  525. &-item-info {
  526. border: 1px solid #f5f5f5;
  527. text-align: center;
  528. color: #222;
  529. background-color: #f5f5f5;
  530. border-radius: 3px;
  531. padding: 5px;
  532. margin: 0 10px 10px 0;
  533. }
  534. &-active {
  535. border: 1px solid #1677ff !important;
  536. color: #1677ff !important;
  537. background-color: #e7f1fe !important;
  538. }
  539. }
  540. .headbox {
  541. background-color: #fff;
  542. }
  543. .headnav {
  544. padding: 15px 12px;
  545. margin: 0 -10px -10px 0;
  546. box-sizing: border-box;
  547. image {
  548. height: 60px;
  549. width: 50px;
  550. position: absolute;
  551. z-index: 0;
  552. bottom: 0;
  553. right: 0;
  554. display: none;
  555. }
  556. &-item {
  557. flex: 1;
  558. font-size: 16px;
  559. padding: 10px;
  560. border-radius: 10px;
  561. background: #f5f5f5;
  562. margin: 0 10px 10px 0;
  563. position: relative;
  564. z-index: 1;
  565. overflow: hidden;
  566. color: #555;
  567. }
  568. &-active {
  569. background-color: rgb(231, 241, 255) !important;
  570. .headnav-num {
  571. color: #1677ff !important;
  572. }
  573. image {
  574. display: block !important;
  575. }
  576. }
  577. &-num {
  578. font-family: DIN, DIN;
  579. font-weight: bold;
  580. font-size: 25px;
  581. margin: 5px 0;
  582. }
  583. }
  584. .searchbar {
  585. flex: 1;
  586. padding-bottom: 10px;
  587. .arrow-down {
  588. margin-left: 5px;
  589. }
  590. &-active {
  591. color: #1677ff !important;
  592. .arrow-down {
  593. transform: rotate(180deg);
  594. }
  595. }
  596. }
  597. .container-right {
  598. flex: 1;
  599. height: calc(100% - 80rpx);
  600. overflow-y: scroll;
  601. // padding-bottom: 80rpx;
  602. .list {
  603. padding: 10px;
  604. box-sizing: border-box;
  605. width: 100%;
  606. }
  607. }
  608. </style>