diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Web/Controllers/HomeController.cs b/Learun.Framework.Ultimate V7/Learun.Application.Web/Controllers/HomeController.cs
index c4e999f14..3326afb2d 100644
--- a/Learun.Framework.Ultimate V7/Learun.Application.Web/Controllers/HomeController.cs
+++ b/Learun.Framework.Ultimate V7/Learun.Application.Web/Controllers/HomeController.cs
@@ -431,8 +431,8 @@ namespace Learun.Application.Web.Controllers
[HttpGet]
public ActionResult Index()
{
- #if DEBUG
- #else
+#if DEBUG
+#else
//判断当前ip是否是123服务器,如果是123服务器,跳过授权验证
if (Net.GetLanIp() != "172.17.3.181")
{
@@ -443,7 +443,7 @@ namespace Learun.Application.Web.Controllers
return Content("");
}
}
- #endif
+#endif
//return View("AdminTop");
string learn_UItheme = WebHelper.GetCookie("Learn_ADMS_V6.1_UItheme");
@@ -670,7 +670,7 @@ namespace Learun.Application.Web.Controllers
{
return View();
}
-#endregion
+ #endregion
private ICache cache = CacheFactory.CaChe();
@@ -691,25 +691,116 @@ namespace Learun.Application.Web.Controllers
}
#endregion
- #region 解绑微信
+ #region 解绑微信、短信发送、校验
+
+ public ActionResult CancelWeiXinBindForm()
+ {
+ return View();
+ }
+
///
/// 解绑微信
///
///
[HttpPost]
[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;
- 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("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("验证失败,验证码错误或已失效。");
+ }
}
+
+ ///
+ /// 发送短信验证码
+ ///
+ /// 发送短信类型:忘记密码forgetpwd,首次登录firstlogin,绑定微信bindwx,解绑微信unbindwx,修改手机号modifymobile,;
+ /// 手机号
+ ///
+ [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();
+ 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("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
///
diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Web/Learun.Application.Web.csproj b/Learun.Framework.Ultimate V7/Learun.Application.Web/Learun.Application.Web.csproj
index 40194920e..7cdd9f0e4 100644
--- a/Learun.Framework.Ultimate V7/Learun.Application.Web/Learun.Application.Web.csproj
+++ b/Learun.Framework.Ultimate V7/Learun.Application.Web/Learun.Application.Web.csproj
@@ -4233,6 +4233,7 @@
+
@@ -8128,6 +8129,7 @@
+
diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Web/Views/Home/CancelWeiXinBindForm.cshtml b/Learun.Framework.Ultimate V7/Learun.Application.Web/Views/Home/CancelWeiXinBindForm.cshtml
new file mode 100644
index 000000000..38f5201d8
--- /dev/null
+++ b/Learun.Framework.Ultimate V7/Learun.Application.Web/Views/Home/CancelWeiXinBindForm.cshtml
@@ -0,0 +1,102 @@
+@{
+ ViewBag.Title = "解绑微信";
+ Layout = "~/Views/Shared/_Form.cshtml";
+}
+
+
+
+@Html.AppendJsFile("/Views/Home/CancelWeiXinBindForm.js")
diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Web/Views/Home/CancelWeiXinBindForm.js b/Learun.Framework.Ultimate V7/Learun.Application.Web/Views/Home/CancelWeiXinBindForm.js
new file mode 100644
index 000000000..e037b30e4
--- /dev/null
+++ b/Learun.Framework.Ultimate V7/Learun.Application.Web/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();
+ });
+}
\ No newline at end of file
diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Web/Views/LR_Content/script/lr-admin.js b/Learun.Framework.Ultimate V7/Learun.Application.Web/Views/LR_Content/script/lr-admin.js
index 3a860bdcb..803b0d5a9 100644
--- a/Learun.Framework.Ultimate V7/Learun.Application.Web/Views/LR_Content/script/lr-admin.js
+++ b/Learun.Framework.Ultimate V7/Learun.Application.Web/Views/LR_Content/script/lr-admin.js
@@ -122,18 +122,13 @@ var loaddfimg;
});
},
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 () {