test.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. <template>
  2. <view class="content">
  3. <view class="text-area">
  4. <button @click="print">打印</button>
  5. <button @click="test">关闭黑标</button>
  6. <button @click="test2">开启黑标</button>
  7. <button @click="scan">扫描</button>
  8. <button @click="init">初始化</button>
  9. <button @click="start">start</button>
  10. <button @click="stop">stop</button>
  11. <button @click="over">over</button>
  12. <span>{{ title }}</span>
  13. </view>
  14. </view>
  15. </template>
  16. <script>
  17. const modal = uni.requireNativePlugin('js-pda');
  18. const uhf = uni.requireNativePlugin('js-uhf');
  19. export default {
  20. data() {
  21. return {
  22. title: 'Hello'
  23. }
  24. },
  25. onLoad() {
  26. uhf.init({}, res => {
  27. uni.showToast({
  28. title: res.msg
  29. })
  30. })
  31. },
  32. methods: {
  33. over() {
  34. uhf.onDestroy({}, res => {
  35. this.title = res
  36. uni.showToast({
  37. title: res.msg
  38. })
  39. })
  40. },
  41. stop() {
  42. uhf.stop({}, res => {
  43. this.title = res
  44. uni.showToast({
  45. title: res
  46. })
  47. })
  48. },
  49. start() {
  50. uhf.start({}, res => {
  51. this.title = JSON.stringify(res.data)
  52. uni.showToast({
  53. title: res.msg
  54. })
  55. })
  56. },
  57. init() {
  58. uhf.init({}, res => {
  59. uni.showToast({
  60. title: res.msg
  61. })
  62. })
  63. },
  64. scan() {
  65. modal.scanCode({}, res => {
  66. uni.showToast({
  67. title: res
  68. })
  69. })
  70. },
  71. print() {
  72. modal.print({
  73. code: 0,
  74. text: 'ljs print',
  75. align: 0,
  76. size: 1
  77. }, res => {
  78. uni.showToast({
  79. title: res
  80. })
  81. })
  82. modal.print({
  83. code: 1,
  84. text: '131774539099',
  85. align: 0,
  86. size: 1
  87. }, res => {
  88. uni.showToast({
  89. title: res
  90. })
  91. })
  92. },
  93. test2() {
  94. modal.setPaperPosition(
  95. {
  96. code: 1
  97. },
  98. res => {
  99. uni.showToast({
  100. title: res
  101. })
  102. }
  103. )
  104. },
  105. test() {
  106. modal.setPaperPosition(
  107. {
  108. code: 0
  109. },
  110. res => {
  111. uni.showToast({
  112. title: res
  113. })
  114. }
  115. )
  116. // modal.aaaa({}, res=> {
  117. // uni.showToast({
  118. // title: res.type
  119. // })
  120. // var Intent = plus.android.importClass('android.content.Intent');
  121. // var intent = new Intent('ismart.intent.scandown');
  122. // // 添加内容
  123. // intent.putExtra('text', 'hahahahahahahaaaha');
  124. // // 添加对齐方式,0为左对齐,1为居中,2为居右
  125. // intent.putExtra('align', 0);
  126. // // 添加文字大小设置, 1为正常字体,2为双倍字体
  127. // intent.putExtra('size', 1);
  128. // var main = plus.android.runtimeMainActivity();
  129. // main.sendBroadcast(intent);
  130. // })
  131. }
  132. }
  133. }
  134. </script>
  135. <style>
  136. </style>