Beruflich Dokumente
Kultur Dokumente
window.sunmiInnerPrinter.printerInit();
window.sunmiInnerPrinter.printerSelfChecking();
window.sunmiInnerPrinter.printOriginalText("Hello World!");
window.sunmiInnerPrinter.printString("Hello World!");
(<any>window).plugins.sunmiInnerPrinter.printString("Hello String!");
https://github.com/labibramadhan/cordova-sunmi-inner-printer
window.sunmiInnerPrinter.printOriginalText("Hello World!")
https://github.com/labibramadhan/cordova-sunmi-inner-
printer/blob/master/www/innerprinter.js
Thank you
For Ionic 3: In .ts file, add "declare let sunmiInnerPrinter: any;" before
@Component and call the methods as "sunmiInnerPrinter.printOriginalText("Hello
Printer");"
@gayu1712
cd PATH/TO/NEW/SUNMI/PRINTER
git clone git@github.com@tmalbonph:cordova-plugin-sunmi-inner-printer.git
cd PATH/OF/YOUR/IONIC/PROJECT
ionic cordova plugin rm cordova-plugin-sunmi-inner-printer
edit PATH/OF/YOUR/IONIC/PROJECT/platforms/android/build.gradle
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
compile "com.sunmi:sunmiui:latest.release" <------ ADD THIS
// SUB-PROJECT DEPENDENCIES START
debugCompile(project(path: "CordovaLib", configuration: "debug"))
releaseCompile(project(path: "CordovaLib", configuration: "release"))
// SUB-PROJECT DEPENDENCIES END
}
https://github.com/labibramadhan/cordova-sunmi-inner-printer/issues/14
toPrintOrder(){
var lines = ["产品","数量","单价"];
var widths = [16,4,6,];
var aligns = [0,1,2];
var address = this.state.order.address;
var orderNumber = this.state.order.orderNumber;
if(orderNumber){
orderNumber = orderNumber.replace('OTN_','');
}
SunmiInnerPrinter.printString("牛家作订单: "+ dateFormat(new Date(),'yyyy-
MM-dd HH:mm:ss')
+"\n 地址:\n"
+"--"+address.province+address.city+address.district+address.street+address.address
+"\n"
+"联系方式:\n"
+"--"+address.contact+"\n\n")
.then(()=>SunmiInnerPrinter.printString("================================\n"))
.then(()=>SunmiInnerPrinter.printColumnsText(lines,widths,aligns))
.then(()=>{
for(var i=0;i<this.state.order.products.length;i++){
var p = this.state.order.products[i];
var lines = [p.name,p.quantity+"",p.price+""]
SunmiInnerPrinter.printColumnsText(lines,widths,aligns)
if(i== this.state.order.products.length-1){
//set timeout to make sure print completed.
setTimeout(()=> {
return
SunmiInnerPrinter.printString("================================\n")
.then(()=>SunmiInnerPrinter.printString("共"+this.state.order.products.length+"件,共
计:"+this.state.order.bill.total+"元\n"))
.then(()=>SunmiInnerPrinter.printBarCode(orderNumber,8,80,2,2))
.then(()=>SunmiInnerPrinter.printString("\n\n\n\n"))
.then(()=>{
SunmiInnerPrinter.commitPrinterBuffer();// actually no
need to commit.
Alert.alert("打印完成","打印完成");
});
},200);
}
}
}).catch((err)=>{
Alert.alert("打印出错","打印出错");
});
esto está sucediendo porque es sincrónica. simplemente esperar a que cada promesa
de resolver antes de pasar a la siguiente. Esto debería funcionar.