请参考以下脚本代码
// 实现sendWeixinRichTextMessage(touser,title,description,url,picUrl)函数的应用,发送微信信息给指定用户
var userids=getCurrentDocument().getItemValueAsString("接收人");//表单,获取接收人的值
var touser="";
if(userids!=""&&userids!=null){
userids = userids.split(';');
for (var i=0; i < userids.length; i++ ) {
var user = getUserById(userids[i]);
if(user!=null && user.isUseWEI() == true){ //user.isUseWEI() == true后台设置该用户是否发送微信
touser+= user.getLoginno()+"|";
}
}
touser=touser.substring(0,touser.length-1);
}
var formid=getCurrentDocument().getFormid();
var agentid="1";
var docid=getCurrentDocument().getId();
var request = $WEB.getParamsTable().getHttpRequest();//获取当前request
//如果服务器本身就可以访问,就可以通过函数获取
var url0="http://"+request.getServerName()+":"+request.getServerPort()+getConte
xtPath();
var url1="http://ws.jhkj.com/jhkj/portal/dynaform/document/view.action?_docid="+docid+"&_formid="+formid+"&application="+applicationId;
//打开的url需要转码
url1=encodeURIComponent(url1);
var url = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxe36ce2ae5ff0a86c&redirect_uri="+url1+"&response_type=code&scope=snsapi_base&state="+domainId+"#wechat_redirect";
var title="发送的标题";
var description="发送的内容";
var picUrl=url1+"/resource/image/photo.png";
var flag=sendWeixinRichTextMessage(agentid,touser,title,description,url,picUrl);
println("flag==========="+flag); |