微信小程序帶參數生成二維碼


wx.request({
            url: 'https://api.weixin.qq.com/cgi-bin/token',
            header: { 'content-type': 'application/json' },
            data: {
                grant_type: 'client_credential',
                appid:'appid
                secret: '秘鑰'
            },
            success(res) {
                accessToken = res.data.access_token
                wx.request({
                    //url: 'https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token='+accessToken,
                    url: 'https://api.weixin.qq.com/wxa/getwxacode?access_token='+accessToken,
                    method: 'POST',
                    responseType: 'arraybuffer',
                    data: {
                        "path": '掃碼跳轉的路徑',
                        "width": 430,   
                    },
                    success(res) {
                        console.log(res.data)
                        let base64 = wx.arrayBufferToBase64(res.data)
                        console.log(base64)
                        let codeImg= 'data:image/PNG;base64,' + base64

                        console.log(codeImg)
                        _this.sdd = codeImg
                    },
                })
            }
        })

來個大佬鏈接:

https://juejin.im/post/5b9b8772e51d450e9162a271


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM