print-config.vue 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. <template>
  2. <view>
  3. <view v-if="" class="initPrint">
  4. <view>使用须知</view>
  5. <view>使用前先连接wifi打印机</view>
  6. </view>
  7. <button type="primary" @click="initPrinter()">打印初始化</button>
  8. <button type="primary" @click="print()">打印</button>
  9. </view>
  10. </template>
  11. <script>
  12. const plug= uni.requireNativePlugin('Html5app-Gprinter');
  13. export default {
  14. data() {
  15. return {
  16. }
  17. },
  18. methods: {
  19. initPrinter(){
  20. var GPrinter = uni.requireNativePlugin('G-Printer');
  21. GPrinter.openNetPort('192.168.50.200', 9100, (res)=>{
  22. })
  23. },
  24. print() {
  25. TSC.initPrint();
  26. TSC.addSize({
  27. width:40,
  28. height:30
  29. });
  30. TSC.addGap({
  31. gap:2
  32. });
  33. TSC.addReference({
  34. x:0,
  35. y:0
  36. });
  37. TSC.addTear({
  38. enable:1
  39. });
  40. TSC.addQueryPrinterStatus({
  41. mode:"ON"
  42. });
  43. TSC.addCls();
  44. TSC.addBox({
  45. x:16,
  46. y:16,
  47. thickness:2,
  48. xend:312,
  49. yend:232
  50. });
  51. TSC.addText({
  52. x:72,
  53. y:16,
  54. font:"TSS24.BF2",
  55. rotation:0,
  56. Xscal:1,
  57. Yscal:1,
  58. text:"欢迎使用Printer"
  59. });
  60. var image = plus.io.convertLocalFileSystemURL("_www/static/test.jpg")
  61. TSC.addBitmap({
  62. x:20,
  63. y:48,
  64. mode:0,
  65. nWidth:90,
  66. b:image
  67. });
  68. TSC.addQRCode({
  69. x:200,
  70. y:48,
  71. level:"L",
  72. cellwidth:5,
  73. rotation:0,
  74. data:" www.smarnet.cc"
  75. });
  76. TSC.add1DBarcode({
  77. x:40,
  78. y:160,
  79. type:"CODE128",
  80. height:60,
  81. readable:1,
  82. rotation:0,
  83. content:"SMARNET"
  84. });
  85. TSC.addPrint({
  86. m:1
  87. });
  88. TSC.addSound({
  89. level:2,
  90. interval:100
  91. });
  92. TSC.addCashdrwer({
  93. m:1,
  94. t1:255,
  95. t2:255
  96. });
  97. TSC.commitPrint();
  98. }
  99. }
  100. }
  101. </script>
  102. <style>
  103. </style>