asp.net做微信端的开发,调用扫一扫接口扫除的字符串如何传到后端的解密函数进行解密,再将结果返回到前端
前端代码:
wx.ready(function () {
wx.scanQRCode({
needResult: 0, // 默认为0,扫描结果由微信处理,1则直接返回扫描结果,
scanType: ["qrCode", "barCode"], // 可以指定扫二维码还是一维码,默认二者都有
success: function (res) {
result = res.resultStr; // 当needResult 为 1 时,扫码返回的结果
if (typeof (result) != "undefined") {
alert("扫码成功!");// 扫描后的值
result = res.resultStr
$.ajax({
type: "POST",
cache: false,
url: "qzsm.aspx/getPrintData", //页面名/要调用的后台方法名
data: {'weixin':result}, //json格式的字符串将参数传入后台,参数名必须一致
contentType: "application/json;charset=utf-8",
dataType: "json",
success: function (result) {
if (result.d[0] == "0") {
alert("扫码失败!");
}
else {
getDoc(result.d[1]);
}
},
error: function (err) {
alert("获取打印数据失败!");
}
});
}
}
});
});
wx.error(function (res) {
// config信息验证失败执行的函数
});
}
后端接收参数的函数
public static List<String> getPrintData(String weixin)
{
string sData = "";
sData = DeCode(weixin);
List<String> str = new List<String>();
if (sData == "")
{
str.Add("0");
}
else
{
str.Add("1");
str.Add(sData);
}
return str;
}
//后端解密函数
private static string DeCode(string strSrc)
{
}