|
@ -1,10 +1,22 @@ |
|
|
<template> |
|
|
<template> |
|
|
<view> |
|
|
<view> |
|
|
<button @click="printImage"> 打印图片</button> |
|
|
<view class="" style="font-size: 40rpx; margin-top: 20rpx; margin-left: 20rpx;"> |
|
|
|
|
|
({{userName}})用户,测试打印功能 |
|
|
|
|
|
|
|
|
|
|
|
</view> |
|
|
|
|
|
<view class="" style="font-size: 40rpx; margin-top: 20rpx; margin-left: 20rpx;"> |
|
|
|
|
|
打印时间 {{time}} |
|
|
|
|
|
</view> |
|
|
|
|
|
|
|
|
|
|
|
<button style="position: fixed; bottom: 0;right: 0; width: 100%;" @click="printImage" type="primary" >app打印测试</button> |
|
|
</view> |
|
|
</view> |
|
|
</template> |
|
|
</template> |
|
|
|
|
|
|
|
|
<script> |
|
|
<script> |
|
|
|
|
|
import { |
|
|
|
|
|
getCurrDateTime, |
|
|
|
|
|
} from '@/common/basic.js'; |
|
|
|
|
|
import store from '@/store' |
|
|
// #ifdef APP |
|
|
// #ifdef APP |
|
|
var testModule = uni.requireNativePlugin("TestModule") |
|
|
var testModule = uni.requireNativePlugin("TestModule") |
|
|
// #endif |
|
|
// #endif |
|
@ -12,16 +24,23 @@ |
|
|
export default { |
|
|
export default { |
|
|
data() { |
|
|
data() { |
|
|
return { |
|
|
return { |
|
|
bufferData:'' |
|
|
bufferData:'', |
|
|
|
|
|
time:"", |
|
|
|
|
|
userName:"" |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
onLoad(){ |
|
|
|
|
|
this.time =getCurrDateTime() |
|
|
|
|
|
this.userName =store.state.user.name |
|
|
|
|
|
}, |
|
|
components:{ |
|
|
components:{ |
|
|
|
|
|
|
|
|
}, |
|
|
}, |
|
|
methods: { |
|
|
methods: { |
|
|
// #ifdef APP |
|
|
// #ifdef APP |
|
|
printImage(){ |
|
|
printImage(){ |
|
|
var content ="<html><body><h1>Test Content测试打印,测试打印</h1><p>Testing, testing, testing...测试测试测试测试</p></body></html>" |
|
|
var content =`<html><body><h1 class="font-40">(${this.userName})用户,测试打印功能</h1><h1 class="font-40">打印时间+${this.time}zuot</h1> </body></html>` |
|
|
testModule.doHTMLPrint(content) |
|
|
testModule.doHTMLPrint(content) |
|
|
} |
|
|
} |
|
|
// #endif |
|
|
// #endif |
|
@ -31,4 +50,7 @@ |
|
|
</script> |
|
|
</script> |
|
|
|
|
|
|
|
|
<style> |
|
|
<style> |
|
|
|
|
|
.font-40 { |
|
|
|
|
|
font-size: 40rpx; |
|
|
|
|
|
} |
|
|
</style> |
|
|
</style> |