Share distal applet implementation generates two-dimensional code (not need to be configured with parameters) (Reference rear end)

    Before and after the applet parameters can generate two-dimensional code terminal can be achieved, but it is better to be generated by the rear end of the front side of the pass is the method I introduces the tip of the tip of the generated carry parameters scene have normal length limit sharing demand can be achieved, official documents have described.

    First of all it is necessary to obtain the access_token parameter back-end development of small procedures, the same front-end interfaces also be obtained by requesting official, has made token is very simple, direct calls to the official interface to obtain two-dimensional code small program with parameters ( Note that the return of As the front-end format is the format will deal with the problem if it is, then the back-end database can be stored directly ) front-end and convert image formats to undertake display pictures   

To test a small application developers have authority inside

Get access_token

/ ** * Gets access_token * * @paramappid * @paramappsecret * @ return * /

Official documents  get access_token

wx.request({

      url: 'https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=wx9743427e009a5d0&secret=decff2504655b08ec20260e3699039c',

      method: 'get',

      success: function (res) {

        console.log(res)

      }

    })

Get applet access_token get two-dimensional code (the original data is binary image) is provided to return the format of the request method arraybuffer 

Official documents  to obtain two-dimensional code applet

let data = {

      scene: '123456', the parameter to be passed

      page: 'pages / hotinfo / hotinfo', scan code into the applet pages

    }

wx.request({

      url: 'https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token=31_92uKEw2joJRdBP75gViNwBwZu-LGZ4-99EwkjpOy-iT3yW4B4Q7e_iscapbVQ3uIBoJXdo5sv0IJVyz8e6XfxAZHAbmmSFi8W1Fhu-OTSNJBQ57_h0aOlfjUIxChman-gaxZy_XOQVgdwpJ8DTRaAFAJZX',

      method: 'post',

      date: date,

      // dataType: 'json',

      responseType: 'arraybuffer',          // returns the data by parsing the text modify arraybuffer

      success: function (res) {

        console.log()

        self.setData({

           // display pictures again arraybuffer into base64

          url: 'data:image/png;base64,'+wx.arrayBufferToBase64(res.data)

        })

      }

    })

Guess you like

Origin www.cnblogs.com/wukongz/p/12580880.html