1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- /**
- * 简易互联网医院 企业微信消息推送 SDK,提供互联网医院 企业微信消息推送接口调用。
- */
- 'use strict';
- var wechatreqq = require('request');
- 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,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)
- 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);
- }
- });
- }
- static requestSms(params,handler){
- log.info("7:"+params)
- wechatreqq({
- url: "http://"+config.thirdApiMessageConfig.host+":"+config.thirdApiMessageConfig.port+"/open/noLogin/smsToDoctor?consult="+params,
- json: true,
- headers: {
- "content-type": "application/json",
- },
- method: 'GET'
- }, 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);
- }
- });
- }
- }
- module.exports = HlwyyWechatAssistantSDK;
|