index.vue 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377
  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="@/static/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="@/static/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="@/static/images/finished.png" mode="aspectFill"></image>
  19. </view>
  20. </view> -->
  21. <!-- <view class="x-bc">
  22. <view :class="searchbarNav == index ? 'searchbar x-c searchbar-active':'searchbar x-c'" v-for="(item,index) in searchbar" :key="index" @click="clickSearchbar(index)">
  23. <text>{{item.name}}</text><u-icon class="arrow-down" name="arrow-down" :color="searchbarNav == index ?'#1677ff':'#999'" size="12"></u-icon>
  24. </view>
  25. </view> -->
  26. <view>
  27. <dropdownPanel :filterData='filterData' @onChange="onChange" @confirm="confirm" @reset="reset">
  28. <view v-if="searchbarNav == 0">
  29. <view class="boxnav x-bc">
  30. <view class="boxnav-item" v-for="(item,index) in courseList" :key="index">
  31. <view class="boxnav-item-info one-t"
  32. :class="courserIndex == item.courseId ? 'boxnav-active':''"
  33. @click="handleCourse(item)">{{item.courseName}}</view>
  34. </view>
  35. </view>
  36. </view>
  37. </dropdownPanel>
  38. </view>
  39. </view>
  40. <view class="container-right" >
  41. <scroll-view style="height:100%" :scroll-y="true" :refresher-enabled="true" :refresher-triggered="triggered"
  42. refresher-background="rgba(0,0,0,0)" @refresherrefresh="pullDownRefresh"
  43. @refresherrestore="triggered = false" :upper-threshold="100" :lower-threshold="100"
  44. @refresherabort="triggered = false" @scrolltolower="reachBottom">
  45. <view class="list">
  46. <courseItem :from="'course'" :activeTab="1" v-for="(item,index) in dataList" :key="index"
  47. :info="item" />
  48. <u-loadmore :status="loadStatus" />
  49. </view>
  50. </scroll-view>
  51. </view>
  52. </view>
  53. </template>
  54. <script>
  55. import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
  56. import {
  57. getFsCourseList,
  58. getCourseVdieoList
  59. } from "@/api/courseManage.js"
  60. import dropdownPanel from "../components/dropdownPanel.vue"
  61. import courseItem from "../components/courseItem.vue"
  62. export default {
  63. mixins: [MescrollMixin],
  64. components: {
  65. courseItem,
  66. dropdownPanel
  67. },
  68. data() {
  69. return {
  70. user: {},
  71. filterData: [{
  72. name: '训练营-营期',
  73. value: 0,
  74. },
  75. // {
  76. // name: '课程状态',
  77. // value: 1,
  78. // },
  79. ],
  80. defaultIndex: [0, 0],
  81. contentH: 0,
  82. activeTab: 1,
  83. courseList: [],
  84. courseId: '',
  85. searchbarNav: 0,
  86. courserIndex: 0,
  87. searchbar: [{
  88. name: '训练营-营期'
  89. },
  90. {
  91. name: '课程状态'
  92. }
  93. ],
  94. mescroll: null,
  95. downOption: {
  96. use: true,
  97. auto: false
  98. },
  99. upOption: {
  100. onScroll: false,
  101. use: true, // 是否启用上拉加载; 默认true
  102. auto: true,
  103. page: {
  104. pae: 0, // 当前页码,默认0,回调之前会加1,即callback(page)会从1开始
  105. size: 10 // 每页数据的数量,默认10
  106. },
  107. noMoreSize: 10, // 配置列表的总数量要大于等于5条才显示'-- END --'的提示
  108. textNoMore: "已经到底了",
  109. empty: {
  110. icon: 'https://cos.his.cdwjyyh.com/fs/20240423/cf4a86b913a04341bb44e34bb4d37aa2.png',
  111. tip: '暂无数据'
  112. }
  113. },
  114. dataList: [],
  115. params: {
  116. pageNum: 1,
  117. pageSize: 10
  118. },
  119. triggered: false,
  120. loadStatus: 'loadmore',
  121. }
  122. },
  123. mounted() {
  124. const windowHeight = uni.getSystemInfoSync().windowHeight
  125. this.contentH = `calc(${windowHeight}px - 132px - 56px)`
  126. this.user = uni.getStorageSync("companyUserInfo") ? JSON.parse(uni.getStorageSync("companyUserInfo")) : {}
  127. this.getFsCourseList()
  128. },
  129. methods: {
  130. onChange(index) {
  131. this.searchbarNav = index
  132. },
  133. reset() {
  134. this.courserIndex = ''
  135. },
  136. handleCourse(item) {
  137. this.courserIndex = item.courseId
  138. },
  139. confirm() {
  140. this.courseId = this.courserIndex
  141. console.log(this.courseId)
  142. this.getFsCourseList()
  143. },
  144. // 训练营
  145. getFsCourseList() {
  146. const day = uni.$u.timeFormat(new Date(), 'yyyy-mm-dd')
  147. const param = {
  148. companyId: this.user.companyId,
  149. companyUserId: this.user.userId,
  150. type: this.user.userType == '00' ? 0 : 1, // 0:经销商/1:群管
  151. }
  152. getFsCourseList(param).then(res => {
  153. if (res.code == 200) {
  154. this.courseList = res.data || []
  155. // this.courseId = this.courseList && this.courseList.length > 0 ? this.courseList[0]
  156. // .courseId : ''
  157. // this.searchbar[0].name = this.courseList && this.courseList.length > 0 ? this.courseList[0]
  158. // .courseName : '训练营-营期'
  159. console.log(this.courseId)
  160. // this.mescroll.resetUpScroll()
  161. this.getListInit()
  162. } else {
  163. uni.showToast({
  164. icon: 'none',
  165. title: res.msg,
  166. });
  167. }
  168. })
  169. },
  170. handleNav(type) {
  171. this.activeTab = type
  172. },
  173. clickSearchbar(type) {
  174. this.searchbarNav = type == this.searchbarNav ? 'colse' : type
  175. },
  176. mescrollInit(mescroll) {
  177. this.mescroll = mescroll;
  178. },
  179. getListInit() {
  180. this.params.pageNum = 1
  181. this.getListData('refresh')
  182. },
  183. async getListData(type = 'refresh') {
  184. uni.showLoading({
  185. title: "加载中..."
  186. })
  187. this.loadStatus = 'loading'
  188. const result = await getCourseVdieoList({
  189. courseId: this.courseId,
  190. status: '',
  191. ...this.params
  192. })
  193. if (result) {
  194. const {
  195. isLastPage,
  196. total,
  197. list,
  198. } = result.data
  199. if (type == 'refresh') {
  200. this.dataList = list
  201. } else {
  202. this.dataList = [...this.dataList, ...list]
  203. }
  204. if (isLastPage) {
  205. this.loadStatus = 'nomore';
  206. } else {
  207. this.loadStatus = 'loadmore';
  208. }
  209. uni.hideLoading()
  210. } else {
  211. uni.showToast({
  212. icon: 'none',
  213. title: "请求失败",
  214. });
  215. this.dataList = []
  216. }
  217. },
  218. /**
  219. * 触底添加下一页
  220. */
  221. reachBottom(options) {
  222. if (this.loadStatus === 'loadmore') {
  223. this.loadStatus = 'loading'
  224. uni.showNavigationBarLoading()
  225. setTimeout(() => {
  226. this.params.pageNum += 1;
  227. this.getListData('more')
  228. uni.hideNavigationBarLoading()
  229. }, 500);
  230. }
  231. },
  232. /**
  233. * 下拉列表页
  234. */
  235. pullDownRefresh(options) {
  236. this.triggered = true;
  237. setTimeout(() => {
  238. this.triggered = false;
  239. uni.stopPullDownRefresh()
  240. this.params.pageNum = 1;
  241. this.getListData('refresh')
  242. }, 500)
  243. }
  244. }
  245. }
  246. </script>
  247. <style lang="scss">
  248. .container {
  249. font-family: PingFang SC, PingFang SC;
  250. font-weight: 400;
  251. font-size: 14px;
  252. color: #222;
  253. display: flex;
  254. flex-direction: column;
  255. }
  256. .boxnav {
  257. flex-wrap: wrap;
  258. padding: 0 0 0 10px;
  259. &-item {
  260. width: 50%;
  261. overflow: hidden;
  262. }
  263. &-item-info {
  264. border: 1px solid #f5f5f5;
  265. text-align: center;
  266. color: #222;
  267. background-color: #f5f5f5;
  268. border-radius: 3px;
  269. padding: 5px;
  270. margin: 0 10px 10px 0;
  271. }
  272. &-active {
  273. border: 1px solid #1677ff !important;
  274. color: #1677ff !important;
  275. background-color: #e7f1fe !important;
  276. }
  277. }
  278. .headbox {
  279. background-color: #fff;
  280. }
  281. .headnav {
  282. padding: 15px 12px;
  283. margin: 0 -10px -10px 0;
  284. box-sizing: border-box;
  285. image {
  286. height: 60px;
  287. width: 50px;
  288. position: absolute;
  289. z-index: 0;
  290. bottom: 0;
  291. right: 0;
  292. display: none;
  293. }
  294. &-item {
  295. flex: 1;
  296. font-size: 16px;
  297. padding: 10px;
  298. border-radius: 10px;
  299. background: #f5f5f5;
  300. margin: 0 10px 10px 0;
  301. position: relative;
  302. z-index: 1;
  303. overflow: hidden;
  304. color: #555;
  305. }
  306. &-active {
  307. background-color: rgb(231, 241, 255) !important;
  308. .headnav-num {
  309. color: #1677ff !important;
  310. }
  311. image {
  312. display: block !important;
  313. }
  314. }
  315. &-num {
  316. font-family: DIN, DIN;
  317. font-weight: bold;
  318. font-size: 25px;
  319. margin: 5px 0;
  320. }
  321. }
  322. .searchbar {
  323. flex: 1;
  324. padding-bottom: 10px;
  325. .arrow-down {
  326. margin-left: 5px;
  327. }
  328. &-active {
  329. color: #1677ff !important;
  330. .arrow-down {
  331. transform: rotate(180deg);
  332. }
  333. }
  334. }
  335. .coursebox {
  336. position: relative;
  337. overflow-y: auto;
  338. box-sizing: border-box;
  339. }
  340. .courselist {
  341. padding: 12px;
  342. box-sizing: border-box;
  343. }
  344. .container-right {
  345. flex: 1;
  346. height: calc(100% - 80rpx);
  347. overflow-y: scroll;
  348. padding-bottom: 80rpx;
  349. .list {
  350. padding: 10px;
  351. box-sizing: border-box;
  352. width: 100%;
  353. }
  354. }
  355. </style>