Kaynağa Gözat

【增加】移动端登录页:忘记密码功能;

西昌分支
dyy 4 ay önce
ebeveyn
işleme
32d4f471c1
9 değiştirilmiş dosya ile 405 ekleme ve 4 silme
  1. +21
    -0
      Learun.Framework.Ultimate V7/Learun.Application.Organization/User/UserBLL.cs
  2. +2
    -0
      Learun.Framework.Ultimate V7/Learun.Application.Organization/User/UserIBLL.cs
  3. +26
    -0
      Learun.Framework.Ultimate V7/Learun.Application.Organization/User/UserService.cs
  4. +5
    -0
      Learun.Framework.Ultimate V7/Learun.Application.WebApi/Learun.Application.WebApi.csproj
  5. +31
    -0
      Learun.Framework.Ultimate V7/Learun.Application.WebApi/Modules/UserApi.cs
  6. +147
    -0
      Learun.Framework.Ultimate V7/Learun.Application.WebApi/Modules/UsernologinApi.cs
  7. +14
    -0
      Learun.Framework.Ultimate V7/LearunApp-2.2.0/pages.json
  8. +148
    -0
      Learun.Framework.Ultimate V7/LearunApp-2.2.0/pages/forgotPassword.vue
  9. +11
    -4
      Learun.Framework.Ultimate V7/LearunApp-2.2.0/pages/login.vue

+ 21
- 0
Learun.Framework.Ultimate V7/Learun.Application.Organization/User/UserBLL.cs Dosyayı Görüntüle

@@ -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>


+ 2
- 0
Learun.Framework.Ultimate V7/Learun.Application.Organization/User/UserIBLL.cs Dosyayı Görüntüle

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

UserEntity GetEntityByMobile(string mobile);
/// <summary>
/// 获取实体,通过用户账号
/// </summary>


+ 26
- 0
Learun.Framework.Ultimate V7/Learun.Application.Organization/User/UserService.cs Dosyayı Görüntüle

@@ -27,6 +27,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>


+ 5
- 0
Learun.Framework.Ultimate V7/Learun.Application.WebApi/Learun.Application.WebApi.csproj Dosyayı Görüntüle

@@ -267,6 +267,7 @@
<Compile Include="Modules\LR_Crm\CrmOrder.cs" />
<Compile Include="Modules\LR_Crm\Invoice.cs" />
<Compile Include="Modules\TimeTable.cs" />
<Compile Include="Modules\UsernologinApi.cs" />
<Compile Include="Modules\UtilityApi.cs" />
<Compile Include="Modules\WeixinApi.cs" />
<Compile Include="Modules\WorkFlowApi.cs" />
@@ -361,6 +362,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\" />


+ 31
- 0
Learun.Framework.Ultimate V7/Learun.Application.WebApi/Modules/UserApi.cs Dosyayı Görüntüle

