微信小程序> 小程序怎么弄成二维码-微信小程序-生成二维码-小程序二维码

小程序怎么弄成二维码-微信小程序-生成二维码-小程序二维码

浏览量:1689 时间: 来源:L林蛋大

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自己加,其余都不用更改

版权声明

即速应用倡导尊重与保护知识产权。如发现本站文章存在版权问题,烦请提供版权疑问、身份证明、版权证明、联系方式等发邮件至197452366@qq.com ,我们将及时处理。本站文章仅作分享交流用途,作者观点不等同于即速应用观点。用户与作者的任何交易与本站无关,请知悉。

产品经理

手机 : 13312967497

擅长 : 小程序流量变现

扫码领取礼包

最新资讯

热门模板

  • 头条
  • 搜狐
  • 微博
  • 百家
  • 一点资讯
  • 知乎