Commit 585063b0 authored by 张海景's avatar 张海景

update:实现打印pdf功能

parent 97f5de25
{ {
"dependencies": { "dependencies": {
"@hyoga/uni-socket.io": "^2.0.3",
"svg-sprite-loader": "^6.0.11", "svg-sprite-loader": "^6.0.11",
"uni-read-pages": "^1.0.5", "uni-read-pages": "^1.0.5",
"uni-simple-router": "^2.0.8-beta.4" "uni-simple-router": "^2.0.8-beta.4"
......
<template> <template>
<view> <view>
<u-button @click="exportPDF">预览pdf</u-button> <u-button @click="exportPDF">预览pdf</u-button>
<u-button @click="handlePrint">打印pdf</u-button>
</view> </view>
</template> </template>
<script> <script>
import { io } from 'socket.io-client'; import io from '@hyoga/uni-socket.io';
// import { SOCKET_IO_CLIENT, OPTIONS } from '@/uni_modules/bunny-socket-io-client';
import uButton from '../../uview-ui/components/u-button/u-button.vue'; import uButton from '../../uview-ui/components/u-button/u-button.vue';
export default { export default {
components: { uButton }, components: { uButton },
...@@ -16,34 +18,34 @@ export default { ...@@ -16,34 +18,34 @@ export default {
}; };
}, },
created() { created() {
// this.socket = io('http://192.168.23.19:17521', { this.socket = io('http://192.168.21.104:17521', {
// transports: ['websocket'], transports: ['websocket'],
// auth: { auth: {
// token: 'Bearer ' + this.vuex_token // 在此处填入你 client 设置的 token,缺省可留空 token: 'Bearer ' + this.vuex_token // 在此处填入你 client 设置的 token,缺省可留空
// } }
// }); });
// this.socket.on('connect', () => { this.socket.on('connect', () => {
// globalThis.connect = true; globalThis.connect = true;
// console.log('连接成功444'); console.log('连接成功444');
// // TODO: Do something for your project // TODO: Do something for your project
// }); });
// this.socket.on('clients', (clients) => { this.socket.on('clients', (clients) => {
// globalThis.clients = clients; globalThis.clients = clients;
// console.log(clients, 'clients'); console.log(clients, 'clients');
// }); });
// this.socket.on('printerList', (printerList) => { this.socket.on('printerList', (printerList) => {
// globalThis.printerList = printerList; globalThis.printerList = printerList;
// console.log(printerList, 'printerList'); console.log(printerList, 'printerList');
// }); });
}, },
methods: { methods: {
handlePrint() { handlePrint() {
console.log(this.socket, 'this.$socket'); console.log(this.socket, 'this.$socket');
this.$socket.emit('news', { this.socket.emit('news', {
client: null, client: null,
printer: null, printer: 'HP LaserJet 1022n',
type: 'url_pdf', type: 'url_pdf',
pdf_path: 'http://192.168.23.19:8081/static/123.pdf' pdf_path: 'http://192.168.3.91:8082/static/123.pdf'
}); });
}, },
previewPdf() { previewPdf() {
...@@ -207,4 +209,4 @@ export default { ...@@ -207,4 +209,4 @@ export default {
}; };
</script> </script>
<style lang="scss"></style> <style lang="scss"></style>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment