Browse Source

微信快捷登录支持代码加入

大厂分支
liangkun 4 years ago
parent
commit
ce684524c6
24 changed files with 1117 additions and 2 deletions
  1. +39
    -0
      Learun.Framework.Ultimate V7/Learun.Application.Organization/User/UserBLL.cs
  2. +3
    -0
      Learun.Framework.Ultimate V7/Learun.Application.Organization/User/UserEntity.cs
  3. +2
    -0
      Learun.Framework.Ultimate V7/Learun.Application.Organization/User/UserIBLL.cs
  4. +48
    -0
      Learun.Framework.Ultimate V7/Learun.Application.Organization/User/UserService.cs
  5. +3
    -1
      Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/TeachSwitch/Index.js
  6. +111
    -0
      Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LR_Desktop/Controllers/WeChatDevelopController.cs
  7. +19
    -0
      Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LR_Desktop/Views/WeChatDevelop/Form.cshtml
  8. +54
    -0
      Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LR_Desktop/Views/WeChatDevelop/Form.js
  9. +30
    -0
      Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LR_Desktop/Views/WeChatDevelop/Index.cshtml
  10. +90
    -0
      Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LR_Desktop/Views/WeChatDevelop/Index.js
  11. +119
    -1
      Learun.Framework.Ultimate V7/Learun.Application.Web/Controllers/LoginController.cs
  12. +7
    -0
      Learun.Framework.Ultimate V7/Learun.Application.Web/Learun.Application.Web.csproj
  13. +4
    -0
      Learun.Framework.Ultimate V7/Learun.Application.Web/Views/Login/Default.cshtml
  14. +53
    -0
      Learun.Framework.Ultimate V7/Learun.Application.Web/Views/Login/LoginForWeixin.cshtml
  15. +47
    -0
      Learun.Framework.Ultimate V7/Learun.Application.Web/Views/Login/RegisterBind.cshtml
  16. +2
    -0
      Learun.Framework.Ultimate V7/Learun.Application.Web/XmlConfig/system.config
  17. +29
    -0
      Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.Mapping/LR_Desktop/WeChatDevelopMap.cs
  18. +1
    -0
      Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.Mapping/Learun.Application.Mapping.csproj
  19. +11
    -0
      Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/TeachSwitch/TeachSwitchService.cs
  20. +148
    -0
      Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/LR_Desktop/WeChatDevelop/WeChatDevelopBLL.cs
  21. +60
    -0
      Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/LR_Desktop/WeChatDevelop/WeChatDevelopEntity.cs
  22. +51
    -0
      Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/LR_Desktop/WeChatDevelop/WeChatDevelopIBLL.cs
  23. +182
    -0
      Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/LR_Desktop/WeChatDevelop/WeChatDevelopService.cs
  24. +4
    -0
      Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/Learun.Application.TwoDevelopment.csproj

+ 39
- 0
Learun.Framework.Ultimate V7/Learun.Application.Organization/User/UserBLL.cs View File

@@ -497,6 +497,24 @@ namespace Learun.Application.Organization
}
}
}
public void UpdateWeixinOpenIdPC(string keyValue, string openid)
{
try
{
userService.UpdateWeixinOpenIdPC(keyValue, openid);
}
catch (Exception ex)
{
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowBusinessException(ex);
}
}
}

/// <summary>
/// 获取超级管理员用户列表
@@ -1106,6 +1124,27 @@ namespace Learun.Application.Organization
FileDownHelper.DownLoadnew(img);
}

public UserEntity GetEntityByWeixinOpenIdPC(string openId)
{
try
{
UserEntity userEntity;
userEntity = userService.GetEntityByWeixinOpenIdPC(openId);
return userEntity;
}
catch (Exception ex)
{
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowBusinessException(ex);
}
}
}

///// <summary>
///// 获取用户头像
///// </summary>


+ 3
- 0
Learun.Framework.Ultimate V7/Learun.Application.Organization/User/UserEntity.cs View File

@@ -222,6 +222,9 @@ namespace Learun.Application.Organization
[Column("OPENIDFORWEIXIN")]
public string OpenIdForWeixin { get; set; }

[Column("OPENIDFORWEIXINPC")]
public string OpenIdForWeixinPC { get; set; }

[Column("OPENIDFORQQ")]
public string OpenIdForQQ { get; set; }
[Column("LASTIP")]


+ 2
- 0
Learun.Framework.Ultimate V7/Learun.Application.Organization/User/UserIBLL.cs View File

@@ -178,6 +178,7 @@ namespace Learun.Application.Organization

UserEntity GetEntityByWeixinOpenId(string openid);
void UpdateWeixinOpenId(string userEntityFUserId, string loginModelOpenid);
void UpdateWeixinOpenIdPC(string userEntityFUserId, string loginModelOpenid);
/// <summary>
/// 获取超级管理员用户列表
/// </summary>
@@ -186,5 +187,6 @@ namespace Learun.Application.Organization

void UpdateIp(string ip, string id);
void GetImgForDC(string userId);
UserEntity GetEntityByWeixinOpenIdPC(string openId);
}
}

+ 48
- 0
Learun.Framework.Ultimate V7/Learun.Application.Organization/User/UserService.cs View File

@@ -631,6 +631,30 @@ namespace Learun.Application.Organization
}
}

public UserEntity GetEntityByWeixinOpenIdPC(string openid)
{
try
{
var strSql = new StringBuilder();
strSql.Append("SELECT ");
strSql.Append(fieldSql);
strSql.Append(" FROM LR_Base_User t ");
strSql.Append(" WHERE t.OpenIdForWeixinPC = @openid AND t.F_DeleteMark = 0 ");
return this.BaseRepository().FindEntity<UserEntity>(strSql.ToString(), new { openid = openid });
}
catch (Exception ex)
{
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowServiceException(ex);
}
}
}

public void UpdateWeixinOpenId(string keyValue, string openid)
{
try
@@ -655,6 +679,30 @@ namespace Learun.Application.Organization
}
}
}
public void UpdateWeixinOpenIdPC(string keyValue, string openid)
{
try
{
var userEntity = this.BaseRepository().FindEntity<UserEntity>(keyValue);
if (userEntity != null)
{
userEntity.OpenIdForWeixinPC = openid;
userEntity.Modify(keyValue);
this.BaseRepository().Update(userEntity);
}
}
catch (Exception ex)
{
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowServiceException(ex);
}
}
}

/// <summary>
/// 获取超级管理员用户列表


+ 3
- 1
Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/TeachSwitch/Index.js View File

@@ -70,7 +70,7 @@ var bootstrap = function ($, learun) {
url: top.$.rootUrl + '/EducationalAdministration/TeachSwitch/GetPageList',
headData: [
{
label: "开关名称", name: "type", width: 100, align: "left",
label: "开关名称", name: "type", width: 150, align: "left",
formatter: function (val) {
if (val == 'js') {
return '教师注册开关';
@@ -78,6 +78,8 @@ var bootstrap = function ($, learun) {
return '飞信下载开关';
} else if (val == 'ssosystem') {
return '网上办事大厅开关';
} else if (val == 'wxloginforpc') {
return '微信快捷登录PC端';
}

}


+ 111
- 0
Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LR_Desktop/Controllers/WeChatDevelopController.cs View File

@@ -0,0 +1,111 @@
using Learun.Util;
using System.Data;
using Learun.Application.TwoDevelopment.LR_Desktop;
using System.Web.Mvc;
using System.Collections.Generic;

namespace Learun.Application.Web.Areas.LR_Desktop.Controllers
{
/// <summary>
/// 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园
/// Copyright (c) 2013-2018 北京泉江科技有限公司
/// 创 建:超级管理员
/// 日 期:2019-11-06 11:46
/// 描 述:微信开发者号配置
/// </summary>
public class WeChatDevelopController : MvcControllerBase
{
private WeChatDevelopIBLL weChatDevelopIBLL = new WeChatDevelopBLL();

#region 视图功能

/// <summary>
/// 主页面
/// <summary>
/// <returns></returns>
[HttpGet]
public ActionResult Index()
{
return View();
}
/// <summary>
/// 表单页
/// <summary>
/// <returns></returns>
[HttpGet]
public ActionResult Form()
{
return View();
}
#endregion

#region 获取数据

/// <summary>
/// 获取页面显示列表数据
/// <summary>
/// <param name="queryJson">查询参数</param>
/// <returns></returns>
[HttpGet]
[AjaxOnly]
public ActionResult GetPageList(string pagination, string queryJson)
{
Pagination paginationobj = pagination.ToObject<Pagination>();
var data = weChatDevelopIBLL.GetPageList(paginationobj, queryJson);
var jsonData = new
{
rows = data,
total = paginationobj.total,
page = paginationobj.page,
records = paginationobj.records
};
return Success(jsonData);
}
/// <summary>
/// 获取表单数据
/// <summary>
/// <returns></returns>
[HttpGet]
[AjaxOnly]
public ActionResult GetFormData(string keyValue)
{
var WeChatDevelopData = weChatDevelopIBLL.GetWeChatDevelopEntity( keyValue );
var jsonData = new {
WeChatDevelop = WeChatDevelopData,
};
return Success(jsonData);
}
#endregion

#region 提交数据

/// <summary>
/// 删除实体数据
/// <param name="keyValue">主键</param>
/// <summary>
/// <returns></returns>
[HttpPost]
[AjaxOnly]
public ActionResult DeleteForm(string keyValue)
{
weChatDevelopIBLL.DeleteEntity(keyValue);
return Success("删除成功!");
}
/// <summary>
/// 保存实体数据(新增、修改)
/// <param name="keyValue">主键</param>
/// <summary>
/// <returns></returns>
[HttpPost]
[ValidateAntiForgeryToken]
[AjaxOnly]
public ActionResult SaveForm(string keyValue, string strEntity)
{
WeChatDevelopEntity entity = strEntity.ToObject<WeChatDevelopEntity>();
weChatDevelopIBLL.SaveEntity(keyValue,entity);
return Success("保存成功!");
}
#endregion

}
}

+ 19
- 0
Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LR_Desktop/Views/WeChatDevelop/Form.cshtml View File

@@ -0,0 +1,19 @@
@{
ViewBag.Title = "公众号配置";
Layout = "~/Views/Shared/_Form.cshtml";
}
<div class="lr-form-wrap">
<div class="col-xs-12 lr-form-item" data-table="WeChatDevelop" >
<div class="lr-form-item-title">APPId</div>
<input id="APPId" type="text" class="form-control" />
</div>
<div class="col-xs-12 lr-form-item" data-table="WeChatDevelop" >
<div class="lr-form-item-title">secret</div>
<input id="secret" type="text" class="form-control" />
</div>
<div class="col-xs-12 lr-form-item" data-table="WeChatDevelop" >
<div class="lr-form-item-title">是否启用</div>
<div id="IsEnable"></div>
</div>
</div>
@Html.AppendJsFile("/Areas/LR_Desktop/Views/WeChatDevelop/Form.js")

+ 54
- 0
Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LR_Desktop/Views/WeChatDevelop/Form.js View File

@@ -0,0 +1,54 @@
/* * 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园(http://www.learun.cn)
* Copyright (c) 2013-2018 北京泉江科技有限公司
* 创建人:超级管理员
* 日 期:2019-11-06 11:46
* 描 述:公众号配置
*/
var acceptClick;
var keyValue = request('keyValue');
var bootstrap = function ($, learun) {
"use strict";
var page = {
init: function () {
$('.lr-form-wrap').lrscroll();
page.bind();
page.initData();
},
bind: function () {
$('#IsEnable').lrRadioCheckbox({
type: 'radio',
code: 'YesOrNoBit',
});
},
initData: function () {
if (!!keyValue) {
$.lrSetForm(top.$.rootUrl + '/LR_Desktop/WeChatDevelop/GetFormData?keyValue=' + keyValue, function (data) {
for (var id in data) {
if (!!data[id].length && data[id].length > 0) {
$('#' + id ).jfGridSet('refreshdata', data[id]);
}
else {
$('[data-table="' + id + '"]').lrSetFormData(data[id]);
}
}
});
}
}
};
// 保存数据
acceptClick = function (callBack) {
if (!$('body').lrValidform()) {
return false;
}
var postData = {
strEntity: JSON.stringify($('body').lrGetFormData())
};
$.lrSaveForm(top.$.rootUrl + '/LR_Desktop/WeChatDevelop/SaveForm?keyValue=' + keyValue, postData, function (res) {
// 保存成功后才回调
if (!!callBack) {
callBack();
}
});
};
page.init();
}

+ 30
- 0
Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LR_Desktop/Views/WeChatDevelop/Index.cshtml View File

@@ -0,0 +1,30 @@
@{
ViewBag.Title = "微信开发者号配置";
Layout = "~/Views/Shared/_Index.cshtml";
}
<div class="lr-layout ">
<div class="lr-layout-center">
<div class="lr-layout-wrap lr-layout-wrap-notitle ">
<div class="lr-layout-tool">
<div class="lr-layout-tool-left">
<div class="alert alert-danger" style="text-align: left; margin: 10px; padding: 5px;">
<i class="fa fa-question-circle" style="position: relative; top: 1px; font-size: 15px; padding-right: 5px;"></i>
注:此处用来配置微信第三方登录的微信开发者帐号。AppID和secret,请不要告诉不信任的人!
</div>
</div>
<div class="lr-layout-tool-right">
<div class=" btn-group btn-group-sm">
<a id="lr_refresh" class="btn btn-default"><i class="fa fa-refresh"></i></a>
</div>
<div class=" btn-group btn-group-sm" learun-authorize="yes">
<a id="lr_add" class="btn btn-default"><i class="fa fa-plus"></i>&nbsp;录入</a>
<a id="lr_edit" class="btn btn-default"><i class="fa fa-pencil-square-o"></i>&nbsp;修改</a>
<a id="lr_delete" class="btn btn-default"><i class="fa fa-trash-o"></i>&nbsp;删除</a>
</div>
</div>
</div>
<div class="lr-layout-body" id="gridtable"></div>
</div>
</div>
</div>
@Html.AppendJsFile("/Areas/LR_Desktop/Views/WeChatDevelop/Index.js")

+ 90
- 0
Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LR_Desktop/Views/WeChatDevelop/Index.js View File

@@ -0,0 +1,90 @@
/* * 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园(http://www.learun.cn)
* Copyright (c) 2013-2018 北京泉江科技有限公司
* 创建人:超级管理员
* 日 期:2019-11-06 11:46
* 描 述:微信开发者号配置
*/
var refreshGirdData;
var bootstrap = function ($, learun) {
"use strict";
var page = {
init: function () {
page.initGird();
page.bind();
},
bind: function () {
// 刷新
$('#lr_refresh').on('click', function () {
location.reload();
});
// 新增
$('#lr_add').on('click', function () {
learun.layerForm({
id: 'form',
title: '新增',
url: top.$.rootUrl + '/LR_Desktop/WeChatDevelop/Form',
width: 600,
height: 400,
callBack: function (id) {
return top[id].acceptClick(refreshGirdData);
}
});
});
// 编辑
$('#lr_edit').on('click', function () {
var keyValue = $('#gridtable').jfGridValue('ID');
if (learun.checkrow(keyValue)) {
learun.layerForm({
id: 'form',
title: '编辑',
url: top.$.rootUrl + '/LR_Desktop/WeChatDevelop/Form?keyValue=' + keyValue,
width: 600,
height: 400,
callBack: function (id) {
return top[id].acceptClick(refreshGirdData);
}
});
}
});
// 删除
$('#lr_delete').on('click', function () {
var keyValue = $('#gridtable').jfGridValue('ID');
if (learun.checkrow(keyValue)) {
learun.layerConfirm('是否确认删除该项!', function (res) {
if (res) {
learun.deleteForm(top.$.rootUrl + '/LR_Desktop/WeChatDevelop/DeleteForm', { keyValue: keyValue}, function () {
refreshGirdData();
});
}
});
}
});
},
// 初始化列表
initGird: function () {
$('#gridtable').lrAuthorizeJfGrid({
url: top.$.rootUrl + '/LR_Desktop/WeChatDevelop/GetPageList',
headData: [
{ label: "APPId", name: "APPId", width: 300, align: "left"},
{ label: "secret", name: "secret", width: 300, align: "left"},
{
label: "是否启用", name: "IsEnable", width: 100, align: "left",
formatter: function (cellvalue) {
return cellvalue == 1 ? "<i class=\"fa fa-toggle-on\"></i>" : "<i class=\"fa fa-toggle-off\"></i>";
}},
],
mainId:'',
isPage: true
});
page.search();
},
search: function (param) {
param = param || {};
$('#gridtable').jfGridSet('reload',{ queryJson: JSON.stringify(param) });
}
};
refreshGirdData = function () {
page.search();
};
page.init();
}

+ 119
- 1
Learun.Framework.Ultimate V7/Learun.Application.Web/Controllers/LoginController.cs View File

@@ -13,6 +13,7 @@ using System.Management;
using System.Net;
using System.Net.Http;
using System.Text;
using System.Web;
using Quanjiang.DigitalScholl.WebLicense;
using Learun.Application.TwoDevelopment.EducationalAdministration;
using Newtonsoft.Json;
@@ -36,6 +37,7 @@ namespace Learun.Application.Web.Controllers
private TeachSwitchIBLL teachSwitchIBLL = new TeachSwitchBLL();
private LoginModelIBLL loginModelIbll = new LoginModelBLL();
private AnnexesFileIBLL annexesFileIbll = new AnnexesFileBLL();
WeChatDevelopIBLL weChatDevelopIbll=new WeChatDevelopBLL();
#endregion

#region 视图功能
@@ -213,7 +215,9 @@ namespace Learun.Application.Web.Controllers
//网上办事大厅
var result3 = teachSwitchIBLL.FindFirst("ssosystem");
ViewBag.SSOSystemSwitch = result3;

//微信快捷登录
var result4 = teachSwitchIBLL.FindFirst("wxloginforpc");
ViewBag.WeixinLoginSwitch = result4;
//获取在线用户人数
ViewBag.OnlineUserNum = 0;
var onlineUserResult = sys_UpdateRecordIBLL.GetOnlineUserNum();
@@ -733,6 +737,120 @@ namespace Learun.Application.Web.Controllers

#endregion

#region 微信登录

public ActionResult LoginForWeixin()
{
string redirect_url = HttpUtility.UrlEncode(ConfigurationManager.AppSettings["redirect_url"]);
var weichatdevelop = weChatDevelopIbll.GetEnableEntity();
//微信appid
string appid = weichatdevelop.APPId;
string secret = weichatdevelop.secret;
ViewBag.login = Request.QueryString["login"];
ViewBag.CODE = Request.QueryString["CODE"];
if (!string.IsNullOrEmpty(ViewBag.login))
{
return Redirect("https://open.weixin.qq.com/connect/qrconnect?appid=" + appid + "&redirect_uri=" + redirect_url + "%2fLogin%2fLoginForWeixin&response_type=code&scope=snsapi_login&state=one#wechat_redirect");
}
else
{
if (!string.IsNullOrEmpty(ViewBag.CODE))
{
string response = Util.HttpMethods.HttpGet("https://api.weixin.qq.com/sns/oauth2/access_token?appid=" + appid + "&secret=" + secret + "&code=" + ViewBag.CODE + "&grant_type=authorization_code");
ViewBag.access_token = response;
}
return View();
}

}

[HttpPost]
public ActionResult DoWeixinLogin()
{
string openId = Request["openId"];
var userEntity = userBll.GetEntityByWeixinOpenIdPC(openId);
if (userEntity != null)
{
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端微信登录";
//记录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();
return Success("登录成功");
}
else
{
return Success("帐号还未关联,请先关联帐号", new { returnurl = "/Login/RegisterBind?WeixinOpenId=" + openId + "" });
}
}

public ActionResult RegisterBind()
{
string QQOpenId = Request["QQOpenId"];
string WeixinOpenId = Request["WeixinOpenId"];
ViewBag.WeixinOpenId = WeixinOpenId;
ViewBag.QQOpenId = QQOpenId;
return View();
}

[HttpPost]
public ActionResult CheckLoginBind()
{
string username = Request["username"].Trim();
string password = Request["pwd"].Trim();
//string QQOpenId = Request["QQOpenId"];
string WeixinOpenId = Request["WeixinOpenId"];
string up = Request["up"];
UserEntity userEntity = userBll.CheckLogin(username, password);
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 = username + "(" + userEntity.F_RealName + ")";
logEntity.F_OperateUserId = !string.IsNullOrEmpty(userEntity.F_UserId) ? userEntity.F_UserId : username;
logEntity.F_Module = Config.GetValue("SoftName");
logEntity.F_Description = "PC端微信登录";
if (!userEntity.LoginOk) //登录失败
{
//写入日志
logEntity.F_ExecuteResult = 0;
logEntity.F_ExecuteResultJson = "PC端微信登录失败:" + userEntity.LoginMsg;
logEntity.WriteLog();
return Fail(userEntity.LoginMsg);
}
else
{
//更新openid
userBll.UpdateWeixinOpenIdPC(userEntity.F_UserId,WeixinOpenId);
//记录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 = "PC端微信登录成功";
logEntity.WriteLog();
//是否强密码验证
if (!string.IsNullOrEmpty(ConfigurationManager.AppSettings["verifypwd"]) &&
ConfigurationManager.AppSettings["verifypwd"] == "true" && up == "false")
{
return Success(new { pwd = true });
}
return Success("登录成功");
}
}

#endregion

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


+ 7
- 0
Learun.Framework.Ultimate V7/Learun.Application.Web/Learun.Application.Web.csproj View File

@@ -389,6 +389,7 @@
<Compile Include="Areas\LR_Desktop\Controllers\DTListController.cs" />
<Compile Include="Areas\LR_Desktop\Controllers\DTSettingController.cs" />
<Compile Include="Areas\LR_Desktop\Controllers\DTTargetController.cs" />
<Compile Include="Areas\LR_Desktop\Controllers\WeChatDevelopController.cs" />
<Compile Include="Areas\LR_Desktop\LR_DesktopAreaRegistration.cs" />
<Compile Include="Areas\LR_DisplayBoard\Controllers\LR_KBConfigInfoController.cs" />
<Compile Include="Areas\LR_DisplayBoard\Controllers\LR_KBFeaManageController.cs" />
@@ -1217,6 +1218,8 @@
<Content Include="Areas\LR_Desktop\Views\DTSetting\App\AppIndex.js" />
<Content Include="Areas\LR_Desktop\Views\DTSetting\PC\PcIndex.css" />
<Content Include="Areas\LR_Desktop\Views\DTSetting\PC\PcIndex.js" />
<Content Include="Areas\LR_Desktop\Views\WeChatDevelop\Form.js" />
<Content Include="Areas\LR_Desktop\Views\WeChatDevelop\Index.js" />
<Content Include="Areas\LR_DisplayBoard\Views\LR_KBConfigInfo\ChartForm.css" />
<Content Include="Areas\LR_DisplayBoard\Views\LR_KBConfigInfo\ChartForm.js" />
<Content Include="Areas\LR_DisplayBoard\Views\LR_KBConfigInfo\ColStatisForm.css" />
@@ -6822,6 +6825,8 @@
<Content Include="Areas\EducationalAdministration\Views\Sys_ReceiveFile\IndexGWJS.cshtml" />
<Content Include="Areas\EducationalAdministration\Views\StuInfoFresh\StatusView.cshtml" />
<Content Include="Areas\EducationalAdministration\Views\StuInfoFresh\StatisticClassIndex.cshtml" />
<Content Include="Areas\LR_Desktop\Views\WeChatDevelop\Form.cshtml" />
<Content Include="Areas\LR_Desktop\Views\WeChatDevelop\Index.cshtml" />
<None Include="Properties\PublishProfiles\FolderProfile.pubxml" />
<Content Include="Views\Login\Default-beifen.cshtml" />
<None Include="Properties\PublishProfiles\FolderProfile1.pubxml" />
@@ -6881,6 +6886,8 @@
<Content Include="Views\Shared\_jqGrid.cshtml" />
<Content Include="Views\Shared\_ReportForm.cshtml" />
<Content Include="Views\UserCenter\LanguageForm.cshtml" />
<Content Include="Views\Login\LoginForWeixin.cshtml" />
<Content Include="Views\Login\RegisterBind.cshtml" />
</ItemGroup>
<ItemGroup>
<WCFMetadata Include="Connected Services\" />


+ 4
- 0
Learun.Framework.Ultimate V7/Learun.Application.Web/Views/Login/Default.cshtml View File

@@ -97,6 +97,10 @@
{
<a style="float: left;font-family: PingFangSC-Regular;font-size: 12px;color: #3298DC;" href="/EducationalAdministration/EmpInfoEnternal/FormAdd">教师注册</a>
}
@if (ViewBag.WeixinLoginSwitch)
{
<a style="float: left;font-family: PingFangSC-Regular;font-size: 12px;color: #3298DC;" href="LoginForWeixin?login=one" title="微信登录">微信登录</a>
}
@if (ViewBag.Version)
{
<span class="versionBtn" style="cursor:pointer;">版本号:<span>@ViewBag.VersionNum</span></span>


+ 53
- 0
Learun.Framework.Ultimate V7/Learun.Application.Web/Views/Login/LoginForWeixin.cshtml View File

@@ -0,0 +1,53 @@

@{
Layout = null;
}

<!DOCTYPE html>
<html>
<head>
<title>LoginForWeixin</title>
</head>
<body>
<input id="access_token" type="hidden" value="@ViewBag.access_token"/>
</body>
</html>
<script src="~/Content/jquery/jquery-1.10.2.min.js"></script>
<script type="text/javascript">
var code = "@ViewBag.CODE";
$(document).ready(function () {
@if(string.IsNullOrEmpty(ViewBag.login))
{
<text>
$.ajax({
dataType: "json",
type: "post",
data: { "openId": JSON.parse($("#access_token").val()).unionid },
url: "/Login/DoWeixinLogin",
success: function (result) {
if (result.code == 200) {
if (result.data != undefined && result.data != null) {
if (result.data.returnurl != undefined && result.data.returnurl != null) {
location.href = result.data.returnurl;
}
else {
location.href = "/CGPI/Index";
}
}
else
{
location.href = "/CGPI/Index";
}
}
else {
location.href = "/CGPI/Login";
}
},
error: function (msg) {
alert(msg);
}
});
</text>
}
});
</script>

+ 47
- 0
Learun.Framework.Ultimate V7/Learun.Application.Web/Views/Login/RegisterBind.cshtml View File

@@ -0,0 +1,47 @@
@{
Layout = null;
ViewBag.Title = "快捷登录帐号绑定";
}
<div class="warpper">
<div class="reg_sec">
<div class="index_box">
<div class="reg_box">
<form id="regbindform">
<div class="reg_con">
@{
if (!string.IsNullOrEmpty(ViewBag.QQOpenId))
{
<h3> <img src="/Content/web/images/qq.png" alt=""/> 快捷登录帐号绑定</h3>
}
else
{
<h3> <img src="/Content/web/images/weixin.png" alt="" /> 快捷登录帐号绑定</h3>
}
}
<input type="hidden" name="QQOpenId" id="QQOpenId" value="@ViewBag.QQOpenId"/>
<input type="hidden" name="WeixinOpenId" id="WeixinOpenId" value="@ViewBag.WeixinOpenId"/>
<div class="reg_input">
<img src="/Content/web/images/phone.png" alt=""/>
<input type="text" id="mobile" name="mobile" maxlength="11" placeholder="请输入您的手机号码"/>
</div>
<div class="reg_input">
<img src="/Content/web/images/unlock.png" alt=""/>
<input type="password" id="pass" name="pass" placeholder="请输入您的密码"/>
</div>
<div class="reg_input reg_input1">
<input type="text" placeholder="输入验证码" id="mcode" Name="mcode" maxlength="6"/>
<button id="btngcode" class="duanxin" onclick="return false;">获取短信验证码</button>
</div>
<div class="reg_btn" id="regbtn">
<a href="javascript:void(0);">绑&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;定</a>
</div>
<div class="reg_qq">
</div>
</div>
</form>
</div>
</div>
</div>
</div>
<link href="~/Content/dist/jquery.validator.css" rel="stylesheet" />
<script src="~/Content/dist/jquery.validator.js?local=zh-CN"></script>

+ 2
- 0
Learun.Framework.Ultimate V7/Learun.Application.Web/XmlConfig/system.config View File

@@ -156,4 +156,6 @@
<add key="EmpNoRule" value="jy"/>
<!--考勤明细统计时查询的职工编号前缀 大厂:DCZZ-->
<add key="ADR_RecordUserNoPrev" value="DCZZ"/>
<!--第三方登录跳转地址(最后不加/)-->
<add key="redirect_url" value="http://localhost:20472"/>
</appSettings>

+ 29
- 0
Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.Mapping/LR_Desktop/WeChatDevelopMap.cs View File

@@ -0,0 +1,29 @@
using Learun.Application.TwoDevelopment.LR_Desktop;
using System.Data.Entity.ModelConfiguration;

namespace Learun.Application.Mapping
{
/// <summary>
/// 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园
/// Copyright (c) 2013-2018 北京泉江科技有限公司
/// 创 建:超级管理员
/// 日 期:2019-11-06 11:46
/// 描 述:微信开发者号配置
/// </summary>
public class WeChatDevelopMap : EntityTypeConfiguration<WeChatDevelopEntity>
{
public WeChatDevelopMap()
{
#region 表、主键
//表
this.ToTable("WECHATDEVELOP");
//主键
this.HasKey(t => t.ID);
#endregion

#region 配置关系
#endregion
}
}
}


+ 1
- 0
Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.Mapping/Learun.Application.Mapping.csproj View File

@@ -110,6 +110,7 @@
<Compile Include="LR_CodeDemo\LR_OA_ProjectMap.cs" />
<Compile Include="LR_CRM\CrmCustomerContactMap.cs" />
<Compile Include="LR_CRM\CrmChanceMap.cs" />
<Compile Include="LR_Desktop\WeChatDevelopMap.cs" />
<Compile Include="LR_Excel\ExcelExportMap.cs" />
<Compile Include="LR_Excel\ExcelImportFieldMap.cs" />
<Compile Include="LR_Excel\ExcelImportMap.cs" />


+ 11
- 0
Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/TeachSwitch/TeachSwitchService.cs View File

@@ -61,6 +61,17 @@ namespace Learun.Application.TwoDevelopment.EducationalAdministration
jsEntity.Create();
this.BaseRepository().Insert(jsEntity);
}
//微信快捷登录
if (!data.Any(a => a.type == "wxloginforpc"))
{
var jsEntity = new TeachSwitchEntity()
{
status = "0",
type = "wxloginforpc"
};
jsEntity.Create();
this.BaseRepository().Insert(jsEntity);
}
var strSql = new StringBuilder();
strSql.Append("SELECT ");
strSql.Append(@"


+ 148
- 0
Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/LR_Desktop/WeChatDevelop/WeChatDevelopBLL.cs View File

@@ -0,0 +1,148 @@
using Learun.Util;
using System;
using System.Data;
using System.Collections.Generic;

namespace Learun.Application.TwoDevelopment.LR_Desktop
{
/// <summary>
/// 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园
/// Copyright (c) 2013-2018 北京泉江科技有限公司
/// 创 建:超级管理员
/// 日 期:2019-11-06 11:46
/// 描 述 微信开发者号配置
/// </summary>
public class WeChatDevelopBLL : WeChatDevelopIBLL
{
private WeChatDevelopService weChatDevelopService = new WeChatDevelopService();

#region 获取数据

/// <summary>
/// 获取页面显示列表数据
/// <summary>
/// <param name="queryJson">查询参数</param>
/// <returns></returns>
public IEnumerable<WeChatDevelopEntity> GetPageList(Pagination pagination, string queryJson)
{
try
{
return weChatDevelopService.GetPageList(pagination, queryJson);
}
catch (Exception ex)
{
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowBusinessException(ex);
}
}
}

/// <summary>
/// 获取WeChatDevelop表实体数据
/// <param name="keyValue">主键</param>
/// <summary>
/// <returns></returns>
public WeChatDevelopEntity GetWeChatDevelopEntity(string keyValue)
{
try
{
return weChatDevelopService.GetWeChatDevelopEntity(keyValue);
}
catch (Exception ex)
{
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowBusinessException(ex);
}
}
}
/// <summary>
/// 获取WeChatDevelop表实体数据
/// <param name="keyValue">主键</param>
/// <summary>
/// <returns></returns>
public WeChatDevelopEntity GetEnableEntity()
{
try
{
return weChatDevelopService.GetEnableEntity();
}
catch (Exception ex)
{
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowBusinessException(ex);
}
}
}


#endregion

#region 提交数据

/// <summary>
/// 删除实体数据
/// <param name="keyValue">主键</param>
/// <summary>
/// <returns></returns>
public void DeleteEntity(string keyValue)
{
try
{
weChatDevelopService.DeleteEntity(keyValue);
}
catch (Exception ex)
{
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowBusinessException(ex);
}
}
}

/// <summary>
/// 保存实体数据(新增、修改)
/// <param name="keyValue">主键</param>
/// <summary>
/// <returns></returns>
public void SaveEntity(string keyValue, WeChatDevelopEntity entity)
{
try
{
weChatDevelopService.SaveEntity(keyValue, entity);
}
catch (Exception ex)
{
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowBusinessException(ex);
}
}
}

#endregion

}
}

