Browse Source

增加微信公众号中通过链接直接登录并进入客户系统

master
yashen 7 years ago
parent
commit
580899b5f0
4 changed files with 67 additions and 2 deletions
  1. +1
    -0
      B3WeChat.Web/B3WeChat.Web.csproj
  2. +47
    -0
      B3WeChat.Web/Pages/B3WeChat/B3Auth.cs
  3. +1
    -1
      B3WeChat.sln
  4. +18
    -1
      B3WeChat/Rpcs/ClientRpc.cs

+ 1
- 0
B3WeChat.Web/B3WeChat.Web.csproj View File

@ -116,6 +116,7 @@
<Compile Include="..\..\..\version\Misc_version.cs">
<Link>Misc_version.cs</Link>
</Compile>
<Compile Include="Pages\B3WeChat\B3Auth.cs" />
<Compile Include="Pages\B3WeChat\ContentTemplate_\ContentTemplateEdit.cs">
<SubType>ASPXCodeBehind</SubType>
</Compile>


+ 47
- 0
B3WeChat.Web/Pages/B3WeChat/B3Auth.cs View File

@ -0,0 +1,47 @@
using BWP.B3WeChat;
using BWP.B3WeChat.BO;
using Forks.EnterpriseServices.BusinessInterfaces;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
namespace BWP.Web.Pages.B3WeChat
{
class B3Auth:IHttpHandler
{
public bool IsReusable
{
get { return true; }
}
public void ProcessRequest(HttpContext context)
{
var request = context.Request;
var service = context.Request.QueryString["service"];
var customerCode = request.QueryString["customerCode"];
var userContext = WeChatUserContext.Current;
var customer = userContext.Customers.SingleOrDefault((item) => item.CustomerCode == customerCode);
if (customer == null)
{
throw new Exception("微信号没有关联B3系统中的用户");
}
var loginRequest = new ScanLoginRequest();
loginRequest.CustomerCode = customerCode;
loginRequest.Confirmed = true;
loginRequest.CustomerUsername = customer.CustomerUsername;
using (var tranContext = new TransactionContext())
{
tranContext.Session.Insert(loginRequest);
tranContext.Commit();
}
var result = service + "&code=" + loginRequest.ID.ToString();
context.Response.Redirect(result);
}
}
}

+ 1
- 1
B3WeChat.sln View File

@ -1,6 +1,6 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2013
# Visual Studio 2012
VisualStudioVersion = 12.0.21005.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "B3WeChat", "B3WeChat\B3WeChat.csproj", "{9E680662-8323-494F-8140-237DB0A9F0D9}"


+ 18
- 1
B3WeChat/Rpcs/ClientRpc.cs View File

@ -1,4 +1,5 @@
using Bwp.MainSystem.BO;
using Bwp.MainSystem;
using Bwp.MainSystem.BO;
using BWP.B3WeChat.BO;
using BWP.B3WeChat.BO.NamedValueTemplate;
using BWP.B3WeChat.Utils;
@ -13,6 +14,7 @@ using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Web;
using TSingSoft.WebPluginFramework;
namespace BWP.B3WeChat.Rpcs
@ -46,6 +48,21 @@ namespace BWP.B3WeChat.Rpcs
SendMessageUtil.SendSystemMessage(CustomerUserContext.Current.GetOpenID(username), username, content);
}
[Rpc]
public static void SendAuthLinkMessage(string username, string content, string serverUrl,string pathUrl)
{
var userContext = CustomerUserContext.Current;
var fullUrl = serverUrl + pathUrl;
var loginUrl = string.Format("{0}OuterLogin.aspx?source=BWPScanLogin&redirectUrl={1}", serverUrl, HttpUtility.UrlEncode(fullUrl));
var config = new MainSystemConfig();
var linkUrl = config.InternetAccessAddress.Value + "B3WeChat/B3Auth.aspx?service=" + HttpUtility.UrlEncode(loginUrl) + "&customerCode=" + HttpUtility.UrlEncode(userContext.CustomerCode);
SendMessageUtil.SendSystemMessage(CustomerUserContext.Current.GetOpenID(username), username, content, linkUrl);
}
[Rpc]
public static void SendFollowMessage(string username, string content, string businessNo)
{


Loading…
Cancel
Save