闫增涛
2024-03-28 0b523220931d70aa752c3beaca5ed32ca85511c5
packageBookService/pages/bookServices/detail/index.js
@@ -44,7 +44,10 @@
    shoppingList: [],
    loading: false,
    isShowTeachDownload: false,  // 提示PC下载弹窗状态
    confirmBtn: { content: '我知道了', variant: 'base' },
    confirmBtn: {
      content: '我知道了',
      variant: 'base'
    },
    mockData: {
      id: 0, // 销售id
      price: 0, // 售价
@@ -157,6 +160,20 @@
        userInfo: JSON.parse(wx.getStorageSync(app.config.userInfoKey))
      })
    }
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {
  },
  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {
    if (wx.getStorageSync("paperBookList")) {
      this.setData({
        paperBookList: wx.getStorageSync("paperBookList"),
@@ -171,18 +188,6 @@
      num: this.data.paperBookList.length + this.data.electronicBookList.length
    })
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {
  },
  /**
   * 生命周期函数--监听页面显示
   */
  onShow() { },
  /**
   * 生命周期函数--监听页面隐藏
@@ -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: [
            {
          requests: [{
              saleMethodId: this.data.selectedIds,
              storeEventId: null,
              agentCode: '电子书'
            }
          ]
          }]
        }
        const addRes = app.MG.store.addShoppingCart(query)
        this.showSuccessToast()
@@ -814,8 +819,8 @@
        Toast({
          context: this,
          selector: '#t-toast',
          message: '已添加',
          theme: 'success',
          message: '该书已在购物车,请勿重复添加',
          theme: 'warning',
          direction: 'column',
        });
      }
@@ -846,12 +851,10 @@
      let bookOrdersId = ''
      let query = {
        remarks: '电子书',
        requests: [
          {
        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([
        {
      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: [
          {
        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,19 +1431,22 @@
    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: [
        {
      setKeyRequests: [{
          domain: 'mockData',
          key: this.data.bookDetail.id + '',
          value: JSON.stringify(this.data.mockData.mockList)
        }
      ]
      }]
    })
  },
  // 底部购买按钮
@@ -1450,14 +1454,14 @@
    if (this.data.tabValue == 'brief' && !this.data.bookBuy) {
      this.buyBook()
    }
    else if (this.data.tabValue == 'jsek_cloudLearning') {
      const tree = this.selectComponent('#tree')
      tree.onCloudShoppingCart()
    } else if (this.data.tabValue == 'questionBank') {
      this.buyMock()
    } else {
      console.log(this.data.tabValue);
    }
    // else if (this.data.tabValue == 'jsek_cloudLearning') {
    //   const tree = this.selectComponent('#tree')
    //   tree.onCloudShoppingCart()
    // } else if (this.data.tabValue == 'questionBank') {
    //   this.buyMock()
    // } else {
    //   console.log(this.data.tabValue);
    // }
  },
  goRead() {
@@ -1502,8 +1506,7 @@
                wx.navigateTo({
                  url: "/packageDomain/pages/teacherCertification/index",
                });
              } else if (res.cancel) {
              }
              } else if (res.cancel) {}
            }
          })
        }
@@ -1532,8 +1535,7 @@
                wx.navigateTo({
                  url: "/packageDomain/pages/teacherCertification/index",
                });
              } else if (res.cancel) {
              }
              } else if (res.cancel) {}
            }
          })
        }