using System; using System.Collections.Generic; using System.Windows.Forms; using System.Web.Script.Serialization; namespace 成套报价软件 { /// 会员信息对话框:按手机号查会员服务,展示会员类型/有效期。 public partial class 会员信息 : Form { public 会员信息() { InitializeComponent(); this.BackColor = System.Drawing.Color.White; this.Load += 会员信息_Load; } private void 会员信息_Load(object sender, EventArgs e) { try { if (!会员服务Host.EnsureRunning()) { MessageBox.Show(this, "会员服务启动失败,请联系技术支持。", "会员信息", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } string q = "?手机号=" + Uri.EscapeDataString(txt手机号码.Text.Trim()); var resp = new JavaScriptSerializer() .Deserialize>(会员服务Host.Get("/api/member" + q)); bool ok = resp.ContainsKey("ok") && Convert.ToBoolean(resp["ok"]); if (ok) { txt会员类型.Text = resp.ContainsKey("会员类型") ? Convert.ToString(resp["会员类型"]) : ""; txt有效期.Text = resp.ContainsKey("有效期") ? Convert.ToString(resp["有效期"]) : ""; } else { txt会员类型.Text = ""; txt有效期.Text = ""; MessageBox.Show(this, resp.ContainsKey("msg") ? Convert.ToString(resp["msg"]) : "查询失败", "会员信息", MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch (Exception ex) { MessageBox.Show(this, "查询异常: " + ex.Message, "会员信息", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } }