|
sunmiV2printer模块demo示例(手持便携式打印机)
[复制链接]
本帖最后由 潘文 于 2019-7-10 07:45 编辑
本模块封装了商米手持便携打印设备V2的打印功能。
点击进入模块说明文档
示例代码如下:
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8">
- <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
- <title>title</title>
- <link rel="stylesheet" type="text/css" href="../css/api.css" />
- <style>
- html body {
- padding: 20px;
- }
- span {
- margin: 10px;
- }
- </style>
- </head>
- <body>
- <span tapmode onclick="startService()">startService</span><br>
- <span tapmode onclick="printText()">printText</span><br>
- <span tapmode onclick="lineWrap()">lineWrap</span><br>
- <span tapmode onclick="printData()">printData</span><br>
- <span tapmode onclick="printQRCode()">printQRCode</span><br>
- <span tapmode onclick="initPrinter()">initPrinter</span><br>
- <span tapmode onclick="stopService()">stopService</span><br>
- </body>
- <script type="text/javascript" src="../script/api.js"></script>
- <script type="text/javascript">
- var button;
- apiready = function() {
- sunmiV2Printer = api.require('sunmiV2Printer');
- };
- function startService() {
- sunmiV2Printer.startService(function(ret, err){
- //alert(JSON.stringify(ret));
- if(ret.status){
- alert("打印服务已启动!");
- }
- });
- }
- function printText() {
- sunmiV2Printer.printText({
- text:'Hello APICloud!',
- size:24,
- isBole:false,
- isUnderLine:false,
- }, function( ret , err ) {
- //alert(JSON.stringify(ret));
- });
-
- sunmiV2Printer.lineWrap({
- n:3
- }, function( ret , err ) {
- //alert(JSON.stringify(ret));
- });
-
- }
- function lineWrap() {
- sunmiV2Printer.lineWrap({
- n:3
- }, function( ret , err ) {
- //alert(JSON.stringify(ret));
- });
- }
-
- <blockquote>function printData() {
复制代码
|
本帖子中包含更多资源,您需要 登录 才可以下载或查看,没有帐号?立即注册
X
|