Browse Source

添加打印测试页

hella_online_20241011
lijuncheng 2 months ago
parent
commit
8f6eba1ee7
  1. 28
      src/pages/print/index.vue
  2. 3
      src/pages/setter/index.vue

28
src/pages/print/index.vue

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

3
src/pages/setter/index.vue

@ -17,6 +17,7 @@
<u-cell-item icon="order" title="版本号" :arrow="false">{{version}}</u-cell-item> <u-cell-item icon="order" title="版本号" :arrow="false">{{version}}</u-cell-item>
<!-- #ifdef APP --> <!-- #ifdef APP -->
<u-cell-item icon="reload" title="检查更新" @click="update">{{version}}</u-cell-item> <u-cell-item icon="reload" title="检查更新" @click="update">{{version}}</u-cell-item>
<u-cell-item icon="tags" title="app打印测试" @click="printTest"></u-cell-item>
<!-- #endif --> <!-- #endif -->
</u-cell-group> </u-cell-group>
@ -146,7 +147,7 @@
}) })
} }
function print() { function printTest() {
uni.navigateTo({ uni.navigateTo({
url:"/pages/print/index" url:"/pages/print/index"
}) })

Loading…
Cancel
Save