瀏覽代碼

【增加】忘记密码、修改手机号功能增加;

塔里木分支
dyy 4 月之前
父節點
當前提交
8461615f4d
共有 18 個檔案被更改,包括 1207 行新增1 行删除
  1. +44
    -0
      Learun.Framework.Ultimate V7/Learun.Application.Organization/User/UserBLL.cs
  2. +5
    -0
      Learun.Framework.Ultimate V7/Learun.Application.Organization/User/UserEntity.cs
  3. +8
    -0
      Learun.Framework.Ultimate V7/Learun.Application.Organization/User/UserIBLL.cs
  4. +55
    -0
      Learun.Framework.Ultimate V7/Learun.Application.Organization/User/UserService.cs
  5. +119
    -0
      Learun.Framework.Ultimate V7/Learun.Application.Web/Controllers/LoginController.cs
  6. +6
    -0
      Learun.Framework.Ultimate V7/Learun.Application.Web/Learun.Application.Web.csproj
  7. +2
    -0
      Learun.Framework.Ultimate V7/Learun.Application.Web/Views/Login/Default.cshtml
  8. +149
    -0
      Learun.Framework.Ultimate V7/Learun.Application.Web/Views/Login/ForgotPassword.cshtml
  9. +179
    -0
      Learun.Framework.Ultimate V7/Learun.Application.Web/Views/Login/ForgotPassword.js
  10. +5
    -0
      Learun.Framework.Ultimate V7/Learun.Application.WebApi/Learun.Application.WebApi.csproj
  11. +149
    -0
      Learun.Framework.Ultimate V7/Learun.Application.WebApi/Modules/UserApi.cs
  12. +168
    -0
      Learun.Framework.Ultimate V7/Learun.Application.WebApi/Modules/UsernologinApi.cs
  13. +15
    -0
      Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Util/Learun.Util/Common/CommonHelper.cs
  14. +14
    -0
      Learun.Framework.Ultimate V7/LearunApp-2.2.0/pages.json
  15. +150
    -0
      Learun.Framework.Ultimate V7/LearunApp-2.2.0/pages/forgotPassword.vue
  16. +14
    -1
      Learun.Framework.Ultimate V7/LearunApp-2.2.0/pages/login.vue
  17. +4
    -0
      Learun.Framework.Ultimate V7/LearunApp-2.2.0/pages/my.vue
  18. +121
    -0
      Learun.Framework.Ultimate V7/LearunApp-2.2.0/pages/my/changePhone.vue

+ 44
- 0
Learun.Framework.Ultimate V7/Learun.Application.Organization/User/UserBLL.cs 查看文件

@@ -382,6 +382,27 @@ namespace Learun.Application.Organization
}
}
}

public UserEntity GetEntityByMobile(string mobile)
{
try
{
UserEntity userEntity;
userEntity = userService.GetEntityByMobile(mobile);
return userEntity;
}
catch (Exception ex)
{
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowBusinessException(ex);
}
}
}
/// <summary>
/// 获取实体,通过用户账号
/// </summary>
@@ -1060,6 +1081,29 @@ namespace Learun.Application.Organization
}
}
}
/// <summary>
/// 修改手机号
/// </summary>
/// <param name="keyValue"></param>
/// <param name="mobile"></param>
public void UpdateMobile(string keyValue, string mobile)
{
try
{
userService.UpdateMobile(keyValue, mobile);
}
catch (Exception ex)
{
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowBusinessException(ex);
}
}
}
#endregion

#region 验证数据


+ 5
- 0
Learun.Framework.Ultimate V7/Learun.Application.Organization/User/UserEntity.cs 查看文件

@@ -240,6 +240,11 @@ namespace Learun.Application.Organization
/// </summary>
[Column("F_MODIFYPWDDATE")]
public DateTime? F_ModifyPwdDate { get; set; }
/// <summary>
/// 是否已登录标记
/// </summary>
[Column("F_HAVELOGMARK")]
public bool? F_HaveLogMark { get; set; }
#endregion

#region 扩展操作


+ 8
- 0
Learun.Framework.Ultimate V7/Learun.Application.Organization/User/UserIBLL.cs 查看文件

@@ -69,6 +69,8 @@ namespace Learun.Application.Organization
/// </summary>
/// <returns></returns>
void GetExportListOfStudent();

UserEntity GetEntityByMobile(string mobile);
/// <summary>
/// 获取实体,通过用户账号
/// </summary>
@@ -153,6 +155,12 @@ namespace Learun.Application.Organization
/// 解绑微信
/// </summary>
void DoUnbundWeiXin(string keyValue);
/// <summary>
/// 修改手机号
/// </summary>
/// <param name="keyValue"></param>
/// <param name="mobile"></param>
void UpdateMobile(string keyValue, string mobile);
#endregion

#region 验证数据


+ 55
- 0
Learun.Framework.Ultimate V7/Learun.Application.Organization/User/UserService.cs 查看文件

@@ -26,6 +26,32 @@ namespace Learun.Application.Organization
#endregion

