Browse Source

添加打印功能

hella_vue3
lijuncheng 7 months ago
parent
commit
25eb91a677
  1. 2
      .hbuilderx/launch.json
  2. BIN
      nativeplugins/TestModule/android/TestModule.aar
  3. BIN
      nativeplugins/TestModule/libs/itextpdf-5.5.8.jar
  4. 35
      nativeplugins/TestModule/package.json
  5. 18
      src/manifest.json
  6. 12
      src/pages.json
  7. 34
      src/pages/print/index.vue
  8. 9
      src/pages/setter/index.vue

2
.hbuilderx/launch.json

@ -17,7 +17,7 @@
"type" : "uni-app:h5" "type" : "uni-app:h5"
}, },
{ {
"playground" : "standard", "playground" : "custom",
"type" : "uni-app:app-android" "type" : "uni-app:app-android"
} }
] ]

BIN
nativeplugins/TestModule/android/TestModule.aar

Binary file not shown.

BIN
nativeplugins/TestModule/libs/itextpdf-5.5.8.jar

Binary file not shown.

35
nativeplugins/TestModule/package.json

@ -0,0 +1,35 @@
{
"name": "TestModule",
"id": "TestModule",
"version": "1.0.0",
"description": "打印",
"_dp_type": "nativeplugin",
"_dp_nativeplugin": {
"android": {
"integrateType": "aar",
"plugins": [
{
"type": "module",
"name": "TestModule",
"class": "io.dcloud.uniplugin.TestModule"
}
]
}
}
}

18
src/manifest.json

@ -25,6 +25,7 @@
"Barcode" : {}, "Barcode" : {},
"Camera" : {} "Camera" : {}
}, },
/* */ /* */
"distribute" : { "distribute" : {
/* android */ /* android */
@ -58,8 +59,25 @@
/* SDK */ /* SDK */
"sdkConfigs" : { "sdkConfigs" : {
"ad" : {} "ad" : {}
},
"nativePlugins" : {
"TestModule" : {
"__plugin_info__" : {
"name" : "TestModule",
"description" : "打印",
"platforms" : "Android",
"url" : "",
"android_package_name" : "",
"ios_bundle_id" : "",
"isCloud" : false,
"bought" : -1,
"pid" : "",
"parameters" : {}
}
}
} }
} }
}, },
/* */ /* */
"quickapp" : {}, "quickapp" : {},

12
src/pages.json

@ -2021,8 +2021,16 @@
"navigationBarTitleText": "翻包任务详情", "navigationBarTitleText": "翻包任务详情",
"enablePullDownRefresh": false "enablePullDownRefresh": false
} }
},{ },
"path": "pages/point/index", // ,{
// "path": "pages/point/index",
// "style": {
// "navigationBarTitleText": "打印",
// "enablePullDownRefresh": false
// }
// },
{
"path": "pages/print/index",
"style": { "style": {
"navigationBarTitleText": "打印", "navigationBarTitleText": "打印",
"enablePullDownRefresh": false "enablePullDownRefresh": false

34
src/pages/print/index.vue

@ -0,0 +1,34 @@
<template>
<view>
<button @click="printImage"> 打印图片</button>
</view>
</template>
<script>
// #ifdef APP
var testModule = uni.requireNativePlugin("TestModule")
// #endif
export default {
data() {
return {
bufferData:''
}
},
components:{
},
methods: {
// #ifdef APP
printImage(){
var content ="<html><body><h1>Test Content测试打印,测试打印</h1><p>Testing, testing, testing...测试测试测试测试</p></body></html>"
testModule.doHTMLPrint(content)
}
// #endif
}
}
</script>
<style>
</style>

9
src/pages/setter/index.vue

@ -12,6 +12,7 @@
<u-cell-item icon="level" v-if="userInfo!=null" title="角色" :arrow="false">{{(userInfo.roles || []).map(role => role.name).join(',')}}</u-cell-item> <u-cell-item icon="level" v-if="userInfo!=null" title="角色" :arrow="false">{{(userInfo.roles || []).map(role => role.name).join(',')}}</u-cell-item>
<u-cell-item icon="trash" title="清除缓存" @click="clear()" ></u-cell-item> <u-cell-item icon="trash" title="清除缓存" @click="clear()" ></u-cell-item>
<u-cell-item icon="edit-pen" title="修改密码" @click="modifiedPassWord()" ></u-cell-item> <u-cell-item icon="edit-pen" title="修改密码" @click="modifiedPassWord()" ></u-cell-item>
<u-cell-item icon="edit-pen" title="打印" @click="print()" ></u-cell-item>
<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>
@ -140,6 +141,14 @@
}) })
} }
function print() {
uni.navigateTo({
url:"/pages/print/index"
})
}
</script> </script>
<style> <style>

Loading…
Cancel
Save