litian
2024-03-27 ccf200b60ad213343a13d36c17c5ee5ac5cd7b7a
packageBookService/pages/bookServices/detail/index.js
@@ -34,17 +34,20 @@
    openTeachids: [],
    openLearnids: [],
    openTestids: [],
    applyResourceState: false,  // 申请教学资源按钮防抖
    applyResourceState: false, // 申请教学资源按钮防抖
    resourceClassList: [], // 资源所属分类
    applyState: "",  // 教学资源申请状态
    deadline: "",  // 教学资源申请有效日期
    rejectCause: "",  // 下载拒绝原因
    applyState: "", // 教学资源申请状态
    deadline: "", // 教学资源申请有效日期
    rejectCause: "", // 下载拒绝原因
    buyIdList: [],
    shoppingCartGetId: [], // 已购买id列表
    shoppingList: [],
    loading: false,
    isShowTeachDownload: false,  // 提示PC下载弹窗状态
    confirmBtn: { content: '我知道了', variant: 'base' },
    isShowTeachDownload: false, // 提示PC下载弹窗状态
    confirmBtn: {
      content: '我知道了',
      variant: 'base'
    },
    mockData: {
      id: 0, // 销售id
      price: 0, // 售价
@@ -55,9 +58,9 @@
    },
    flag: true,
    noResources: false,
    selectedIds: "",//商品或子商品销售方式
    selectedIds: "", //商品或子商品销售方式
    bookBuy: false, //商品或子商品是否购买
    expire: false,//商品或子商品销售方式是否过期
    expire: false, //商品或子商品销售方式是否过期
    noFile: false, //商品或子商有无电子书文件
    num: 0, //样书申请单数量
    alreadyPaperBookList: [], //已申请纸质样书