+ 60
- 0
Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/LR_Desktop/WeChatDevelop/WeChatDevelopEntity.cs View File

@@ -0,0 +1,60 @@
using Learun.Util;
using System;
using System.ComponentModel.DataAnnotations.Schema;

namespace Learun.Application.TwoDevelopment.LR_Desktop
{
/// <summary>
/// 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园
/// Copyright (c) 2013-2018 北京泉江科技有限公司
/// 创 建:超级管理员
/// 日 期:2019-11-06 11:46
/// 描 述:微信开发者号配置
/// </summary>
public class WeChatDevelopEntity
{
#region 实体成员
/// <summary>
/// 编号
/// </summary>
[Column("ID")]
public string ID { get; set; }
/// <summary>
/// APPId
/// </summary>
[Column("APPID")]
public string APPId { get; set; }
/// <summary>
/// secret
/// </summary>
[Column("SECRET")]
public string secret { get; set; }
/// <summary>
/// 是否启用
/// </summary>
[Column("ISENABLE")]
public bool? IsEnable { get; set; }
#endregion

#region 扩展操作
/// <summary>
/// 新增调用
/// </summary>
public void Create()
{
this.ID = Guid.NewGuid().ToString();
}
/// <summary>
/// 编辑调用
/// </summary>
/// <param name="keyValue"></param>
public void Modify(string keyValue)
{
this.ID = keyValue;
}
#endregion
#region 扩展字段
#endregion
}
}