#region 获取数据
public UserEntity GetEntityByMobile(string mobile)
{
try
{
var strSql = new StringBuilder();
strSql.Append("SELECT ");
strSql.Append(fieldSql);
strSql.Append(" FROM LR_Base_User t ");
strSql.Append(" WHERE t.F_Mobile = @account AND t.F_DeleteMark = 0 ");
return this.BaseRepository().FindEntity<UserEntity>(strSql.ToString(), new
{
account = mobile
});
}
catch (Exception ex)
{
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowServiceException(ex);
}
}
}
/// <summary>
/// 获取实体,通过用户账号
/// </summary>
@@ -833,6 +859,35 @@ namespace Learun.Application.Organization
}
}
}
/// <summary>
/// 修改手机号
/// </summary>
/// <param name="keyValue"></param>
/// <param name="mobile"></param>
public void UpdateMobile(string keyValue, string mobile)
{
try
{
var userEntity = this.BaseRepository().FindEntity<UserEntity>(keyValue);
if (userEntity != null)
{
userEntity.F_Mobile = mobile;
userEntity.Modify(keyValue);
this.BaseRepository().Update(userEntity);
}
}
catch (Exception ex)
{
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowServiceException(ex);
}
}
}

public void UpdateIp(string ip, string id)
{


+ 119
- 0
Learun.Framework.Ultimate V7/Learun.Application.Web/Controllers/LoginController.cs 查看文件

@@ -17,6 +17,10 @@ using System.Web;
using Quanjiang.DigitalScholl.WebLicense;
using Learun.Application.TwoDevelopment.EducationalAdministration;
using Newtonsoft.Json;
using Quanjiang.DigitalScholl.SendSms;
using Learun.Cache.Factory;
using Learun.Cache.Base;
using System.Collections.Generic;

namespace Learun.Application.Web.Controllers
{
@@ -38,6 +42,8 @@ namespace Learun.Application.Web.Controllers
private LoginModelIBLL loginModelIbll = new LoginModelBLL();
private AnnexesFileIBLL annexesFileIbll = new AnnexesFileBLL();
WeChatDevelopIBLL weChatDevelopIbll = new WeChatDevelopBLL();
private readonly ISms aliyunSms = new AliyunSms();
private ICache redisCache = CacheFactory.CaChe();
#endregion

#region 视图功能
@@ -1010,6 +1016,119 @@ namespace Learun.Application.Web.Controllers

#endregion

#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>("sendcodeinpc_" + 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>("sendcodeinpc_" + 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("验证失败,验证码错误或已失效。");
}
}

#endregion

/// <summary>
/// 获取IP
/// </summary>


+ 6
- 0
Learun.Framework.Ultimate V7/Learun.Application.Web/Learun.Application.Web.csproj 查看文件

@@ -4371,6 +4371,7 @@
<Content Include="Views\Login\Default\Index.css" />
<Content Include="Views\Login\Default\Index.js" />
<Content Include="Views\Login\Default\qrcode.min.js" />
<Content Include="Views\Login\ForgotPassword.js" />
<Content Include="Views\Login\images\login1.png" />
<Content Include="Views\Login\images\loginBg.jpg" />
<Content Include="Views\Login\PageFive\IndexWxLogin.js" />
@@ -7332,6 +7333,10 @@
<Project>{1d192591-b85a-41db-ae3a-4bf9765786c1}</Project>
<Name>Learun.Workflow.Engine</Name>
</ProjectReference>
<ProjectReference Include="..\Quanjiang.DigitalScholl.SendSms\Quanjiang.DigitalScholl.SendSms.csproj">
<Project>{55F0F08D-2A9F-489A-BE1B-2EEAE80687E6}</Project>
<Name>Quanjiang.DigitalScholl.SendSms</Name>
</ProjectReference>
<ProjectReference Include="..\Quanjiang.DigitalScholl.WebLicense\Quanjiang.DigitalScholl.WebLicense.csproj">
<Project>{4D841EAD-3FD8-4FAC-BC67-C4CE6C0D1181}</Project>
<Name>Quanjiang.DigitalScholl.WebLicense</Name>
@@ -8431,6 +8436,7 @@
<None Include="Properties\PublishProfiles\FolderProfile8.pubxml" />
<None Include="Properties\PublishProfiles\FolderProfile9.pubxml" />
<None Include="Properties\PublishProfiles\learunadms6.1.pubxml" />
<Content Include="Views\Login\ForgotPassword.cshtml" />
</ItemGroup>
<ItemGroup>
<WCFMetadata Include="Connected Services\" />


+ 2
- 0
Learun.Framework.Ultimate V7/Learun.Application.Web/Views/Login/Default.cshtml 查看文件

@@ -99,6 +99,8 @@

<!-- <div class="lr-login-weixin" style="font-size: 12px;margin-top: 15px;text-align: right;padding-right: 71px;"><a href="https://open.weixin.qq.com/connect/qrconnect?appid=wxd75b6651c86f816b&redirect_uri=http%3a%2f%2fwww.learun.cn&response_type=code&scope=snsapi_login&state=STATE#wechat_redirect">微信登录</a></div> -->
<div class="lr-login-version">
<a style="float: left;font-family: PingFangSC-Regular;font-size: 12px;color: #3298DC;margin-right:20px;" href="/Login/ForgotPassword">忘记密码?</a>

