Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

完善菜单扫二维码/条码功能 #58

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified Senparc.Weixin.MP.BuildOutPut/Senparc.Weixin.MP.MvcExtension.dll
Binary file not shown.
Binary file modified Senparc.Weixin.MP.BuildOutPut/Senparc.Weixin.MP.dll
Binary file not shown.
Binary file modified Senparc.Weixin.MP.BuildOutPut/Senparc.Weixin.dll
Binary file not shown.
Binary file modified Senparc.Weixin.MP.BuildOutPut/Senparc.Weixin.pdb
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -214,5 +214,42 @@ public override IResponseMessageBase OnEvent_UnsubscribeRequest(RequestMessageEv
responseMessage.Content = "有空再来";
return responseMessage;
}

public override IResponseMessageBase OnEvent_ScancodePushRequest(RequestMessageEvent_ScancodePush requestMessage)
{
return base.OnEvent_ScancodePushRequest(requestMessage);
}

public override IResponseMessageBase OnEvent_ScancodeWaitmsgRequest(RequestMessageEvent_ScancodeWaitmsg requestMessage)
{
IResponseMessageBase responseMessage = null;

switch (requestMessage.EventKey)
{
case "Scancode_Waitmsg":
{
var strongResponseMessage = CreateResponseMessage<ResponseMessageText>();
responseMessage = strongResponseMessage;
strongResponseMessage.Content = "您点击了扫码带提示按钮。";
}
break;
default:
{
var strongResponseMessage = CreateResponseMessage<ResponseMessageText>();
responseMessage = strongResponseMessage;
if (requestMessage.ScanCodeInfo == null)
{
strongResponseMessage.Content = "扫描失败!";
}
else
{
strongResponseMessage.Content = "扫描信息如下:\r\n扫描类型:" + requestMessage.ScanCodeInfo.ScanType + "\r\n扫描结果:" + requestMessage.ScanCodeInfo.ScanResult;
}
}
break;
}

return responseMessage;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ProjectView>ShowAllFiles</ProjectView>
<ProjectView>ProjectFiles</ProjectView>
</PropertyGroup>
<ProjectExtensions>
<VisualStudio>
Expand Down
Binary file modified Senparc.Weixin.MP/Senparc.Weixin.MP.suo
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,10 @@ public override Event Event
/// 事件KEY值,与自定义菜单接口中KEY值对应
/// </summary>
public string EventKey { get; set; }

/// <summary>
/// 扫描信息
/// </summary>
public ScanCodeInfo ScanCodeInfo { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,10 @@ public override Event Event
/// 事件KEY值,与自定义菜单接口中KEY值对应
/// </summary>
public string EventKey { get; set; }

/// <summary>
/// 扫描信息
/// </summary>
public ScanCodeInfo ScanCodeInfo { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Senparc.Weixin.MP.Entities
{
public class ScanCodeInfo
{
/// <summary>
/// 扫描类型
/// </summary>
public string ScanType { get; set; }

/// <summary>
/// 扫描结果,即二维码或条码对应的字符串信息
/// </summary>
public string ScanResult { get; set; }
}
}
5 changes: 5 additions & 0 deletions Senparc.Weixin.MP/Senparc.Weixin.MP/Helpers/EntityHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,11 @@ public static class EntityHelper
FillEntityWithXml(video, new XDocument(root.Element(propName)));
prop.SetValue(entity, video, null);
break;
case "ScanCodeInfo"://菜单扫码信息
ScanCodeInfo scanInfo = new ScanCodeInfo();
FillEntityWithXml(scanInfo, new XDocument(root.Element(propName)));
prop.SetValue(entity, scanInfo, null);
break;
default:
prop.SetValue(entity, root.Element(propName).Value, null);
break;
Expand Down
6 changes: 6 additions & 0 deletions Senparc.Weixin.MP/Senparc.Weixin.MP/RequestMessageFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,12 @@ public static IRequestMessageBase GetRequestEntity(XDocument doc, PostModel post
case "MASSSENDJOBFINISH":
requestMessage = new RequestMessageEvent_MassSendJobFinish();
break;
case "SCANCODE_PUSH"://扫码推事件
requestMessage = new RequestMessageEvent_ScancodePush();
break;
case "SCANCODE_WAITMSG"://扫码推事件且弹出“消息接收中”提示框
requestMessage = new RequestMessageEvent_ScancodeWaitmsg();
break;
default://其他意外类型(也可以选择抛出异常)
requestMessage = new RequestMessageEventBase();
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
<Compile Include="Entities\Request\Event\RequestMessageEvent_TemplateSendJobFinish.cs" />
<Compile Include="Entities\Request\Event\RequestMessageEvent_LocationSelect.cs" />
<Compile Include="Entities\Request\Event\RequestMessageEvent_PicWeixin.cs" />
<Compile Include="Entities\Request\ScanCodeInfo.cs" />
<Compile Include="Entities\Request\PostModel.cs" />
<Compile Include="Entities\Response\ResponseMessageBase.cs" />
<Compile Include="Helpers\EventHelper.cs" />
Expand Down