+ 51
- 0
Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/LR_Desktop/WeChatDevelop/WeChatDevelopIBLL.cs View File

@@ -0,0 +1,51 @@
using Learun.Util;
using System.Data;
using System.Collections.Generic;

namespace Learun.Application.TwoDevelopment.LR_Desktop
{
/// <summary>
/// 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园
/// Copyright (c) 2013-2018 北京泉江科技有限公司
/// 创 建:超级管理员
/// 日 期:2019-11-06 11:46
/// 描 述:微信开发者号配置
/// </summary>
public interface WeChatDevelopIBLL
{
#region 获取数据

/// <summary>
/// 获取页面显示列表数据
/// <summary>
/// <param name="queryJson">查询参数</param>
/// <returns></returns>
IEnumerable<WeChatDevelopEntity> GetPageList(Pagination pagination, string queryJson);
/// <summary>
/// 获取WeChatDevelop表实体数据
/// <param name="keyValue">主键</param>
/// <summary>
/// <returns></returns>
WeChatDevelopEntity GetWeChatDevelopEntity(string keyValue);

WeChatDevelopEntity GetEnableEntity();
#endregion

#region 提交数据

/// <summary>
/// 删除实体数据
/// <param name="keyValue">主键</param>
/// <summary>
/// <returns></returns>
void DeleteEntity(string keyValue);
/// <summary>
/// 保存实体数据(新增、修改)
/// <param name="keyValue">主键</param>
/// <summary>
/// <returns></returns>
void SaveEntity(string keyValue, WeChatDevelopEntity entity);
#endregion

}
}

