|
|
|
@ -31,10 +31,11 @@ namespace _24Hour
|
|
|
|
|
/// 小程序secretID |
|
|
|
|
/// </summary> |
|
|
|
|
private string secid = "e752e4fba67526eca21313a18c96a58f"; |
|
|
|
|
public WechatMessagerClient(HttpClient _httpCliet, IConfiguration configuration) |
|
|
|
|
private readonly ILogger<WechatMessagerClient> logger; |
|
|
|
|
public WechatMessagerClient(HttpClient _httpCliet, IConfiguration configuration, ILogger<WechatMessagerClient> _logger) |
|
|
|
|
{ |
|
|
|
|
this.httpCliet = _httpCliet; |
|
|
|
|
|
|
|
|
|
this.logger = _logger; |
|
|
|
|
httpCliet.DefaultRequestHeaders.Add("Accept", "application/json"); |
|
|
|
|
httpCliet.DefaultRequestHeaders.Add("User-Agent", "HttpClientFactory-Sample"); |
|
|
|
|
httpCliet.DefaultRequestHeaders.ConnectionClose = true; |
|
|
|
@ -43,6 +44,10 @@ namespace _24Hour
|
|
|
|
|
appid = $"{configuration.GetSection("Wechat:appid").Value}"; |
|
|
|
|
secret = $"{configuration.GetSection("Wechat:secret").Value}"; |
|
|
|
|
secid = $"{configuration.GetSection("Wechat:secid").Value}"; |
|
|
|
|
|
|
|
|
|
logger.LogInformation($"appid {appid}"); |
|
|
|
|
logger.LogInformation($"secret {secret}"); |
|
|
|
|
logger.LogInformation($"secid {secid}"); |
|
|
|
|
} |
|
|
|
|
public async Task<Result> GetOpenId(string code) |
|
|
|
|
{ |
|
|
|
@ -74,7 +79,7 @@ namespace _24Hour
|
|
|
|
|
/// 律师预约微信消息提醒,成功 |
|
|
|
|
/// </summary> |
|
|
|
|
/// <returns></returns> |
|
|
|
|
public bool wxts(string? useropenId, string? name, string? unit, DateTime? datetime, string? matter,string? attention) |
|
|
|
|
public bool wxts(string? useropenId, string? name, string? unit, DateTime? datetime, string? matter, string? attention) |
|
|
|
|
{ |
|
|
|
|
try |
|
|
|
|
{ |
|
|
|
@ -104,23 +109,23 @@ namespace _24Hour
|
|
|
|
|
string posturl = $"{url}{token}";//发送地址 |
|
|
|
|
var thing4 = matter; |
|
|
|
|
var thing5 = attention; |
|
|
|
|
if (!string.IsNullOrEmpty(matter) && matter.Length>20) |
|
|
|
|
thing4 = matter.Substring(0, 17)+"..."; |
|
|
|
|
if (!string.IsNullOrEmpty(matter) && matter.Length > 20) |
|
|
|
|
thing4 = matter.Substring(0, 17) + "..."; |
|
|
|
|
if (!string.IsNullOrEmpty(attention) && attention.Length > 20) |
|
|
|
|
thing5 = attention.Substring(0, 17) + "..."; |
|
|
|
|
msg = new |
|
|
|
|
{ |
|
|
|
|
touser = useropenId, |
|
|
|
|
template_id = "mRfzPnc_3JuV9cPhjKrRL3jX1C_JJoBGYtqEnbfadRM", |
|
|
|
|
page= "pages/selfService/reception/reception", |
|
|
|
|
miniprogram_state= $"{_configuration.GetSection("Wechat:miniprogram_state").Value}", |
|
|
|
|
lang ="zh_CN", |
|
|
|
|
page = "pages/selfService/reception/reception", |
|
|
|
|
miniprogram_state = $"{_configuration.GetSection("Wechat:miniprogram_state").Value}", |
|
|
|
|
lang = "zh_CN", |
|
|
|
|
data = new |
|
|
|
|
{ |
|
|
|
|
//name1 = new { value = $"{name}"},// |
|
|
|
|
thing2 = new { value = $"{unit}"},// |
|
|
|
|
date3 = new { value = $"{datetime:yyyy年MM月dd日 HH:mm}"},// |
|
|
|
|
thing4 = new { value = $"{thing4}"},// |
|
|
|
|
thing2 = new { value = $"{unit}" },// |
|
|
|
|
date3 = new { value = $"{datetime:yyyy年MM月dd日 HH:mm}" },// |
|
|
|
|
thing4 = new { value = $"{thing4}" },// |
|
|
|
|
thing5 = new { value = $"{thing5}", color = "#173177" },// |
|
|
|
|
}, |
|
|
|
|
}; |
|
|
|
@ -145,7 +150,7 @@ namespace _24Hour
|
|
|
|
|
/// 律师预约微信消息提醒,失败 |
|
|
|
|
/// </summary> |
|
|
|
|
/// <returns></returns> |
|
|
|
|
public bool sbwxts(string? useropenId,string? name,string? unit,DateTime? datetime,string? matter,string? reason) |
|
|
|
|
public bool sbwxts(string? useropenId, string? name, string? unit, DateTime? datetime, string? matter, string? reason) |
|
|
|
|
{ |
|
|
|
|
try |
|
|
|
|
{ |
|
|
|
@ -174,7 +179,7 @@ namespace _24Hour
|
|
|
|
|
object msg = null; |
|
|
|
|
string posturl = $"{url}{token}";//发送地址 |
|
|
|
|
var thing4 = matter; |
|
|
|
|
if (!string.IsNullOrEmpty(matter)&&matter.Length > 20) |
|
|
|
|
if (!string.IsNullOrEmpty(matter) && matter.Length > 20) |
|
|
|
|
thing4 = matter.Substring(0, 17) + "..."; |
|
|
|
|
var thing5 = reason; |
|
|
|
|
if (!string.IsNullOrEmpty(reason) && reason.Length > 20) |
|
|
|
|