@if (ViewBag.TeachSwitch)
{
<a style="float: left;font-family: PingFangSC-Regular;font-size: 12px;color: #3298DC;" href="/EducationalAdministration/EmpInfoEnternal/FormAdd">教师注册</a>


+ 149
- 0
Learun.Framework.Ultimate V7/Learun.Application.Web/Views/Login/ForgotPassword.cshtml 查看文件

@@ -0,0 +1,149 @@
<!DOCTYPE html>
<html lang="zh-cn">
<head>
<meta name=”renderer” content=”webkit|ie-comp|ie-stand” />
<meta name="viewport" content="width=device-width" />
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta http-equiv="X-UA-Compatible" content="chrome=1,IE=edge">

<link rel="icon" href="~/favicon.ico">
<title>数字化校园 - 登录页面</title>
<style>
/* for Chrome */
body::-webkit-scrollbar {
display: none;
}

.lr-login-logo .lr-login-title:before {
background-color: transparent !important
}

.lr-login-footer .OnlineUserNumBox {
float: right;
}

.lr-login-footer > p {
width: 880px;
margin: auto;
}

.tips {
position: absolute;
left: 50%;
bottom: 35px;
color: #fff;
font-size: 13px;
margin-left: -91px;
}

.tips > * {
display: inline-block;
vertical-align: middle;
}

.tips img {
margin-right: 8px
}

.titleImg {
border: none !important;
}

.titleImg img {
width: 35px !important;
}

.wxLogin {
color: #53b947 !important;
}

.titleImg {
color: #da9835 !important;
}

.wxLogin img {
width: 35px !important;
top: -2px;
}

.downBox {
width: 100%;
height: 60px;
/*background: red;*/
position: absolute;
bottom: -40px;
right: 0 color:#fff !important;
}

.downBox a {
color: #fff !important;
border: 1px solid #fff
}

.codeBtn {
border: 1px solid #DCDFE6;
padding: 6px 10px;
color: #606266;
font-size: 12px;
cursor: pointer;
border-radius: 2px;
position: absolute;
left: 260px;
top: 10px;
}

.codeBtn:hover {
border-color: #CBCFD5;
}
</style>
</head>

<body>
@Html.AppendCssFile("/Views/Login/Default/Index.css")
<link href="~/Content/css/process.css" rel="stylesheet" />
<!-- <img src="~/Content/images/Logins/loginBg.jpg" /> -->
<input id="errornum" type="hidden" value="@ViewBag.errornum" />
<div class="lr-login-body">
<div class="lr-login-logo">
<div class="lr-login-title" style="left: 0%;margin-left: 0;width: 100%;text-align: center;">
<img src="/Content/images/logins/login4.png" alt="">
</div>
</div>
<div class="lr-login-middle" style="height:480px">
<img src="~/Content/images/logins/login2.png" />
<!--修改密码框-->
<div class="lr-login-main lr-login-normal" id="updatepwBox">
<!--表单-->
<div class="lr-login-bypsw">
<div class="error_info">*&nbsp;<span></span></div>
<div class="lr-login-input">
<img class="inp_icon" src="~/Content/images/Login/default_account0.png" alt=""> <input id="phone" type="text" placeholder="请输入用户绑定的手机号">
</div>
<div class="lr-login-input">
<img class="inp_icon" src="~/Content/images/Login/default_psw0.png" alt=""><input id="newpassword" type="password" placeholder="请输入新密码">
<span id="psw_change" class="psw_change"></span>
</div>
<div class="lr-login-input">
<img class="inp_icon" src="~/Content/images/Login/default_psw0.png" alt=""><input id="newpassword1" type="password" placeholder="请再次输入新密码">
<span id="psw_change" class="psw_change"></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>
<a href="Javascript:void(0)" id="goLogin" class="down titleImg" title="去登录">
<img src="~/Content/images/LoginPage/title.jpg" alt="" /> <span>去登录</span>
</a>
</div>
</div>
<img id="loginFoot" src="~/Content/images/logins/login1.png" alt="">
<script src="~/Content/jquery/jquery-1.10.2.min.js"></script>
<script src="~/Content/jquery/jquery.md5.min.js"></script>
<script src="~/Content/jquery/qrcode.min.js"></script>
<script src="~/Content/jquery/plugin/layer/layer.js"></script>
@Html.AppendJsFile("/Views/Login/ForgotPassword.js")
</body>
</html>

+ 179
- 0
Learun.Framework.Ultimate V7/Learun.Application.Web/Views/Login/ForgotPassword.js 查看文件

@@ -0,0 +1,179 @@
/*!
* 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园(http://www.learun.cn)
* Copyright (c) 2013-2018 北京泉江科技有限公司
* 创建人:陈彬彬
* 日 期:2017.03.08
* 描 述:登录页面前端脚本
*/
(function ($) {
"use strict";
var codeType = 'forgetpwd', hasSendCode = false, time = 0, timeT = '', isSending = false;
var lrPage = {
init: function () {
lrPage.bind();
},
bind: function () {
// 去登陆
$('#goLogin').click(function () {
window.location.href = "/";
})

// 确认修改按钮
$("#confirmUpdate").on('click', function () {
lrPage.confirmUpdate();
});

// 发送验证码事件
$("#sendCode").on('click', function () {
lrPage.sendCode();
});

$('.psw_change').css({
'background': 'url(' + '/Content/images/Login/psw0.png) no-repeat center center'
});

//点击密码icon 显示/隐藏
$('.psw_change').click(function (event) {
var event = event || window.event;
event.stopPropagation();
var $this = $(this);
$this.toggleClass('psw_show');
//如果当前隐藏 变显示
if ($this.hasClass('psw_show')) {
$this.css({
'background': 'url(' + '/Content/images/Login/psw1.png) no-repeat center center'
});
$this.prev().attr('type', 'text');
} else {
$this.css(
'background', 'url(/Content/images/Login/psw0.png) no-repeat center center'
);
$this.prev().attr('type', 'password');
}
});
},
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;
let phone = $('#phone').val()
if (!phone) {
$('#updatepwBox .error_info span').text('请输入手机号')
$('#updatepwBox .error_info').show()
return
} else if (!/^1[0-9]{10}$/.test(phone)) {
$('#updatepwBox .error_info span').text('手机号格式不正确')
$('#updatepwBox .error_info').show()
return
}
$('#updatepwBox .error_info').hide()
isSending = true
$.ajax({
url: "/Login/Sendcode",
data: { phone, 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 phone = $('#phone').val()
let verifycode = $('#verifycode').val()
let newpassword = $('#newpassword').val()
let newpassword1 = $('#newpassword1').val()
if (!phone) {
$('#updatepwBox .error_info span').text('请输入手机号')
$('#updatepwBox .error_info').show()
return
} else if (!/^1[0-9]{10}$/.test(phone)) {
$('#updatepwBox .error_info span').text('手机号格式不正确')
$('#updatepwBox .error_info').show()
return
}

if (!newpassword) {
$('#updatepwBox .error_info span').text('请输入新密码')
$('#updatepwBox .error_info').show()
return
}
if (!/^(?=.*[0-9])(?=.*[A-Z])(?=.*[a-z])(?=.*[!@#$%^&*,\.])[0-9a-zA-Z!@#$%^&*,\.]{8,20}$/.test(newpassword)) {
$('#updatepwBox .error_info span').text('您的密码不满足强度要求,请重新输入')
$('#updatepwBox .error_info').show()
return
}
if (!newpassword1) {
$('#updatepwBox .error_info span').text('请再次输入新密码')
$('#updatepwBox .error_info').show()
return
}
if (newpassword != newpassword1) {
$('#updatepwBox .error_info span').text('两次密码输入不一致')
$('#updatepwBox .error_info').show()
return
}

if (!verifycode) {
$('#updatepwBox .error_info span').text('请输入验证码')
$('#updatepwBox .error_info').show()
return
}
$('#updatepwBox .error_info').hide()
lrPage.updating(true);
$.ajax({
url: "/Login/ForgotPasswordHandle",
data: { phone, verifycode, codeType, newpassword: $.md5(newpassword) },
dataType: 'json',
type: "post",
success: (res) => {
if (res.code == 200) {
$('#updatepwBox .error_info span').text('修改密码成功')
$('#updatepwBox .error_info').show()
setTimeout(() => {
window.location.href = "/";
}, 1500)
} else {
lrPage.updating(false);
$('#updatepwBox .error_info span').text(res.info)
$('#updatepwBox .error_info').show()
}
}
});
}
};
$(function () {
lrPage.init();
});
})(window.jQuery)

+ 5
- 0
Learun.Framework.Ultimate V7/Learun.Application.WebApi/Learun.Application.WebApi.csproj 查看文件

@@ -220,6 +220,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="Bootstraper.cs" />
<Compile Include="Modules\UsernologinApi.cs" />
<Compile Include="Modules\VisitmanageApi.cs" />
<Compile Include="Modules\LessonInfoOfElectiveOnlineApi.cs" />
<Compile Include="Modules\RepairReport\RepairReportTeacherApi.cs" />
@@ -396,6 +397,10 @@
<Project>{1D192591-B85A-41DB-AE3A-4BF9765786C1}</Project>
<Name>Learun.Workflow.Engine</Name>
</ProjectReference>
<ProjectReference Include="..\Quanjiang.DigitalScholl.SendSms\Quanjiang.DigitalScholl.SendSms.csproj">
<Project>{55F0F08D-2A9F-489A-BE1B-2EEAE80687E6}</Project>
<Name>Quanjiang.DigitalScholl.SendSms</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Folder Include="App_Data\" />


+ 149
- 0
Learun.Framework.Ultimate V7/Learun.Application.WebApi/Modules/UserApi.cs 查看文件

@@ -1,9 +1,13 @@
using Learun.Application.Base.SystemModule;
using Learun.Application.Organization;
using Learun.Application.TwoDevelopment.EducationalAdministration;
using Learun.Cache.Base;
using Learun.Cache.Factory;
using Learun.Util;
using Learun.Util.Operat;
using Nancy;
using Quanjiang.DigitalScholl.SendSms;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
@@ -30,6 +34,7 @@ namespace Learun.Application.WebApi
Post["/modifypwiden"] = ModifyPasswordiden;
Post["/unbundWeiXin"] = DoUnbundWeiXin;
Post["/loginbyIdCard"] = LoginByIdCard;
Post["/updateMobile"] = UpdateMobile;

Get["/info"] = Info;
Get["/map"] = GetMap;
@@ -43,9 +48,106 @@ namespace Learun.Application.WebApi
private RoleIBLL roleIBLL = new RoleBLL();
private StuInfoBasicIBLL stuInfoBasicIBLL = new StuInfoBasicBLL();
CdMajorIBLL majorIbll = new CdMajorBLL();
private readonly ISms aliyunSms = new AliyunSms();
private ICache redisCache = CacheFactory.CaChe();



/// <summary>
/// 短信验证码校验
/// </summary>
/// <param name="_"></param>
/// <returns></returns>
private Response LoginCodeVerify(dynamic _)
{
MobileVerify mobileVerify = this.GetReqData<MobileVerify>();
if (string.IsNullOrEmpty(mobileVerify.codeType))
{
return Fail("未指定短信类型。");
}
if (string.IsNullOrEmpty(mobileVerify.mobile))
{
return Fail("手机号不能为空。");
}
var code = redisCache.Read<string>("sendcodeinapp_" + mobileVerify.codeType + "_" + mobileVerify.mobile, CacheId.sms);
if (!string.IsNullOrEmpty(code) && code == mobileVerify.verifycode)
{
return Success("验证成功。");
}
else
{
return Fail("验证失败,验证码错误或已失效。");
}

}
/// <summary>
/// 发送短信验证码
/// </summary>
/// <param name="_"></param>
/// <returns></returns>
private Response Sendcode(dynamic _)
{
LoginModel loginModel = this.GetReqData<LoginModel>();
if (string.IsNullOrEmpty(loginModel.codeType))
{
return Fail("未指定短信类型。");
}
UserEntity userEntity = null;
userEntity = userIBLL.GetEntityByUserId(userInfo.userId);
if (userEntity == null)
{
return Fail("用户不存在!");
}
if (loginModel.codeType == "unbindwx")
{
if (string.IsNullOrEmpty(userEntity.F_Mobile))
{
return Fail("用户手机号不存在!");
}
loginModel.username = userEntity.F_Mobile;
}
if (string.IsNullOrEmpty(loginModel.username))
{
return Fail("手机号不能为空。");
}
if (!CommonHelper.IsValidMobile(loginModel.username))
{
return Fail("手机号格式不正确!");
}
var listStr = new List<string>();
var result = aliyunSms.SendSmsToSingle(loginModel.username, SmsType.LoginBind, listStr);
if (result.Result.code == "OK")
{
redisCache.Write<string>("sendcodeinapp_" + loginModel.codeType + "_" + loginModel.username, result.Result.randomNum, new TimeSpan(0, 5, 0), CacheId.sms);
//日志
LogEntity logEntity = new LogEntity();
logEntity.F_CategoryId = 3;
logEntity.F_SourceObjectId = loginModel.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 = "短信发送:" + loginModel.username + " 验证码:" + result.Result.randomNum;
logEntity.WriteLog();
return Success("短信发送成功:" + result.Result.message);
}
else
{
LogEntity logEntity = new LogEntity();
logEntity.F_CategoryId = 4;
logEntity.F_SourceObjectId = loginModel.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 = "短信发送:" + loginModel.username;
logEntity.WriteLog();
return Fail("短信发送失败:" + result.Result.message + result.Result.errorType);
}
}

/// <summary>
/// 登录接口
/// </summary>
@@ -284,6 +386,34 @@ namespace Learun.Application.WebApi

}
/// <summary>
/// 修改手机号
/// </summary>
/// <param name="_"></param>
/// <returns></returns>
private Response UpdateMobile(dynamic _)
{
MobileVerify mobileVerify = this.GetReqData<MobileVerify>();
if (string.IsNullOrEmpty(mobileVerify.codeType))
{
return Fail("未指定短信类型。");
}
if (string.IsNullOrEmpty(mobileVerify.mobile))
{
return Fail("手机号不能为空。");
}
var code = redisCache.Read<string>("sendcodeinapp_" + mobileVerify.codeType + "_" + mobileVerify.mobile, CacheId.sms);
if (!string.IsNullOrEmpty(code) && code == mobileVerify.verifycode)
{
//return Success("验证成功。");
userIBLL.UpdateMobile(userInfo.userId, mobileVerify.mobile);
return Success("修改成功");
}
else
{
return Fail("验证失败,验证码错误或已失效。");
}
}
/// <summary>
/// 获取所有员工账号列表
/// </summary>
/// <param name="_"></param>
@@ -488,12 +618,21 @@ namespace Learun.Application.WebApi
/// </summary>
public string deviceid { get; set; }
public string openid { get; set; }
/// <summary>
/// 发送短信类型:忘记密码forgetpwd,首次登录firstlogin,绑定微信bindwx,解绑微信unbindwx,修改手机号modifymobile,;
/// </summary>
public string codeType { get; set; }
/// <summary>
/// 短信验证码
/// </summary>
public string verifycode { get; set; }
}
/// <summary>
/// 修改密码
/// </summary>
public class ModifyModel
{
public string phone { set; get; }
/// <summary>
/// 新密码
/// </summary>
@@ -504,6 +643,16 @@ namespace Learun.Application.WebApi
public string oldpassword { get; set; }
}

public class MobileVerify
{
public string mobile { get; set; }
public string verifycode { get; set; }
/// <summary>
/// 发送短信类型
/// </summary>
public string codeType { get; set; }
}

public class UserAccount
{


+ 168
- 0
Learun.Framework.Ultimate V7/Learun.Application.WebApi/Modules/UsernologinApi.cs 查看文件

@@ -0,0 +1,168 @@
using System;
using Learun.Application.Base.SystemModule;
using Learun.Application.Organization;
using Learun.Application.TwoDevelopment.EducationalAdministration;
using Learun.Util;
using Learun.Util.Operat;
using Nancy;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using Learun.Application.TwoDevelopment.LR_Desktop;
using Learun.Cache.Base;
using Learun.Cache.Factory;
using Quanjiang.DigitalScholl.SendSms;

namespace Learun.Application.WebApi
{
/// <summary>
/// 版 本 Learun-ADMS V7.0.0 数字化智慧校园
/// Copyright (c) 2013-2018 北京泉江科技有限公司
/// 创建人:数字化智慧校园-框架开发组
/// 日 期:2017.05.12
/// 描 述:用户信息
/// </summary>
public class UsernologinApi : BaseNoLoginApi
{
/// <summary>
/// 注册接口
/// </summary>
public UsernologinApi()
: base("/learun/adms/usernologin")
{
Post["/logincodeverify"] = LoginCodeVerify;
Post["/sendcode"] = Sendcode;
Post["/forgetpass"] = forgetpass;

}
private UserIBLL userIBLL = new UserBLL();
private PostIBLL postIBLL = new PostBLL();
private RoleIBLL roleIBLL = new RoleBLL();
private StuInfoBasicIBLL stuInfoBasicIBLL = new StuInfoBasicBLL();
private EmpInfoIBLL empInfoIBLL = new EmpInfoBLL();
CdMajorIBLL majorIbll = new CdMajorBLL();
private readonly ISms aliyunSms = new AliyunSms();
private ICache redisCache = CacheFactory.CaChe();
private Sys_UpdateRecordIBLL sysUpdateRecordIbll = new Sys_UpdateRecordBLL();
AnnexesFileIBLL annexesFileIbll = new AnnexesFileBLL();



/// <summary>
/// 短信验证码校验
/// </summary>
/// <param name="_"></param>
/// <returns></returns>
private Response LoginCodeVerify(dynamic _)
{
MobileVerify mobileVerify = this.GetReqData<MobileVerify>();
if (string.IsNullOrEmpty(mobileVerify.codeType))
{
return Fail("未指定短信类型。");
}
if (string.IsNullOrEmpty(mobileVerify.mobile))
{
return Fail("手机号不能为空。");
}
var code = redisCache.Read<string>("sendcodeinapp_" + mobileVerify.codeType + "_" + mobileVerify.mobile, CacheId.sms);
if (!string.IsNullOrEmpty(code) && code == mobileVerify.verifycode)
{
return Success("验证成功。");
}
else
{
return Fail("验证失败,验证码错误或已失效。");
}

}
/// <summary>
/// 发送短信验证码
/// </summary>
/// <param name="_"></param>
/// <returns></returns>
private Response Sendcode(dynamic _)
{
LoginModel loginModel = this.GetReqData<LoginModel>();
if (string.IsNullOrEmpty(loginModel.codeType))
{
return Fail("未指定短信类型。");
}
UserEntity userEntity = null;
if (loginModel.codeType == "bindwx")
{
userEntity = userIBLL.GetEntityByAccount(loginModel.username);
}
else
{
userEntity = userIBLL.GetEntityByMobile(loginModel.username);
}
if (userEntity == null)
{
return Fail("用户不存在!");
}
if (string.IsNullOrEmpty(userEntity.F_Mobile))
{
return Fail("用户手机号不存在!");
}
if (!CommonHelper.IsValidMobile(userEntity.F_Mobile))
{
return Fail("手机号格式不正确!");
}
if (loginModel.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>("sendcodeinapp_" + loginModel.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 = loginModel.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 = loginModel.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="_"></param>
/// <returns></returns>
private Response forgetpass(dynamic _)
{
ModifyModel modifyModel = this.GetReqData<ModifyModel>();

UserEntity userEntity = userIBLL.GetEntityByMobile(modifyModel.phone);
if (userEntity == null)
{
return Fail("用户不存在");
}
userIBLL.setPassword(userEntity.F_UserId, modifyModel.newpassword);

return Success("密码修改成功");
}

}
}

+ 15
- 0
Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Util/Learun.Util/Common/CommonHelper.cs 查看文件

@@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
using System.Text.RegularExpressions;

namespace Learun.Util
{
@@ -145,5 +146,19 @@ namespace Learun.Util
return str;
}
#endregion

#region 验证字符串的格式

/// <summary>
/// 是否是手机格式
/// </summary>
/// <param name="mobile"></param>
/// <returns></returns>
public static bool IsValidMobile(string mobile)
{
return Regex.IsMatch(mobile, @"^(\+\d{2,3}\-)?\d{11}$");
}

#endregion
}
}

+ 14
- 0
Learun.Framework.Ultimate V7/LearunApp-2.2.0/pages.json 查看文件

@@ -66,6 +66,13 @@
"disableScroll": true
}
},
{
"path": "pages/forgotPassword",
"style": {
"navigationBarTitleText": "忘记密码",
"disableScroll": true
}
},

// 消息(tabBar #2)
{
@@ -150,6 +157,13 @@
"backgroundColor": "#FFFFFF"
}
},
{
"path": "pages/my/changePhone",
"style": {
"navigationBarTitleText": "修改手机号",
"backgroundColor": "#FFFFFF"
}
},
// 统一应用
{
"path": "pages/SSO/MyApp/list",


+ 150
- 0
Learun.Framework.Ultimate V7/LearunApp-2.2.0/pages/forgotPassword.vue 查看文件

@@ -0,0 +1,150 @@
<template>
<view class="page">
<view class="content" v-if="type == 'sendCode'">
<l-input v-model="phone" placeholder="请输入用户绑定的手机号" left>
<l-icon slot="title" type="phone" />
</l-input>
<view class="btn" @click="sendCode">发送验证码</view>
</view>
<view class="content" v-if="type == 'checkCode'">
<l-input v-model="phone" placeholder="请输入用户绑定的手机号" left disabled>
<l-icon slot="title" type="phone" />
</l-input>
<l-input v-model="verifycode" placeholder="请输入验证码" left password>
<l-icon slot="title" type="lock" />
</l-input>
<view style="margin-top: 4px;color: color: #606266;">
未收到验证码?<text :style="{color:time==0?'#409EFF':'#999'}" @click="()=>{if(time==0)type='sendCode'}">重新发送</text>
{{time?'( '+time+ 's'+' )' :''}}
</view>
<view class="btn" @click="checkverifycode">下一步</view>
</view>
<view class="content" v-if="type == 'setPassword'">
<l-input v-model="phone" placeholder="请输入用户绑定的手机号" left disabled>
<l-icon slot="title" type="phone" />
</l-input>
<l-input v-model="form.newpassword" placeholder="请输入新密码" left password>
<l-icon slot="title" type="lock" />
</l-input>
<l-input v-model="form.newpassword1" placeholder="请再次输入新密码" left password>
<l-icon slot="title" type="lock" />
</l-input>
<view class="btn" @click="setPassword">确认修改</view>
</view>
</view>
</template>

<script>
// import moment from 'moment';
export default{
data() {
return {
type:'sendCode',
phone:'',
verifycode:'',
time: 0,
timeT: '',
form:{
newpassword:'',
newpassword1:'',
},
codeType:'forgetpwd',
}
},
destroyed() {
this.timeT && clearInterval(this.timeT)
},
methods:{
// 发送验证码
sendCode(){
if(!this.phone){
this.TOAST('请输入手机号!')
return
}else if(!/^1[0-9]{10}$/.test(this.phone)){
this.TOAST('手机号格式不正确!')
return
}
this.LOADING()
this.HTTP_POST('learun/adms/usernologin/sendcode',{username:this.phone,codeType:this.codeType}).then(res=>{
this.HIDE_LOADING()
if(!res){
return
}
this.type = 'checkCode'
this.time = 60
this.timeT = setInterval(() => {
this.time--
if (this.time == 0) {
clearInterval(this.timeT)
this.timeT = ''
return
}
}, 1000);
})
},
// 验证码校验
async checkverifycode() {
if (!this.verifycode) {
this.TOAST('请输入验证码');
return
}
this.LOADING('正在校验...')
let codeResult = await this.HTTP_POST('learun/adms/usernologin/logincodeverify', {
mobile: this.phone,
verifycode: this.verifycode,
codeType: this.codeType
})
this.HIDE_LOADING()
if(!codeResult)return
this.type = 'setPassword'
},
// 设置密码
async setPassword(){
if(!this.form.newpassword){
this.TOAST('请输入新密码');
return
}
if(!/^(?=.*[0-9])(?=.*[A-Z])(?=.*[a-z])(?=.*[!@#$%^&*,\.])[0-9a-zA-Z!@#$%^&*,\.]{8,20}$/.test(this.form.newpassword)){
this.TOAST('您的密码不满足强度要求,请重新输入');
return
}
if(!this.form.newpassword1){
this.TOAST('请再次输入新密码');
return
}
if(this.form.newpassword != this.form.newpassword1){
this.TOAST('两次密码输入不一致');
return
}
this.LOADING()
let res = await this.HTTP_POST('learun/adms/usernologin/forgetpass', {
newpassword:this.MD5(this.form.newpassword),
// this.MD5()
phone:this.phone
})
this.HIDE_LOADING()
if(!res)return
this.TOAST('修改成功')
setTimeout(()=>{
this.NAV_TO('/pages/login')
},500)
}
},
}
</script>

<style scoped>
.page {
height: 100vh;
width: 100%;
display: flex;
justify-content: center;
align-items: center;
}
.content{
width: 80%;
padding-bottom: 60px;
}
</style>

+ 14
- 1
Learun.Framework.Ultimate V7/LearunApp-2.2.0/pages/login.vue 查看文件

@@ -33,7 +33,9 @@
</l-input>
<l-button @click="login(null)" size="lg" color="blue" class="margin-top-sm block" block>登 录</l-button>
<l-button @click="signUp('/pages/wxLogin')" size="lg" color="blue" class="margin-top-sm block" block>微信登录</l-button>

<view class="otherLogin">
<navigator url="/pages/forgotPassword">忘记密码?</text></navigator>
</view>
<!-- 【仅小程序】一键登录按钮 -->
<!-- #ifdef MP -->
<l-button v-if="MPLogin" @click="login(PLATFORM)" size="lg" line="green" class="margin-top-sm block" block>
@@ -279,6 +281,17 @@ page {
margin-top: 20rpx;
}
}
.otherLogin{
display: flex;
justify-content: space-between;
margin-top: 4px;
color: #2e82ff;
.textBtn{
width: 100px;
color: #606266;
}
}

.more {
margin-top: 30rpx;


+ 4
- 0
Learun.Framework.Ultimate V7/LearunApp-2.2.0/pages/my.vue 查看文件

@@ -37,6 +37,10 @@
<image src="@/static/unbound.png" mode="" style="color: #0081ff;width: 14px;height: 14px;margin: 0 10px 0 5px;"></image>
解绑微信
</l-list-item>
<l-list-item @click="goTo('changePhone')" arrow>
<l-icon type="edit" color="blue" />
修改手机号
</l-list-item>
</l-list>

<!-- 关于菜单 -->


+ 121
- 0
Learun.Framework.Ultimate V7/LearunApp-2.2.0/pages/my/changePhone.vue 查看文件

@@ -0,0 +1,121 @@
<template>
<view class="page">
<view class="content">
<l-input v-model="phone" placeholder="请输入将绑定的手机号" left :disabled="hasSendCode">
<l-icon slot="title" type="phone" />
</l-input>
<view class="inputBtn">
<l-input v-model="verifycode" placeholder="请输入验证码" left>
<l-icon slot="title" type="lock" />
</l-input>
<view class="btn" @click="sendCode" v-if="!hasSendCode">
发送验证码
</view>
<view class="btn" @click="()=>{time==0&&sendCode()}" v-if="hasSendCode" :style="{opacity:time==0?1:0.5}">
<text>重新发送{{time?'( '+time+ 's'+' )' :''}}</text>
</view>
</view>
<view class="btn" style="width: 100%;margin-top: 24px;margin-bottom: 8px;" @click="changePhone">确认更换手机号</view>
</view>
</view>
</template>

<script>
export default{
data() {
return {
hasSendCode:false,
phone:'',
verifycode:'',
time: 0,
timeT: '',
codeType:'modifymobile',
}
},
destroyed() {
this.timeT && clearInterval(this.timeT)
},
methods:{
// 发送验证码
sendCode(){
if(!this.phone){
this.TOAST('请输入手机号!')
return
}else if(!/^1[0-9]{10}$/.test(this.phone)){
this.TOAST('手机号格式不正确!')
return
}
this.LOADING()
this.HTTP_POST('learun/adms/user/sendcode',{username:this.phone,codeType:this.codeType}).then(res=>{
this.HIDE_LOADING()
if(!res){
return
}
this.TOAST('短信已发送!')
this.hasSendCode = true
this.time = 60
this.timeT = setInterval(() => {
this.time--
if (this.time == 0) {
this.hasSendCode = false
clearInterval(this.timeT)
this.timeT = ''
return
}
}, 1000);
})
},
// 验证码校验
async changePhone() {
if(!this.phone){
this.TOAST('请输入手机号!')
return
}else if(!/^1[0-9]{10}$/.test(this.phone)){
this.TOAST('手机号格式不正确!')
return
}
if (!this.verifycode) {
this.TOAST('请输入验证码');
return
}
this.LOADING('正在修改...')
let res = await this.HTTP_POST('learun/adms/user/updateMobile',{
mobile: this.phone,
verifycode: this.verifycode,
codeType: this.codeType
})
this.HIDE_LOADING()
if(!res)return
this.TOAST('修改手机号成功!');
setTimeout(()=>{
this.NAV_BACK()
},500)
},
},
}
</script>

<style scoped>
.page {
height: 100vh;
width: 100%;
display: flex;
justify-content: center;
align-items: center;
}
.content{
width: 80%;
padding-bottom: 60px;
text-align: center;
}
.inputBtn{
background-color: #fff;
display: flex;
align-items: center;
.btn{
margin: 0;
}
}
</style>

Loading…
取消
儲存