+ 182
- 0
Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/LR_Desktop/WeChatDevelop/WeChatDevelopService.cs View File

@@ -0,0 +1,182 @@
using Dapper;
using Learun.DataBase.Repository;
using Learun.Util;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;

namespace Learun.Application.TwoDevelopment.LR_Desktop
{
/// <summary>
/// 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园
/// Copyright (c) 2013-2018 北京泉江科技有限公司
/// 创 建:超级管理员
/// 日 期:2019-11-06 11:46
/// 描 述:微信开发者号配置
/// </summary>
public class WeChatDevelopService : RepositoryFactory
{
#region 获取数据

/// <summary>
/// 获取页面显示列表数据
/// <summary>
/// <param name="queryJson">查询参数</param>
/// <returns></returns>
public IEnumerable<WeChatDevelopEntity> GetPageList(Pagination pagination, string queryJson)
{
try
{
var strSql = new StringBuilder();
strSql.Append("SELECT ");
strSql.Append(@"
t.ID,
t.APPId,
t.secret,
t.IsEnable
");
strSql.Append(" FROM WeChatDevelop t ");
strSql.Append(" WHERE 1=1 ");
var queryParam = queryJson.ToJObject();
// 虚拟参数
var dp = new DynamicParameters(new { });
return this.BaseRepository().FindList<WeChatDevelopEntity>(strSql.ToString(), dp, pagination);
}
catch (Exception ex)
{
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowServiceException(ex);
}
}
}

/// <summary>
/// 获取WeChatDevelop表实体数据
/// <param name="keyValue">主键</param>
/// <summary>
/// <returns></returns>
public WeChatDevelopEntity GetWeChatDevelopEntity(string keyValue)
{
try
{
return this.BaseRepository().FindEntity<WeChatDevelopEntity>(keyValue);
}
catch (Exception ex)
{
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowServiceException(ex);
}
}
}
/// <summary>
/// 获取WeChatDevelop表实体数据
/// <param name="keyValue">主键</param>
/// <summary>
/// <returns></returns>
public WeChatDevelopEntity GetEnableEntity()
{
try
{
return this.BaseRepository().FindEntity<WeChatDevelopEntity>(a => a.IsEnable == true);
}
catch (Exception ex)
{
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowServiceException(ex);
}
}
}

