出入码支持支付宝小程序
This commit is contained in:
parent
47cb9a730b
commit
070cb9a997
@ -98,7 +98,7 @@ export default {
|
||||
},
|
||||
methods: {
|
||||
drawCode(text = 'https://www.baidu.com/', foreground = 'red') {
|
||||
const query = wx.createSelectorQuery()
|
||||
const query = Taro.createSelectorQuery()
|
||||
query.select('#myQrcode')
|
||||
.fields({
|
||||
node: true,
|
||||
@ -108,7 +108,7 @@ export default {
|
||||
var canvas = res[0].node
|
||||
|
||||
// 调用方法drawQrcode生成二维码
|
||||
drawQrcode({
|
||||
drawQrcode(Taro, {
|
||||
canvas: canvas,
|
||||
canvasId: 'myQrcode',
|
||||
width: 260,
|
||||
|
@ -25,7 +25,7 @@ function utf16to8(str) {
|
||||
return out
|
||||
}
|
||||
|
||||
function drawQrcode(options, debug) {
|
||||
function drawQrcode(Taro, options, debug) {
|
||||
options = options || {}
|
||||
options = extend(true, {
|
||||
canvasId: 'myQrcode',
|
||||
@ -66,18 +66,18 @@ function drawQrcode(options, debug) {
|
||||
} else {
|
||||
|
||||
return new Promise(function (resolve, reject) {
|
||||
return resolve(createCanvas());
|
||||
return resolve(createCanvas(Taro));
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
function createCanvas() {
|
||||
function createCanvas(Taro) {
|
||||
// create the qrcode itself
|
||||
var qrcode = new QRCode(options.typeNumber, options.correctLevel)
|
||||
qrcode.addData(utf16to8(options.text))
|
||||
qrcode.make()
|
||||
|
||||
const dpr = wx ? wx.getSystemInfoSync().pixelRatio : 1 // 兼容支付宝小程序
|
||||
const dpr = Taro.getSystemInfoSync().pixelRatio
|
||||
var canvas = options.canvas
|
||||
const ctx = canvas.getContext('2d')
|
||||
canvas.width = options.width * dpr
|
||||
|
Loading…
x
Reference in New Issue
Block a user