index.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  1. <template>
  2. <view>
  3. <view class="training-camp">
  4. <view class="training-camp-btn" @click="choose">{{title}}</view>
  5. </view>
  6. <u-picker ref="upicker" :show="show" :columns="columns" title="训练营选择" keyName="courseName" @confirm="confirm"
  7. @cancel="cancel"></u-picker>
  8. <view class="container-body x-start" :style="{height: contentH,width:'100%'}">
  9. <view class="container-right">
  10. <scroll-view style="height:100%" :scroll-y="true" :refresher-enabled="true"
  11. :refresher-triggered="triggered" refresher-background="rgba(0,0,0,0)"
  12. @refresherrefresh="pullDownRefresh" @refresherrestore="triggered = false" :upper-threshold="100"
  13. :lower-threshold="100" @refresherabort="triggered = false" @scrolltolower="reachBottom">
  14. <view class="list">
  15. <courseItem :from="'course'" :activeTab="0" v-for="(item,index) in dataList" :key="index"
  16. :info="item" />
  17. <u-loadmore :status="loadStatus" />
  18. </view>
  19. </scroll-view>
  20. </view>
  21. </view>
  22. </view>
  23. </template>
  24. <script>
  25. import {
  26. getFsCourseList,
  27. getCourseVdieoList
  28. } from "@/api/courseManage.js"
  29. import courseItem from "../components/courseItem.vue"
  30. import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
  31. import MescrollMoreItemMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mixins/mescroll-more-item.js";
  32. export default {
  33. mixins: [MescrollMixin, MescrollMoreItemMixin],
  34. components: {
  35. courseItem
  36. },
  37. data() {
  38. return {
  39. title: '请选择训练营',
  40. contentH: 0,
  41. show: false,
  42. columns: [
  43. []
  44. ],
  45. downOption: {
  46. auto: false // 不自动加载 (mixin已处理第一个tab触发downCallback)
  47. },
  48. upOption: {
  49. auto: false, // 不自动加载
  50. page: {
  51. num: 0, // 当前页码,默认0,回调之前会加1,即callback(page)会从1开始
  52. size: 10 // 每页数据的数量
  53. },
  54. noMoreSize: 4, //如果列表已无数据,可设置列表的总数量要大于半页才显示无更多数据;避免列表数据过少(比如只有一条数据),显示无更多数据会不好看; 默认5
  55. toTop: {
  56. width: 0,
  57. }
  58. },
  59. keyword: "",
  60. dataList: [],
  61. user: {},
  62. courseList: [],
  63. chooseIndex: [0],
  64. courseId: '',
  65. mescroll: null,
  66. params: {
  67. pageNum: 1,
  68. pageSize: 10
  69. },
  70. triggered: false,
  71. loadStatus: 'loadmore',
  72. }
  73. },
  74. mounted() {
  75. console.log("======cou")
  76. const windowHeight = uni.getSystemInfoSync().windowHeight
  77. this.contentH = `calc(${windowHeight}px - 52px - 56px)`
  78. this.user = uni.getStorageSync("companyUserInfo") ? JSON.parse(uni.getStorageSync("companyUserInfo")) : {}
  79. this.getFsCourseList()
  80. },
  81. methods: {
  82. choose() {
  83. this.show = true
  84. this.$refs.upicker.setIndexs(this.chooseIndex)
  85. },
  86. cancel() {
  87. this.show = false
  88. },
  89. confirm(e) {
  90. this.chooseIndex = e.indexs
  91. this.courseId = e.value[0].courseId
  92. this.title = e.value[0].courseName
  93. this.show = false
  94. // this.mescroll.resetUpScroll()
  95. this.getListInit()
  96. },
  97. // 训练营
  98. getFsCourseList() {
  99. const day = uni.$u.timeFormat(new Date(), 'yyyy-mm-dd')
  100. const param = {
  101. companyId: this.user.companyId,
  102. companyUserId: this.user.userId,
  103. type: this.user.userType == '00' ? 0 : 1, // 0:经销商/1:群管
  104. }
  105. getFsCourseList(param).then(res => {
  106. if (res.code == 200) {
  107. this.courseList = res.data || []
  108. this.columns = [this.courseList]
  109. this.courseId = this.courseList && this.courseList.length > 0 ? this.courseList[0]
  110. .courseId : ''
  111. this.title = this.courseList && this.courseList.length > 0 ? this.courseList[0]
  112. .courseName : '请选择训练营'
  113. this.getListInit()
  114. // this.mescroll.resetUpScroll()
  115. } else {
  116. uni.showToast({
  117. icon: 'none',
  118. title: res.msg,
  119. });
  120. }
  121. })
  122. },
  123. getListInit() {
  124. this.params.pageNum = 1
  125. this.getListData('refresh')
  126. },
  127. async getListData(type = 'refresh') {
  128. uni.showLoading({
  129. title: "加载中..."
  130. })
  131. this.loadStatus = 'loading'
  132. const result = await getCourseVdieoList({
  133. courseId: this.courseId,
  134. status: '',
  135. ...this.params
  136. })
  137. if (result) {
  138. const {
  139. isLastPage,
  140. total,
  141. list,
  142. } = result.data
  143. if (type == 'refresh') {
  144. this.dataList = list
  145. } else {
  146. this.dataList = [...this.dataList, ...list]
  147. }
  148. if (isLastPage) {
  149. this.loadStatus = 'nomore';
  150. } else {
  151. this.loadStatus = 'loadmore';
  152. }
  153. uni.hideLoading()
  154. } else {
  155. uni.showToast({
  156. icon: 'none',
  157. title: "请求失败",
  158. });
  159. this.dataList = []
  160. }
  161. },
  162. /**
  163. * 触底添加下一页
  164. */
  165. reachBottom(options) {
  166. if (this.loadStatus === 'loadmore') {
  167. this.loadStatus = 'loading'
  168. uni.showNavigationBarLoading()
  169. setTimeout(() => {
  170. this.params.pageNum += 1;
  171. this.getListData('more')
  172. uni.hideNavigationBarLoading()
  173. }, 500);
  174. }
  175. },
  176. /**
  177. * 下拉列表页
  178. */
  179. pullDownRefresh(options) {
  180. this.triggered = true;
  181. setTimeout(() => {
  182. this.triggered = false;
  183. uni.stopPullDownRefresh()
  184. this.params.pageNum = 1;
  185. this.getListData('refresh')
  186. }, 500)
  187. }
  188. }
  189. }
  190. </script>
  191. <style>
  192. page {
  193. background-color: #f5f4f5;
  194. }
  195. </style>
  196. <style lang="scss" scoped>
  197. .training-camp {
  198. padding: 10px;
  199. font-family: PingFang SC, PingFang SC;
  200. font-weight: 400;
  201. font-size: 14px;
  202. color: #222222;
  203. &-btn {
  204. font-size: 15px;
  205. width: 100%;
  206. height: 32px;
  207. line-height: 32px;
  208. text-align: center;
  209. background-color: #fff;
  210. border-radius: 50px;
  211. border: 1px solid #ccc;
  212. }
  213. }
  214. .container-left {
  215. flex-shrink: 0;
  216. background-color: #fff;
  217. width: 80px;
  218. height: 100%;
  219. overflow-y: auto;
  220. font-family: PingFang SC, PingFang SC;
  221. font-weight: 400;
  222. font-size: 14px;
  223. color: #222222;
  224. .active {
  225. background-color: #f5f4f5;
  226. font-weight: bold;
  227. position: relative;
  228. &::after {
  229. content: "";
  230. height: 15px;
  231. width: 4px;
  232. background-color: #1677ff;
  233. position: absolute;
  234. top: 50%;
  235. left: 0;
  236. transform: translateY(-50%);
  237. }
  238. }
  239. .classification {
  240. padding: 20px 16px;
  241. box-sizing: border-box;
  242. }
  243. }
  244. .container-right {
  245. flex: 1;
  246. height: 100%;
  247. overflow-y: scroll;
  248. .list {
  249. padding: 10px;
  250. box-sizing: border-box;
  251. width: 100%;
  252. }
  253. }
  254. </style>