【Uniapp 原生插件】芯烨云打印机插件

芯烨云打印机插件

插件地址:https://ext.dcloud.net.cn/plugin?id=8358

插件需求

使用插件前,请先使用试用版本,在本地调试好,看插件是否满足,再进行购买。如果插件不满足你的需求,可以联系我(微信:18386474459),尝试修改插件或者增加功能的方式,来帮助实现你的业务逻辑。

接口列表

  • 获取插件
  • 测试插件
  • 初始化配置:在线
  • 初始化配置:离线
  • 添加打印机【必接】
  • 设置打印机语音类型
  • 打印小票订单
  • 打印标签订单
  • 删除打印机
  • 修改打印机信息
  • 清空待打印队列
  • 查询订单状态
  • 查询打印机订单数
  • 查询打印机状态
  • 批量查询打印机状态
  • 云喇叭播放语音
  • POS 指令
  • 钱箱控制

使用案例

获取插件

// 芯烨云打印机插件
let xpyunPrinterPlugin = uni.requireNativePlugin('Tellsea-XpyunPrinterPlugin');
console.log('芯烨云打印机插件:' + JSON.stringify(xpyunPrinterPlugin));

测试插件

// 测试插件
testPlugin() {
    xpyunPrinterPlugin.testPlugin('测试插件', (e) => {
        let res = JSON.parse(e);
        if (res.code == 200) {
            that.$msg('安装成功');
        } else {
            that.$msg(res.msg);
        }
    });
},

初始化配置:在线

// 初始化配置:在线
onLine() {
    let params = {
        userName: '账号',
        userKey: 'key'
    };
    xpyunPrinterPlugin.onLine(params.userName, params.userKey, (e) => {
        let res = JSON.parse(e);
        console.log(res);
        if (res.code == 200) {
            that.$msg(res.msg);
        } else {
            that.$msg(res.msg);
        }
    });
},

初始化配置:离线

// 初始化配置:离线
offLine() {
    let params = {
        userName: '账号',
        userKey: 'key'
        // 内网IP映射到公网地址 https://open.xpyun.net/api/openapi
        baseUrl: '这里填写内网地址',
    };
    xpyunPrinterPlugin.offLine(params.userName, params.userKey, params.baseUrl, (e) => {
        let res = JSON.parse(e);
        console.log(res);
        if (res.code == 200) {
            that.$msg(res.msg);
        } else {
            that.$msg(res.msg);
        }
    });
},

添加打印机【必接】

// 添加打印机【必接】
addPrinters() {
    let params = {
        items: [{
            sn: 'XPY123456789A',
            name: '测试打印机'
        },
            {
                sn: 'XPY123456789A',
                name: '测试打印机'
            }
        ]
    };
    xpyunPrinterPlugin.execute('addPrinters', params, (e) => {
        let res = JSON.parse(e);
        console.log(res);
        if (res.code == 200) {
            that.$msg(res.msg);
        } else {
            that.$msg(res.msg);
        }
    });
},

设置打印机语音类型

// 设置打印机语音类型
setPrinterVoiceType() {
    let params = {
        sn: 'XPY123456789A',
        'voiceType': 3,
        'volumeLevel': 0
    };
    xpyunPrinterPlugin.execute('setPrinterVoiceType', params, (e) => {
        let res = JSON.parse(e);
        console.log(res);
        if (res.code == 200) {
            that.$msg(res.msg);
        } else {
            that.$msg(res.msg);
        }
    });
},

打印小票订单

// 打印小票订单
print() {
    let params = {
        "sn": "XPY123456789A",
        "content": "<CB>配送总单<BR></CB><CB>配送总单<BR></CB><CB>配送总单<BR></CB><CB>配送总单<BR></CB>",
        "copies": 1,
        "voice": 1,
    };
    xpyunPrinterPlugin.execute('print', params, (e) => {
        let res = JSON.parse(e);
        console.log(res);
        if (res.code == 200) {
            that.$msg(res.msg);
        } else {
            that.$msg(res.msg);
        }
    });
},

打印标签订单

// 打印标签订单
printLabel() {
    let params = {
        "sn": "XPY123456789A",
        "content": "<TEXT x=\"10\" y=\"100\" font=\"9\" w=\"1\" h=\"2\" r=\"0\">测试文本内容1</TEXT>",
        "copies": 1,
        "voice": 2,
    };
    xpyunPrinterPlugin.execute('printLabel', params, (e) => {
        let res = JSON.parse(e);
        console.log(res);
        if (res.code == 200) {
            that.$msg(res.msg);
        } else {
            that.$msg(res.msg);
        }
    });
},

删除打印机

