You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
|
<template>
|
|
|
|
|
<view class="network-print-page">
|
|
|
|
|
<!-- <button type="primary" @tap="linkPrint">连接打印机</button>
|
|
|
|
|
|
|
|
|
|
<button type="warn" @tap="unlinkPrint">断开打印机</button> -->
|
|
|
|
|
</view>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script setup>
|
|
|
|
|
import { onLoad } from '@dcloudio/uni-app'
|
|
|
|
|
|
|
|
|
|
onLoad(() => {
|
|
|
|
|
// uni.requireNativePlugin('hy-print')
|
|
|
|
|
})
|
|
|
|
|
// uni.onSocketOpen(function (res) {
|
|
|
|
|
// console.log('WebSocket连接已打开!');
|
|
|
|
|
// });
|
|
|
|
|
|
|
|
|
|
// uni.onSocketClose(() => {
|
|
|
|
|
// console.log('websocket 已关闭')
|
|
|
|
|
// })
|
|
|
|
|
|
|
|
|
|
// uni.onSocketError((error) => {
|
|
|
|
|
// console.log('websocket 报错', error)
|
|
|
|
|
// })
|
|
|
|
|
// function linkPrint () {
|
|
|
|
|
// uni.connectSocket({
|
|
|
|
|
// url: 'ws://192.168.1.15:9100',
|
|
|
|
|
// success: (res) => {
|
|
|
|
|
// console.log('连接打印机成功', res)
|
|
|
|
|
// uni.getDeviceInfo({
|
|
|
|
|
|
|
|
|
|
// })
|
|
|
|
|
// },
|
|
|
|
|
// fail: (error) => {
|
|
|
|
|
// console.log('连接打印机失败', error)
|
|
|
|
|
// }
|
|
|
|
|
// })
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
// function unlinkPrint() {
|
|
|
|
|
// uni.closeSocket()
|
|
|
|
|
// }
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style lang="scss">
|
|
|
|
|
|
|
|
|
|
</style>
|