yiming
2024-03-27 feead902a64345472895b9d4d9a335574ab728ad
packageBookService/pages/bookServices/detail/components/tree/index.js
@@ -37,20 +37,34 @@
    }
  },
  data: {
    sonPurchaseSaleMethodId: '',
    superiorPurchaseSaleMethodId: [],
    activeValues: [1, 2],
    webpageSrc: '',
    cloudShoppingCart: []
  },
  ready() {
    this.setData({
    })
    console.log('准备');
  },
  onShow() {
  },
  observers: {
    'treeList': function (newValue) {
    'openIds': function (newValue) {
      // var myEventDetail = {
      // }
      // var myEventOption = {
      //   bubbles: true,
      //   composed: true
      // }
      // this.triggerEvent('handleTree', myEventDetail, myEventOption)
    }
  },
  methods: {
    handleList(tree) {
      for (let index = 0; index < tree.length; index++) {
        const item = tree[index];
@@ -64,11 +78,9 @@
    },
    // 节点展开
    handleChange(e) {
      // console.log(this.properties.treeList, 'this.properties.treeList');
      this.setData({
        activeValues: e.detail.value,
        openIds: e.detail.value,
      });
      // console.log('传递', this.properties.buyIds);
    },
    handleCheck(data) {
      for (let index = 0; index < data.length; index++) {
@@ -275,17 +287,25 @@
    // 章节勾选
    checkResourceTitle(e) {
      // 这个时候checked的值是fals
      let checkResourceTitleList = []
      const item = e.currentTarget.dataset.item
      //
      let list = this.flattenTree([item])
      let ids = []
      list.forEach(item => {
        ids.push(item.id)
      })
      // console.log(list, 'list789');
      const updatedTreeList = this.findAndUpdateItemsByIds(this.properties.treeList, ids);
      this.setData({
        treeList: updatedTreeList  // 更新 treeList 数据
      });
      console.log(list, 'list');
      this.setData({
        superiorPurchaseSaleMethodId: list
      })
      console.log(this.data.superiorPurchaseSaleMethodId, 'superiorPurchaseSaleMethodId');
      list.forEach(items => {
        console.log(items.checked, 'itesasd');
        if (!items.checked) {
@@ -299,12 +319,16 @@
    // 子项勾选
    checkResource(e) {
      const citem = e.currentTarget.dataset.item
      console.log(e);
      // console.log(e);
      const updataList = this.checkResoucrceInfo(this.properties.treeList, citem.id)
      console.log(updataList);
      this.setData({
        treeList: updataList
        treeList: updataList,
        sonPurchaseSaleMethodId: citem.saleMethod[0].Id
      })
    },
    // 加入购物车
    async onCloudShoppingCart() {
@@ -338,8 +362,8 @@
    },
  },
  onCheckAllChange(e) {
    debugger
    console.log('checkbox', e.detail.value);
    // debugger
    // console.log('checkbox', e.detail.value);
    // this.setData({
    //   checkAllValues: event.detail,
    // });