courseManage.vue 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416
  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. }
  111. },
  112. mounted() {
  113. const windowHeight = uni.getSystemInfoSync().windowHeight
  114. this.contentH = `calc(${windowHeight}px - 132px - 56px)`
  115. this.user = uni.getStorageSync("companyUserInfo") ? JSON.parse(uni.getStorageSync("companyUserInfo")) : {}
  116. this.getFsCourseList()
  117. },
  118. methods: {
  119. scroll: function(e) {
  120. this.old.scrollTop = e.detail.scrollTop
  121. },
  122. onChange(index) {
  123. this.searchbarNav = index
  124. },
  125. reset() {
  126. this.courseId = ''
  127. this.keyword=''
  128. this.courseList=[]
  129. this.getFsCourseList()
  130. },
  131. handleCourse(item,index) {
  132. this.courserIndex = index
  133. this.actid=item.periodId
  134. this.selname=item.periodName
  135. },
  136. confirm() {
  137. this.courseId = this.actid
  138. this.params.pageNum=1
  139. this.filterData[0].name=this.selname
  140. this.getListData()
  141. },
  142. searchKeyword(value){
  143. this.courseList=[]
  144. this.keyword = value
  145. this.getFsCourseList()
  146. },
  147. searchKeywordlist(value){
  148. this.dataList=[]
  149. this.keywordlist = value
  150. this.getListData()
  151. },
  152. pullDownRefreshs() {
  153. this.triggereds = true; //下拉了状态为true
  154. setTimeout(() => {
  155. this.triggereds = false;
  156. uni.stopPullDownRefresh()
  157. this.pageNum = 1;
  158. this.getFsCourseList('refresh') //触底 不穿执行else
  159. }, 1000)
  160. },
  161. reachBottoms() {
  162. if (this.status === 'loadmore') {
  163. this.status = 'loading'
  164. uni.showNavigationBarLoading()
  165. setTimeout(() => {
  166. this.pageNum++
  167. this.getFsCourseList() //触底 不穿执行else
  168. uni.hideNavigationBarLoading()
  169. }, 1000);
  170. }
  171. },
  172. getFsCourseList(type) {
  173. const day = uni.$u.timeFormat(new Date(), 'yyyy-mm-dd')
  174. const param = {
  175. pageNum:this.pageNum,
  176. pageSize:this.pageSize,
  177. periodName:this.keyword,
  178. companyId: 11,
  179. }
  180. getOperationlist(param).then(res => {
  181. if (res.code == 200) {
  182. if (type == 'refresh') {
  183. this.courseList = res.data.list
  184. } else {
  185. this.courseList = [...this.courseList, ...res.data.list]
  186. }
  187. if ( res.data.isLastPage) {
  188. this.status = 'nomore'
  189. } else {
  190. this.status = 'loadmore'
  191. }
  192. // this.searchbar[0].name = this.courseList && this.courseList.length > 0 ? this.courseList[0]
  193. // .courseName : '训练营-营期'
  194. this.filterData[0].name=this.courseList[0].periodName
  195. this.getListInit()
  196. } else {
  197. uni.showToast({
  198. icon: 'none',
  199. title: res.msg,
  200. });
  201. }
  202. })
  203. },
  204. handleNav(type) {
  205. this.activeTab = type
  206. },
  207. clickSearchbar(type) {
  208. this.searchbarNav = type == this.searchbarNav ? 'colse' : type
  209. },
  210. mescrollInit(mescroll) {
  211. this.mescroll = mescroll;
  212. },
  213. getListInit() {
  214. this.params.pageNum = 1
  215. this.getListData('refresh')
  216. },
  217. async getListData(type = 'refresh') {
  218. uni.showLoading({
  219. title: "加载中..."
  220. })
  221. this.loadStatus = 'loading'
  222. const result = await getcourselist({
  223. periodId: this.courseId,
  224. keyword:this.keywordlist,
  225. companyId: 11,
  226. ...this.params
  227. })
  228. if (result) {
  229. const {
  230. isLastPage,
  231. total,
  232. list,
  233. } = result.data
  234. if (type == 'refresh') {
  235. this.dataList = list
  236. } else {
  237. this.dataList = [...this.dataList, ...list]
  238. }
  239. if (isLastPage) {
  240. this.loadStatus = 'nomore';
  241. } else {
  242. this.loadStatus = 'loadmore';
  243. }
  244. if (this.params.pageNum === 1) {
  245. this.scrollTop = this.old.scrollTop
  246. this.$nextTick(function() {
  247. this.scrollTop = 0
  248. });
  249. }
  250. uni.hideLoading()
  251. } else {
  252. uni.showToast({
  253. icon: 'none',
  254. title: "请求失败",
  255. });
  256. this.dataList = []
  257. // console.log(res.data)
  258. }
  259. },
  260. reachBottom(options) {
  261. if (this.loadStatus === 'loadmore') {
  262. this.loadStatus = 'loading'
  263. uni.showNavigationBarLoading()
  264. setTimeout(() => {
  265. this.params.pageNum += 1;
  266. this.getListData('more')
  267. uni.hideNavigationBarLoading()
  268. }, 500);
  269. }
  270. },
  271. pullDownRefresh(options) {
  272. this.triggered = true;
  273. setTimeout(() => {
  274. this.triggered = false;
  275. uni.stopPullDownRefresh()
  276. this.params.pageNum = 1;
  277. this.getListData('refresh')
  278. }, 500)
  279. }
  280. }
  281. }
  282. </script>
  283. <style lang="scss">
  284. .container {
  285. font-family: PingFang SC, PingFang SC;
  286. font-weight: 400;
  287. font-size: 14px;
  288. color: #222;
  289. display: flex;
  290. flex-direction: column;
  291. /* #ifdef MP-WEIXIN */
  292. height: 100vh;
  293. /* #endif */
  294. }
  295. .boxnav {
  296. flex-wrap: wrap;
  297. padding: 0 0 0 10px;
  298. &-item {
  299. width: 50%;
  300. overflow: hidden;
  301. }
  302. &-item-info {
  303. border: 1px solid #f5f5f5;
  304. text-align: center;
  305. color: #222;
  306. background-color: #f5f5f5;
  307. border-radius: 3px;
  308. padding: 5px;
  309. margin: 0 10px 10px 0;
  310. }
  311. &-active {
  312. border: 1px solid #1677ff !important;
  313. color: #1677ff !important;
  314. background-color: #e7f1fe !important;
  315. }
  316. }
  317. .headbox {
  318. background-color: #fff;
  319. }
  320. .headnav {
  321. padding: 15px 12px;
  322. margin: 0 -10px -10px 0;
  323. box-sizing: border-box;
  324. image {
  325. height: 60px;
  326. width: 50px;
  327. position: absolute;
  328. z-index: 0;
  329. bottom: 0;
  330. right: 0;
  331. display: none;
  332. }
  333. &-item {
  334. flex: 1;
  335. font-size: 16px;
  336. padding: 10px;
  337. border-radius: 10px;
  338. background: #f5f5f5;
  339. margin: 0 10px 10px 0;
  340. position: relative;
  341. z-index: 1;
  342. overflow: hidden;
  343. color: #555;
  344. }
  345. &-active {
  346. background-color: rgb(231, 241, 255) !important;
  347. .headnav-num {
  348. color: #1677ff !important;
  349. }
  350. image {
  351. display: block !important;
  352. }
  353. }
  354. &-num {
  355. font-family: DIN, DIN;
  356. font-weight: bold;
  357. font-size: 25px;
  358. margin: 5px 0;
  359. }
  360. }
  361. .searchbar {
  362. flex: 1;
  363. padding-bottom: 10px;
  364. .arrow-down {
  365. margin-left: 5px;
  366. }
  367. &-active {
  368. color: #1677ff !important;
  369. .arrow-down {
  370. transform: rotate(180deg);
  371. }
  372. }
  373. }
  374. .coursebox {
  375. position: relative;
  376. overflow-y: auto;
  377. box-sizing: border-box;
  378. }
  379. .courselist {
  380. padding: 12px;
  381. box-sizing: border-box;
  382. }
  383. .container-right {
  384. flex: 1;
  385. height: calc(100% - 80rpx);
  386. overflow-y: scroll;
  387. // padding-bottom: 80rpx;
  388. .list {
  389. padding: 10px;
  390. box-sizing: border-box;
  391. width: 100%;
  392. }
  393. }
  394. </style>