zs
litian
2024-09-20 fba71ba1ae5030cb1a20f54f29fb06ad97060297
pages/digitalCourses/index.js
@@ -20,6 +20,8 @@
    active: 0,
    activeItem: null,
    loading: false,
    contentLoading: false,
    noData: false,
    shoppingCartGetId: [],
    sorter: {
      value: "*",
@@ -45,7 +47,7 @@
        },
      ],
    },
    sortActive: ''
    sortActive: '',
  },
  /**
@@ -119,6 +121,9 @@
  },
  onTabsChange(event) {
    const value = event.detail.value
    this.setData({
      contentLoading: true
    })
    this.getCourseList(this.data.tabList[value])
  },
@@ -128,14 +133,14 @@
  },
  getCourseTypeListList() {
    this.setData({
      loading: true
      loading: true,
    })
    const data = {
      path: '*',
      filterList: [{
        value: 'Normal',
        field: 'state'
      }],
      // filterList: [{
      //   value: 'Normal',
      //   field: 'state'
      // }],
      queryType: '\\',
      searchList: [],
      size: '20',
@@ -147,8 +152,12 @@
      }
    }
    app.MG.store.getStoreChannelList(data).then((res) => {
      // 去除数组最后一个元素
      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
@@ -166,14 +175,17 @@
  },
  getCourseList(item) {
    this.setData({
      noData: false,
    })
    let searchObj = {}
    let sort = {}
    // // 搜索框
    if (this.data.searchValue) {
      searchObj = {
        'Name*': this.data.searchValue.trim(),
        '||isbn*': searchInputValue.value.trim(),
        '||courseLeader*': searchInputValue.value.trim()
        '||isbn*': this.data.searchValue.trim(),
        '||courseLeader*': this.data.searchValue.trim()
      }
    }
@@ -197,7 +209,9 @@
    //     // 组合的写法 要查询的字段:升序和降序
    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
      },
@@ -220,14 +234,21 @@
      }
    }
    app.MG.store.getProductList(obj).then((res) => {
      if (!res.datas.length) {
        return this.setData({
          noData: true,
          contentLoading: false
        })
      }
      res.datas.forEach(item => {
        item.price = item.price.toFixed(2)
        item.productLinkInfo = JSON.parse(item.productLinkInfo)
      })
      // 排除其他分类里的数据
      this.setData({
        courseList: res.datas
        courseList: res.datas,
        contentLoading: false,
      })
    })
  },
  searchBook() {
@@ -237,7 +258,6 @@
    this.setData({
      "sortActive": e.detail.value,
    });
    console.log(e)
    this.getCourseList(this.data.activeItem);
  },
  courseDetail(e) {
@@ -245,7 +265,7 @@
    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
    })
  },
@@ -289,7 +309,7 @@
          )
        ) {
          wx.showToast({
            title: "该书已在购物车,请勿重复添加空",
            title: "该课程已在购物车,请勿重复添加",
            icon: 'none',
            duration: 1000
          })