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

update:实现打印pdf功能

parent 97f5de25
{
"dependencies": {
"@hyoga/uni-socket.io": "^2.0.3",
"svg-sprite-loader": "^6.0.11",
"uni-read-pages": "^1.0.5",
"uni-simple-router": "^2.0.8-beta.4"
......
<template>
<view>
<u-button @click="exportPDF">预览pdf</u-button>
<u-button @click="handlePrint">打印pdf</u-button>
</view>
</template>
<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';
export default {
components: { uButton },
......@@ -16,34 +18,34 @@ export default {
};
},
created() {
// this.socket = io('http://192.168.23.19:17521', {
// transports: ['websocket'],
// auth: {
// token: 'Bearer ' + this.vuex_token // 在此处填入你 client 设置的 token,缺省可留空
// }
// });
// this.socket.on('connect', () => {
// globalThis.connect = true;
// console.log('连接成功444');
// // TODO: Do something for your project
// });
// this.socket.on('clients', (clients) => {
// globalThis.clients = clients;
// console.log(clients, 'clients');
// });
// this.socket.on('printerList', (printerList) => {
// globalThis.printerList = printerList;
// console.log(printerList, 'printerList');
// });
this.socket = io('http://192.168.21.104:17521', {
transports: ['websocket'],
auth: {
token: 'Bearer ' + this.vuex_token // 在此处填入你 client 设置的 token,缺省可留空
}
});
this.socket.on('connect', () => {
globalThis.connect = true;
console.log('连接成功444');
// TODO: Do something for your project
});
this.socket.on('clients', (clients) => {
globalThis.clients = clients;
console.log(clients, 'clients');
});
this.socket.on('printerList', (printerList) => {
globalThis.printerList = printerList;
console.log(printerList, 'printerList');
});
},
methods: {
handlePrint() {
console.log(this.socket, 'this.$socket');
this.$socket.emit('news', {
this.socket.emit('news', {
client: null,
printer: null,
printer: 'HP LaserJet 1022n',
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() {
......@@ -207,4 +209,4 @@ export default {
};
</script>
<style lang="scss"></style>
\ No newline at end of file
<style lang="scss"></style>
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