|
|
@ -1,10 +1,22 @@ |
|
|
|
<template> |
|
|
|
<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> |
|
|
|
</template> |
|
|
|
|
|
|
|
<script> |
|
|
|
import { |
|
|
|
getCurrDateTime, |
|
|
|
} from '@/common/basic.js'; |
|
|
|
import store from '@/store' |
|
|
|
// #ifdef APP |
|
|
|
var testModule = uni.requireNativePlugin("TestModule") |
|
|
|
// #endif |
|
|
@ -12,16 +24,23 @@ |
|
|
|
export default { |
|
|
|
data() { |
|
|
|
return { |
|
|
|
bufferData:'' |
|
|
|
bufferData:'', |
|
|
|
time:"", |
|
|
|
userName:"" |
|
|
|
} |
|
|
|
}, |
|
|
|
|
|
|
|
onLoad(){ |
|
|
|
this.time =getCurrDateTime() |
|
|
|
this.userName =store.state.user.name |
|
|
|
}, |
|
|
|
components:{ |
|
|
|
|
|
|
|
}, |
|
|
|
methods: { |
|
|
|
// #ifdef APP |
|
|
|
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) |
|
|
|
} |
|
|
|
// #endif |
|
|
@ -31,4 +50,7 @@ |
|
|
|
</script> |
|
|
|
|
|
|
|
<style> |
|
|
|
.font-40 { |
|
|
|
font-size: 40rpx; |
|
|
|
} |
|
|
|
</style> |