shanji 2 years ago
parent
commit
5a9a28a2b8
  1. 21
      WebTest/GlobalContext.cs
  2. 10
      WebTest/MainWindow.xaml.cs
  3. 36
      WebTest/ShellExecuteHelper.cs

21
WebTest/GlobalContext.cs

@ -1,5 +1,7 @@
using Newtonsoft.Json;
using System;
using System.Runtime.InteropServices;
using System.Windows;
namespace WebTest
{
@ -27,5 +29,24 @@ namespace WebTest
{
return "10123";
}
public void CallALiWangWang(string sellerLoginId)
{
var url = $"aliim:sendmsg?siteid=cnalichn&portalId=&gid=&itemsId=&touid=cnalichn{sellerLoginId}&status=1";
try
{
//Process.Start("explorer.exe", url);
ShellExecuteHelper.ShellExecute(IntPtr.Zero, "open", url, string.Empty, string.Empty, ShellExecuteHelper.ShowCommands.SW_SHOWNORMAL);
}
catch (Exception ex)
{
try
{
Clipboard.SetText(url);
}
catch { }
MessageBox.Show($"{ex.Message}\r\n唤醒旺旺失败,唤醒链接已复制到剪切板,请手动打开浏览器唤醒", "提示");
}
}
}
}

10
WebTest/MainWindow.xaml.cs

@ -26,6 +26,14 @@ namespace WebTest
private MdsApiService mdsApiService;
private ShopService shopService;
#if DEBUG
private string registerName = "webTestContext";
#else
private string registerName = "webContext";
#endif
public MainWindow()
{
InitializeComponent();
@ -87,7 +95,7 @@ namespace WebTest
if (args.PermissionKind == CoreWebView2PermissionKind.ClipboardRead)
args.State = CoreWebView2PermissionState.Allow;
};
w2m.wb2.CoreWebView2.AddHostObjectToScript("webTestContext", this.globalContext);
w2m.wb2.CoreWebView2.AddHostObjectToScript(registerName, this.globalContext);
};
w2m.Init();

36
WebTest/ShellExecuteHelper.cs

@ -0,0 +1,36 @@
using System;
using System.Runtime.InteropServices;
namespace WebTest
{
public class ShellExecuteHelper
{
public enum ShowCommands : int
{
SW_HIDE = 0,
SW_SHOWNORMAL = 1,
SW_NORMAL = 1,
SW_SHOWMINIMIZED = 2,
SW_SHOWMAXIMIZED = 3,
SW_MAXIMIZE = 3,
SW_SHOWNOACTIVATE = 4,
SW_SHOW = 5,
SW_MINIMIZE = 6,
SW_SHOWMINNOACTIVE = 7,
SW_SHOWNA = 8,
SW_RESTORE = 9,
SW_SHOWDEFAULT = 10,
SW_FORCEMINIMIZE = 11,
SW_MAX = 11
}
[DllImport("shell32.dll")]
public static extern IntPtr ShellExecute(
IntPtr hwnd,
string lpOperation,
string lpFile,
string lpParameters,
string lpDirectory,
ShowCommands nShowCmd);
}
}
Loading…
Cancel
Save