闫增涛
2024-04-09 253245731d2b0c5ea4994a9c4e17ad6b60136f2c
packageBookService/pages/bookServices/detail/components/tree/index.js
@@ -43,6 +43,9 @@
      type: Boolean,
      value: false,
    },
    checkAllState: {
      type: Boolean,
    },
  },
  data: {
    sonPurchaseSaleMethodId: "",
@@ -54,10 +57,7 @@
    shoppingCart: true,
    stop: false,
  },
  ready() {
    this.setData({});
    console.log("准备");
  },
  ready() {},
  onLoad() {
    this.setData({
@@ -72,7 +72,6 @@
    treeList: function (newValue) {
      const list = [];
      let checked = "";
      console.log("新值", this.properties.treeList);
      this.properties.treeList.forEach((item) => {
        if (item.children && item.children.length > 0) {
          list.push(...this.flattenTree([item]));
@@ -166,7 +165,9 @@
        ) {
          return wx.showToast({
            icon: "error",
            title: "请先购买该资源",
            title: item.saleMethod[0].Price > 0 ?
              "请先购买该资源" :
              "请先点击领取查看按钮",
          });
        }
        wx.navigateTo({
@@ -308,16 +309,9 @@
        ids.push(item.id);
        checked = item.checked;
      });
      const flag =
        list.findIndex((item) => item.checked == false) > -1 ? true : false;
      var myEventDetail = {
        value: flag,
      }; // detail对象,提供给事件监听函数
      var myEventOption = {
        bubbles: true,
        composed: true,
      }; // 触发事件的选项
      this.triggerEvent("changeCheckAll", myEventDetail, myEventOption);
      // const flag =
      //   list.findIndex((item) => item.checked == false) > -1 ? true : false;
      const flag = this.properties.checkAllState;
      const updataList = this.findAndUpdateItemsByIds(
        this.properties.treeList,
        ids,
@@ -332,6 +326,14 @@
      this.setData({
        treeList: updataList,
      });
      var myEventDetail = {
        value: !flag,
      }; // detail对象,提供给事件监听函数
      var myEventOption = {
        bubbles: true,
        composed: true,
      }; // 触发事件的选项
      this.triggerEvent("changeCheckAll", myEventDetail, myEventOption);
    },
    // 章节勾选
@@ -381,13 +383,10 @@
        this.properties.treeList,
        citem.id
      );
      console.log(citem.checked, "citem.checked");
      if (!citem.checked) {
        //选中的时候添加id
        let sonPurchaseSaleMethodId = this.data.sonPurchaseSaleMethodId || [];
        console.log(this.properties.paymentPage, "this.properties.paymentPage");
        if (this.properties.paymentPage) {
          console.log(789987);
          sonPurchaseSaleMethodId = [];
          this.properties.paymentPage = false;
        }
@@ -450,13 +449,11 @@
      }
    },
    sadd() {
      this.triggerEvent('updateShoppingCartHidden');
      this.triggerEvent('updateCloudLearning');
      this.triggerEvent("updateShoppingCartHidden");
      this.triggerEvent("updateCloudLearning");
      console.log(789);
    },
  },
  catchtap() {}
})
  catchtap() {},
});