二维码生成

This commit is contained in:
结发受长生
2018-07-03 13:23:15 +08:00
parent fc48469f69
commit 6b57563306
13 changed files with 42 additions and 27 deletions
+11 -2
View File
@@ -1,5 +1,6 @@
import addClass from 'dom101/add-class'
import removeClass from 'dom101/remove-class'
import QRious from 'qrious'
function generate(url, opts) {
var url = url.replace(/<%-sUrl%>/g, encodeURIComponent(opts.sUrl))
@@ -10,9 +11,17 @@ function generate(url, opts) {
window.open(url);
}
var qrcodeInit = false
function showWX() {
let $wx = document.querySelector('.js-wx-box')
let $mask = document.querySelector('.mask')
if(!qrcodeInit) {
new QRious({
element: document.querySelector('.qrcode-canvas'),
value: location.href
});
qrcodeInit = true
}
addClass($wx, 'in')
addClass($wx, 'ready')
addClass($mask, 'in')
@@ -68,8 +77,8 @@ let init = function() {
})
}
})
document.querySelector('.mask').onclick = hideWX
document.querySelector('.js-modal-close').onclick = hideWX
document.querySelector('.mask').addEventListener('click', hideWX)
document.querySelector('.js-modal-close').addEventListener('click', hideWX)
}
export default { init }