import axios from 'axios'
import qs from 'qs'
export function printLable(dataq) {
console.log('开始');
var data = {};
data.reqParam = "1";
var printparamsJsonArray = [];
printparamsJsonArray.push({"PTK_OpenUSBPort" : "1"});
printparamsJsonArray.push( {"PTK_SetLabelHeight" : "480,16,0,false"});
printparamsJsonArray.push( {"PTK_SetLabelWidth" : "960"});
//printparamsJsonArray.push( {"PTK_SetAllPrinterInfo" : "24,10"});
printparamsJsonArray.push({"PTK_DrawText_TrueType":"25,10,80,0,微软雅黑,1,650,0,0,0,微软雅黑体常规测试文本"});
printparamsJsonArray.push({"PTK_DrawText_TrueType":"25,80,80,0,微软雅黑,1,650,0,0,0,单位:采油五厂"});
printparamsJsonArray.push({"PTK_DrawBar2D_QREx" : "700,200,0,8,0,0,8,test1,QR测试数据2"},);
printparamsJsonArray.push({"PTK_PrintLabel" : "1,1"});
printparamsJsonArray.push({"PTK_CloseUSBPort":""});
data.printparams = JSON.stringify(printparamsJsonArray);
console.log("打印数据1111", JSON.stringify(data), typeof (JSON.stringify(data)), window.location.href.indexOf('http:'), window.location.protocol)
var url = "http://127.0.0.1:888/postek/print"
axios.post(url, qs.stringify(data), {headers: {
'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8'
}
})
.then(response => {
//console.log('post发送Ajax请求,请求成功', response.data)
})
.catch(response => {
console.log('post发送Ajax请求,请求失败', response)
})
}
export function getPrintPort() {
console.log('开始');
var data = {};
data.reqParam = "printerList";
//当有多台POSTEK打印机是获取打印机清单
//如若一台电脑有且仅有一台POSTEK打印机 则无需获取 USB端口用255
var url = "http://127.0.0.1:888/postek/print"
axios.post(url, qs.stringify(data), {
})
.then(response => {
// console.log('post发送Ajax请求,请求成功', response.data)
})
.catch(response => {
console.log('post发送Ajax请求,请求失败', response)
})
}