64 lines
2.2 KiB
C#
64 lines
2.2 KiB
C#
|
|
using System;
|
|||
|
|
using System.Collections.Generic;
|
|||
|
|
using System.Linq;
|
|||
|
|
using System.Web;
|
|||
|
|
using System.Web.Services;
|
|||
|
|
using System.Web.UI;
|
|||
|
|
using System.Web.UI.WebControls;
|
|||
|
|
|
|||
|
|
public partial class SystemManage_openid2 : System.Web.UI.Page
|
|||
|
|
{
|
|||
|
|
public string qrurl = "";
|
|||
|
|
public string headimgurl = "";
|
|||
|
|
public string nickname = "";
|
|||
|
|
protected void Page_Load(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
if (!Page.IsPostBack)
|
|||
|
|
{
|
|||
|
|
string id = Request.QueryString["ID"];
|
|||
|
|
if (string.IsNullOrEmpty(id))
|
|||
|
|
id = ZWL.Common.PublicMethod.GetSessionValue("UserID");
|
|||
|
|
if (id == "NoLogin")
|
|||
|
|
{
|
|||
|
|
Response.Write("请先登录");
|
|||
|
|
Response.End();
|
|||
|
|
}
|
|||
|
|
string url = "https://api.weixin.qq.com/cgi-bin/qrcode/create?access_token=" + globle.Global.getAccessToken.access_token;
|
|||
|
|
|
|||
|
|
var wc = new System.Net.WebClient();
|
|||
|
|
string res = wc.UploadString(url, "{\"expire_seconds\": 120, \"action_name\": \"QR_SCENE\", \"action_info\": {\"scene\": {\"scene_id\": " + id + "}}}");
|
|||
|
|
|
|||
|
|
var qr = Newtonsoft.Json.JsonConvert.DeserializeObject<wxQR_SCENE>(res);
|
|||
|
|
if (qr == null || qr.ticket == null || qr.ticket == "")
|
|||
|
|
{
|
|||
|
|
Response.Write("获取参数二维码失败:" + res);
|
|||
|
|
Response.End();
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
qrurl = "https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=" + qr.ticket;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
ZWL.BLL.ERPUser bll = new ZWL.BLL.ERPUser();
|
|||
|
|
string openid = bll.Getopenid(id);
|
|||
|
|
if (!string.IsNullOrEmpty(openid))
|
|||
|
|
{
|
|||
|
|
string userinfo = bll.GetUserinfo(openid);
|
|||
|
|
string[] userinfos = userinfo.Split(new string[] { "|||||" }, StringSplitOptions.RemoveEmptyEntries);
|
|||
|
|
if (userinfos.Length == 2)
|
|||
|
|
{
|
|||
|
|
headimgurl = userinfos[0];
|
|||
|
|
nickname = userinfos[1];
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private class wxQR_SCENE
|
|||
|
|
{
|
|||
|
|
public string ticket { get; set; }
|
|||
|
|
public int expire_seconds { get; set; }
|
|||
|
|
public string url { get; set; }
|
|||
|
|
}
|
|||
|
|
}
|