1
YM
2024-09-07 6851680b996e64c1d66c035245b2f0f6eb3425c6
pages/digitalCourses/index.js
@@ -20,7 +20,33 @@
    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: '',
    otherType: null
  },
  /**
@@ -107,10 +133,10 @@
    })
    const data = {
      path: '*',
      filterList: [{
        value: 'Normal',
        field: 'state'
      }],
      // filterList: [{
      //   value: 'Normal',
      //   field: 'state'
      // }],
      queryType: '\\',
      searchList: [],
      size: '20',
@@ -123,7 +149,15 @@
    }
    app.MG.store.getStoreChannelList(data).then((res) => {
      // 去除数组最后一个元素
      // 找出其他分类的path,用于排除其他分类里的数据
      this.data.otherType = res.datas.find(item => item.refCode == "jsek_dCOther")
      res.datas = res.datas.filter(item => item.state == 'Normal')
      const newData = res.datas.slice(0, res.datas.length - 1)
      newData.unshift({
        name: "全部",
        pathList: newData[0].pathList[0],
        id: ""
      })
      this.setData({
        tabList: newData,
        loading: false
@@ -142,35 +176,39 @@
  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,
      // path: item.pathList + '\\' + item.id,
      path: item.id ? item.pathList + '\\' + item.id : item.pathList,
      queryType: "*",
      coverSize: {
        width: 260
      },
@@ -182,7 +220,7 @@
        value: 'Normal',
        field: 'state'
      }],
      // sort: sort,
      sort: sort,
      fields: {
        courseLeader: [],
        affiliatedUnit: [],
@@ -195,23 +233,30 @@
    app.MG.store.getProductList(obj).then((res) => {
      res.datas.forEach(item => {
        item.price = item.price.toFixed(2)
        item.productLinkInfo = JSON.parse(item.productLinkInfo)
      })
      // 排除其他分类里的数据
      this.setData({
        courseList: res.datas
        courseList: res.datas.filter(item => item.productLinkInfo[0].LinkPath != this.data.otherType.pathList[0] + '\\' + this.data.otherType.id)
      })
    })
  },
  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)
    this.getCourseTypeListList()
    wx.navigateTo({
      url: '/pages/digitalCourses/digitalCoursesDetails/index?id=' + item.id,
      url: '/pages/digitalCourses/digitalCoursesDetails/index?id=' + item.id + '&path=' + item.idPath,
    })
  },