litian
2024-09-02 c3086cda662e2b908cf96b6b3ff599713eb924d6
pages/digitalCourses/index.js
@@ -20,7 +20,32 @@
    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: ''
  },
  /**
@@ -142,7 +167,7 @@
  getCourseList(item) {
    let searchObj = {}
    // let sort = {}
    let sort = {}
    // // 搜索框
    if (this.data.searchValue) {
      searchObj = {
@@ -151,23 +176,24 @@
      }
    }
    // 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,
@@ -182,7 +208,7 @@
        value: 'Normal',
        field: 'state'
      }],
      // sort: sort,
      sort: sort,
      fields: {
        courseLeader: [],
        affiliatedUnit: [],
@@ -206,6 +232,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)