123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263 |
- <template>
- <view>
- <view class="training-camp">
- <view class="training-camp-btn" @click="choose">{{title}}</view>
- </view>
- <u-picker ref="upicker" :show="show" :columns="columns" title="训练营选择" keyName="courseName" @confirm="confirm"
- @cancel="cancel"></u-picker>
- <view class="container-body x-start" :style="{height: contentH,width:'100%'}">
- <view class="container-right">
- <scroll-view style="height:100%" :scroll-y="true" :refresher-enabled="true"
- :refresher-triggered="triggered" refresher-background="rgba(0,0,0,0)"
- @refresherrefresh="pullDownRefresh" @refresherrestore="triggered = false" :upper-threshold="100"
- :lower-threshold="100" @refresherabort="triggered = false" @scrolltolower="reachBottom">
- <view class="list">
- <courseItem :from="'course'" :activeTab="0" v-for="(item,index) in dataList" :key="index"
- :info="item" />
- <u-loadmore :status="loadStatus" />
- </view>
- </scroll-view>
- </view>
- </view>
- </view>
- </template>
- <script>
- import {
- getFsCourseList,
- getCourseVdieoList
- } from "@/api/courseManage.js"
- import courseItem from "../components/courseItem.vue"
- import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
- import MescrollMoreItemMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mixins/mescroll-more-item.js";
- export default {
- mixins: [MescrollMixin, MescrollMoreItemMixin],
- components: {
- courseItem
- },
- data() {
- return {
- title: '请选择训练营',
- contentH: 0,
- show: false,
- columns: [
- []
- ],
- downOption: {
- auto: false // 不自动加载 (mixin已处理第一个tab触发downCallback)
- },
- upOption: {
- auto: false, // 不自动加载
- page: {
- num: 0, // 当前页码,默认0,回调之前会加1,即callback(page)会从1开始
- size: 10 // 每页数据的数量
- },
- noMoreSize: 4, //如果列表已无数据,可设置列表的总数量要大于半页才显示无更多数据;避免列表数据过少(比如只有一条数据),显示无更多数据会不好看; 默认5
- toTop: {
- width: 0,
- }
- },
- keyword: "",
- dataList: [],
- user: {},
- courseList: [],
- chooseIndex: [0],
- courseId: '',
- mescroll: null,
- params: {
- pageNum: 1,
- pageSize: 10
- },
- triggered: false,
- loadStatus: 'loadmore',
- }
- },
- mounted() {
- console.log("======cou")
- const windowHeight = uni.getSystemInfoSync().windowHeight
- this.contentH = `calc(${windowHeight}px - 52px - 56px)`
- this.user = uni.getStorageSync("companyUserInfo") ? JSON.parse(uni.getStorageSync("companyUserInfo")) : {}
- this.getFsCourseList()
- },
- methods: {
- choose() {
- this.show = true
- this.$refs.upicker.setIndexs(this.chooseIndex)
- },
- cancel() {
- this.show = false
- },
- confirm(e) {
- this.chooseIndex = e.indexs
- this.courseId = e.value[0].courseId
- this.title = e.value[0].courseName
- this.show = false
- // this.mescroll.resetUpScroll()
- this.getListInit()
- },
- // 训练营
- getFsCourseList() {
- const day = uni.$u.timeFormat(new Date(), 'yyyy-mm-dd')
- const param = {
- companyId: this.user.companyId,
- companyUserId: this.user.userId,
- type: this.user.userType == '00' ? 0 : 1, // 0:经销商/1:群管
- }
- getFsCourseList(param).then(res => {
- if (res.code == 200) {
- this.courseList = res.data || []
- this.columns = [this.courseList]
- this.courseId = this.courseList && this.courseList.length > 0 ? this.courseList[0]
- .courseId : ''
- this.title = this.courseList && this.courseList.length > 0 ? this.courseList[0]
- .courseName : '请选择训练营'
- this.getListInit()
- // this.mescroll.resetUpScroll()
- } else {
- uni.showToast({
- icon: 'none',
- title: res.msg,
- });
- }
- })
- },
- getListInit() {
- this.params.pageNum = 1
- this.getListData('refresh')
- },
- async getListData(type = 'refresh') {
- uni.showLoading({
- title: "加载中..."
- })
- this.loadStatus = 'loading'
- const result = await getCourseVdieoList({
- courseId: this.courseId,
- status: '',
- ...this.params
- })
- if (result) {
- const {
- isLastPage,
- total,
- list,
- } = result.data
- if (type == 'refresh') {
- this.dataList = list
- } else {
- this.dataList = [...this.dataList, ...list]
- }
- if (isLastPage) {
- this.loadStatus = 'nomore';
- } else {
- this.loadStatus = 'loadmore';
- }
- uni.hideLoading()
- } else {
- uni.showToast({
- icon: 'none',
- title: "请求失败",
- });
- this.dataList = []
- }
- },
- /**
- * 触底添加下一页
- */
- reachBottom(options) {
- if (this.loadStatus === 'loadmore') {
- this.loadStatus = 'loading'
- uni.showNavigationBarLoading()
- setTimeout(() => {
- this.params.pageNum += 1;
- this.getListData('more')
- uni.hideNavigationBarLoading()
- }, 500);
- }
- },
- /**
- * 下拉列表页
- */
- pullDownRefresh(options) {
- this.triggered = true;
- setTimeout(() => {
- this.triggered = false;
- uni.stopPullDownRefresh()
- this.params.pageNum = 1;
- this.getListData('refresh')
- }, 500)
- }
- }
- }
- </script>
- <style>
- page {
- background-color: #f5f4f5;
- }
- </style>
- <style lang="scss" scoped>
- .training-camp {
- padding: 10px;
- font-family: PingFang SC, PingFang SC;
- font-weight: 400;
- font-size: 14px;
- color: #222222;
- &-btn {
- font-size: 15px;
- width: 100%;
- height: 32px;
- line-height: 32px;
- text-align: center;
- background-color: #fff;
- border-radius: 50px;
- border: 1px solid #ccc;
- }
- }
- .container-left {
- flex-shrink: 0;
- background-color: #fff;
- width: 80px;
- height: 100%;
- overflow-y: auto;
- font-family: PingFang SC, PingFang SC;
- font-weight: 400;
- font-size: 14px;
- color: #222222;
- .active {
- background-color: #f5f4f5;
- font-weight: bold;
- position: relative;
- &::after {
- content: "";
- height: 15px;
- width: 4px;
- background-color: #1677ff;
- position: absolute;
- top: 50%;
- left: 0;
- transform: translateY(-50%);
- }
- }
- .classification {
- padding: 20px 16px;
- box-sizing: border-box;
- }
- }
- .container-right {
- flex: 1;
- height: 100%;
- overflow-y: scroll;
- .list {
- padding: 10px;
- box-sizing: border-box;
- width: 100%;
- }
- }
- </style>
|