@@ -431,8 +431,8 @@ namespace Learun.Application.Web.Controllers | |||||
[HttpGet] | [HttpGet] | ||||
public ActionResult Index() | public ActionResult Index() | ||||
{ | { | ||||
#if DEBUG | |||||
#else | |||||
#if DEBUG | |||||
#else | |||||
//判断当前ip是否是123服务器,如果是123服务器,跳过授权验证 | //判断当前ip是否是123服务器,如果是123服务器,跳过授权验证 | ||||
if (Net.GetLanIp() != "172.17.3.181") | if (Net.GetLanIp() != "172.17.3.181") | ||||
{ | { | ||||
@@ -443,7 +443,7 @@ namespace Learun.Application.Web.Controllers | |||||
return Content("<script>alert('" + lc.Message + "');location.href='/ShowRegister/Index';</script>"); | return Content("<script>alert('" + lc.Message + "');location.href='/ShowRegister/Index';</script>"); | ||||
} | } | ||||
} | } | ||||
#endif | |||||
#endif | |||||
//return View("AdminTop"); | //return View("AdminTop"); | ||||
string learn_UItheme = WebHelper.GetCookie("Learn_ADMS_V6.1_UItheme"); | string learn_UItheme = WebHelper.GetCookie("Learn_ADMS_V6.1_UItheme"); | ||||
@@ -670,7 +670,7 @@ namespace Learun.Application.Web.Controllers | |||||
{ | { | ||||
return View(); | return View(); | ||||
} | } | ||||
#endregion | |||||
#endregion | |||||
private ICache cache = CacheFactory.CaChe(); | private ICache cache = CacheFactory.CaChe(); | ||||
@@ -691,25 +691,116 @@ namespace Learun.Application.Web.Controllers | |||||
} | } | ||||
#endregion | #endregion | ||||
#region 解绑微信 | |||||
#region 解绑微信、短信发送、校验 | |||||
public ActionResult CancelWeiXinBindForm() | |||||
{ | |||||
return View(); | |||||
} | |||||
/// <summary> | /// <summary> | ||||
/// 解绑微信 | /// 解绑微信 | ||||
/// </summary> | /// </summary> | ||||
/// <returns></returns> | /// <returns></returns> | ||||
[HttpPost] | [HttpPost] | ||||
[AjaxOnly] | [AjaxOnly] | ||||
public ActionResult CancelWeiXinBind(string keyValue) | |||||
public ActionResult CancelWeiXinBind(string keyValue, string codeType, string verifycode) | |||||
{ | { | ||||
//短信验证码校验 | |||||
if (string.IsNullOrEmpty(codeType)) | |||||
{ | |||||
return Fail("未指定短信类型。"); | |||||
} | |||||
var userId = LoginUserInfo.Get().userId; | var userId = LoginUserInfo.Get().userId; | ||||
if (!string.IsNullOrEmpty(keyValue)) | |||||
var mobile = userIBLL.GetEntityByUserId(userId)?.F_Mobile; | |||||
if (string.IsNullOrEmpty(mobile)) | |||||
{ | { | ||||
userId = keyValue; | |||||
return Fail("手机号不能为空。"); | |||||
} | } | ||||
//更新openid | |||||
userIBLL.UpdateWeixinOpenIdPC(userId, ""); | |||||
var code = redisCache.Read<string>("sendcodeinpc_" + codeType + "_" + mobile, CacheId.sms); | |||||
if (!string.IsNullOrEmpty(code) && code == verifycode) | |||||
{ | |||||
//return Success("验证成功。"); | |||||
return Success("解绑成功"); | |||||
if (!string.IsNullOrEmpty(keyValue)) | |||||
{ | |||||
userId = keyValue; | |||||
} | |||||
//更新openid | |||||
userIBLL.UpdateWeixinOpenIdPC(userId, ""); | |||||
return Success("解绑成功"); | |||||
} | |||||
else | |||||
{ | |||||
return Fail("验证失败,验证码错误或已失效。"); | |||||
} | |||||
} | } | ||||
/// <summary> | |||||
/// 发送短信验证码 | |||||
/// </summary> | |||||
/// <param name="codeType">发送短信类型:忘记密码forgetpwd,首次登录firstlogin,绑定微信bindwx,解绑微信unbindwx,修改手机号modifymobile,;</param> | |||||
/// <param name="phone">手机号</param> | |||||
/// <returns></returns> | |||||
[HttpPost] | |||||
public ActionResult Sendcode(string codeType) | |||||
{ | |||||
if (string.IsNullOrEmpty(codeType)) | |||||
{ | |||||
return Fail("未指定短信类型。"); | |||||
} | |||||
UserEntity userEntity = null; | |||||
userEntity = userIBLL.GetEntityByUserId(LoginUserInfo.Get().userId); | |||||
if (userEntity == null) | |||||
{ | |||||
return Fail("用户不存在!"); | |||||
} | |||||
if (string.IsNullOrEmpty(userEntity.F_Mobile)) | |||||
{ | |||||
return Fail("用户手机号不存在!"); | |||||
} | |||||
//todo:待取消注释 | |||||
//string raRndNum = Learun.Util.CommonHelper.RndNum(6); | |||||
string raRndNum = "123456"; | |||||
var listStr = new List<string>(); | |||||
var str1 = $"欢迎使用智慧校园,您本次登录的验证码是 " + raRndNum + "。"; | |||||
listStr.Add(str1); | |||||
//todo:待开发短信平台 | |||||
//var result = aliyunSms.SendSmsToSingle(userEntity.F_Mobile, SmsType.LoginBind, listStr); | |||||
//if (result.Result.code == "0") | |||||
if (true) | |||||
{ | |||||
redisCache.Write<string>("sendcodeinpc_" + codeType + "_" + userEntity.F_Mobile, raRndNum, 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 + " 验证码:" + raRndNum; | |||||
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); | |||||
} | |||||
} | |||||
#endregion | #endregion | ||||
/// <summary> | /// <summary> | ||||
@@ -4233,6 +4233,7 @@ | |||||
<Content Include="Views\Home\FirstChangePwd.js" /> | <Content Include="Views\Home\FirstChangePwd.js" /> | ||||
<Content Include="Views\Home\DataBaseInit.js" /> | <Content Include="Views\Home\DataBaseInit.js" /> | ||||
<Content Include="Views\Home\ChangePwd.js" /> | <Content Include="Views\Home\ChangePwd.js" /> | ||||
<Content Include="Views\Home\CancelWeiXinBindForm.js" /> | |||||
<Content Include="Views\Home\NeedToDoForm.js" /> | <Content Include="Views\Home\NeedToDoForm.js" /> | ||||
<Content Include="Views\Home\Guide\guide.css" /> | <Content Include="Views\Home\Guide\guide.css" /> | ||||
<Content Include="Views\Home\Guide\index.css" /> | <Content Include="Views\Home\Guide\index.css" /> | ||||
@@ -8128,6 +8129,7 @@ | |||||
<Content Include="Views\Login\FirstLoginForWeixin.cshtml" /> | <Content Include="Views\Login\FirstLoginForWeixin.cshtml" /> | ||||
<Content Include="Views\Home\FirstChangePwd.cshtml" /> | <Content Include="Views\Home\FirstChangePwd.cshtml" /> | ||||
<Content Include="Views\Login\ForgotPassword.cshtml" /> | <Content Include="Views\Login\ForgotPassword.cshtml" /> | ||||
<Content Include="Views\Home\CancelWeiXinBindForm.cshtml" /> | |||||
</ItemGroup> | </ItemGroup> | ||||
<ItemGroup> | <ItemGroup> | ||||
<WCFMetadata Include="Connected Services\" /> | <WCFMetadata Include="Connected Services\" /> | ||||
@@ -0,0 +1,102 @@ | |||||
@{ | |||||
ViewBag.Title = "解绑微信"; | |||||
Layout = "~/Views/Shared/_Form.cshtml"; | |||||
} | |||||
<style> | |||||
.lr-login-bypsw { | |||||
position: relative; | |||||
width: 100%; | |||||
height: 100%; | |||||
padding: 60px 0 52px 45px; | |||||
} | |||||
.error_info { | |||||
font-family: PingFangSC-Regular; | |||||
position: absolute; | |||||
font-size: 12px; | |||||
color: #ED3232; | |||||
right: 75px; | |||||
top: 32px; | |||||
display: none; | |||||
} | |||||
.lr-login-input { | |||||
position: relative; | |||||
width: 100%; | |||||
height: 48px; | |||||
margin-bottom: 25px | |||||
} | |||||
.lr-login-input input { | |||||
display: block; | |||||
width: 365px; | |||||
text-indent: 31px; | |||||
height: 48px; | |||||
line-height: 46px; | |||||
outline: 0; | |||||
font-family: PingFangSC-Regular; | |||||
font-size: 12px; | |||||
color: #666; | |||||
opacity: .99; | |||||
background: #FFF; | |||||
border: 1px solid #CCC; | |||||
border-radius: 2px | |||||
} | |||||
.lr-login-input > .inp_icon { | |||||
position: absolute; | |||||
left: 10px; | |||||
top: 18.5px; | |||||
z-index: 10 | |||||
} | |||||
.lr-login-input input:focus { | |||||
opacity: .99; | |||||
background: #FFF; | |||||
border: 1px solid #3298DC; | |||||
border-radius: 2px | |||||
} | |||||
.codeBtn { | |||||
border: 1px solid #DCDFE6; | |||||
padding: 6px 10px; | |||||
color: #606266; | |||||
font-size: 12px; | |||||
cursor: pointer; | |||||
border-radius: 2px; | |||||
position: absolute; | |||||
left: 260px; | |||||
top: 10px; | |||||
} | |||||
.lr-login-btn { | |||||
display: inline-block; | |||||
text-align: center; | |||||
cursor: pointer; | |||||
background: #3298DC; | |||||
border: 1px solid #3298DC; | |||||
border-radius: 2px; | |||||
font-family: PingFangSC-Regular; | |||||
font-size: 16px; | |||||
color: #FFF; | |||||
height: 48px; | |||||
line-height: 48px; | |||||
width: 365px; | |||||
text-align: center; | |||||
margin-top: 5px; | |||||
} | |||||
</style> | |||||
<div class="lr-form-wrap" id="form"> | |||||
<div class="lr-login-main lr-login-normal" id="updatepwBox"> | |||||
<!--表单--> | |||||
<div class="lr-login-bypsw"> | |||||
<div class="error_info">* <span></span></div> | |||||
<div class="lr-login-input"> | |||||
<img class="inp_icon" src="~/Content/images/Login/default_psw0.png" alt=""><input id="verifycode" type="text" placeholder="请输入验证码"> | |||||
<span id="sendCode" class="codeBtn">发送验证码</span> | |||||
</div> | |||||
<div class="lr-login-btn" id="confirmUpdate"><span>确认解绑</span></div> | |||||
</div> | |||||
</div> | |||||
</div> | |||||
@Html.AppendJsFile("/Views/Home/CancelWeiXinBindForm.js") |
@@ -0,0 +1,108 @@ | |||||
/* | |||||
* 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园(http://www.learun.cn) | |||||
* Copyright (c) 2013-2018 北京泉江科技有限公司 | |||||
* 创建人:陈彬彬 | |||||
* 日 期:2024.07.12 | |||||
* 描 述:解绑微信 | |||||
*/ | |||||
var bootstrap = function ($, learun) { | |||||
"use strict"; | |||||
var codeType = 'unbindwx', hasSendCode = false, time = 0, timeT = '', isSending = false; | |||||
var lrPage = { | |||||
init: function () { | |||||
lrPage.bind(); | |||||
}, | |||||
bind: function () { | |||||
// 确认按钮 | |||||
$("#confirmUpdate").on('click', function () { | |||||
lrPage.confirmUpdate(); | |||||
}); | |||||
// 发送验证码事件 | |||||
$("#sendCode").on('click', function () { | |||||
lrPage.sendCode(); | |||||
}); | |||||
}, | |||||
updating: function (isShow) { | |||||
if (isShow) { | |||||
$('#updatepwBox input').attr('disabled', 'disabled'); | |||||
$("#confirmUpdate").addClass('active').attr('disabled', 'disabled').find('span').hide(); | |||||
$("#confirmUpdate").css('background', '#eeecec url(/Content/images/Login/loading.gif) no-repeat center 10px'); | |||||
} | |||||
else { | |||||
$('#updatepwBox input').removeAttr('disabled'); | |||||
$("#confirmUpdate").removeClass('active').removeAttr('disabled').find('span').show(); | |||||
$("#confirmUpdate").css('background', '#268fe2'); | |||||
} | |||||
}, | |||||
sendCode: function () { | |||||
if (isSending || hasSendCode) return; | |||||
$('#updatepwBox .error_info').hide() | |||||
isSending = true | |||||
$.ajax({ | |||||
url: top.$.rootUrl + "/Home/Sendcode", | |||||
data: { codeType }, | |||||
dataType: 'json', | |||||
type: "post", | |||||
success: (res) => { | |||||
isSending = false; | |||||
if (res.code == 200) { | |||||
$('#updatepwBox .error_info span').text('短信已发送') | |||||
$('#updatepwBox .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 { | |||||
$('#updatepwBox .error_info span').text(res.info) | |||||
$('#updatepwBox .error_info').show() | |||||
} | |||||
} | |||||
}); | |||||
}, | |||||
confirmUpdate: async function () { | |||||
let verifycode = $('#verifycode').val() | |||||
if (!verifycode) { | |||||
$('#updatepwBox .error_info span').text('请输入验证码') | |||||
$('#updatepwBox .error_info').show() | |||||
return | |||||
} | |||||
$('#updatepwBox .error_info').hide() | |||||
lrPage.updating(true); | |||||
$.ajax({ | |||||
url: top.$.rootUrl + '/Home/CancelWeiXinBind', | |||||
data: { verifycode, codeType }, | |||||
dataType: 'json', | |||||
type: "post", | |||||
success: (res) => { | |||||
if (res.code == 200) { | |||||
$('#updatepwBox .error_info span').text('解绑成功') | |||||
$('#updatepwBox .error_info').show() | |||||
setTimeout(() => { | |||||
learun.layerClose('CancelWeiXinBindForm', ''); | |||||
}, 1500) | |||||
} else { | |||||
lrPage.updating(false); | |||||
$('#updatepwBox .error_info span').text(res.info) | |||||
$('#updatepwBox .error_info').show() | |||||
} | |||||
} | |||||
}); | |||||
} | |||||
}; | |||||
$(function () { | |||||
lrPage.init(); | |||||
}); | |||||
} |
@@ -122,18 +122,13 @@ var loaddfimg; | |||||
}); | }); | ||||
}, | }, | ||||
cancelWeiXinBind: function () { | cancelWeiXinBind: function () { | ||||
learun.layerConfirm("注:您确定要解绑微信吗?", function (r) { | |||||
if (r) { | |||||
learun.loading(true, '解除绑定中...'); | |||||
learun.httpAsyncPost($.rootUrl + '/Home/CancelWeiXinBind', {}, function (data) { | |||||
if (data.code == 200) { | |||||
learun.alert.success(data.info); | |||||
} else { | |||||
learun.alert.error("异常,请刷新!"); | |||||
} | |||||
learun.loading(false); | |||||
}); | |||||
} | |||||
learun.layerForm({ | |||||
id: "CancelWeiXinBindForm", | |||||
title: '解绑微信', | |||||
url: top.$.rootUrl + '/Home/CancelWeiXinBindForm', | |||||
width: 500, | |||||
height: 400, | |||||
btn: null | |||||
}); | }); | ||||
}, | }, | ||||
openUserCenter: function () { | openUserCenter: function () { | ||||