From 49d49b9d5f3cc27c7ded14c87f042fedc767fe03 Mon Sep 17 00:00:00 2001 From: TM <923727421@qq.com> Date: Mon, 14 Dec 2020 15:04:47 +0800 Subject: [PATCH] 更新代码 --- pages/shskPage/qrCode/qrCode.js | 30 +++++++++++++++--------------- 1 files changed, 15 insertions(+), 15 deletions(-) diff --git a/pages/shskPage/qrCode/qrCode.js b/pages/shskPage/qrCode/qrCode.js index 957177b..fced48f 100644 --- a/pages/shskPage/qrCode/qrCode.js +++ b/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) + }, }); -- Gitblit v1.8.0