index.vue 10 KB

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