|
@@ -29,6 +29,7 @@ namespace MySystem.Areas.Api.Controllers
|
|
public JsonResult GetSecret(string value)
|
|
public JsonResult GetSecret(string value)
|
|
{
|
|
{
|
|
value = DesDecrypt(value);
|
|
value = DesDecrypt(value);
|
|
|
|
+ function.WriteLog(DateTime.Now.ToString() + "\n" + value, "小程序-获取secret");
|
|
JsonData data = JsonMapper.ToObject(value);
|
|
JsonData data = JsonMapper.ToObject(value);
|
|
string AppId = data["appId"].ToString(); //小程序AppId
|
|
string AppId = data["appId"].ToString(); //小程序AppId
|
|
string AuthCode = data["authCode"].ToString(); //小程序授权码
|
|
string AuthCode = data["authCode"].ToString(); //小程序授权码
|
|
@@ -45,6 +46,7 @@ namespace MySystem.Areas.Api.Controllers
|
|
Dictionary<string, object> Obj = new Dictionary<string, object>();
|
|
Dictionary<string, object> Obj = new Dictionary<string, object>();
|
|
Obj.Add("appSecret", pro.AppSecret); //小程序密钥
|
|
Obj.Add("appSecret", pro.AppSecret); //小程序密钥
|
|
Obj.Add("appSalt", pro.AppIv); //小程序IV
|
|
Obj.Add("appSalt", pro.AppIv); //小程序IV
|
|
|
|
+ function.WriteLog(Newtonsoft.Json.JsonConvert.SerializeObject(Obj), "小程序-获取用户信息");
|
|
return Json(new AppResultJson() { Status = "1", Info = "", Data = Obj });
|
|
return Json(new AppResultJson() { Status = "1", Info = "", Data = Obj });
|
|
}
|
|
}
|
|
|
|
|
|
@@ -55,6 +57,7 @@ namespace MySystem.Areas.Api.Controllers
|
|
public JsonResult Auth(string value)
|
|
public JsonResult Auth(string value)
|
|
{
|
|
{
|
|
value = DesDecrypt(value);
|
|
value = DesDecrypt(value);
|
|
|
|
+ function.WriteLog(DateTime.Now.ToString() + "\n" + value, "小程序-授权");
|
|
JsonData data = JsonMapper.ToObject(value);
|
|
JsonData data = JsonMapper.ToObject(value);
|
|
string AppId = data["appId"].ToString(); //小程序AppId
|
|
string AppId = data["appId"].ToString(); //小程序AppId
|
|
string Code = data["code"].ToString(); //加密Code
|
|
string Code = data["code"].ToString(); //加密Code
|
|
@@ -74,6 +77,7 @@ namespace MySystem.Areas.Api.Controllers
|
|
return Json(new AppResultJson() { Status = "-1", Info = "授权失败" });
|
|
return Json(new AppResultJson() { Status = "-1", Info = "授权失败" });
|
|
}
|
|
}
|
|
string UserId = Data.Substring(16);
|
|
string UserId = Data.Substring(16);
|
|
|
|
+ function.WriteLog(UserId, "小程序-获取用户信息");
|
|
int PlateformUserId = int.Parse(UserId);
|
|
int PlateformUserId = int.Parse(UserId);
|
|
string OpenId = "kxsmp_" + function.MD5_16(UserId + AppId);
|
|
string OpenId = "kxsmp_" + function.MD5_16(UserId + AppId);
|
|
string Token = function.MD532(Guid.NewGuid().ToString() + "948576");
|
|
string Token = function.MD532(Guid.NewGuid().ToString() + "948576");
|
|
@@ -100,6 +104,7 @@ namespace MySystem.Areas.Api.Controllers
|
|
Dictionary<string, object> Obj = new Dictionary<string, object>();
|
|
Dictionary<string, object> Obj = new Dictionary<string, object>();
|
|
Obj.Add("appToken", Token); //小程序获取用户信息的Token
|
|
Obj.Add("appToken", Token); //小程序获取用户信息的Token
|
|
Obj.Add("openId", OpenId); //小程序openId
|
|
Obj.Add("openId", OpenId); //小程序openId
|
|
|
|
+ function.WriteLog(Newtonsoft.Json.JsonConvert.SerializeObject(Obj), "小程序-获取用户信息");
|
|
return Json(new AppResultJson() { Status = "1", Info = "", Data = Obj });
|
|
return Json(new AppResultJson() { Status = "1", Info = "", Data = Obj });
|
|
}
|
|
}
|
|
|
|
|
|
@@ -110,6 +115,7 @@ namespace MySystem.Areas.Api.Controllers
|
|
public JsonResult GetUserInfo(string value)
|
|
public JsonResult GetUserInfo(string value)
|
|
{
|
|
{
|
|
value = DesDecrypt(value);
|
|
value = DesDecrypt(value);
|
|
|
|
+ function.WriteLog(DateTime.Now.ToString() + "\n" + value, "小程序-获取用户信息");
|
|
JsonData data = JsonMapper.ToObject(value);
|
|
JsonData data = JsonMapper.ToObject(value);
|
|
string AppToken = data["appToken"].ToString(); //小程序获取用户信息的Token
|
|
string AppToken = data["appToken"].ToString(); //小程序获取用户信息的Token
|
|
string OpenId = data["openId"].ToString(); //小程序openId
|
|
string OpenId = data["openId"].ToString(); //小程序openId
|
|
@@ -122,7 +128,7 @@ namespace MySystem.Areas.Api.Controllers
|
|
}
|
|
}
|
|
PlateformModels.Users user = pdb.Users.FirstOrDefault(m => m.Id == userFor.PlateformUserId) ?? new PlateformModels.Users();
|
|
PlateformModels.Users user = pdb.Users.FirstOrDefault(m => m.Id == userFor.PlateformUserId) ?? new PlateformModels.Users();
|
|
Obj.Add("mobile", user.Mobile);
|
|
Obj.Add("mobile", user.Mobile);
|
|
- Obj.Add("nickName", user.RealName); //昵称
|
|
|
|
|
|
+ Obj.Add("nickName", !string.IsNullOrEmpty(user.RealName) ? user.RealName : "未实名用户"); //昵称
|
|
Obj.Add("headPhoto", SourceHost + user.HeadPhoto); //头像
|
|
Obj.Add("headPhoto", SourceHost + user.HeadPhoto); //头像
|
|
Obj.Add("makerCode", user.MakerCode);
|
|
Obj.Add("makerCode", user.MakerCode);
|
|
string province = "";
|
|
string province = "";
|
|
@@ -138,9 +144,10 @@ namespace MySystem.Areas.Api.Controllers
|
|
Obj.Add("province", province); //省
|
|
Obj.Add("province", province); //省
|
|
Obj.Add("city", city); //市
|
|
Obj.Add("city", city); //市
|
|
Obj.Add("district", district); //区
|
|
Obj.Add("district", district); //区
|
|
- Dictionary<string, string> tokens = GetToken(user.Id);
|
|
|
|
- Obj.Add("accessToken", tokens["access_token"]);
|
|
|
|
- Obj.Add("refreshToken", tokens["refresh_token"]);
|
|
|
|
|
|
+ function.WriteLog(Newtonsoft.Json.JsonConvert.SerializeObject(Obj), "小程序-获取用户信息");
|
|
|
|
+ // Dictionary<string, string> tokens = GetToken(user.Id);
|
|
|
|
+ // Obj.Add("accessToken", tokens["access_token"]);
|
|
|
|
+ // Obj.Add("refreshToken", tokens["refresh_token"]);
|
|
return Json(new AppResultJson() { Status = "1", Info = "", Data = Obj });
|
|
return Json(new AppResultJson() { Status = "1", Info = "", Data = Obj });
|
|
}
|
|
}
|
|
public Dictionary<string, string> GetToken(int UserId)
|
|
public Dictionary<string, string> GetToken(int UserId)
|