litian
2024-09-06 266c7278841d2cbae5e9ab969ffd2efae1d0dda5
pages/digitalCourses/index.js
@@ -17,9 +17,35 @@
    tabList: [],
    courseList: [],
    searchValue: '',
    active: 0,
    activeItem: null,
    loading: false,
    shoppingCartGetId: []
    shoppingCartGetId: [],
    sorter: {
      value: "*",
      options: [{
          value: "*",
          label: "默认排序",
        },
        {
          value: "nameAsc",
          label: "点击量正序",
        },
        {
          value: "nameDesc",
          label: "点击量倒序",
        },
        {
          value: "timeAsc",
          label: "创建时间正序",
        },
        {
          value: "timeDesc",
          label: "创建时间倒序",
        },
      ],
    },
    sortActive: ''
  },
  /**
@@ -34,6 +60,11 @@
      barHeight: systInfo.statusBarHeight,
      navBarHeight: navBarHeight,
    });
    if (options.courseTypeActive) {
      this.setData({
        active: JSON.parse(options.courseTypeActive),
      });
    }
    this.getCourseTypeListList()
    this.getShoppingCartList()
  },
@@ -96,7 +127,6 @@
    wx.navigateBack();
  },
  getCourseTypeListList() {
    this.setData({
      loading: true
    })
@@ -119,46 +149,52 @@
    app.MG.store.getStoreChannelList(data).then((res) => {
      // 去除数组最后一个元素
      const newData = res.datas.slice(0, res.datas.length - 1)
      this.setData({
        tabList: newData,
        activeItem: newData[0],
        loading: false
      })
      this.getCourseList(newData[0])
      if (this.data.active) {
        this.getCourseList(newData[this.data.active])
      } else {
        this.setData({
          activeItem: newData[0],
        })
        this.getCourseList(newData[0])
      }
    })
  },
  getCourseList(item) {
    let searchObj = {}
    // let sort = {}
    let sort = {}
    // // 搜索框
    if (this.data.searchValue) {
      searchObj = {
        'Name*': this.data.searchValue.trim()
        // '||subtitle*': searchInputValue.value.trim()
        'Name*': this.data.searchValue.trim(),
        '||isbn*': searchInputValue.value.trim(),
        '||courseLeader*': searchInputValue.value.trim()
      }
    }
    // if (timeSort.value) {
    //     sort = {
    //         CreateDate: timeSort.value || 'Desc'
    //     }
    // } else {
    //     sort = {
    //         ViewCount: nameSort.value || 'Desc'
    //     }
    if (this.data.sortActive == 'nameAsc') {
      sort = {
        ViewCount: 'Asc'
      }
    } else if (this.data.sortActive == 'nameDesc') {
      sort = {
        ViewCount: 'Desc'
      }
    } else if (this.data.sortActive == 'timeAsc') {
      sort = {
        CreateDate: 'Asc'
      }
    } else if (this.data.sortActive == 'timeDesc') {
      sort = {
        CreateDate: 'Desc'
      }
    }
    //     // 组合的写法 要查询的字段:升序和降序
    //     // Name: "Desc"
    //     //一般的排序传法
    //     // type: "Asc",
    //     // field: "CreateDate",
    // }
    // courseList.value = [];
    const obj = {
      storeInfo: app.config.goodsStore,
      path: item.pathList + '\\' + item.id,
@@ -173,7 +209,7 @@
        value: 'Normal',
        field: 'state'
      }],
      // sort: sort,
      sort: sort,
      fields: {
        courseLeader: [],
        affiliatedUnit: [],
@@ -197,6 +233,13 @@
  searchBook() {
    this.getCourseList(this.data.activeItem)
  },
  onSort(e) {
    this.setData({
      "sortActive": e.detail.value,
    });
    console.log(e)
    this.getCourseList(this.data.activeItem);
  },
  courseDetail(e) {
    const item = e.currentTarget.dataset.item
    setNewView('productId', item.id)