首页 > 微信 > 详细

通过数据流处理-微信小程序生成临时二维码

时间:2017-10-10 18:23:15      阅读:1145      评论:0      收藏:0      [点我收藏+]

标签:ant   eat   index   ppi   fun   ppm   nload   his   gif   

1.小程序代码

onLoad: function (options) {
    var that = this
    api.Login(function (login) {
      var codeModel = new function () { }
      codeModel.scene = login.UserId
      codeModel.width=430
      codeModel.auto_color = false
      codeModel.line_color = { "r": "0", "g": "0", "b": "0" }
      console.log(‘----‘)

      api.RequestApiURL("WeixinAPI/CreateMyCode", { data: JSON.stringify(codeModel)}, function (e) {
        console.log(e)
        wx.hideLoading()
        console.log(e.data.data)
        that.setData({
          imgurl: e.data.data
        })
      })
    })
  }

  2.后台代码

 public string CreateMyCode(string data)
        {
            string gettokenurl = string.Format("https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid={0}&secret={1}", "appid", "AppSecret");
            string access_token = GetWebRequest(gettokenurl);
            if (access_token.IndexOf("access_token") > 0)
            {
                access_token = access_token.Substring(access_token.IndexOf(":") + 2,
                    access_token.IndexOf(",") - access_token.IndexOf(":") - 3);
            }
            string url = string.Format("http://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token={0}", access_token);
            var io = PostMoths(url, data);
            byte[] by = StreamToBytes(io);

            var rs = new ReturnResult<byte[]>(by);
            return rs.Serialize();
        }

  3.前台显示

  <view class="weui-media-box__hd_in-appmsg">
          <image class="weui-media-box__thumb" src="data:image/jpeg;base64,{{imgurl}}" />
        </view>

 

通过数据流处理-微信小程序生成临时二维码

标签:ant   eat   index   ppi   fun   ppm   nload   his   gif   

原文:http://www.cnblogs.com/wangbin0582/p/7647012.html

(0)
(0)
   
举报
评论 一句话评论(0
0条  
登录后才能评论!
© 2014 bubuko.com 版权所有 鲁ICP备09046678号-4
打开技术之扣,分享程序人生!
             

鲁公网安备 37021202000002号