BondingAccount.aspx.cs 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Web.UI;
  6. using System.Web.UI.WebControls;
  7. namespace LYFZ.WeixinServers.WeiXinAPP
  8. {
  9. public partial class BondingAccount : System.Web.UI.Page
  10. {
  11. public string openid = "";
  12. public string cusid = "";
  13. public string appid = "";
  14. public string jsInfo = "";
  15. protected void Page_Load(object sender, EventArgs e)
  16. {
  17. if(!IsPostBack)
  18. {
  19. cusid = Request.QueryString["cusid"];
  20. openid = Request.QueryString["openid"];
  21. appid = Request.QueryString["appid"];
  22. }
  23. else
  24. {
  25. cusid = Request["cusid"];
  26. openid = Request["openid"];
  27. appid = Request["appid"];
  28. }
  29. }
  30. public void WriteLog(HttpContext context, string content, string filename = "")
  31. {
  32. if (string.IsNullOrEmpty(filename))
  33. {
  34. filename = DateTime.Now.ToString("yyyyMMddHHmmssffff");
  35. }
  36. string dirPath = context.Server.MapPath("/") + "/WeiXinDir/";
  37. if (!System.IO.Directory.Exists(dirPath))
  38. {
  39. System.IO.Directory.CreateDirectory(dirPath);
  40. }
  41. System.IO.File.AppendAllText(dirPath + "/" + filename + ".txt", content + "\r\n");
  42. }
  43. protected void Button1_Click(object sender, EventArgs e)
  44. {
  45. LYFZ.WeixinServiceDate.Model.Model_CustomerInterfaces cusModel = Global.GetCustomerModelById(Request.Form["cusid"]);
  46. string openid = Request.Form["openid"];
  47. string telephone = Request.Form["mobilenumber"];
  48. string ordernumber = Request.Form["ordernumber"];
  49. string appid = Request.Form["appid"];
  50. string paramStr = "openid=" + openid + "&telePhone=" + telephone + "&orderFourNumber=" + ordernumber + "&appid=" + appid;
  51. string getText = LYFZ.WinAPI.HttpClientHelper.GetResponse(cusModel.GetRequestUrl()
  52. + "/api/WXApi.ashx/BindWXCustomerAccount?" + paramStr);
  53. Newtonsoft.Json.Linq.JObject jobject = (Newtonsoft.Json.Linq.JObject)Newtonsoft.Json.JsonConvert.DeserializeObject(getText);
  54. if (jobject.GetValue("code").ToString().Equals("200"))
  55. {
  56. Response.Redirect("BindOK.html");
  57. }
  58. else
  59. {
  60. jsInfo = "<script>alert('" + jobject.GetValue("info").ToString() + "-" + jobject.GetValue("data").ToString() + "')</script>";
  61. }
  62. // WriteLog(HttpContext.Current, getText);
  63. }
  64. }
  65. }