小程序 获取指定人的二维码

当用户扫描二维码时获得二维码里面带的scene信息:

// 这是首页的 js
Page({
  onLoad: function(options) {
    // options 中的 scene 需要使用 decodeURIComponent 才能获取到生成二维码时传入的 scene
    var scene = decodeURIComponent(options.scene)
  }
})

获得二维码:

var _this = this
    wx.request({
      url: 'https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token=12_jDsjnmlZIdwYCDUAvskZGLdpdLULFPPO515L4-8iRsyt2WgHh6_-hZwD4o3fNuFo8hr6kfXjgHul9DZOybrJT84PED44TQDnedsYn-E9meH_qtKpr5D57Vb3xqtfxSCTbRa5ZkytcT__J1u4FATgABAQLE',
      data: {
        scene: '1231313142342342',
        page: 'pages/index/index',
        width: 500,
        auto_color: false,
        line_color: { "r": "0", "g": "0", "b": "0" },
        is_hyaline: false
      },
      method: 'POST',
      header: {
        'content-type': 'application/json'
      },
      success: function (res) {
        _this.setData({urls: res.data})
        console.log(res.data)
      }
    })

猜你喜欢

转载自www.cnblogs.com/yzyh/p/9504804.html