闫增涛
2 天以前 d7b7435558c15789e9a2c650389cd28ce88d443b
packageBookService/pages/bookServices/detail/index.js
@@ -212,9 +212,19 @@
    protocolTxt: '',
    learnMenu: null,
    md5List: [],
    editDialog: false
    editDialog: false,
    scrollTop: 0, // 扫码进资源滚动
    source: '',
    activeId: '',
    qrTabValue: ''
  },
  // 扫码到资源列表,滚动到该资源位置
  handleScrollTop(e) {
    if (this.data.tabValue == this.data.qrTabValue)
      this.setData({
        scrollTop: e.detail.top
      })
  },
  resetTree: function (e) {
    this.setData({
      currentCheck: e.detail.checkedItem,
@@ -258,7 +268,11 @@
        name: decodeURI(options.name),
        storeInfo: options.storeInfo,
      },
      source: options.source,
      activeId: options.resourceId,
      qrTabValue: options.tabValue
    });
    console.log('传参', this.data);
    wx.setNavigationBarTitle({
      title: decodeURI(options.name),
    })
@@ -301,6 +315,7 @@
    }
    this.setData({
      num: Number(this.data.paperBookList.length) + Number(this.data.electronicBookList.length),
      editDialog: false
    });
    if (this.data.bookDetail.id) {
      this.getBookInfo(this.data.bookDetail.id)
@@ -771,7 +786,11 @@
      editDialog: true
    })
  },
  closeEditDialog() {
    this.setData({
      editDialog: false
    })
  },
  // 我要建议
  suggestBtn() {
    // 检查登录状态
@@ -1081,7 +1100,11 @@
      }
      let result = [];
      if (type.refCode == "jsek_teachingResources") {
        this.findChildIds(list, result);
        if (this.data.activeId) {
          result = this.findChildIdsByCode(res.datas.cmsDatas[0].datas)
        } else {
          this.findChildIds(list, result);
        }
        this.setData({
          openTeachids: result,
          loading: false,
@@ -1100,14 +1123,21 @@
        ) || (flags && cloundSaleMethod.Price == 0)
        // 判断云学习全部购买按钮是否显示
        let isShowBuyCloundMenu = flags && cloundSaleMethod.Price > 0 && !this.data.buyIdList.includes(cloundSaleMethod.Id)
        // 判断资源购买按钮是否显示
        let isShowBuyCloundBtn = !flags && res.datas.cmsDatas[0].datas.some(citem => citem.saleMethod.length != 0)
        // 判断资源购买按钮是否显示 (云学习无销售方式,资源和目录中有销售方式,且售价大于0)
        let isShowBuyCloundBtn = !flags && res.datas.cmsDatas[0].datas.some(item => item.saleMethod.length &&
          item.saleMethod.find((citem) => citem.SaleType == 'Normal').Price > 0 &&
          new Date(item.saleMethod.find((citem) => citem.SaleType == 'Normal').EndDate).getTime() >= new Date().getTime() &&
          new Date(item.saleMethod.find((citem) => citem.SaleType == 'Normal').BeginDate).getTime() <= new Date().getTime())
        // 判断购物车按钮和锁按钮是否显示
        this.handleTreeData(list).forEach(item => {
          item.isbuy = this.resourceIsBuy(item);
          item.isShopCar = this.isShoppingCart(item);
        })
        this.findChildIds(list, result);
        if (this.data.activeId) {
          result = this.findChildIdsByCode(res.datas.cmsDatas[0].datas)
        } else {
          this.findChildIds(list, result);
        }
        this.setData({
          isshowDrawBtn,
          isShowBuyCloundMenu,
@@ -1119,7 +1149,7 @@
          learnPath: type.productLinkPath
        });
      }
      console.log('1', this.data.teach);
      console.log('1', result);
    })
  },
  //  获取 云测试
