public JsonResult GetUserRoomInfo(int browserUserId, int loginUserId) { var url = WebConfig.BaseAddress + "User/GetUserRoomInfo?browserUserId=" + browserUserId + "&loginUserId=" + loginUserId; string strData = WebApiHelper.InvokeApi <string>(url); var result = (!string.IsNullOrEmpty(strData) && !strData.StartsWith("null")) ? strData.JsonToEntity <Result>() : null; if (result != null && result.Data != null) { dynamic userView = (dynamic)result.Data; userView.Picture = GlobalMemberInfo.GetQiniuUserPicture((int)userView.Id); } return(Json(result, JsonRequestBehavior.AllowGet)); }
/// <summary> /// 保存用户选择的系统预定义头像 /// Author : AxOne /// </summary> /// <param name="key">qiniu key/系统图片路径</param> /// <returns></returns> public JsonResult UpdateUserPic(string key) { if (string.IsNullOrWhiteSpace(key)) { return(Json(new { Success = false }, JsonRequestBehavior.AllowGet)); } var result = UpdateUserPicApi(key); if (result == null || result.Data == null || !result.Success) { return(Json(new { Success = false }, JsonRequestBehavior.AllowGet)); } result.Data.Picture = GlobalMemberInfo.GetQiniuUserPicture(result.Data.Id); GlobalMemberInfo.SetUserCookie(result.Data, GlobalMemberInfo.RemberMe); return(Json(new { Success = true }, JsonRequestBehavior.AllowGet)); }
/// <summary> /// 第三方注册并绑定 /// </summary> /// <param name="tpaccount">账户</param> /// <param name="tppwd">密码</param> /// <param name="tptypeCode">第三方类型编码</param> /// <param name="tprelatedId">第三方唯一身份标识</param> /// <param name="nickName">昵称</param> /// <param name="figureURL">头像路径</param> /// <param name="type">手机、邮箱类型</param> /// <returns></returns> public JsonResult ThirdPartyBindAndRegister(string tpaccount, string tppwd, string tptypeCode, string tprelatedId, string tpnickName, string tpfigureURL, int type = 0) { if (string.IsNullOrWhiteSpace(tpaccount) || string.IsNullOrWhiteSpace(tppwd) || string.IsNullOrWhiteSpace(tptypeCode) || string.IsNullOrWhiteSpace(tprelatedId)) { return(Json(new { Success = false, Message = LanguageUtil.Translate("web_Controllers_Regist_ThirdPartyBindAndRegister_messageone") }, JsonRequestBehavior.AllowGet)); } var result = ThirdPartyBindAndRegisterAPI(tpaccount, tppwd, tptypeCode, tprelatedId, tpnickName, tpfigureURL, type); if (result == null || result.Data == null || result.Data.Id <= 0 || !result.Success) { return(Json(new { Success = false, Message = LanguageUtil.Translate("web_Controllers_Regist_ThirdPartyBindAndRegister_messagetwo") }, JsonRequestBehavior.AllowGet)); } result.Data.Picture = GlobalMemberInfo.GetQiniuUserPicture(result.Data.Id); GlobalMemberInfo.SetUserCookie(result.Data); return(Json(new { Success = true, result.Data })); }
/// <summary> /// 用户注册 /// </summary> /// <param name="raccount">帐号/手机号码</param> /// <param name="rpwd">密码</param> /// <param name="type">账户类型(0:手机1:邮箱)</param> /// <returns></returns> public JsonResult UserRegist(string raccount, string rpwd, int type = 0) { if (string.IsNullOrWhiteSpace(raccount) || string.IsNullOrWhiteSpace(rpwd)) { return(Json(new { Success = false }, JsonRequestBehavior.AllowGet)); } var result = RegistApi(raccount, rpwd, type); if (result == null || result.Data == null || result.Data.Id <= 0 || !result.Success) { return(Json(new { Success = false }, JsonRequestBehavior.AllowGet)); } result.Data.Picture = GlobalMemberInfo.GetQiniuUserPicture(result.Data.Id); GlobalMemberInfo.SetUserCookie(result.Data, 1); return(Json(new { Success = true, result.Data })); }
/// <summary> /// 第三方自动注册并绑定 /// </summary> /// <param name="typeCode">第三方类型编码</param> /// <param name="relatedId">第三方唯一身份标识</param> /// <param name="nickName">昵称</param> /// <param name="figureURL">头像路径</param> /// <returns></returns> public JsonResult AutoRegisterAndBindThirdParty(string typeCode, string relatedId, string nickName, string figureURL) { if (string.IsNullOrWhiteSpace(typeCode) || string.IsNullOrWhiteSpace(relatedId)) { return(Json(new { Success = false, Message = LanguageUtil.Translate("web_Controllers_Regist_AutoRegisterAndBindThirdParty_messageone") }, JsonRequestBehavior.AllowGet)); } var result = AutoRegisterAndBindThirdPartyAPI(typeCode, relatedId, nickName, figureURL); if (result == null || result.Data == null || result.Data.Id <= 0 || !result.Success) { return(Json(new { Success = false, Message = LanguageUtil.Translate("web_Controllers_Regist_AutoRegisterAndBindThirdParty_messagetwo") }, JsonRequestBehavior.AllowGet)); } result.Data.Picture = GlobalMemberInfo.GetQiniuUserPicture(result.Data.Id); GlobalMemberInfo.SetUserCookie(result.Data); return(Json(new { Success = true, result.Data })); }
/// <summary> /// 登录 /// Author : AxOne /// </summary> /// <param name="account">用户名/手机号</param> /// <param name="pwd">密码</param> /// <param name="remb">是否记住(0:不记住1:记住)</param> /// <param name="type">账户类型(0:手机1:邮箱)</param> /// <returns></returns> public JsonResult UserLogin(string account, string pwd, int remb = 0) { if (string.IsNullOrWhiteSpace(account) || string.IsNullOrWhiteSpace(pwd)) { return(Json(new { Success = false }, JsonRequestBehavior.AllowGet)); } var result = LoginApi(account, pwd); if (result == null || result.Data == null || !result.Success || result.Data.Id <= 0) { return(Json(new { Success = false }, JsonRequestBehavior.AllowGet)); } result.Data.Picture = GlobalMemberInfo.GetQiniuUserPicture(result.Data.Id); GlobalMemberInfo.SetUserCookie(result.Data, remb); return(Json(new { Success = true, result.Data, remb })); }
/// <summary> /// 登录SSO /// </summary> /// <param name="userId">用户ID</param> /// <returns></returns> public JsonResult UserLoginById(int userId) { if (userId <= 0) { return(Json(new { Success = false }, JsonRequestBehavior.AllowGet)); } var result = LoginApi(userId); if (result == null || result.Data == null || !result.Success || result.Data.Id <= 0) { return(Json(new { Success = false }, JsonRequestBehavior.AllowGet)); } result.Data.Picture = GlobalMemberInfo.GetQiniuUserPicture(result.Data.Id); GlobalMemberInfo.SetUserCookie(result.Data); return(Json(new { Success = true, result.Data })); }
/// <summary> /// 绑定已有帐号并登录 /// </summary> /// <param name="account">帐号</param> /// <param name="pwd">密码</param> /// <param name="typeCode">第三方类型</param> /// <param name="relatedId">第三方唯一标识</param> /// <param name="nickName">昵称</param> /// <param name="figureURL">头像路径</param> /// <returns></returns> public JsonResult ThirdPartyBindAndLogin(string account, string pwd, string typeCode, string relatedId, string nickName, string figureURL) { if (string.IsNullOrWhiteSpace(account) || string.IsNullOrWhiteSpace(pwd) || string.IsNullOrWhiteSpace(typeCode) || string.IsNullOrWhiteSpace(relatedId)) { return(Json(new { Success = false, Message = LanguageUtil.Translate("web_Controllers_Login_ThirdPartyBindAndLogin_messageone") }, JsonRequestBehavior.AllowGet)); } var result = ThirdPartyBindAndLoginAPI(account, pwd, typeCode, relatedId, nickName, figureURL); if (result == null || result.Data == null || !result.Success || result.Data.Id <= 0) { return(Json(new { Success = false, Message = LanguageUtil.Translate("web_Controllers_Login_ThirdPartyBindAndLogin_messagetwo") }, JsonRequestBehavior.AllowGet)); } result.Data.Picture = GlobalMemberInfo.GetQiniuUserPicture(result.Data.Id); GlobalMemberInfo.SetUserCookie(result.Data); return(Json(new { Success = true, result.Data })); }
//------公共数据------------------------- protected UserModel GetUserModel() { var model = new UserModel(); if (string.IsNullOrWhiteSpace(GlobalMemberInfo.Account) || GlobalMemberInfo.UserId <= 0) { return(model); } var result = WebApiHelper.InvokeApi <string>("Login/UserLogin", new { account = GlobalMemberInfo.Account, pwd = GlobalMemberInfo.PassWord, IpAddress = ClientHelper.GetIPAddress }); //TODO update 刘强 处理null异常 if (string.IsNullOrEmpty(result)) { return(model); } var resultView = JsonConvert.DeserializeObject(result, typeof(ResultView <UserView>)) as ResultView <UserView>; if (resultView == null || resultView.Data == null || !resultView.Success) { return(model); } model.Id = resultView.Data.Id; model.Account = resultView.Data.Account; model.Phone = resultView.Data.Phone; model.Pwd = resultView.Data.Pwd; model.NickName = resultView.Data.NickName; model.BB = resultView.Data.BB; model.PlayCount = resultView.Data.PlayCount; model.Picture = GlobalMemberInfo.GetQiniuUserPicture(model.Id); resultView.Data.Picture = model.Picture; model.SubscribeNum = resultView.Data.SubscribeNum; model.FansCount = resultView.Data.FansCount; model.State = resultView.Data.State; model.SkinId = resultView.Data.SkinId; GlobalMemberInfo.SetUserCookie(resultView.Data, GlobalMemberInfo.RemberMe); return(model); }