通过数据流处理-微信小程序生成临时二维码
Posted 专业.net码农
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了通过数据流处理-微信小程序生成临时二维码相关的知识,希望对你有一定的参考价值。
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>
以上是关于通过数据流处理-微信小程序生成临时二维码的主要内容,如果未能解决你的问题,请参考以下文章