@@ -72,7 +75,7 @@
      fileType: "",
      md5: "",
      freePage: ""
    },  //阅读器数据
    }, //阅读器数据
    buyResourceData: {
      productLinkPath: '',
      refCode: '',
@@ -157,6 +160,20 @@
        userInfo: JSON.parse(wx.getStorageSync(app.config.userInfoKey))
      })
    }
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {
  },
  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {
    if (wx.getStorageSync("paperBookList")) {
      this.setData({
        paperBookList: wx.getStorageSync("paperBookList"),
@@ -173,26 +190,14 @@
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {
  },
  /**
   * 生命周期函数--监听页面显示
   */
  onShow() { },
  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() { },
  onHide() {},
  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() { },
  onUnload() {},
  /**
   * 页面相关事件处理函数--监听用户下拉动作
@@ -215,7 +220,7 @@
  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() { },
  onShareAppMessage() {},
  // 格式化日期
  formatDate(dateString) {
    if (!dateString) {
@@ -522,7 +527,9 @@
  },
  // 跳转网店
  goShop(e) {
    const { link } = e.currentTarget.dataset;
    const {
      link
    } = e.currentTarget.dataset;
    wx.navigateTo({
      url: `/packageBookService/pages/bookServices/webpage/index?url=${link}`,
    })
@@ -541,9 +548,9 @@
            'buyResourceData.refCode': checkData.refCode
          })
        }
        if ((e.detail.value == 'jsek_teachingResources' && !this.data.teach.length)
          || (e.detail.value == 'jsek_cloudLearning' && !this.data.learn.length)
          || (e.detail.value == 'questionBank' && !this.data.test.length)) {
        if ((e.detail.value == 'jsek_teachingResources' && !this.data.teach.length) ||
          (e.detail.value == 'jsek_cloudLearning' && !this.data.learn.length) ||
          (e.detail.value == 'questionBank' && !this.data.test.length)) {
          this.getResourceData(checkData)
        }
      } else {
@@ -799,13 +806,11 @@
      console.log(determine);
      if (!determine) {
        let query = {
          requests: [
            {
              saleMethodId: this.data.selectedIds,
              storeEventId: null,
              agentCode: '电子书'
            }
          ]
          requests: [{
            saleMethodId: this.data.selectedIds,
            storeEventId: null,
            agentCode: '电子书'
          }]
        }
        const addRes = app.MG.store.addShoppingCart(query)
        this.showSuccessToast()
@@ -846,12 +851,10 @@
      let bookOrdersId = ''
      let query = {
        remarks: '电子书',
        requests: [
          {
            saleMethodId: this.data.bookItemDetail.defaultSaleMethodId ? this.data.bookItemDetail.defaultSaleMethodId : this.data.bookDetail.defaultSaleMethodId,
            count: 1
          }
        ]
        requests: [{
          saleMethodId: this.data.bookItemDetail.defaultSaleMethodId ? this.data.bookItemDetail.defaultSaleMethodId : this.data.bookDetail.defaultSaleMethodId,
          count: 1
        }]
      }
      // 发起订单初始化请求并等待结果
      const res = await app.MG.store.initOrder(query)
@@ -975,14 +978,12 @@
      cmsTypeRefCode: '',
      newDataListRequest: [],
      name: this.data.bookDetail.name, // name为申请的书本名称
      content: JSON.stringify([
        {
          name: this.data.bookDetail.name,
          id: this.data.bookDetail.id,
          // defaultSaleMethodId: bookData.value.defaultSaleMethodId,
          icon: this.data.bookDetail.icon
        }
      ])
      content: JSON.stringify([{
        name: this.data.bookDetail.name,
        id: this.data.bookDetail.id,
        // defaultSaleMethodId: bookData.value.defaultSaleMethodId,
        icon: this.data.bookDetail.icon
      }])
    }
    app.MG.ugc.newTopicMessage(query).then(async (res) => {
      if (res) {
@@ -1333,9 +1334,9 @@
        if (new RegExp('(' + k + ')').test(fmt)) {
          fmt = fmt.replace(
            RegExp.$1,
            RegExp.$1.length == 1
              ? (o)[k]
              : ('00' + (o)[k]).substr(('' + (o)[k]).length)
            RegExp.$1.length == 1 ?
            (o)[k] :
            ('00' + (o)[k]).substr(('' + (o)[k]).length)
          )
        }
      }
@@ -1388,12 +1389,10 @@
    try {
      let query = {
        remarks: '组卷',
        requests: [
          {
            saleMethodId: this.data.mockData.id,
            count: 1
          }
        ]
        requests: [{
          saleMethodId: this.data.mockData.id,
          count: 1
        }]
      }
      if (this.data.flag) {
        this.setData({
@@ -1408,7 +1407,9 @@
      } else {
        // 0元直接领取
        // 确认订单
        const confirmOrderRes = await app.MG.store.confirmOrder({ orderNum: res.orderNumber })
        const confirmOrderRes = await app.MG.store.confirmOrder({
          orderNum: res.orderNumber
        })
        if (confirmOrderRes) {
          wx.showToast({
            icon: "success",
@@ -1430,27 +1431,29 @@
    const id = tool.uuid(8)
    const createDate = this.DateFormat(new Date().getTime(), 'yyyy-MM-dd')
    const mockList = this.data.mockData.mockList
    mockList.push({ id, createDate, name: `第${num + 1}套试卷`, state: '0' })
    mockList.push({
      id,
      createDate,
      name: `第${num + 1}套试卷`,
      state: '0'
    })
    this.setData({
      'mockData.mockList': mockList
    })
    // 记录购买时间,并设状态state为1,表示刚购买完成组卷
    app.MG.identity.setUserKey({
      setKeyRequests: [
        {
          domain: 'mockData',
          key: this.data.bookDetail.id + '',
          value: JSON.stringify(this.data.mockData.mockList)
        }
      ]
      setKeyRequests: [{
        domain: 'mockData',
        key: this.data.bookDetail.id + '',
        value: JSON.stringify(this.data.mockData.mockList)
      }]
    })
  },
  // 底部购买按钮
  buyBtn() {
    if (this.data.tabValue == 'brief' && !this.data.bookBuy) {
      this.buyBook()
    }
    else if (this.data.tabValue == 'jsek_cloudLearning') {
    } else if (this.data.tabValue == 'jsek_cloudLearning') {
      const tree = this.selectComponent('#tree')
      tree.onCloudShoppingCart()
    } else if (this.data.tabValue == 'questionBank') {
@@ -1502,8 +1505,7 @@
                wx.navigateTo({
                  url: "/packageDomain/pages/teacherCertification/index",
                });
              } else if (res.cancel) {
              }
              } else if (res.cancel) {}
            }
          })
        }
@@ -1532,8 +1534,7 @@
                wx.navigateTo({
                  url: "/packageDomain/pages/teacherCertification/index",
                });
              } else if (res.cancel) {
              }
              } else if (res.cancel) {}
            }
          })
        }
@@ -1787,4 +1788,4 @@
      teach: tree
    })
  },
})
})