courseManage.vue 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420
  1. <template>
  2. <view class="container">
  3. <view class="headbox">
  4. <dropdownPanel :filterData='filterData' @onChange="onChange" @confirm="confirm" @reset="reset">
  5. <scroll-view scroll-y="true" class="hb" :refresher-enabled="isEnableds"
  6. :refresher-triggered="triggereds" refresher-background="rgba(0,0,0,0)"
  7. @refresherrefresh="pullDownRefreshs" @refresherrestore="triggereds = false"
  8. :upper-threshold="100" :lower-threshold="100" @refresherabort="triggereds = false"
  9. @scrolltolower="reachBottoms">
  10. <view class="justify-between align-center mb20 mlr20 ">
  11. <u-search placeholder="搜索训练营" v-model="keyword" :showAction="false" height="30px"
  12. @search='searchKeyword'></u-search>
  13. </view>
  14. <view v-if="searchbarNav == 0">
  15. <view class="boxnav x-bc">
  16. <view class="boxnav-item" v-for="(item,index) in courseList" :key="index">
  17. <view class="boxnav-item-info one-t"
  18. :class="courserIndex == index ? 'boxnav-active':''"
  19. @click="handleCourse(item,index)">{{item.periodName}}</view>
  20. </view>
  21. </view>
  22. </view>
  23. <u-loadmore :status="status" />
  24. </scroll-view>
  25. </dropdownPanel>
  26. </view>
  27. <view class="justify-between align-center mb20 mlr20 mt20 ">
  28. <u-search placeholder="请输入课程名称" v-model="keywordlist" :showAction="false" height="30px"
  29. @search='searchKeywordlist' bgColor='#fff'></u-search>
  30. </view>
  31. <view class="container-right" >
  32. <scroll-view style="height:100%" :scroll-y="true" :refresher-enabled="true" :refresher-triggered="triggered"
  33. refresher-background="rgba(0,0,0,0)" @refresherrefresh="pullDownRefresh" :scroll-top='scrollTop'
  34. @refresherrestore="triggered = false" :upper-threshold="100" :lower-threshold="100"
  35. @refresherabort="triggered = false" @scrolltolower="reachBottom" @scroll="scroll">
  36. <view class="list">
  37. <courseItem :from="'course'" :activeTab="1" v-for="(item,index) in dataList" :key="index"
  38. :info="item" :parent-method="parentMethod"/>
  39. <u-loadmore :status="loadStatus" />
  40. </view>
  41. </scroll-view>
  42. </view>
  43. </view>
  44. </template>
  45. <script>
  46. import {
  47. getFsCourseList,
  48. getCourseVdieoList
  49. } from "@/api/courseManage.js"
  50. import {
  51. getOperationlist,
  52. getcourselist
  53. } from "@/api/user.js";
  54. import dropdownPanel from "@/components/dropdownPanel.vue"
  55. import courseItem from "@/components/courseItem.vue"
  56. export default {
  57. name:"liveCourse",
  58. components: {
  59. courseItem,
  60. dropdownPanel
  61. },
  62. props: ['parentMethod'],
  63. data() {
  64. return {
  65. user: {},
  66. filterData: [{
  67. name: '训练营-营期',
  68. value: 0,
  69. },
  70. ],
  71. contentH: 0,
  72. activeTab: 1,
  73. courseList: [],
  74. courseId: '',
  75. searchbarNav: 0,
  76. courserIndex: '',
  77. searchbar: [{
  78. name: '训练营-营期'
  79. },
  80. {
  81. name: '课程状态'
  82. }
  83. ],
  84. mescroll: null,
  85. downOption: {
  86. use: true,
  87. auto: false
  88. },
  89. dataList: [],
  90. params: {
  91. pageNum: 1,
  92. pageSize: 10
  93. },
  94. triggered: false,
  95. loadStatus: 'loadmore',
  96. pageNum:1,
  97. pageSize: 10,
  98. triggereds: false,
  99. status: 'loadmore',
  100. keyword:'',
  101. isEnableds:true,
  102. keywordlist:'',
  103. actid:'',
  104. scrollTop: 0,
  105. old: {
  106. scrollTop: 0
  107. },
  108. shareConfig:'',
  109. selname:'',
  110. qwUserId:''
  111. }
  112. },
  113. onLoad(options) {
  114. this.qwUserId=options.userId
  115. },
  116. mounted() {
  117. const windowHeight = uni.getSystemInfoSync().windowHeight
  118. this.contentH = `calc(${windowHeight}px - 132px - 56px)`
  119. this.user = uni.getStorageSync("companyUserInfo") ? JSON.parse(uni.getStorageSync("companyUserInfo")) : {}
  120. this.getFsCourseList()
  121. },
  122. methods: {
  123. scroll: function(e) {
  124. this.old.scrollTop = e.detail.scrollTop
  125. },
  126. onChange(index) {
  127. this.searchbarNav = index
  128. },
  129. reset() {
  130. this.courseId = ''
  131. this.keyword=''
  132. this.courseList=[]
  133. this.getFsCourseList()
  134. },
  135. handleCourse(item,index) {
  136. this.courserIndex = index
  137. this.actid=item.periodId
  138. this.selname=item.periodName
  139. },
  140. confirm() {
  141. this.courseId = this.actid
  142. this.params.pageNum=1
  143. this.filterData[0].name=this.selname
  144. this.getListData()
  145. },
  146. searchKeyword(value){
  147. this.courseList=[]
  148. this.keyword = value
  149. this.getFsCourseList()
  150. },
  151. searchKeywordlist(value){
  152. this.dataList=[]
  153. this.keywordlist = value
  154. this.getListData()
  155. },
  156. pullDownRefreshs() {
  157. this.triggereds = true; //下拉了状态为true
  158. setTimeout(() => {
  159. this.triggereds = false;
  160. uni.stopPullDownRefresh()
  161. this.pageNum = 1;
  162. this.getFsCourseList('refresh') //触底 不穿执行else
  163. }, 1000)
  164. },
  165. reachBottoms() {
  166. if (this.status === 'loadmore') {
  167. this.status = 'loading'
  168. uni.showNavigationBarLoading()
  169. setTimeout(() => {
  170. this.pageNum++
  171. this.getFsCourseList() //触底 不穿执行else
  172. uni.hideNavigationBarLoading()
  173. }, 1000);
  174. }
  175. },
  176. getFsCourseList(type) {
  177. const day = uni.$u.timeFormat(new Date(), 'yyyy-mm-dd')
  178. const param = {
  179. pageNum:this.pageNum,
  180. pageSize:this.pageSize,
  181. periodName:this.keyword,
  182. companyId: 11,
  183. }
  184. getOperationlist(param).then(res => {
  185. if (res.code == 200) {
  186. if (type == 'refresh') {
  187. this.courseList = res.data.list
  188. } else {
  189. this.courseList = [...this.courseList, ...res.data.list]
  190. }
  191. if ( res.data.isLastPage) {
  192. this.status = 'nomore'
  193. } else {
  194. this.status = 'loadmore'
  195. }
  196. // this.searchbar[0].name = this.courseList && this.courseList.length > 0 ? this.courseList[0]
  197. // .courseName : '训练营-营期'
  198. this.filterData[0].name=this.courseList[0].periodName
  199. this.getListInit()
  200. } else {
  201. uni.showToast({
  202. icon: 'none',
  203. title: res.msg,
  204. });
  205. }
  206. })
  207. },
  208. handleNav(type) {
  209. this.activeTab = type
  210. },
  211. clickSearchbar(type) {
  212. this.searchbarNav = type == this.searchbarNav ? 'colse' : type
  213. },
  214. mescrollInit(mescroll) {
  215. this.mescroll = mescroll;
  216. },
  217. getListInit() {
  218. this.params.pageNum = 1
  219. this.getListData('refresh')
  220. },
  221. async getListData(type = 'refresh') {
  222. uni.showLoading({
  223. title: "加载中..."
  224. })
  225. this.loadStatus = 'loading'
  226. const result = await getcourselist({
  227. periodId: this.courseId,
  228. keyword:this.keywordlist,
  229. companyId: 11,
  230. ...this.params
  231. })
  232. if (result) {
  233. const {
  234. isLastPage,
  235. total,
  236. list,
  237. } = result.data
  238. if (type == 'refresh') {
  239. this.dataList = list
  240. } else {
  241. this.dataList = [...this.dataList, ...list]
  242. }
  243. if (isLastPage) {
  244. this.loadStatus = 'nomore';
  245. } else {
  246. this.loadStatus = 'loadmore';
  247. }
  248. if (this.params.pageNum === 1) {
  249. this.scrollTop = this.old.scrollTop
  250. this.$nextTick(function() {
  251. this.scrollTop = 0
  252. });
  253. }
  254. uni.hideLoading()
  255. } else {
  256. uni.showToast({
  257. icon: 'none',
  258. title: "请求失败",
  259. });
  260. this.dataList = []
  261. // console.log(res.data)
  262. }
  263. },
  264. reachBottom(options) {
  265. if (this.loadStatus === 'loadmore') {
  266. this.loadStatus = 'loading'
  267. uni.showNavigationBarLoading()
  268. setTimeout(() => {
  269. this.params.pageNum += 1;
  270. this.getListData('more')
  271. uni.hideNavigationBarLoading()
  272. }, 500);
  273. }
  274. },
  275. pullDownRefresh(options) {
  276. this.triggered = true;
  277. setTimeout(() => {
  278. this.triggered = false;
  279. uni.stopPullDownRefresh()
  280. this.params.pageNum = 1;
  281. this.getListData('refresh')
  282. }, 500)
  283. }
  284. }
  285. }
  286. </script>
  287. <style lang="scss">
  288. .container {
  289. font-family: PingFang SC, PingFang SC;
  290. font-weight: 400;
  291. font-size: 14px;
  292. color: #222;
  293. display: flex;
  294. flex-direction: column;
  295. /* #ifdef MP-WEIXIN */
  296. height: 100vh;
  297. /* #endif */
  298. }
  299. .boxnav {
  300. flex-wrap: wrap;
  301. padding: 0 0 0 10px;
  302. &-item {
  303. width: 50%;
  304. overflow: hidden;
  305. }
  306. &-item-info {
  307. border: 1px solid #f5f5f5;
  308. text-align: center;
  309. color: #222;
  310. background-color: #f5f5f5;
  311. border-radius: 3px;
  312. padding: 5px;
  313. margin: 0 10px 10px 0;
  314. }
  315. &-active {
  316. border: 1px solid #1677ff !important;
  317. color: #1677ff !important;
  318. background-color: #e7f1fe !important;
  319. }
  320. }
  321. .headbox {
  322. background-color: #fff;
  323. }
  324. .headnav {
  325. padding: 15px 12px;
  326. margin: 0 -10px -10px 0;
  327. box-sizing: border-box;
  328. image {
  329. height: 60px;
  330. width: 50px;
  331. position: absolute;
  332. z-index: 0;
  333. bottom: 0;
  334. right: 0;
  335. display: none;
  336. }
  337. &-item {
  338. flex: 1;
  339. font-size: 16px;
  340. padding: 10px;
  341. border-radius: 10px;
  342. background: #f5f5f5;
  343. margin: 0 10px 10px 0;
  344. position: relative;
  345. z-index: 1;
  346. overflow: hidden;
  347. color: #555;
  348. }
  349. &-active {
  350. background-color: rgb(231, 241, 255) !important;
  351. .headnav-num {
  352. color: #1677ff !important;
  353. }
  354. image {
  355. display: block !important;
  356. }
  357. }
  358. &-num {
  359. font-family: DIN, DIN;
  360. font-weight: bold;
  361. font-size: 25px;
  362. margin: 5px 0;
  363. }
  364. }
  365. .searchbar {
  366. flex: 1;
  367. padding-bottom: 10px;
  368. .arrow-down {
  369. margin-left: 5px;
  370. }
  371. &-active {
  372. color: #1677ff !important;
  373. .arrow-down {
  374. transform: rotate(180deg);
  375. }
  376. }
  377. }
  378. .coursebox {
  379. position: relative;
  380. overflow-y: auto;
  381. box-sizing: border-box;
  382. }
  383. .courselist {
  384. padding: 12px;
  385. box-sizing: border-box;
  386. }
  387. .container-right {
  388. flex: 1;
  389. height: calc(100% - 80rpx);
  390. overflow-y: scroll;
  391. // padding-bottom: 80rpx;
  392. .list {
  393. padding: 10px;
  394. box-sizing: border-box;
  395. width: 100%;
  396. }
  397. }
  398. </style>