111
QYF-GitLab1
2025-01-03 2ee8ddb1ecac7df4198e54e08ec7f22daf4b07c0
packageBookService/pages/bookServices/detail/index.js
@@ -7,6 +7,7 @@
} from "../../../../assets/js/login";
import FormData from '../../../../utils/formdata/index.js';
const app = getApp();
var pastData = require('../../psychologyAnswer/testdata/index')
Page({
  /**
   * 页面的初始数据
@@ -74,7 +75,8 @@
      residue: 0, // 组卷剩余次数
      mockList: [], // 用户组卷提交信息
    },
    isBuyBank: false,
    isBuyBank: false, // 题库是否购买
    isShoppingBank: false, // 题库是否加入购物车
    bankSaleData: null,
    relatedBookLoading: false,
    noRelatedBookData: false,
@@ -212,7 +214,8 @@
    protocolShow: false,
    protocolTxt: '',
    learnMenu: null,
    md5List: []
    md5List: [],
    editDialog: false
  },
  resetTree: function (e) {
@@ -269,8 +272,6 @@
      this.setData({
        tabValue: options.tabValue,
      });
    }
  },
@@ -291,7 +292,7 @@
    this.setData({
      num: Number(this.data.paperBookList.length) + Number(this.data.electronicBookList.length),
    });
    if (this.data.bookDetail) {
    if (this.data.bookDetail.id) {
      this.getBookInfo(this.data.bookDetail.id)
    }
  },
@@ -431,10 +432,14 @@
        protectedEpub: [],
        probationPage: [], //pdf试读页数
        freeEpubPage: [], //epub试读百分比
        bookEditor: [], //图书编辑
        contactInformation: [], //联系方式
      },
    };
    app.MG.store.getProductDetail(query).then(async (res) => {
      this.getResourceCode(id, res.datas.rootCmsItemId)
      res.datas.bookEditor = res.datas.bookEditor ? res.datas.bookEditor : '-'
      res.datas.contactInformation = res.datas.contactInformation ? res.datas.contactInformation : '-'
      this.setData({
        bookDetail: res.datas,
        buyIdList: res.datas.purchasedSaleMethodIdList,
@@ -468,6 +473,16 @@
          }
          await this.getBookClass(classData);
        }
      }
      // 扫码从题库跳转回图书详情
      const localData = wx.getStorageSync('tabValue')
      if (localData) {
        this.setData({
          tabValue: localData
        })
        wx.removeStorage({
          key: 'tabValue',
        })
      }
      if (this.data.tabValue == 'questionBank' || this.data.tabValue == 'jsek_cloudLearning' || this.data.tabValue == 'jsek_teachingResources') {
        const checkData = this.data.cmsDatas.find(
@@ -506,13 +521,12 @@
        }
      }
      this.setData({
        "bookDetail.publicationDate": moment(this.data.bookDetail.publicationDate).format("YYYY年MM月"),
        "bookDetail.publicationDate": this.data.bookDetail.publicationDate ? moment(this.data.bookDetail.publicationDate).format("YYYY年MM月") : '',
        "bookDetail.price": this.numFormat(this.data.bookDetail.price),
        "bookDetail.oldPrice": this.numFormat(this.data.bookDetail.oldPrice),
        "bookDetail.paperPrice": this.numFormat(
          this.data.bookDetail.paperPrice
        ),
      });
    });
  },
@@ -531,8 +545,8 @@
      }
    }
    app.MG.store.getProductDetail(query).then((res) => {
      console.log(111, res.datas.cmsDatas[0].datas);
      let isBuyBank = true
      let isShoppingBank = true
      let bankSaleData = null
      // 判断题库是否整体购买
      const bank = res.datas.cmsDatas[0].datas.find((item) => item.refCode == 'questionBank')
@@ -541,6 +555,7 @@
          bankSaleData = bank.saleMethod.find((item) => item.SaleType == 'Normal')
          if (bankSaleData) {
            isBuyBank = this.data.buyIdList.includes(bankSaleData.Id)
            isShoppingBank = this.data.buyIdList.includes(bankSaleData.Id) ? true : this.data.shoppingCartGetId.includes(bankSaleData.Id)
          }
        }
      }
@@ -548,6 +563,7 @@
        resourceCodeList: res.datas.cmsDatas[0].datas,
        learnTaskData: res.datas.cmsDatas[0].datas.filter((item) => item.refCode == 'jsek_learningTasks')[0],
        isBuyBank,
        isShoppingBank,
        bankSaleData
      })
      if (res.datas.cmsDatas[0].datas.length) this.setData({
@@ -743,6 +759,14 @@
      }
    }
  },
  // 联系
  editPhone() {
    this.setData({
      editDialog: true
    })
  },
  // 我要建议
  suggestBtn() {
    // 检查登录状态
@@ -1162,17 +1186,22 @@
            }
          } else {
            if (isTSFW.length > 0) {
              data = res.datas.cmsDatas[0].datas.filter((item) => item.type == 'questionBankFolder' && item.childrenFolderCount > 0)
              data = res.datas.cmsDatas[0].datas.filter((item) => item.type == 'questionBankFolder' && item.refCode != 'jsek_interaction' && (item.childrenFolderCount > 0 || item.childrenCount > 0) && (item.name !== '填空题' &&
                item.name !== '判断题' &&
                item.name !== '多选题' &&
                item.name !== '简答题') && item.name !== '单选题')
              that.setData({
                jslx: false,
              });
            } else {
              data = res.datas.cmsDatas[0].datas.filter((item) => item.type == 'questionBankFolder')
              // && item.refCode != 'jsek_interaction'
              that.setData({
                jslx: true,
              });
            }
            if (data.length > 0) {
              console.log('data', data);
              let list = []
              that.getTreeList(data, list, query.cmsPath)
              list = that.ensureTreeConsistency(list)
@@ -1182,6 +1211,20 @@
                loading: false,
                openTeachids: result,
              });
              //Json赋值
              // const bookId = that.data.bookId
              // if (bookId == 6619) {
              //   const jsonData = {}
              //   jsonData.name = "心理测评"
              //   jsonData.children = [...pastData.postData.list]
              //   var test = that.data.test;
              //   test.push(jsonData);
              //   that.setData({
              //     test: test,
              //   });
              //   console.log(that.data.test, "教学互动");
              // }
            } else {
              that.setData({
                noResources: true,
@@ -1878,7 +1921,6 @@
  // 云学习全部购买
  async buyCloudLearnClass() {
    const cloundMenu = this.data.resourceCodeList.find((item) => item.refCode == 'jsek_cloudLearning')
    debugger
    let query = {
      remarks: '云学习',
      requests: [{
@@ -1930,7 +1972,6 @@
  // 题库购买
  async buyBank() {
    console.log(11, this.data.bankSaleData);
    let query = {
      remarks: '云测试',
      requests: [{
@@ -1963,6 +2004,24 @@
        });
    }
  },
  // 题库加入购物车
  handleShoppingBank() {
    let query = {
      requests: [{
        saleMethodId: this.data.bankSaleData.Id,
        storeEventId: null,
        agentCode: "云测试",
      }, ],
    };
    app.MG.store.addShoppingCart(query).then(res => {
      wx.showToast({
        icon: 'success',
        title: '加入成功',
      })
      this.getShoppingCartProductGet();
      this.getBookInfo(this.data.bookDetail.id)
    })
  },
  // 组卷格式化日期显示
  DateFormat(date, fmt) {
    if (date && fmt) {