zf
litian
2024-09-27 3ec10b0c2654e1243e42a5ad563d088ac89c87fe
pages/cart/paymentPage/index.js
@@ -28,7 +28,6 @@
    isPayComplete: false,
    type: '',
    onNorderSaleMethod: '',
    ImmediatelyReceive: '',
    integral: 0,
    defaultVal: false,
    deductioRate: 0,
@@ -54,7 +53,6 @@
      selectedIds: options.selectedIds,
      onNorderSaleMethod: options.onNorderSaleMethod
    })
    console.log(this.data.onNorderSaleMethod, 'options');
    this.getIntegral()
    this.getOrderByOrderNumData()
    this.getDataList()
@@ -144,7 +142,6 @@
    return intPartFormat + floatPart;
  },
  getOrderByOrderNumData() {
    console.log(this.data.orderNumber, 'this.data.orderNumber');
    let query = {
      orderNum: this.data.orderNumber,
      fields: {
@@ -154,21 +151,17 @@
    }
    app.MG.store.getOrderByOrderNum(query).then(res => {
      this.setData({
        orderGoods: res.orderNumber
      })
      this.setData({
        price: res.payPrice.toFixed(2),
        orderGoods: res.orderNumber,
        price: res.totalPrice.toFixed(2),
        payPrice: res.payPrice.toFixed(2),
        ImmediatelyReceive: res.payPrice
      })
      console.log(1, res.saleMethodLinks);
      if (Number(this.data.payPrice) < Number(this.data.price)) {
        this.handleChange()
      }
      res.saleMethodLinks.forEach(item => {
        const type = item.orderSaleMethod.type == 'createProductItemSaleMethod' ? 'item' : 'product';
        item.type = type; // 将type设置为item对象的属性,而不是使用setData
        item.paymentIcon = getPublicImage(item.orderSaleMethod.product.icon)
        item.payPrice = this.numFormat(item.payPrice)
        item.orderSaleMethod.price = this.numFormat(item.orderSaleMethod.price)
        //
        if (item.orderSaleMethod.product.cmsTypeRefCode == 'jsek_digitalTextbooks') {
          item.typeTxt = '数字教材'
          item.productType = "数字教材"
@@ -190,7 +183,6 @@
        loading: false,
        hidden: false,
      })
    })
  },
  getDataList() {
@@ -207,21 +199,25 @@
      }
    }
    app.MG.store.getUserOrderList(data).then((res) => {
      res.datas.forEach((item) => {
        this.data.myOrderOrderNumber.push(item.saleMethodLinks[0].orderSaleMethod.id)
        console.log(this.data.myOrderOrderNumber);
      })
    })
  },
  handleChange(e) {
    this.setData({
      defaultVal: e.detail.value,
    });
    console.log(this.data.defaultVal)
    if (e) {
      this.setData({
        defaultVal: e.detail.value,
      });
    } else {
      this.setData({
        defaultVal: true,
      });
    }
    if (this.data.defaultVal) {
      let useBalance = Math.floor(this.data.payPrice * this.data.deductioRate);
      let useBalance = Math.round(Number(this.data.payPrice) * Number(this.data.deductioRate));
      if (useBalance >= this.data.integral) {
        this.setData({
          currentBalance: this.data.integral,
@@ -246,7 +242,6 @@
            integral: this.data.integral - this.data.currentBalance,
            showIntegral: true
          });
          console.log(this.data.price, this.data.payPrice, 123)
        }
      })
    } else {
@@ -255,7 +250,6 @@
        payId: this.data.payId,
      }
      app.MG.store.delOrderPay(data).then(res => {
        console.log(res, "取消用积分")
        if (res) {
          this.setData({
            payPrice: res.payPrice.toFixed(2),
@@ -283,19 +277,15 @@
        orderNum: this.data.orderGoods
      }
      app.MG.store.confirmOrder(query).then(res => {
        console.log(res.orderNumber, 'res');
        if (res.orderNumber) {
          let resOrderNum = {
            orderNum: res.orderNumber,
            platform: "WeChatAppCustom"
          };
          console.log(resOrderNum, 'resOrderNum');
          // 用户未绑定微信 报500
          app.MG.store.makeWeChatPay(resOrderNum).then(payRes => {
            console.log(payRes, 'payRes');
            if (payRes) {
              const payVal = JSON.parse(payRes);
              console.log(payVal);
              wx.requestPayment({
                "appId": payVal.appId,
                "timeStamp": payVal.timeStamp,
@@ -304,7 +294,6 @@
                "signType": payVal.signType,
                "paySign": payVal.paySign,
                success: function (res) {
                  console.log('支付成功');
                  if (res.errMsg == 'requestPayment:ok') {
                    that.setData({
                      isPaySuccess: true