You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

175 lines
6.2 KiB

import router from '../router'
export default {
ReqSign(url, callback) {
const host = 'http://127.0.0.1:8065'
// url += "?time="+new Date().toTimeString();
let xmlHttpReq = null // 声明一个空对象用来装入XMLHttpRequest
if (window.ActiveXObject) { // IE5 IE6是以ActiveXObject的方式引入XMLHttpRequest的
// eslint-disable-next-line no-undef
xmlHttpReq = new ActiveXObject('Microsoft.XMLHTTP')
} else if (window.XMLHttpRequest) { // 除IE5 IE6 以外的浏览器XMLHttpRequest是window的子对象
xmlHttpReq = new XMLHttpRequest()// 实例化一个XMLHttpRequest
}
if (xmlHttpReq != null) { // 如果对象实例化成功
// 时间戳
if (url.indexOf('?') >= 0) {
url = url + '&t=' + (new Date()).valueOf()
} else {
url = url + '?t=' + (new Date()).valueOf()
}
xmlHttpReq.open('GET', host + url, true) // 调用open()方法并采用异步方式
// xmlHttpReq.setRequestHeader('If-Modified-Since', '0');
// xmlHttpReq.open("GET",url,false);
xmlHttpReq.onreadystatechange = RequestCallBack // 设置回调函数
xmlHttpReq.send(null) // 因为使用get方式提交,所以可以使用null参调用
}
function RequestCallBack() { // 一旦readyState值改变,将会调用这个函数
if (xmlHttpReq.readyState === 4) {
// alert(0)
if (xmlHttpReq.status === 200) {
// alert(1)
// 将xmlHttpReq.responseText的值赋给ID为 resText 的元素
if (typeof callback === 'function') {
// debugger
try {
const end = xmlHttpReq.responseText.indexOf(')')
const substr = xmlHttpReq.responseText.substring(2, end)
const resp_ = substr.replace(/\n/g, '').replace(/\r/g, '')// 去掉base64换行符
const resp = JSON.parse(resp_.replace(/\n/g, '').replace(/\s|\xA0/g, ''))// 去掉字符串中的所有空格
// console.log(resp)
callback(resp)
} catch (e) {
// console.log(xmlHttpReq.responseText)
// document.getElementById("textInfo").innerHTML = "数据解析失败。";
alert('数据解析失败。')
}
}
} else {
// console.log(xmlHttpReq)
alert('代理服务因异常未启动(C:\\Program Files (x86)\\Browser_proxy)双击启动。')
// document.getElementById("textInfo").innerHTML = "代理服务未启动。";
}
}
}
},
// 启动设备
ZCStartDeviceA_onclick(ids) {
this.ReqSign('/ZCStartDeviceAB', function(xmlHttpReq) {
})
},
// 启动签名模式
ZCBeginSignA_onclick() {
this.ReqSign('/ZCBeginSignAB/AA660BB350CC600DD400', function(xmlHttpReq) {
if (xmlHttpReq.resp === '0') {
// 成功签名
// this.ZCOutputImageBase64A_onclick()
}
})
},
ZCShowHtmlA_onclick(ids) { // 推送网页
const routeData = router.resolve({
path: '/showGrantInfo',
query: { jsonInfo: JSON.stringify(ids) }
})
window.open('http://jinan.sdsei.org.cn/' + routeData.href, '_blank', 'height=screen.height, width=screen.width, top=0, left=0, toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, status=no, fullscreen=yes')
this.ReqSign('/ZCShowHtmlAB/' + 'http://jinan.sdsei.org.cn/' + routeData.href, this.startMouse)
},
// 关闭网页
ZCStopHtmlA_onclick() {
this.ReqSign('/ZCStopHtmlAB', function(xmlHttpReq) {
// document.all['retinfo'].value = xmlHttpReq.resp
})
},
ZCStopDeviceA_onclick() { // 停止设备
this.ReqSign('/ZCStopDeviceAB', function(xmlHttpReq) {
// document.all['retinfo'].value = xmlHttpReq.resp
})
},
ZCEndSignA_onclick() { // 退出签名模式
const url = '/ZCEndSignAB'
this.ReqSign(url, function(xmlHttpReq) {
// document.all['retinfo'].value = xmlHttpReq.resp
})
},
ZCGetSerialNumA_onclick() { // 获取序列号
document.all['retinfo'].value = ''
const url = '/ZCGetSerialNumAB'
this.ReqSign(url, function(xmlHttpReq) {
document.all['retinfo'].value = xmlHttpReq.resp
})
},
ZCSetModeA_onclick() { // 设置笔宽
document.all['retinfo'].value = ''
const width = document.getElementById('textpenwid')
const url = '/ZCSetModeAB/' + width.value
this.ReqSign(url, function(xmlHttpReq) {
document.all['retinfo'].value = xmlHttpReq.resp
})
},
// 获取base64图片
ZCOutputImageBase64A_onclick() {
this.ReqSign('/ZCOutputImageBase64AB', function(xmlHttpReq) {
console.log(xmlHttpReq.resp)
})
},
// 获取地址
ZCSaveJpgA_onclick() {
const picPath = 'D:\\Pic001.jpg'
document.all['retinfo'].value = ''
const url = '/ZCSaveJpgAB/' + picPath
this.ReqSign(url, function(xmlHttpReq) {
document.all['retinfo'].value = xmlHttpReq.resp
})
},
// 获取地址
ZCSaveJpgA_onclick1() {
const picPath = 'D:\\Pic002.png'
document.all['retinfo'].value = ''
const url = '/ZCSaveJpgAB/' + picPath
this.ReqSign(url, function(xmlHttpReq) {
document.all['retinfo'].value = xmlHttpReq.resp
})
}, // 启用鼠标
Zstartmouse_onclick() {
console.log('js:startmouse')
this.ReqSign('/ZCStartMouse', function(xmlHttpReq) {
console.log(xmlHttpReq)
})
}, // 禁用鼠标
endmouse_onclick() {
// document.all['retinfo'].value = ''
const url = '/ZCEndMouse'
this.ReqSign(url, function(xmlHttpReq) {
// document.all['retinfo'].value = xmlHttpReq.resp
})
},
startMouse(xmlHttpReq) { // 启动鼠标
if (xmlHttpReq.resp === '0') {
this.Zstartmouse_onclick()
// this.ZCBeginSignA_onclick()
}
},
stopHtml() {
const that = this
this.ReqSign('/ZCStopHtmlAB', function(xmlHttpReq) {
if (xmlHttpReq.resp === '0') {
that.ReqSign('/ZCEndMouse', function(xmlHtt) {
})
}
})
},
stopHtmlAll() { // 停用网页
const that = this
this.ReqSign('/ZCStopHtmlAB', function(xmlHttpReq) {
if (xmlHttpReq.resp === '0') {
that.ReqSign('/ZCEndMouse', function(xmlHtt) {
if (xmlHtt.resp === '0') {
that.ReqSign('/ZCStopDeviceAB', function(xmlHttpReq) {
console.log(xmlHttpReq)
})
}
})
}
})
}
}