#endregion

#region 提交数据

/// <summary>
/// 删除实体数据
/// <param name="keyValue">主键</param>
/// <summary>
/// <returns></returns>
public void DeleteEntity(string keyValue)
{
try
{
this.BaseRepository().Delete<WeChatDevelopEntity>(t => t.ID == keyValue);
}
catch (Exception ex)
{
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowServiceException(ex);
}
}
}

/// <summary>
/// 保存实体数据(新增、修改)
/// <param name="keyValue">主键</param>
/// <summary>
/// <returns></returns>
public void SaveEntity(string keyValue, WeChatDevelopEntity entity)
{
try
{
if (entity.IsEnable == true)
{

var weChat = this.BaseRepository().FindEntity<WeChatDevelopEntity>(a => a.IsEnable == true);
if (weChat != null)
{
weChat.IsEnable = false;
this.BaseRepository().Update(weChat);
}
}

if (!string.IsNullOrEmpty(keyValue))
{
entity.Modify(keyValue);
this.BaseRepository().Update(entity);
}
else
{
entity.Create();
this.BaseRepository().Insert(entity);
}
}
catch (Exception ex)
{
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowServiceException(ex);
}
}
}

#endregion

}
}

+ 4
- 0
Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/Learun.Application.TwoDevelopment.csproj View File

@@ -256,6 +256,10 @@
<Compile Include="LR_CodeDemo\WorkOrder\WorkOrderBLL.cs" />
<Compile Include="LR_CodeDemo\WorkOrder\WorkOrderIBLL.cs" />
<Compile Include="LR_CodeDemo\WorkOrder\WorkOrderService.cs" />
<Compile Include="LR_Desktop\WeChatDevelop\WeChatDevelopBLL.cs" />
<Compile Include="LR_Desktop\WeChatDevelop\WeChatDevelopEntity.cs" />
<Compile Include="LR_Desktop\WeChatDevelop\WeChatDevelopIBLL.cs" />
<Compile Include="LR_Desktop\WeChatDevelop\WeChatDevelopService.cs" />
<Compile Include="LR_LGManager\CorporateMaterialApply\CorporateMaterialApplyBLL.cs" />
<Compile Include="LR_LGManager\CorporateMaterialApply\CorporateMaterialApplyEntity.cs" />
<Compile Include="LR_LGManager\CorporateMaterialApply\CorporateMaterialApplyIBLL.cs" />


Loading…
Cancel
Save