123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141 |
- <template>
- <view class="content">
- <view class="text-area">
- <button @click="print">打印</button>
- <button @click="test">关闭黑标</button>
- <button @click="test2">开启黑标</button>
- <button @click="scan">扫描</button>
- <button @click="init">初始化</button>
- <button @click="start">start</button>
- <button @click="stop">stop</button>
- <button @click="over">over</button>
- <span>{{ title }}</span>
- </view>
- </view>
- </template>
- <script>
- const modal = uni.requireNativePlugin('js-pda');
- const uhf = uni.requireNativePlugin('js-uhf');
-
- export default {
- data() {
- return {
- title: 'Hello'
- }
- },
- onLoad() {
- uhf.init({}, res => {
- uni.showToast({
- title: res.msg
- })
- })
- },
- methods: {
- over() {
- uhf.onDestroy({}, res => {
- this.title = res
- uni.showToast({
- title: res.msg
- })
- })
-
- },
- stop() {
- uhf.stop({}, res => {
- this.title = res
- uni.showToast({
- title: res
- })
- })
- },
- start() {
- uhf.start({}, res => {
- this.title = JSON.stringify(res.data)
- uni.showToast({
- title: res.msg
- })
- })
- },
- init() {
- uhf.init({}, res => {
- uni.showToast({
- title: res.msg
- })
- })
- },
- scan() {
- modal.scanCode({}, res => {
- uni.showToast({
- title: res
- })
- })
- },
- print() {
- modal.print({
- code: 0,
- text: 'ljs print',
- align: 0,
- size: 1
- }, res => {
- uni.showToast({
- title: res
- })
- })
- modal.print({
- code: 1,
- text: '131774539099',
- align: 0,
- size: 1
- }, res => {
- uni.showToast({
- title: res
- })
- })
- },
- test2() {
- modal.setPaperPosition(
- {
- code: 1
- },
- res => {
- uni.showToast({
- title: res
- })
- }
- )
- },
- test() {
- modal.setPaperPosition(
- {
- code: 0
- },
- res => {
- uni.showToast({
- title: res
- })
- }
- )
- // modal.aaaa({}, res=> {
- // uni.showToast({
- // title: res.type
- // })
- // var Intent = plus.android.importClass('android.content.Intent');
- // var intent = new Intent('ismart.intent.scandown');
- // // 添加内容
- // intent.putExtra('text', 'hahahahahahahaaaha');
- // // 添加对齐方式,0为左对齐,1为居中,2为居右
- // intent.putExtra('align', 0);
- // // 添加文字大小设置, 1为正常字体,2为双倍字体
- // intent.putExtra('size', 1);
- // var main = plus.android.runtimeMainActivity();
- // main.sendBroadcast(intent);
- // })
- }
- }
- }
- </script>
- <style>
- </style>
|