小程序怎么弄成二维码-微信小程序-生成二维码-小程序二维码
1.varapp=getApp();//在page外面定义app
2.ycq:function(){//我的二维码生成
3.varthat=this;
4.wx.request({
5.url:app.getRequestUrl+'/notify_url/QRCode',//官方接口,不用更改;app.getRequestUrl为app.js里面的http路径,需后台提供
6.data:{
7.Appid:app.globalData.appId,
8.Secret:app.globalData.secret,
9.page:'pages/index/index',//扫码进入的页面,填写你小程序的页面
10.scene:app.globalData.openId+','+app.globalData.vid,//你跳传的页面需要什么参数就填什么参数
11.width:'430',
12.},
13.method:'POST',
14.responseType:'text',
15.success:function(res){
16.varImgUrl=app.ImgUrl+res.data.ImgUrl//app.ImgUrl为app.js里面的http地址,需要后台提供
17.wx.downloadFile({
18.url:ImgUrl,
19.success:function(res){
20.console.log(res)
21.if(res.statusCode==200){
22.wx.hideLoading();
23.that.setData({
24.cordimg:res.tempFilePath,
25.})
26.}
27.},
28.fail:function(res){
29.console.log(res)
30.}
31.})
32.},
33.})
34.},
35.//长按保存二维码bindlongpress="SaveImage"
36.SaveImage:function(e){
37.wx.saveImageToPhotosAlbum({
38.filePath:this.data.cordimg,
39.success:function(res){
40.wx.showToast({
41.title:'已保存',
42.icon:'success',
43.duration:2000
44.})
45.},
46.})
47.},
48.ps:基本有备注的地方需要注意还有稍微的修改,事件在wxml自己加,其余都不用更改
TAG标签: 微信小程序小程序怎么弄成二维码小程序二维码
声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。