@@ -1,6 +1,8 @@
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;
@@ -26,6 +28,7 @@ namespace Learun.Application.WebApi
: base("/learun/adms/user")
{
Post["/login"] = Login;
Post["/logincodeverify"] = LoginCodeVerify;
Post["/modifypw"] = ModifyPassword;
Post["/modifypwiden"] = ModifyPasswordiden;
Post["/unbundWeiXin"] = DoUnbundWeiXin;
@@ -43,9 +46,30 @@ namespace Learun.Application.WebApi
private RoleIBLL roleIBLL = new RoleBLL();
private StuInfoBasicIBLL stuInfoBasicIBLL = new StuInfoBasicBLL();
CdMajorIBLL majorIbll = new CdMajorBLL();
private ICache redisCache = CacheFactory.CaChe();



/// <summary>
/// 登录二次短信验证
/// </summary>
/// <param name="_"></param>
/// <returns></returns>
private Response LoginCodeVerify(dynamic _)
{
MobileVerify mobileVerify = this.GetReqData<MobileVerify>();
var code = redisCache.Read<string>("studentuserlogin_" + mobileVerify.mobile);
if (!string.IsNullOrEmpty(code) && code == mobileVerify.verifycode)
{
return Success("验证成功。");
}
else
{
return Fail("验证失败,验证码错误或已失效。");
}

}

/// <summary>
/// 登录接口
/// </summary>
@@ -491,6 +515,7 @@ namespace Learun.Application.WebApi
/// </summary>
public class ModifyModel
{
public string phone { set; get; }
/// <summary>
/// 新密码
/// </summary>
@@ -501,6 +526,12 @@ namespace Learun.Application.WebApi
public string oldpassword { get; set; }
}

public class MobileVerify
{
public string mobile { get; set; }
public string verifycode { get; set; }
}


public class UserAccount
{


+ 147
- 0
Learun.Framework.Ultimate V7/Learun.Application.WebApi/Modules/UsernologinApi.cs Dosyayı Görüntüle

@@ -0,0 +1,147 @@
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["/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 yixintongSms = new YixintongSms();
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>();
var code = redisCache.Read<string>("studentuserlogin_" + mobileVerify.mobile);
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>();
UserEntity userEntity = userIBLL.GetEntityByMobile(loginModel.username);
if (userEntity == null)
{
return Fail("用户不存在");
}
#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 = loginModel.username + "(" + userEntity.F_RealName + ")";
logEntity.F_OperateUserId = !string.IsNullOrEmpty(userEntity.F_UserId) ? userEntity.F_UserId : loginModel.username;
logEntity.F_Module = Config.GetValue("SoftName");
logEntity.F_Description = "移动端";
#endregion

string raRndNum = Learun.Util.CommonHelper.RndNum(6);
var listStr = new List<string>();
var str1 = $"欢迎使用智慧校园,您本次登录的验证码是 " + raRndNum + "。";
listStr.Add(str1);
var result = yixintongSms.SendSmsToSingle(userEntity.F_Mobile, SmsType.LoginBind, listStr);
if (result.Result.code == "0")
{
redisCache.Write<string>("studentuserlogin_" + userEntity.F_Mobile, raRndNum, new TimeSpan(0, 5, 0));
//日志
logEntity = new LogEntity();
logEntity.F_CategoryId = 3;
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;
logEntity.WriteLog();
return Success("短信发送成功:");// + result.Result.message);
}
else
{
logEntity = new LogEntity();
logEntity.F_CategoryId = 4;
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("密码修改成功");
}

}
}

+ 14
- 0
Learun.Framework.Ultimate V7/LearunApp-2.2.0/pages.json Dosyayı Görüntüle

@@ -68,6 +68,20 @@
"disableScroll": true
}
},
{
"path": "pages/forgotPassword",
"style": {
"navigationBarTitleText": "忘记密码",
"disableScroll": true
}
},
// {
// "path": "pages/firstLogin",
// "style": {
// "navigationBarTitleText": "首次登录",
// "disableScroll": true
// }
// },

// 消息(tabBar #2)
{


+ 148
- 0
Learun.Framework.Ultimate V7/LearunApp-2.2.0/pages/forgotPassword.vue Dosyayı Görüntüle

@@ -0,0 +1,148 @@
<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:'',
},
}
},
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}).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/user/logincodeverify', {
mobile: this.phone,
verifycode: this.verifycode
})
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>

+ 11
- 4
Learun.Framework.Ultimate V7/LearunApp-2.2.0/pages/login.vue Dosyayı Görüntüle

@@ -33,9 +33,13 @@
</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/weixinLogin" class="textBtn">新生首次登录</text></navigator>
</view> -->
<view class="otherLogin">
<!-- 首次身份证号登录 -->
<!-- <navigator url="/pages/weixinLogin" class="textBtn">新生首次登录</text></navigator> -->
<navigator url="/pages/forgotPassword">忘记密码?</text></navigator>
<!-- 首次手机号登录 -->
<navigator url="/pages/firstLogin">首次登录</text></navigator>
</view>
<!-- <l-button v-if="enableSignUp" @click="signUp('/pages/signup')" size="lg" line="blue" class="margin-top-sm block" block>
教师注册
@@ -274,7 +278,10 @@ page {
.otherLogin{
display: flex;
justify-content: flex-end;
justify-content: space-between;
margin-top: 4px;
// color: #606266;
color: #2e82ff;
.textBtn{
width: 100px;
color: #606266;


Yükleniyor…
İptal
Kaydet