转【微信小程序 四】二维码生成/扫描二维码
生活随笔
收集整理的這篇文章主要介紹了
转【微信小程序 四】二维码生成/扫描二维码
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
原文:https://blog.csdn.net/xbw12138/article/details/75213274
前端?
二維碼生成?
二維碼要求:每分鐘刷新一次,模擬了個(gè)雞肋,添加了個(gè)按分鐘顯示的時(shí)間加在二維碼中,起到刷新的作用,在onshow中每次打開界面就會(huì)刷新顯示
掃描二維碼
recognizeCode: function () {this.setData({isShowMsg: true, isShowResult: false, recognizeMsg: "", }) var that = this //小程序API wx.scanCode({ //掃描條形碼ISBN success: function (res) { // success console.log('https://book.douban.com/subject/' + res.result+'/'); var url = 'https://book.douban.com/subject/' + res.result + '/'; wx.navigateTo({ url: '../desc/desc?url=' + url }) }, fail: function () { // fail }, complete: function () { // complete } }) },utils.js中添加以下代碼
function formatTimeQrcodeChange(date) {var year = date.getFullYear() var month = date.getMonth() + 1 var day = date.getDate() var hour = date.getHours() var minute = date.getMinutes() //按分鐘顯示,去掉秒 //var second = date.getSeconds() return [year, month, day].map(formatNumber).join('/') + ' ' + [hour, minute].map(formatNumber).join(':') }qrcode.js
var QR = (function () {// alignment pattern var adelta = [ 0, 11, 15, 19, 23, 27, 31, 16, 18, 20, 22, 24, 26, 28, 20, 22, 24, 24, 26, 28, 28, 22, 24, 24, 26, 26, 28, 28, 24, 24, 26, 26, 26, 28, 28, 24, 26, 26, 26, 28, 28 ]; // version block var vpat = [ 0xc94, 0x5bc, 0xa99, 0x4d3, 0xbf6, 0x762, 0x847, 0x60d, 0x928, 0xb78, 0x45d, 0xa17, 0x532, 0x9a6, 0x683, 0x8c9, 0x7ec, 0xec4, 0x1e1, 0xfab, 0x08e, 0xc1a, 0x33f, 0xd75, 0x250, 0x9d5, 0x6f0, 0x8ba, 0x79f, 0xb0b, 0x42e, 0xa64, 0x541, 0xc69 ]; // final format bits with mask: level << 3 | mask var fmtword = [ 0x77c4, 0x72f3, 0x7daa, 0x789d, 0x662f, 0x6318, 0x6c41, 0x6976, //L 0x5412, 0x5125, 0x5e7c, 0x5b4b, 0x45f9, 0x40ce, 0x4f97, 0x4aa0, //M 0x355f, 0x3068, 0x3f31, 0x3a06, 0x24b4, 0x2183, 0x2eda, 0x2bed, //Q 0x1689, 0x13be, 0x1ce7, 0x19d0, 0x0762, 0x0255, 0x0d0c, 0x083b //H ]; // 4 per version: number of blocks 1,2; data width; ecc width var eccblocks = [ 1, 0, 19, 7, 1, 0, 16, 10, 1, 0, 13, 13, 1, 0, 9, 17, 1, 0, 34, 10, 1, 0, 28, 16, 1, 0, 22, 22, 1, 0, 16, 28, 1, 0, 55, 15, 1, 0, 44, 26, 2, 0, 17, 18, 2, 0, 13, 22, 1, 0, 80, 20, 2, 0, 32, 18, 2, 0, 24, 26, 4, 0, 9, 16, 1, 0, 108, 26, 2, 0, 43, 24, 2, 2, 15, 18, 2, 2, 11, 22, 2, 0, 68, 18, 4, 0, 27, 16, 4, 0, 19, 24, 4, 0, 15, 28, 2, 0, 78, 20, 4, 0, 31, 18, 2, 4, 14, 18, 4, 1, 13, 26, 2, 0, 97, 24, 2, 2, 38, 22, 4,總結(jié)
以上是生活随笔為你收集整理的转【微信小程序 四】二维码生成/扫描二维码的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: FC及BFC
- 下一篇: GET和POST两种基本请求方法的区别(