@@ -1270,14 +1300,19 @@
      }
  },
  // 获取目录扫码展开项
  findChildIdsByCode(list) {
    let arr = []
    const data = list.find(item => item.id == this.data.activeId)
    if (data) {
      const ids = data.productLinkInfo.find(item => item.CmsItemId == data.id).LinkPath.split('\\')
      arr = [data.id, ...ids].map(item => Number(item))
    }
    return arr
  },
  // 图书添加购物车
  addBookShopcCar() {
    const token = wx.getStorageSync(app.config.tokenKey);
    if (token) {
      addFun()
    } else {
      this.logInFun(() => {})
    }
    const addFun = async () => {
      if (!this.data.expire) {
        const shoppingCartGetId = [];
@@ -1321,6 +1356,13 @@
        });
      }
    }
    const token = wx.getStorageSync(app.config.tokenKey);
    if (token) {
      addFun()
    } else {
      this.logInFun(() => {})
    }
  },
  showSuccessToast() {
@@ -1796,13 +1838,6 @@
  },
  // 云学习一键领取
  getFreeResource() {
    const child = this.selectComponent("#learn-resource");
    const token = wx.getStorageSync(app.config.tokenKey);
    if (!token) {
      this.logInFun(() => {});
    } else {
      getFreeFun()
    }
    const getFreeFun = async () => {
      // 领取查看 ,先看云学习上的  再看资源上的
      const cloundMenu = this.data.resourceCodeList.find((item) => item.refCode == 'jsek_cloudLearning')
@@ -1871,6 +1906,14 @@
        console.log(error);
      }
    }
    const child = this.selectComponent("#learn-resource");
    const token = wx.getStorageSync(app.config.tokenKey);
    if (!token) {
      this.logInFun(() => {});
    } else {
      getFreeFun()
    }
  },
  // 云学习一键购买
  async allAddShoppiingCar() {
@@ -1924,12 +1967,6 @@
  },
  // 云学习全部购买
  buyCloudLearnClass() {
    const token = wx.getStorageSync(app.config.tokenKey);
    if (token) {
      buyClass()
    } else {
      this.logInFun(() => {})
    }
    const buyClass = async () => {
      const cloundMenu = this.data.resourceCodeList.find((item) => item.refCode == 'jsek_cloudLearning')
      let query = {
@@ -1954,6 +1991,13 @@
        });
      }
    }
    const token = wx.getStorageSync(app.config.tokenKey);
    if (token) {
      buyClass()
    } else {
      this.logInFun(() => {})
    }
  },
  // 变为所有check   true
  findAndUpdateItemsByIds(tree, ids) {
@@ -2096,12 +2140,6 @@
  },
  // 购买组卷
  buyMock() {
    const token = wx.getStorageSync(app.config.tokenKey);
    if (token) {
      buyMockFun()
    } else {
      this.logInFun(() => {})
    }
    const buyMockFun = async () => {
      let res;
      if (!this.data.mockData.id)
@@ -2150,6 +2188,13 @@
        console.log(error);
      }
    }
    const token = wx.getStorageSync(app.config.tokenKey);
    if (token) {
      buyMockFun()
    } else {
      this.logInFun(() => {})
    }
  },
  // 记录购买组卷时间
  recordBuyMock() {
@@ -2251,12 +2296,6 @@
  },
  // 底部购买按钮
  buyBtn() {
    const token = wx.getStorageSync(app.config.tokenKey);
    if (token) {
      buyFun()
    } else {
      this.logInFun(() => {})
    }
    const buyFun = () => {
      if (this.data.tabValue == "brief" && !this.data.bookBuy) {
        this.buyBook();
@@ -2267,6 +2306,13 @@
        console.log(this.data.tabValue);
      }
    }
    const token = wx.getStorageSync(app.config.tokenKey);
    if (token) {
      buyFun()
    } else {
      this.logInFun(() => {})
    }
  },
  goRead(e) {
@@ -2421,12 +2467,6 @@
  //申请电子样书
  appplyElectronicBook() {
    const token = wx.getStorageSync(app.config.tokenKey);
    if (token) {
      applyFun()
    } else {
      this.logInFun(() => {})
    }
    const applyFun = () => {
      // 先判断下教师认证,未对原有逻辑修改
      let role = this.data.userInfo != null ? this.data.userInfo.role : null;
@@ -2534,15 +2574,16 @@
        });
      }
    }
  },
  //申请纸质样书
  appplyPaperBook() {
    const token = wx.getStorageSync(app.config.tokenKey);
    if (token) {
      applyFun()
    } else {
      this.logInFun(() => {})
    }
  },
  //申请纸质样书
  appplyPaperBook() {
    const applyFun = () => {
      let role = this.data.userInfo != null ? this.data.userInfo.role : null;
      if (role && role == "Teacher") {} else {
@@ -2630,6 +2671,13 @@
        });
      }
    }
    const token = wx.getStorageSync(app.config.tokenKey);
    if (token) {
      applyFun()
    } else {
      this.logInFun(() => {})
    }
  },
  //  添加样书
  addBookFun(item, type) {
@@ -2673,9 +2721,14 @@
  //去样书申请单
  goApply() {
    wx.navigateTo({
      url: "/packageDomain/pages/sampleBookList/applicationForm/index",
    });
    const token = wx.getStorageSync(app.config.tokenKey);
    if (token) {
      wx.navigateTo({
        url: "/packageDomain/pages/sampleBookList/applicationForm/index",
      });
    } else {
      this.logInFun(() => {})
    }
  },
  handleTree() {
    // const child = this.selectComponent('#teach-tree')
@@ -2756,14 +2809,6 @@
    return childrenList
  },
  uploadFile(e) {
    const token = wx.getStorageSync(app.config.tokenKey);
    if (token) {
      uploadFun()
    } else {
      this.logInFun(() => {
        uploadFun()
      })
    }
    const uploadFun = () => {
      const userInfo = JSON.parse(wx.getStorageSync(app.config.userInfoKey))
      if (userInfo.role != 'Teacher') return wx.showToast({
@@ -2775,6 +2820,15 @@
        isShowUp: true
      });
    }
    const token = wx.getStorageSync(app.config.tokenKey);
    if (token) {
      uploadFun()
    } else {
      this.logInFun(() => {
        uploadFun()
      })
    }
  },
  closeDialog() {
    this.setData({