总结:这种类似的第三方开发或者是基于控件的开发,其实是比较简单的,让别人给个deamo和(接口文档),然后参考别人的范例,把别人给的deamo改一改(修改一下方法,加一下方法的参数等即可),主要是要有deamo和文档,然后知道别人哪个方法有什么作用,然后再结合自己系统的设计,把别人的功能并入自己的系统即可
例如:人家的deamo中,很多参数都是在一个页面中输入和获取填充的.
但是我们的设计中,可能是吧这些参数当作一个签章服务,然后在制章的时候,调用产品配置的签章服务对应的内容即可.
那么我们就在页面上设置这些参数的隐藏input,然后后台根据产品配置来获取这些信息,回传给页面,然后制章方法中就获取这些隐藏的值,进行填充;
需要动态配置的值,就替换之后再回传,比如企业名称用:enterprise.name,后台获取配置的时候,根据实际值进行替换后再回传页面
document.all.xxx.value,可以根据name或者id获取对应的元素的值.
制章
电子签章
1,根据setMoban方法选择印章模版,进行不同的显示
<td>印章模版:
<select id="sealmodel" onclick="setMoban()">
<option value="0">圆形单边</option>
<option value="1">圆形双边</option>
<option value="2">椭圆单边</option>
<option value="3">椭圆双边</option>
<option value="4">方形个人</option>
</select>
</td>
2,点击制章的时候,也是根据选择印章模版,把输入值填充到document.all.MakeSeal1.xxx中
然后调用控件的方法进行制章
<input type="button" value="生成印章" onclick="setseal()">
function setseal(){
//选择的印章模版
var i=document.all.sealmodel.value;
if(i==0){
//获取输入的制章的参数
document.all.MakeSeal1.TopArcText2=document.all.TopArcText2.value;//内环文字
document.all.MakeSeal1.TopTextAngle2=document.all.TopTextAngle2.value;//内环文字角度
document.all.MakeSeal1.MiddleLineText=document.all.MiddleLineText.value;//中间文字
document.all.MakeSeal1.MiddleTextExtent=document.all.MiddleTextExtent.value;//中间文字间距
document.all.MakeSeal1.BottomArcText=document.all.BottomArcText.value;//下弦文字
document.all.MakeSeal1.BottomTextAngle=document.all.BottomTextAngle.value;//下弦文字角度
}else if(i==1){
document.all.MakeSeal1.TopArcText=document.all.TopArcText.value;//上弦文字
document.all.MakeSeal1.TopTextAngle=document.all.TopTextAngle.value;//上弦文字角度
document.all.MakeSeal1.TopArcText2=document.all.TopArcText2.value;//内环文字
document.all.MakeSeal1.TopTextAngle2=document.all.TopTextAngle2.value;//内环文字角度
}else if(i==2){
document.all.MakeSeal1.TopArcText2=document.all.TopArcText2.value;//内环文字
document.all.MakeSeal1.TopTextAngle2=document.all.TopTextAngle2.value;//内环文字角度
document.all.MakeSeal1.MiddleLineText=document.all.MiddleLineText.value;//中间文字
document.all.MakeSeal1.MiddleTextExtent=document.all.MiddleTextExtent.value;//中间文字间距
document.all.MakeSeal1.BottomArcText=document.all.BottomArcText.value;//下弦文字
document.all.MakeSeal1.BottomTextAngle=document.all.BottomTextAngle.value;//下弦文字角度
}else if(i==3){
document.all.MakeSeal1.TopArcText=document.all.TopArcText.value;//上弦文字
document.all.MakeSeal1.TopTextAngle=document.all.TopTextAngle.value;//上弦占用角度
document.all.MakeSeal1.TopArcText2=document.all.TopArcText2.value;//内环文字
document.all.MakeSeal1.TopTextAngle2=document.all.TopTextAngle2.value;//内环文字角度
document.all.MakeSeal1.MiddleLineText=document.all.MiddleLineText.value;//中间文字
document.all.MakeSeal1.MiddleTextExtent=document.all.MiddleTextExtent.value;//中间文字间距
document.all.MakeSeal1.BottomArcText=document.all.BottomArcText.value;//下弦文字
document.all.MakeSeal1.BottomTextAngle=document.all.BottomTextAngle.value;//下弦文字角度
}
//调用控件进行制章
document.all.MakeSeal1.RegenSealBmp();
}
3.点击写入key的时候,调用如下方法.(应该做一下改造,参数从后台传入)
<input type="button" value="写入key" onclick="setkey()">
function setkey(enterpriseSn,enterpriseName){
document.all.MakeSeal1.SealID=enterpriseSn;//印章id,可以取企业标识
document.all.MakeSeal1.SealName=enterpriseName;//印章名称,可以取公司名称
document.all.MakeSeal1.CompanyName=enterpriseName;//公司名称
document.all.MakeSeal1.SealBpp=8;//改参数作用未知
document.all.MakeSeal1.SaveToSeal(1,"");//调用控件的方法写入key
}
4.导出印章图片,主要是调用控件的函数生成图片数据,
返回存储路径或者图片的BASE64,然后传递到后台进行存储
<input type="button" value="导出图片" onclick="savegif()">
function savegif(){
var sealdata=document.all.MakeSeal1.DirectGetBmp("gif",0);//0为保存文件,返回值为文件路径;1为返回文件base64值。
//var sealdata=document.all.MakeSeal1.DirectGetBmp("gif",1);
alert(sealdata);
}
5,获取印章数据,类似于写入key,参数其实也应该用传入的
getbase(enterpriseSn,enterpriseName)
<input type="button" value="生成印章数据" onclick="getbase()">
function getbase(){
document.all.MakeSeal1.SealID="001";
document.all.MakeSeal1.SealName="123123";
document.all.MakeSeal1.CompanyName="2323";
document.all.MakeSeal1.SealBpp=8;
alert(document.all.MakeSeal1.GetSealBase64());
}
6,导入印章,用加载本地图片或者图片的base64的方式加载印章(base64可以考虑后台回传或者作为回调的接收参数),印章的图片格式目前只能是gif格式的
<input type="button" value="导入印章" onclick="setgif()">
function setgif(){
//document.all.MakeSeal1.DirectSetBmp("c:/test.gif",192);//加载本地图片
var gifbase64="";
document.all.MakeSeal1.DirectSetBmp("STRDATA:"+gifbase64,192);//加载图片base64
}
其他总结:
-有一个控件可以调用key里面的签章进行盖章;并查看证书和签章信息(adobe也可以查看)
-印章id估计也是看配置的,有时候是不可以重读的,有时候可以重复.
授权
1,点击测试按钮
<form>
<input type="button" value="自动更新" onclick="AutoUpdate();">
</form>
2,加载LicRegClient控件,获取控件对象,设置对象属性:授权账号,地址,业务类型等,然后调用控件的方法进行授权
<script Language="JavaScript">
var $=function(id){return document.getElementById(id);};
function AutoUpdate(){
var obj = $("LicRegClient");
if(!obj){
return false;
}
obj.CurrUser="xxx";//设置授权账号
var str="xxx";//设置授权平台地址
obj.ServerAddr=str;
obj.CurrBusiness="";//添加业务类型,多个用;分割
var upd=obj.CardUpdate(0x200);
var res=obj.CheckLic(0);
if(res==0){
alert("授权正确");
}else if(res==-200){
alert("未插入key");
}
}