index.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  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" @cancel="cancel"></u-picker>
  7. <view class="container-body x-start" :style="{height: contentH}">
  8. <!-- <view class="container-left">
  9. <view class="classification active">全部</view>
  10. <view class="classification">测试</view>
  11. </view> -->
  12. <view class="container-right">
  13. <mescroll-body top="0" bottom="0" ref="mescrollRef" @init="mescrollInit" :down="downOption" :up="upOption" @down="downCallback" @up="upCallback">
  14. <view class="list">
  15. <courseItem :from="'course'" :activeTab="0" v-for="(item,index) in dataList" :key="index" :info="item" />
  16. </view>
  17. </mescroll-body>
  18. </view>
  19. </view>
  20. </view>
  21. </template>
  22. <script>
  23. import { getFsCourseList,getCourseVdieoList } from "@/api/courseManage.js"
  24. import courseItem from "../components/courseItem.vue"
  25. import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
  26. export default {
  27. mixins: [MescrollMixin],
  28. components: {
  29. courseItem
  30. },
  31. data() {
  32. return {
  33. title: '请选择训练营',
  34. contentH: 0,
  35. show: false,
  36. columns: [[]],
  37. mescroll:null,
  38. downOption: {
  39. use:true,
  40. auto: false
  41. },
  42. upOption: {
  43. onScroll:false,
  44. use: true, // 是否启用上拉加载; 默认true
  45. auto: false,
  46. page: {
  47. pae: 0, // 当前页码,默认0,回调之前会加1,即callback(page)会从1开始
  48. size: 10 // 每页数据的数量,默认10
  49. },
  50. noMoreSize: 10, // 配置列表的总数量要大于等于5条才显示'-- END --'的提示
  51. textNoMore:"已经到底了",
  52. empty: {
  53. icon:'https://cos.his.cdwjyyh.com/fs/20240423/cf4a86b913a04341bb44e34bb4d37aa2.png',
  54. tip: '暂无数据'
  55. }
  56. },
  57. dataList: [],
  58. user: {},
  59. courseList: [],
  60. chooseIndex: [0],
  61. courseId: ''
  62. }
  63. },
  64. mounted() {
  65. console.log("======cou")
  66. const windowHeight = uni.getSystemInfoSync().windowHeight
  67. this.contentH = `calc(${windowHeight}px - 52px - 56px)`
  68. this.user = uni.getStorageSync("companyUserInfo") ? JSON.parse(uni.getStorageSync("companyUserInfo")) : {}
  69. this.getFsCourseList()
  70. },
  71. methods: {
  72. choose() {
  73. this.show = true
  74. this.$refs.upicker.setIndexs(this.chooseIndex)
  75. },
  76. cancel() {
  77. this.show = false
  78. },
  79. confirm(e) {
  80. this.chooseIndex = e.indexs
  81. this.courseId = e.value[0].courseId
  82. this.title = e.value[0].courseName
  83. this.show = false
  84. this.mescroll.resetUpScroll()
  85. },
  86. // 训练营
  87. getFsCourseList() {
  88. const day = uni.$u.timeFormat(new Date(), 'yyyy-mm-dd')
  89. const param = {
  90. companyId: this.user.companyId,
  91. companyUserId: this.user.userId,
  92. type: this.user.userType=='00' ? 0 : 1, // 0:经销商/1:群管
  93. }
  94. getFsCourseList(param).then(res=>{
  95. if(res.code==200){
  96. this.courseList = res.data || []
  97. this.columns = [this.courseList]
  98. this.courseId = this.courseList && this.courseList.length > 0 ? this.courseList[0].courseId : ''
  99. this.title = this.courseList && this.courseList.length > 0 ? this.courseList[0].courseName : '请选择训练营'
  100. this.mescroll.resetUpScroll()
  101. }else{
  102. uni.showToast({
  103. icon:'none',
  104. title: res.msg,
  105. });
  106. }
  107. })
  108. },
  109. mescrollInit(mescroll) {
  110. this.mescroll = mescroll;
  111. },
  112. /*下拉刷新的回调 */
  113. downCallback(mescroll) {
  114. mescroll.resetUpScroll()
  115. },
  116. upCallback(page) {
  117. //联网加载数据
  118. var that = this;
  119. var data={
  120. courseId:this.courseId,
  121. status: '',
  122. pageNum: page.num,
  123. pageSize: page.size
  124. };
  125. uni.showLoading({
  126. title:"加载中..."
  127. })
  128. getCourseVdieoList(data).then(res => {
  129. uni.hideLoading()
  130. if(res.code==200){
  131. //设置列表数据
  132. if (page.num == 1) {
  133. that.dataList = res.data.list;
  134. } else {
  135. that.dataList = that.dataList.concat(res.data.list);
  136. }
  137. that.mescroll.endBySize(res.data.list.length, res.data.total);
  138. }else{
  139. uni.showToast({
  140. icon:'none',
  141. title: "请求失败",
  142. });
  143. that.dataList = null;
  144. that.mescroll.endErr();
  145. }
  146. });
  147. },
  148. }
  149. }
  150. </script>
  151. <style>
  152. page {
  153. background-color: #f5f4f5;
  154. }
  155. </style>
  156. <style lang="scss" scoped>
  157. .training-camp {
  158. padding: 10px;
  159. font-family: PingFang SC, PingFang SC;
  160. font-weight: 400;
  161. font-size: 14px;
  162. color: #222222;
  163. &-btn {
  164. font-size: 15px;
  165. width: 100%;
  166. height: 32px;
  167. line-height: 32px;
  168. text-align: center;
  169. background-color: #fff;
  170. border-radius: 50px;
  171. border: 1px solid #ccc;
  172. }
  173. }
  174. .container-left {
  175. flex-shrink: 0;
  176. background-color: #fff;
  177. width: 80px;
  178. height: 100%;
  179. overflow-y: auto;
  180. font-family: PingFang SC, PingFang SC;
  181. font-weight: 400;
  182. font-size: 14px;
  183. color: #222222;
  184. .active {
  185. background-color: #f5f4f5;
  186. font-weight: bold;
  187. position: relative;
  188. &::after {
  189. content: "";
  190. height: 15px;
  191. width: 4px;
  192. background-color: #1677ff;
  193. position: absolute;
  194. top: 50%;
  195. left: 0;
  196. transform: translateY(-50%);
  197. }
  198. }
  199. .classification {
  200. padding: 20px 16px;
  201. box-sizing: border-box;
  202. }
  203. }
  204. .container-right {
  205. flex: 1;
  206. height: 100%;
  207. overflow-y: auto;
  208. .list {
  209. padding: 10px;
  210. box-sizing: border-box;
  211. width: 100%;
  212. }
  213. }
  214. </style>