TM
2020-12-14 49d49b9d5f3cc27c7ded14c87f042fedc767fe03
更新代码
3 files modified
54 ■■■■■ changed files
pages/hbfqPage/qrCode/qrCode.js 20 ●●●●● patch | view | raw | blame | history
pages/shskPage/qrCode/qrCode.js 30 ●●●● patch | view | raw | blame | history
utils/ajaxFn.js 4 ●●●● patch | view | raw | blame | history
pages/hbfqPage/qrCode/qrCode.js
@@ -1,9 +1,9 @@
const QRCode = require('qrcode');
const app = getApp();
let $api = require('../../../utils/ajaxFn.js')
var timer;
Page({
  data: {
    timer:'',
    userStyle: {},
    imgSrc: '',
    rateList: [
@@ -32,7 +32,6 @@
        //根据字符串生成svn格式的二维码
        QRCode.toString(res.data.body.payQrCodeUrl, { type: 'svg' }, function (err, url) {
          let str = 'data:image/svg+xml;base64,' + Buffer(url).toString('base64');
          console.log(str)
          self.setData({
            imgSrc: str,
            orderId:res.data.body.orderId,
@@ -43,9 +42,11 @@
              { name: '客户还款总额', rate: res.data.body.repayAmt },
              { name: '客户月还款额', rate: res.data.body.monthAmt },
              { name: '还款期数', rate: res.data.body.term + '期' }
            ],
            timer:setInterval(this.getStatus(),5000)
            ]
          })
          timer = setInterval(()=>{
            self.getStatus()
          },5000)
        });
      },
@@ -63,7 +64,7 @@
      (res)=>{
        let body = res.data.body.orderStatus
        if(body==1){
          clearInterval(this.data.timer)
          clearInterval(timer)
          my.showToast({
            type: 'none',
            content: '支付成功',
@@ -76,7 +77,7 @@
          })
        }
        if(body==2){
          clearInterval(this.data.timer)
          clearInterval(timer)
          my.showToast({
            type: 'none',
            content: '支付超时',
@@ -97,5 +98,10 @@
        orderId:this.data.orderId
      }
    )
  }
  },
  onUnload() {
    // 页面隐藏
    console.log(111)
    clearInterval(timer)
  },
});
pages/shskPage/qrCode/qrCode.js
@@ -1,6 +1,7 @@
let $api = require('../../../utils/ajaxFn.js')
const QRCode = require('qrcode');
const app = getApp();
var timer ;
Page({
  data: {
    userStyle:{},
@@ -19,30 +20,24 @@
  },
  getCode() {
    let self = this;
    // QRCode.toString('https://qr.alipay.com/bax09171hgnaiptzucxe8034',{type: 'svg'}, function (err, url) {
    //   let str = 'data:image/svg+xml;base64,' + Buffer(url).toString('base64');
    //   console.log(str);
    //   self.setData({
    //     imgSrc: str
    //   })
    //  });
    $api.ajax(
      '/sib/xcx/order/createDmf',
      'POST',
      (res) => {
        let myurl = String(res.data.body.payQrCodeUrl)
        //根据字符串生成svn格式的二维码
        QRCode.toString(res.data.body.payQrCodeUrl, {type: 'svg'}, function (err, url) {
        QRCode.toString(myurl, {type: 'svg'}, function (err, url) {
          let str = 'data:image/svg+xml;base64,' + Buffer(url).toString('base64');
          console.log(str)
          self.setData({
            imgSrc: str,
            orderId:res.data.body.orderId,
            rateList: [
              { name: '支付费率', rate: res.data.body.payRate + '%' }
            ],
            timer:setInterval(this.getStatus(),5000)
            ]
          })
          timer = setInterval(()=>{
            self.getStatus()
          },5000)
        });
      },
@@ -60,7 +55,7 @@
      (res)=>{
        let body = res.data.body.orderStatus
        if(body==1){
          clearInterval(this.data.timer)
          clearInterval(timer)
          my.showToast({
            type: 'none',
            content: '支付成功',
@@ -73,7 +68,7 @@
          })
        }
        if(body==2){
          clearInterval(this.data.timer)
          clearInterval(timer)
          my.showToast({
            type: 'none',
            content: '支付超时',
@@ -94,5 +89,10 @@
        orderId:this.data.orderId
      }
    )
  }
  },
  onUnload() {
    // 页面隐藏
    console.log(111)
    clearInterval(timer)
  },
});
utils/ajaxFn.js
@@ -19,9 +19,9 @@
    str = str + data[key]
  }
  var params = {...data}
  console.log(needLogin)
  // console.log(needLogin)
  if(needLogin){
    console.log('验签字符串',str+my.getStorageSync ({ key: 'sessionId' }).data.sessionId)
    // console.log('验签字符串',str+my.getStorageSync ({ key: 'sessionId' }).data.sessionId)
    let sessionId = my.getStorageSync ({ key: 'sessionId' }).data.sessionId
    // params.sessionId = sessionId
    params.jttechSign = md5.hex_md5(str+sessionId)