litian
2024-09-02 c3086cda662e2b908cf96b6b3ff599713eb924d6
pages/digitalTextbooks/index.js
@@ -3,6 +3,11 @@
import {
  getPublicImage
} from "../../assets/js/middleGround/tool";
import {
  setSessionGuid,
  setNewView,
  storage
} from "../../assets/js/userAction";
Page({
  /**
@@ -17,6 +22,32 @@
    selectedIndex: 0,
    digitalTextbooksData: [],
    path: "jsek_dTHigherEducation",
    loading: true,
    sorter: {
      value: "*",
      options: [{
          value: "*",
          label: "默认排序",
        },
        {
          value: "nameAsc",
          label: "点击量正序",
        },
        {
          value: "nameDesc",
          label: "点击量倒序",
        },
        {
          value: "timeAsc",
          label: "创建时间正序",
        },
        {
          value: "timeDesc",
          label: "创建时间倒序",
        },
      ],
    },
    sortActive: ''
  },
@@ -128,8 +159,8 @@
  },
  selectTab(e) {
    // console.log(index);
    let index = e.currentTarget.dataset.index
    console.log(e);
    let index = e.detail.value
    console.log(index);
    this.setData({
      selectedIndex: index
@@ -159,13 +190,20 @@
    this.bookExhibitionGet()
  },
  onSort(e) {
    this.setData({
      "sortActive": e.detail.value,
    });
    console.log(e)
    this.bookExhibitionGet()
  },
  // 获取图片文字列表
  bookExhibitionGet(keyword) {
    // console.log(path.value, '456')
    // loading.value = true
    let searchObj = {}
    // let sort = {}
    let sort = {}
    // 搜索框
    if (keyword) {
      searchObj = {
@@ -174,22 +212,23 @@
      }
    }
    // if (timeSort.value) {
    //     sort = {
    //         CreateDate: timeSort.value || 'Desc'
    //     }
    // } else {
    //     sort = {
    //         ViewCount: nameSort.value || 'Desc'
    //     }
    //     // 组合的写法 要查询的字段:升序和降序
    //     // Name: "Desc"
    //     //一般的排序传法
    //     // type: "Asc",
    //     // field: "CreateDate",
    // }
    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'
      }
    }
    app.MG.store
      .getProductList({
        storeInfo: 'jsek_digitalTextbooks',
@@ -199,7 +238,7 @@
          start: 0,
          size: 99
        },
        // sort: sort,
        sort: sort,
        fields: {
          content: [],
          subtitle: [],
@@ -208,10 +247,10 @@
          viewCount: [],
          ...searchObj
        }
      })
      .then((res) => {
      }).then((res) => {
        this.setData({
          digitalTextbooksData: res.datas
          digitalTextbooksData: res.datas,
          loading: false
        })
        console.log(this.data.digitalTextbooksData);
      })
@@ -224,6 +263,8 @@
    const item = e.currentTarget.dataset.item
    console.log(item);
    // 在某个事件处理函数中,比如按钮的点击事件
    setNewView('productId', item.id)
    this.bookExhibitionGet()
    wx.navigateTo({
      url: '/pages/digitalTextbooks/digitalTextbooksDetails/index?id=' + item.id
    });