@@ -18,6 +18,7 @@ using Learun.Cache.Factory; | |||
using Newtonsoft.Json; | |||
using Learun.Application.TwoDevelopment.LR_Desktop; | |||
using Learun.Application.TwoDevelopment.PersonnelManagement; | |||
using Quanjiang.DigitalScholl.SendSms; | |||
namespace Learun.Application.Web.Controllers | |||
{ | |||
@@ -56,6 +57,7 @@ namespace Learun.Application.Web.Controllers | |||
private TeachSwitchIBLL teachSwitchIBLL = new TeachSwitchBLL(); | |||
private StuSaverecordIBLL stuSaverecordIBLL = new StuSaverecordBLL(); | |||
private StuConsumptionIBLL stuConsumptionIBLL = new StuConsumptionBLL(); | |||
private readonly ISms aliyunSms = new AliyunSms(); | |||
#region 统一身份认证2.0 | |||
/// <summary> | |||
@@ -2021,6 +2023,204 @@ namespace Learun.Application.Web.Controllers | |||
return Success("操作成功"); | |||
} | |||
#region 短信发送、校验 | |||
/// <summary> | |||
/// 忘记密码 | |||
/// </summary> | |||
/// <returns></returns> | |||
public ActionResult ForgotPassword() | |||
{ | |||
return View(); | |||
} | |||
/// <summary> | |||
/// 发送短信验证码 | |||
/// </summary> | |||
/// <param name="codeType">发送短信类型:忘记密码forgetpwd,首次登录firstlogin,绑定微信bindwx,解绑微信unbindwx,修改手机号modifymobile,;</param> | |||
/// <param name="phone">手机号</param> | |||
/// <returns></returns> | |||
[HttpPost] | |||
public ActionResult Sendcode(string codeType, string phone) | |||
{ | |||
if (string.IsNullOrEmpty(codeType)) | |||
{ | |||
return Fail("短信类型错误。"); | |||
} | |||
UserEntity userEntity = null; | |||
userEntity = userBll.GetEntityByMobile(phone); | |||
if (userEntity == null) | |||
{ | |||
return Fail("输入错误!"); | |||
} | |||
if (string.IsNullOrEmpty(userEntity.F_Mobile)) | |||
{ | |||
return Fail("输入错误!"); | |||
} | |||
if (!CommonHelper.IsValidMobile(userEntity.F_Mobile)) | |||
{ | |||
return Fail("输入错误!"); | |||
} | |||
if (codeType == "firstlogin" && userEntity.F_HaveLogMark == true) | |||
{ | |||
return Fail("当前用户非首次登录,请使用账号密码进行登录!"); | |||
} | |||
var listStr = new List<string>(); | |||
var result = aliyunSms.SendSmsToSingle(userEntity.F_Mobile, SmsType.LoginBind, listStr); | |||
if (result.Result.code == "OK") | |||
{ | |||
redisCache.Write<string>("sendcodeinpcsso_" + codeType + "_" + userEntity.F_Mobile, result.Result.randomNum, new TimeSpan(0, 5, 0), CacheId.sms); | |||
//日志 | |||
LogEntity logEntity = new LogEntity(); | |||
logEntity.F_CategoryId = 3; | |||
logEntity.F_SourceObjectId = codeType; | |||
logEntity.F_OperateTypeId = "sms"; | |||
logEntity.F_OperateType = "sms"; | |||
logEntity.F_OperateAccount = "system"; | |||
logEntity.F_ExecuteResult = 200; | |||
logEntity.F_ExecuteResultJson = "短信发送成功:" + result.Result.message; | |||
logEntity.F_Description = "短信发送:" + userEntity.F_Mobile + " 验证码:" + result.Result.randomNum; | |||
logEntity.WriteLog(); | |||
return Success("短信发送成功:" + result.Result.message); | |||
} | |||
else | |||
{ | |||
LogEntity logEntity = new LogEntity(); | |||
logEntity.F_CategoryId = 4; | |||
logEntity.F_SourceObjectId = codeType; | |||
logEntity.F_OperateTypeId = "sms"; | |||
logEntity.F_OperateType = "sms"; | |||
logEntity.F_OperateAccount = "system"; | |||
logEntity.F_ExecuteResult = 400; | |||
logEntity.F_ExecuteResultJson = "短信发送失败:" + result.Result.message + result.Result.errorType; | |||
logEntity.F_Description = "短信发送:" + userEntity.F_Mobile; | |||
logEntity.WriteLog(); | |||
return Fail("短信发送失败:" + result.Result.message + result.Result.errorType); | |||
} | |||
} | |||
/// <summary> | |||
/// 忘记密码:修改密码 | |||
/// </summary> | |||
/// <param name="phone"></param> | |||
/// <param name="newpassword"></param> | |||
/// <returns></returns> | |||
[HttpPost] | |||
public ActionResult ForgotPasswordHandle(string codeType, string phone, string verifycode, string newpassword) | |||
{ | |||
//短信验证码校验 | |||
if (string.IsNullOrEmpty(codeType)) | |||
{ | |||
return Fail("短信类型错误。"); | |||
} | |||
if (string.IsNullOrEmpty(phone)) | |||
{ | |||
return Fail("手机号不能为空。"); | |||
} | |||
var code = redisCache.Read<string>("sendcodeinpcsso_" + codeType + "_" + phone, CacheId.sms); | |||
if (!string.IsNullOrEmpty(code) && code == verifycode) | |||
{ | |||
//return Success("验证成功。"); | |||
UserEntity userEntity = userBll.GetEntityByMobile(phone); | |||
if (userEntity == null) | |||
{ | |||
return Fail("输入错误。"); | |||
} | |||
userBll.setPassword(userEntity.F_UserId, newpassword); | |||
return Success("密码修改成功"); | |||
} | |||
else | |||
{ | |||
return Fail("验证失败,验证码错误或已失效。"); | |||
} | |||
} | |||
/// <summary> | |||
/// 首次登录:手机号登录 | |||
/// </summary> | |||
/// <param name="codeType">发送短信类型</param> | |||
/// <param name="phone">手机号</param> | |||
/// <param name="verifycode">验证码</param> | |||
/// <returns></returns> | |||
[HttpPost] | |||
public ActionResult LoginByMobile(string codeType, string phone, string verifycode) | |||
{ | |||
//短信验证码校验 | |||
if (string.IsNullOrEmpty(codeType)) | |||
{ | |||
return Fail("短信类型错误。"); | |||
} | |||
if (string.IsNullOrEmpty(phone)) | |||
{ | |||
return Fail("手机号不能为空。"); | |||
} | |||
var code = redisCache.Read<string>("sendcodeinpcsso_" + codeType + "_" + phone, CacheId.sms); | |||
if (!string.IsNullOrEmpty(code) && code == verifycode) | |||
{ | |||
//return Success("验证成功。"); | |||
#region 内部账户验证 | |||
UserEntity userEntity = userBll.GetEntityByMobile(phone); | |||
if (userEntity == null) | |||
{ | |||
return Fail("输入错误!"); | |||
} | |||
if (userEntity.F_EnabledMark != 1) | |||
{ | |||
return Fail("账户被系统锁定,请联系管理员!"); | |||
} | |||
if (userEntity.F_HaveLogMark == true) | |||
{ | |||
return Fail("当前用户非首次登录,请使用账号密码进行登录!"); | |||
} | |||
userEntity.LoginOk = true; | |||
#region 写入日志 | |||
LogEntity logEntity = new LogEntity(); | |||
logEntity.F_CategoryId = 1; | |||
logEntity.F_OperateTypeId = ((int)OperationType.Login).ToString(); | |||
logEntity.F_OperateType = EnumAttribute.GetDescription(OperationType.Login); | |||
logEntity.F_OperateAccount = userEntity.F_Account + "(" + userEntity.F_RealName + ")"; | |||
logEntity.F_OperateUserId = !string.IsNullOrEmpty(userEntity.F_UserId) ? userEntity.F_UserId : userEntity.F_Account; | |||
logEntity.F_Module = Config.GetValue("SoftName"); | |||
logEntity.F_Description = "PC端-网上办事大厅-首次登录"; | |||
#endregion | |||
if (!userEntity.LoginOk)//登录失败 | |||
{ | |||
//写入日志 | |||
logEntity.F_ExecuteResult = 0; | |||
logEntity.F_ExecuteResultJson = "登录失败:" + userEntity.LoginMsg; | |||
logEntity.WriteLog(); | |||
return Fail(userEntity.LoginMsg); | |||
} | |||
else | |||
{ | |||
//记录已登录标记 | |||
userBll.UpdateHaveLogMark(userEntity.F_UserId); | |||
//记录ip | |||
userBll.UpdateIp(GetIP(), userEntity.F_UserId); | |||
OperatorHelper.Instance.AddLoginUser(userEntity.F_Account, "Learun_ADMS_6.1_PC", null);//写入缓存信息 | |||
//写入日志 | |||
logEntity.F_ExecuteResult = 1; | |||
logEntity.F_ExecuteResultJson = "登录成功"; | |||
logEntity.WriteLog(); | |||
//结果 | |||
var succresult = new | |||
{ | |||
pwd = true | |||
}; | |||
return Success(succresult); | |||
} | |||
#endregion | |||
} | |||
else | |||
{ | |||
return Fail("验证失败,验证码错误或已失效。"); | |||
} | |||
} | |||
#endregion | |||
[HandlerLogin(FilterMode.Enforce)] | |||
public ActionResult GetYKTPayed() | |||
{ | |||
@@ -8132,6 +8132,7 @@ | |||
<Content Include="Views\Login\ForgotPassword.cshtml" /> | |||
<Content Include="Views\Home\CancelWeiXinBindForm.cshtml" /> | |||
<Content Include="Views\Home\ChangePwdOfFirstLogin.cshtml" /> | |||
<Content Include="Views\SSOSystem\ForgotPassword.cshtml" /> | |||
</ItemGroup> | |||
<ItemGroup> | |||
<WCFMetadata Include="Connected Services\" /> | |||
@@ -119,11 +119,11 @@ | |||
@*<a href="/Login/FirstLoginForWeixin?login=one" class="down titleImg" title="新生首次登录"> | |||
<img src="~/Content/images/LoginPage/title.jpg" alt="" /> 新生首次登录 | |||
</a>*@ | |||
//首次登录-手机号 | |||
<a href="Javascript:void(0)" id="firstLogin" class="down titleImg" title="首次登录"> | |||
<img src="~/Content/images/LoginPage/title.jpg" alt="" /> <span>首次登录</span> | |||
</a> | |||
} | |||
<!--首次登录-手机号--> | |||
<a href="Javascript:void(0)" id="firstLogin" class="down titleImg" title="首次登录"> | |||
<img src="~/Content/images/LoginPage/title.jpg" alt="" /> <span>首次登录</span> | |||
</a> | |||
<img src="~/Content/images/logins/login2.png" /> | |||
<!--登录框 正常登录--> | |||
<div class="lr-login-main lr-login-normal" id="loginBox"> | |||
@@ -264,7 +264,7 @@ | |||
$.ajax({ | |||
url: $.rootUrl + "/Login/Sendcode", | |||
data: { phone, codeType }, | |||
dataType:'json', | |||
dataType: 'json', | |||
type: "post", | |||
success: (res) => { | |||
isSending = false; | |||
@@ -284,7 +284,7 @@ | |||
} | |||
$('#sendCode').text(`重新发送${time ? '(' + time + 's' + ')' : ''}`) | |||
}, 1000); | |||
}else { | |||
} else { | |||
$('#firstLoginBox .error_info span').text(res.info) | |||
$('#firstLoginBox .error_info').show() | |||
} | |||
@@ -321,8 +321,8 @@ | |||
if (res.data.pwd == true) { | |||
//存储seesion | |||
sessionStorage.setItem("pase_29d", "hmfl"); | |||
window.location.href = "/Home/Index"; | |||
} | |||
window.location.href = "/Home/Index"; | |||
} else { | |||
$('#firstLoginBox .error_info span').text(res.info) | |||
$('#firstLoginBox .error_info').show() | |||
@@ -61,8 +61,56 @@ | |||
top: 40px; | |||
display: none; | |||
} | |||
.wx{ | |||
display:block; | |||
.wxLogin { | |||
color: #53b947 !important; | |||
} | |||
.wxLogin img { | |||
width: 35px !important; | |||
top: -2px; | |||
} | |||
.titleImg { | |||
border: none !important; | |||
color: #da9835 !important; | |||
margin-left: 210px; | |||
} | |||
.titleImg img { | |||
width: 35px !important; | |||
} | |||
.down { | |||
position: absolute; | |||
bottom: 100px; | |||
left: 70px; | |||
height: 30px; | |||
line-height: 28px; | |||
padding-right: 20px; | |||
} | |||
.codeBtn { | |||
border: 1px solid #DCDFE6; | |||
padding: 4px 10px; | |||
color: #606266; | |||
font-size: 12px; | |||
cursor: pointer; | |||
border-radius: 2px; | |||
position: absolute; | |||
left: 210px; | |||
top: 8px; | |||
} | |||
.codeBtn:hover { | |||
border-color: #CBCFD5; | |||
} | |||
.versionBox { | |||
margin-top: 10px; | |||
font-family: PingFangSC-Regular; | |||
font-size: 12px; | |||
color: #3298DC; | |||
} | |||
</style> | |||
</head> | |||
@@ -1005,7 +1053,8 @@ | |||
<img class="loginTabImg2" src="/Content/images/DragSSO/login5-2s.png" alt="" /> | |||
</div> | |||
</div> | |||
<div class="loginCon noreg"> | |||
<!--登录框 正常登录--> | |||
<div class="loginCon noreg" id="loginBox"> | |||
<input id="errornum" type="hidden" value="@ViewBag.errornum" /> | |||
<form id="loginForm" role="form" action="" method="post" novalidate="novalidate"> | |||
<div class="loginTitle">用户登录</div> | |||
@@ -1031,13 +1080,9 @@ | |||
<div class="loginBtn"> | |||
<input id="lr_login_btn" type="button" class="btn btn-white btn-outline btn-lg btn-rounded progress-login" value="登录" style="cursor:pointer" /> | |||
</div> | |||
@if (ViewBag.WeixinLoginSwitch) | |||
{ | |||
<a class="wx" href="/Login/LoginForWeixin?login=one&state=ssologin"> | |||
<img src="/Content/images/DragSSO/weixin.png" alt="" /> | |||
<span>微信登录</span> | |||
</a> | |||
} | |||
<div class="versionBox"> | |||
<a style="font-family: PingFangSC-Regular;font-size: 12px;color: #3298DC;margin-right:20px;" href="/SSOSystem/ForgotPassword">忘记密码?</a> | |||
</div> | |||
</form> | |||
<div class="qrCodeBox"> | |||
@@ -1045,6 +1090,38 @@ | |||
<div id="qrCode"></div> | |||
</div> | |||
</div> | |||
<!--登录框 首次登录--> | |||
<div class="loginCon noreg" id="firstLoginBox" style="display:none"> | |||
<form id="loginForm" role="form" action="" method="post" novalidate="novalidate"> | |||
<div class="loginTitle">首次登录</div> | |||
<div class="error_info">* <span></span></div> | |||
<div class="loginInput"> | |||
<div class="loginInputTxt">手机号</div> | |||
<input type="text" placeholder="手机号" id="phone" name="phone" class="form-control required" /> | |||
</div> | |||
<div class="loginInput"> | |||
<div class="loginInputTxt">验证码</div> | |||
<div class="codeBox"> | |||
<input type="text" placeholder="验证码" id="verifycode" name="verifycode" class="form-control required" /> | |||
<span id="sendCode" class="codeBtn">发送验证码</span> | |||
</div> | |||
</div> | |||
<div class="loginBtn"> | |||
<input id="firstLogin_btn" type="button" class="btn btn-white btn-outline btn-lg btn-rounded progress-login" value="首次登录" style="cursor:pointer" /> | |||
</div> | |||
</form> | |||
</div> | |||
@if (ViewBag.WeixinLoginSwitch) | |||
{ | |||
<a class="wxLogin down" href="/Login/LoginForWeixin?login=one&state=ssologin"> | |||
<img src="/Content/images/DragSSO/weixin.png" alt="" /> <span>微信登录</span> | |||
</a> | |||
} | |||
<!--首次登录-手机号--> | |||
<a href="Javascript:void(0)" id="firstLogin" class="down titleImg" title="首次登录"> | |||
<img src="~/Content/images/LoginPage/title.jpg" alt="" /> <span>首次登录</span> | |||
</a> | |||
<div class="tips"> | |||
<img src="/Content/images/DragSSO/tips1.png" alt="" /> <span>建议使用360或谷歌浏览器</span> | |||
</div> | |||
@@ -1109,9 +1186,33 @@ | |||
$('.loginCon').removeClass('noreg'); | |||
$("#lr_verifycode_img").trigger('click'); | |||
} | |||
var codeType = 'firstlogin', hasSendCode = false, time = 0, timeT = '', isSending = false; | |||
// 登录按钮事件 | |||
$("#lr_login_btn").on('click', function () { | |||
login(); | |||
}); | |||
// 点击首次登录按钮 | |||
$('#firstLogin').click(function () { | |||
if ($('#firstLoginBox').css('display') == 'none') { | |||
$('#firstLoginBox').show() | |||
$('#loginBox').hide() | |||
$(this).find('span').text('常规登录') | |||
} else { | |||
$('#firstLoginBox').hide() | |||
$('#loginBox').show() | |||
$(this).find('span').text('首次登录') | |||
} | |||
}); | |||
// 首次登录按钮事件 | |||
$("#firstLogin_btn").on('click', function () { | |||
firstLogin(); | |||
}); | |||
// 发送验证码事件 | |||
$("#sendCode").on('click', function () { | |||
sendCode(); | |||
}); | |||
var login = function () { | |||
var $username = $("#lr_username"), $password = $("#lr_password"), $verifycode = $("#lr_verifycode_input"); | |||
var username = $.trim($username.val()), password = $.trim($password.val()), verifycode = $.trim($verifycode.val()); | |||
if (username == "") { | |||
@@ -1133,17 +1234,17 @@ | |||
layer.msg('登录中...', { | |||
icon: 16 | |||
, shade: 0.01 | |||
,time:-1 | |||
, time: -1 | |||
}); | |||
$.ajax({ | |||
url: "/Login/CheckLogin", | |||
headers: { __RequestVerificationToken: $.lrToken }, | |||
data: { username: username, password: password, verifycode: verifycode, up: "", defaultPwdTip:"" }, | |||
data: { username: username, password: password, verifycode: verifycode, up: "", defaultPwdTip: "" }, | |||
type: "post", | |||
dataType: "json", | |||
success: function (res) { | |||
if (res.code == 200) { | |||
window.location.href ="/SSOSystem/DragModelOne"; | |||
window.location.href = "/SSOSystem/DragModelOne"; | |||
} | |||
else if (res.code == 400) { | |||
tip(res.info, true); | |||
@@ -1160,20 +1261,100 @@ | |||
} | |||
} | |||
}); | |||
}); | |||
}; | |||
//登录错误提示显示 | |||
var tip = function (msg) { | |||
var $tip = $('.error_info'); | |||
var $tip = $('#loginBox .error_info'); | |||
$tip.hide(); | |||
if (!!msg) { | |||
$tip.find('span').html(msg); | |||
$tip.show(); | |||
} | |||
} | |||
var sendCode = function () { | |||
if (isSending || hasSendCode) return; | |||
let phone = $('#phone').val() | |||
if (!phone) { | |||
$('#firstLoginBox .error_info span').text('请输入手机号') | |||
$('#firstLoginBox .error_info').show() | |||
return | |||
} else if (!/^1[0-9]{10}$/.test(phone)) { | |||
$('#firstLoginBox .error_info span').text('手机号格式不正确') | |||
$('#firstLoginBox .error_info').show() | |||
return | |||
} | |||
$('#firstLoginBox .error_info').hide() | |||
isSending = true | |||
$.ajax({ | |||
url: "/SSOSystem/Sendcode", | |||
data: { phone, codeType }, | |||
dataType: 'json', | |||
type: "post", | |||
success: (res) => { | |||
isSending = false; | |||
if (res.code == 200) { | |||
$('#firstLoginBox .error_info span').text('短信已发送') | |||
$('#firstLoginBox .error_info').show() | |||
hasSendCode = true | |||
time = 60 | |||
$('#sendCode').text(`重新发送(${time}s)`) | |||
timeT = setInterval(() => { | |||
time-- | |||
if (time == 0) { | |||
hasSendCode = false | |||
clearInterval(timeT) | |||
timeT = '' | |||
} | |||
$('#sendCode').text(`重新发送${time ? '(' + time + 's' + ')' : ''}`) | |||
}, 1000); | |||
} else { | |||
$('#firstLoginBox .error_info span').text(res.info) | |||
$('#firstLoginBox .error_info').show() | |||
} | |||
} | |||
}); | |||
}; | |||
var firstLogin = function () { | |||
let phone = $('#phone').val() | |||
let verifycode = $('#verifycode').val() | |||
if (!phone) { | |||
$('#firstLoginBox .error_info span').text('请输入手机号') | |||
$('#firstLoginBox .error_info').show() | |||
return | |||
} else if (!/^1[0-9]{10}$/.test(phone)) { | |||
$('#firstLoginBox .error_info span').text('手机号格式不正确') | |||
$('#firstLoginBox .error_info').show() | |||
return | |||
} | |||
if (!verifycode) { | |||
$('#firstLoginBox .error_info span').text('请输入验证码') | |||
$('#firstLoginBox .error_info').show() | |||
return | |||
} | |||
$('#firstLoginBox .error_info').hide() | |||
layer.msg('登录中...', { | |||
icon: 16 | |||
, shade: 0.01 | |||
, time: -1 | |||
}); | |||
$.ajax({ | |||
url: "/SSOSystem/LoginByMobile", | |||
data: { phone, codeType, verifycode }, | |||
dataType: 'json', | |||
type: "post", | |||
success: (res) => { | |||
if (res.code == 200) { | |||
window.location.href = "/SSOSystem/DragModelOne"; | |||
} else { | |||
layer.closeAll(); | |||
$('#firstLoginBox .error_info span').text(res.info) | |||
$('#firstLoginBox .error_info').show() | |||
} | |||
} | |||
}); | |||
} | |||
</script> | |||
</body> | |||