123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130 |
- <template>
- <view>
- <view v-if="" class="initPrint">
- <view>使用须知</view>
- <view>使用前先连接wifi打印机</view>
-
- </view>
- <button type="primary" @click="initPrinter()">打印初始化</button>
- <button type="primary" @click="print()">打印</button>
- </view>
- </template>
- <script>
-
- const plug= uni.requireNativePlugin('Html5app-Gprinter');
- export default {
- data() {
- return {
-
- }
- },
- methods: {
- initPrinter(){
-
- var GPrinter = uni.requireNativePlugin('G-Printer');
-
- GPrinter.openNetPort('192.168.50.200', 9100, (res)=>{
-
- })
- },
- print() {
-
- TSC.initPrint();
-
-
- TSC.addSize({
- width:40,
- height:30
- });
-
- TSC.addGap({
- gap:2
- });
-
- TSC.addReference({
- x:0,
- y:0
- });
-
- TSC.addTear({
- enable:1
- });
-
- TSC.addQueryPrinterStatus({
- mode:"ON"
- });
-
- TSC.addCls();
-
- TSC.addBox({
- x:16,
- y:16,
- thickness:2,
- xend:312,
- yend:232
- });
-
- TSC.addText({
- x:72,
- y:16,
- font:"TSS24.BF2",
- rotation:0,
- Xscal:1,
- Yscal:1,
- text:"欢迎使用Printer"
- });
-
- var image = plus.io.convertLocalFileSystemURL("_www/static/test.jpg")
- TSC.addBitmap({
- x:20,
- y:48,
- mode:0,
- nWidth:90,
- b:image
- });
-
- TSC.addQRCode({
- x:200,
- y:48,
- level:"L",
- cellwidth:5,
- rotation:0,
- data:" www.smarnet.cc"
- });
-
- TSC.add1DBarcode({
- x:40,
- y:160,
- type:"CODE128",
- height:60,
- readable:1,
- rotation:0,
- content:"SMARNET"
- });
-
- TSC.addPrint({
- m:1
- });
-
- TSC.addSound({
- level:2,
- interval:100
- });
-
- TSC.addCashdrwer({
- m:1,
- t1:255,
- t2:255
- });
-
-
- TSC.commitPrint();
- }
- }
- }
- </script>
- <style>
- </style>
|