12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- /**
- * 简易互联网医院 企业微信消息推送 SDK,提供互联网医院 企业微信消息推送接口调用。
- */
- 'use strict';
- let http = require('http');
- var wechatreqq = require('request');
- let querystring = require('querystring');
- let configFile = require('../include/commons').CONFIG_FILE;
- let config = require('../resources/config/' + configFile);
- let log = require('./log.js');
- class HlwyyWechatAssistantSDK {
- constructor(){}
- static request(userName,idCard,phone,title,contentSrt,contentStringStr,url,params,type,handler){
- // log.info("1:"+userName)
- // log.info("2:"+idCard)
- // log.info("3:"+phone)
- // log.info("4:"+title)
- // log.info("5:"+contentSrt)
- // log.info("6:"+contentStringStr)
- // log.info("7:"+params)
- // log.info("8:"+"http://"+config.thirdApiMessageConfig.host+":"+config.thirdApiMessageConfig.port+config.thirdApiMessageConfig.model+config.thirdApiMessageConfig.enpoint+"?"+params)
- //&&config.imClientType.id === 'hz_cloudCare'
- log.info("是否p2p :"+type)
- log.info("是否医养hz_cloudCare:"+config.imClientType.id)
- if ("familyP2P"===type&&config.imClientType.id === 'hz_cloudCare'){
- wechatreqq({
- url: "http://"+config.familyP2PMessageConfig.host+":"+config.familyP2PMessageConfig.port+config.familyP2PMessageConfig.model+config.familyP2PMessageConfig.enpoint+"?"+params,
- json: true,
- headers: {
- "content-type": "application/json",
- },
- method: 'POST',
- body: JSON.stringify(params)
- }, function(error, response, body) {
- if (!error && response.statusCode == 200) {
- log.info('请求居民微信模版消息接口发送模版消息->请求成功:', body);
- // console.log(body) // 请求成功的处理逻辑
- }else{
- // log.error('请求居民微信模版消息发送模版消息->请求失败:', body.toString());
- // log.error('请求居民微信模版消息发送模版消息->请求失败:', response.toString());
- log.error('请求居民微信模版消息发送模版消息->请求失败:', error.message);
- }
- })
- }else {
- wechatreqq({
- url: "http://"+config.thirdApiMessageConfig.host+":"+config.thirdApiMessageConfig.port+config.thirdApiMessageConfig.model+config.thirdApiMessageConfig.enpoint+"?"+params,
- json: true,
- headers: {
- "content-type": "application/json",
- },
- method: 'POST',
- body: JSON.stringify(params)
- }, function(error, response, body) {
- if (!error && response.statusCode == 200) {
- log.info('请求居民微信模版消息接口发送模版消息->请求成功:', body);
- // console.log(body) // 请求成功的处理逻辑
- }else{
- // log.error('请求居民微信模版消息发送模版消息->请求失败:', body.toString());
- // log.error('请求居民微信模版消息发送模版消息->请求失败:', response.toString());
- log.error('请求居民微信模版消息发送模版消息->请求失败:', error.message);
- }
- });}
- log.info("9:"+config.imClientType.id);
- if(config.imClientType.id == 'zsyy'){
- log.info("10:进入i健康模板消息推送");
- //i健康模板消息推送
- wechatreqq({
- url: "http://"+config.xmIjkTemplateConfig.host+":"+config.xmIjkTemplateConfig.port+config.xmIjkTemplateConfig.model+config.xmIjkTemplateConfig.enpoint+"?"+params,
- json: true,
- headers: {
- "content-type": "application/json",
- },
- method: 'POST',
- body: JSON.stringify(params)
- }, function(error, response, body) {
- if (!error && response.statusCode == 200) {
- log.info('请求居民微信模版消息接口发送模版消息->请求成功:', body);
- // console.log(body) // 请求成功的处理逻辑
- }else{
- // log.error('请求居民微信模版消息发送模版消息->请求失败:', body.toString());
- // log.error('请求居民微信模版消息发送模版消息->请求失败:', response.toString());
- log.error('请求居民微信模版消息发送模版消息->请求失败:', error.message);
- }
- });
- log.info("11:结束i健康模板消息推送");
- }
- }
- }
- module.exports = HlwyyWechatAssistantSDK;
|