// 删除打印机
delPrinters() {
    let params = {
        "snlist": ["XPY123456789A", "XPY987654321B", "XPY123456723A", "XPY987654345B"],
    };
    xpyunPrinterPlugin.execute('delPrinters', params, (e) => {
        let res = JSON.parse(e);
        console.log(res);
        if (res.code == 200) {
            that.$msg(res.msg);
        } else {
            that.$msg(res.msg);
        }
    });
},

修改打印机信息

// 修改打印机信息
updPrinter() {
    let params = {
        "sn": "XPY123456789A",
        "name": "X58C1",
        "cardno": "13031547528",
    };
    xpyunPrinterPlugin.execute('updPrinter', params, (e) => {
        let res = JSON.parse(e);
        console.log(res);
        if (res.code == 200) {
            that.$msg(res.msg);
        } else {
            that.$msg(res.msg);
        }
    });
},

清空待打印队列

// 清空待打印队列
delPrinterQueue() {
    let params = {
        "sn": "XPY123456789A",
    };
    xpyunPrinterPlugin.execute('delPrinterQueue', params, (e) => {
        let res = JSON.parse(e);
        console.log(res);
        if (res.code == 200) {
            that.$msg(res.msg);
        } else {
            that.$msg(res.msg);
        }
    });
},

查询订单状态

// 查询订单状态
queryOrderState() {
    let params = {
        "orderId": "OM19081005152569029225",
    };
    xpyunPrinterPlugin.execute('queryOrderState', params, (e) => {
        let res = JSON.parse(e);
        console.log(res);
        if (res.code == 200) {
            that.$msg(res.msg);
        } else {
            that.$msg(res.msg);
        }
    });
},

查询打印机订单数

// 查询打印机订单数
queryOrderStatis() {
    let params = {
        "sn": "XPY123456789A",
        "date": "2019-08-15",
    };
    xpyunPrinterPlugin.execute('queryOrderStatis', params, (e) => {
        let res = JSON.parse(e);
        console.log(res);
        if (res.code == 200) {
            that.$msg(res.msg);
        } else {
            that.$msg(res.msg);
        }
    });
},

查询打印机状态

// 查询打印机状态
queryPrinterStatus() {
    let params = {
        "sn": "XPY123456789A",
    };
    xpyunPrinterPlugin.execute('queryPrinterStatus', params, (e) => {
        let res = JSON.parse(e);
        console.log(res);
        if (res.code == 200) {
            that.$msg(res.msg);
        } else {
            that.$msg(res.msg);
        }
    });
},

批量查询打印机状态

// 批量查询打印机状态
queryPrintersStatus() {
    let params = {
        "snlist": ["XPY123456789A", "XPY123456789B"],
    };
    xpyunPrinterPlugin.execute('queryPrintersStatus', params, (e) => {
        let res = JSON.parse(e);
        console.log(res);
        if (res.code == 200) {
            that.$msg(res.msg);
        } else {
            that.$msg(res.msg);
        }
    });
},

云喇叭播放语音

// 云喇叭播放语音
playVoice() {
    let params = {
        "sn": "0504B38PFGB6A49",
        // 支付方式41~55:支付宝 微信 ...
        "payType": 41,
        // 支付与否59~61:退款 到账 消费
        "payMode": 59,
        // 支付金额
        "money": 100,
    };
    xpyunPrinterPlugin.execute('playVoice', params, (e) => {
        let res = JSON.parse(e);
        console.log(res);
        if (res.code == 200) {
            that.$msg(res.msg);
        } else {
            that.$msg(res.msg);
        }
    });
},

POS 指令

// POS 指令
pos() {
    let params = {
        "sn": "XPY123456789A",
        "content": "<CB>配送总单<BR></CB><CB>配送总单<BR></CB><CB>配送总单<BR></CB><CB>配送总单<BR></CB>",
        "copies": 1,
        "voice": 1,
    };
    xpyunPrinterPlugin.execute('pos', params, (e) => {
        let res = JSON.parse(e);
        console.log(res);
        if (res.code == 200) {
            that.$msg(res.msg);
        } else {
            that.$msg(res.msg);
        }
    });
},

钱箱控制

// 钱箱控制
controlBox() {
    let params = {
        "sn": "XPY123456789A",
        "content": "<CB>配送总单<BR></CB><CB>配送总单<BR></CB><CB>配送总单<BR></CB><CB>配送总单<BR></CB>",
        "copies": 1,
        "voice": 1,
    };
    xpyunPrinterPlugin.execute('controlBox', params, (e) => {
        let res = JSON.parse(e);
        console.log(res);
        if (res.code == 200) {
            that.$msg(res.msg);
        } else {
            that.$msg(res.msg);
        }
    });
},
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Tellsea

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值