<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>