Beispiel #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            LogHelper.Info(this.GetType().ToString(), "page load");
            if (!IsPostBack)
            {
                JsApiPay jsApiPay = new JsApiPay(this);
                try
                {
                    //调用【网页授权获取用户信息】接口获取用户的openid和access_token
                    jsApiPay.GetOpenidAndAccessToken();

                    //获取收货地址js函数入口参数
                    wxEditAddrParam     = jsApiPay.GetEditAddressParameters();
                    ViewState["openid"] = jsApiPay.openid;
                }
                catch (Exception ex)
                {
                    Response.Write("<span style='color:#FF0000;font-size:20px'>" + "页面加载出错,请重试" + "</span>");
                    Button1.Visible = false;
                    Button2.Visible = false;
                    Label1.Visible  = false;
                    Label2.Visible  = false;
                }
            }
        }
Beispiel #2
0
        public ActionResult <string> GetAddress(string accesstoken)
        {
            JsApiPay jsApiPay = new JsApiPay(_httpContext);

            try
            {
                //获取收货地址js函数入口参数
                return(jsApiPay.GetEditAddressParameters(accesstoken));
            }
            catch (Exception ex)
            {
                return(ex.Message);
            }
        }
Beispiel #3
0
        // GET: /WeChat/WeChatPay/ProductPage
        public ActionResult ProductPage(string total_fee = "1")
        {
            var      wxEditAddrParam = "";
            var      openid          = "";
            JsApiPay jsApiPay        = new JsApiPay(HttpContext);

            try
            {
                //调用【网页授权获取用户信息】接口获取用户的openid和access_token
                jsApiPay.GetOpenidAndAccessToken();
                //获取收货地址js函数入口参数
                wxEditAddrParam = jsApiPay.GetEditAddressParameters();
                openid          = jsApiPay.openid;
            }
            catch (Exception ex)
            {
                Response.Write("<span style='color:#FF0000;font-size:20px'>" + "页面加载出错,请重试" + "</span>" + ex.Message + "<hr/>" + ex.InnerException + "<hr/>" + ex.StackTrace);
            }

            return(View(ProductPage_M.Init(wxEditAddrParam, openid, total_fee)));
        }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            JsApiPay jsApiPay = new JsApiPay(this);
            try
            {
                //调用【网页授权获取用户信息】接口获取用户的openid和access_token
                jsApiPay.GetOpenidAndAccessToken();

                //获取收货地址js函数入口参数
                wxEditAddrParam     = jsApiPay.GetEditAddressParameters();
                ViewState["openid"] = jsApiPay.openid;
                openid = jsApiPay.openid;
                HttpContext.Current.Response.Cookies.Add(new HttpCookie("openid", openid)
                {
                    HttpOnly = true
                });
                using (var db = new DBConnection())
                {
                    //Response.Write("<span style='color:#FF0000;font-size:20px'>" + "您的id为" + HttpContext.Current.Request.Cookies["userid"].Value + ",微信标识为:" + openid + "</span>");
                    DataTable        dt  = db.GetEmptyDataTable("tb_b_user");
                    DataTableTracker dtt = new DataTableTracker(dt);
                    DataRow          dr  = dt.NewRow();
                    dr["UserID"] = HttpContext.Current.Request.Cookies["userid"].Value;
                    dr["OpenID"] = openid;
                    dt.Rows.Add(dr);
                    db.UpdateTable(dt, dtt);
                }
            }
            catch (Exception ex)
            {
                Response.Write("<span style='color:#FF0000;font-size:20px'>" + "页面加载出错,请重试</span>");
            }
        }
    }