YM
3 天以前 b5bf6a8ff37d5c363a68697ac8cab88ff21b1614
packageBookService/pages/psychologyAnswer/psychologyAnswer.js
@@ -39,20 +39,57 @@
   */
  onLoad(options) {
    // 在此进行是否购买的查询
    const questionId = options.listId;
    const bookId = options.bookId
    const bookName = options.bookName
    const formPath = options.formPath
    const query = {
      "cmsItemId": Number(questionId)
    };
    app.MG.file.checkCmsItem(query)
      .then((res) => {
        const isBuys = res;
    const questionName = options.listName
    this.setData({
      questuionName: questionName
    });
    const isEmption = questionName.includes('-评审')
    if (isEmption) {
      this.initialize()
    } else {
      const questionList = pastData.postData.list
      var listIndex = 0
      for (let index = 0; index < questionList.length; index++) {
        const item = questionList[index];
        if (item.name == questionName) {
          listIndex = index
        }
      }
      const indexof = listIndex
      const idPath = questionList[indexof].idPath;
      const bookId = questionList[indexof].bookId;
      const bookName = "大学生心理健康(第3版)(融媒体版)"
      const formPath = "questionBank"
      // 进行处理
      const query = {
        path: "*",
        queryType: "*",
        productId: bookId,
        cmsPath: "161796",
        cmsType: "*"
      };
      app.MG.store.getProductDetail(query).then(async (res) => {
        const linkPathList = res.datas.cmsDatas[0].datas
        const isBuyList = res.datas.purchasedSaleMethodIdList
        let isBuy = false
        const idParhList = idPath.split("/").reverse()
        for (let index = 0; index < idParhList.length; index++) {
          const item = idParhList[index];
          const thisItem = linkPathList.find(citem => item == citem.id);
          if (thisItem.saleMethod.length > 0) {
            if (isBuyList.includes(thisItem.saleMethod[0].Id) || thisItem.saleMethod[0].Price == 0) {
              isBuy = true
              break
            } else {
              isBuy = false
              break
            }
          }
        }
        this.setData({
          isBuy: isBuys
          isBuy: isBuy
        });
        if (!isBuys) {
        if (!isBuy) {
          wx.showModal({
            icon: 'error',
            title: '温馨提示',
@@ -69,38 +106,16 @@
          });
          return; // 直接返回,避免执行后续代码
        }
        // 其他逻辑
        const questuionName = options.listName;
        this.setData({
          questionName: questuionName
        });
        const systInfo = wx.getSystemInfoSync();
        const menu = wx.getMenuButtonBoundingClientRect(); // 胶囊信息
        const navBarHeight =
          (menu.top - systInfo.statusBarHeight) * 2 + menu.height; // 导航栏高度
        const token = wx.getStorageSync(app.config.tokenKey);
        if (!token) {
          loginInfo(app, (data) => {
            if (data) {
              this.init();
            } else {
              this.init();
            }
          });
        } else {
          this.init();
        }
      })
      .catch((err) => {
        this.initialize()
      }).catch((err) => {
        console.error('检查题库失败:', err);
        wx.showToast({
          icon: 'error',
          title: '加载失败,请重试'
        });
      });
    }
  },
@@ -131,7 +146,7 @@
        }
      }, 1000);
    }
    this.setData({
      startTime: Date.now(),
    });
@@ -153,6 +168,7 @@
    }
  },
  /**
   * 生命周期函数--监听页面卸载
   */
@@ -172,6 +188,25 @@
    }
  },
  initialize() {
    const systInfo = wx.getSystemInfoSync();
    const menu = wx.getMenuButtonBoundingClientRect(); // 胶囊信息
    const navBarHeight =
      (menu.top - systInfo.statusBarHeight) * 2 + menu.height; // 导航栏高度
    const token = wx.getStorageSync(app.config.tokenKey);
    if (!token) {
      loginInfo(app, (data) => {
        if (data) {
          this.init();
        } else {
          this.init();
        }
      });
    } else {
      this.init();
    }
  },
  count(timeStr) {
    const data = {
      appRefCode: app.config.appRefCode,