1.页面代码
<view class=‘bd-qrcode’>
<image src="{{qrcodeUrl}}" class=‘bd-qrcode-image’></image>
</view>
<view class=“weui-cells__title bd-textinfo”>推荐人({{userInfo.UserDetails.UserName}})</view>
<view class=“weui-panel”>
<view class=“weui-panel__hd bd-textinfo”>微信扫码,即可参与蜂蚂分享经济</view>
<view class=“weui-panel__bd”>
<view class=“weui-media-box weui-media-box_text”>
<view class=“weui-media-box__title weui-media-box__title_in-text”>规则</view>
<view class=“weui-media-box__desc”>目前只支持扫码识别推荐好友</view>
<view class=“weui-media-box__info”>
<view class=“weui-media-box__info__meta”>共享资源</view>
<view class=“weui-media-box__info__meta weui-media-box__info__meta_extra”>合作共赢</view>
<view class=“weui-media-box__info__meta weui-media-box__info__meta_extra”>合作简单</view>
<view class=“weui-media-box__info__meta weui-media-box__info__meta_extra”>自动赚钱</view>
</view>
<view class=“weui-media-box__info”>
<view class="weui-media-box__info__meta ">可分享蜂蚂平台去中心化利润的0-50%奖励</view>
</view>
</view>
</view>
</view>
2.生成带参数小程序二维码:
var parameters = {
scene: “pageurl=qrcode&userid=” +that.data.userInfo.AutoId,
page: “pages/index/index”,
width: 430
}
wx.request({
url: getApp().globalData.api + ‘/api/WeChat/GetQrCodeImage’,
data: JSON.stringify(parameters),
method: ‘PUT’,
responseType: ‘arraybuffer’,
success: function(res) {
console.log(res);
let data = wx.arrayBufferToBase64(res.data);
that.setData({
qrcodeUrl: ‘data:image/jpeg;base64,’ + data
})
}
})
}
});
3.获取二维码代码
var scene = decodeURIComponent (options.scene);
console.log("The from qrcode and share info is " + scene);
//var scene = “pageurl=qrcode&userid=4”
var url = scene.split("&")[0].split("=")[1]
var id = scene.split(’&’)[1].split("=")[1];
if (url == “qrcode”) {
that.setData({
pageUrl: “store”,
isLoad: true,
userId: id
});
}
已经解决此问题,能获取到我的二维码参数,就是一开始调试非常不方便,跑到正式版去了
//来自二维码和分享页面
if (options.scene) {
var scene = decodeURIComponent (options.scene);
console.log("The from qrcode and share info is " + scene);
//var scene = “pageurl=qrcode&userid=4”
var url = scene.split("&")[0].split("=")[1]
var id = scene.split(’&’)[1].split("=")[1];
if (url == “qrcode”) {
that.setData({
pageUrl: “store”,
isLoad: true,
userId: id
});
}
}
想要什么二维码,哪个页面的,都可以用草料授权一下自己生成。https://cli.im/mina/home。测试扫码效果用这个:
。如果你是扫码的:方形二维码,需要对得到的连接进行解析转码。圆形的小程序码的话:直接拿对应字段的值就行了,不用转码。