Пример #1
0
        public ActionResult OnGetUserInfo(string sessionId)
        {
            StatusReport sr = new StatusReport();

            if (string.IsNullOrEmpty(sessionId))//如果sessionId为空,则返回错误信息
            {
                sr.status     = "Fail";
                sr.result     = "sessionId不存在";
                sr.parameters = sessionId;
                return(Json(sr));
            }
            SessionBag sessionBag = null;

            sessionBag = SessionContainer.GetSession(sessionId);
            if (sessionBag == null)
            {
                sr.status = "Fail";
                sr.result = "session已失效";
                return(Json(sr));
            }
            string openId = sessionBag.OpenId;

            sr = EmployeeDal.CheckOpenIdExist(openId);
            //if (sr.data != null)
            //{
            //    var o = JsonConvert.DeserializeObject(sr.data);
            //    return Json(new { status = "Success", result = "成功", data = o });
            //}
            //else
            //{
            return(Json(sr));
            //}
        }
Пример #2
0
        public ActionResult OnGetUserInfoTest(string openid)
        {
            StatusReport sr = new StatusReport();

            sr = EmployeeDal.CheckOpenIdExist(openid);
            return(Json(sr));
        }
Пример #3
0
        public ActionResult OnLogin(string code)
        {
            JsCode2JsonResult jsonResult = SnsApi.JsCode2Json(Comman.Appid, Comman.AppSecret, code);

            if (jsonResult.errcode == Senparc.Weixin.ReturnCode.请求成功)
            {
                SessionBag sessionBag = SessionContainer.UpdateSession(null, jsonResult.openid, jsonResult.session_key);
                Session[sessionBag.Key] = jsonResult;
                Session.Timeout         = 60;
                StatusReport sr = EmployeeDal.CheckOpenIdExist(jsonResult.openid);
                return(Json(new { success = true, msg = "OK", sessionId = sessionBag.Key, userInfo = sr }));
            }
            else
            {
                return(Json(new { success = false, mag = jsonResult.errmsg, result = jsonResult }));
            }
        }