博客列表 >lodop控件打印小票

lodop控件打印小票

南鸢离梦的博客
南鸢离梦的博客原创
2019年11月12日 15:58:242686浏览
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0"/>
  6. <title>小票打印</title>
  7. <script type="text/javascript" src="/static/js/jquery.min.js"></script>
  8. <script src="/static/js/LodopFuncs.js"></script> // 引入看控件JS
  9. <object id="LODOP_OB" classid="clsid:2105C259-1E0C-4534-8141-A753534CB4CA" width=0 height=0>
  10. <embed id="LODOP_EM" type="application/x-print-lodop" width=0 height=0 pluginspage="install_lodop32.exe"></embed>
  11. </object>
  12. <style type="text/css">
  13. .left{
  14. float: left;
  15. }
  16. .right{
  17. float:right;
  18. }
  19. .clearfix{
  20. clear: both;
  21. }
  22. ul{list-style: none;}
  23. .print_container{
  24. width: 200px;
  25. }
  26. .section1{
  27. }
  28. .section2 label{
  29. display: block;
  30. }
  31. .section3 label{
  32. display: block;
  33. }
  34. .section4{
  35. }
  36. .section4 .total label{
  37. display: block;
  38. }
  39. .section4 .other_fee{
  40. border-bottom: 1px solid #DADADA;
  41. }
  42. .section5 label{
  43. display: block;
  44. }
  45. </style>
  46. </head>
  47. <body style="background-color:#fff;" >
  48. <div class="print_container" id="form1" >
  49. <h3>{$title}</h3>
  50. <span>********************************</span>
  51. <div class="section2">
  52. <label>订单备注:{$orders.remark}</label>
  53. </div>
  54. <span>********************************</span>
  55. <div class="section3">
  56. <label>订单编号:{$orders.order_number}</label>
  57. <br>
  58. <label>订单时间:{$orders.time}</label>
  59. </div>
  60. <span>********************************</span>
  61. <div class="section4">
  62. <div style="border-bottom: 1px solid #DADADA;">
  63. <table style="width: 100%;">
  64. <thead>
  65. <tr>
  66. <td width="60%">商品名称</td>
  67. <td width="20%">数量</td>
  68. <td width="20%">金额</td>
  69. </tr>
  70. </thead>
  71. <tbody>
  72. {volist name="goods" id="v"}
  73. <tr>
  74. <td>{$v.name}</td>
  75. <td>{$v.num}</td>
  76. <td>{$v.price * $v.num}</td>
  77. </tr>
  78. {/volist}
  79. </tbody>
  80. </table>
  81. </div>
  82. <div class="total">
  83. <label class="left">总计</label>
  84. <label class="right">¥{$orders.total_price}</label>
  85. <div class="clearfix"></div>
  86. </div>
  87. <div style="text-align: right;">
  88. <label id="f"></label>
  89. </div>
  90. <span>********************************</span>
  91. </div>
  92. <div class="section5">
  93. <label>姓名:{$user.name}</label>
  94. <br>
  95. <label>电话:{$user.phone}</label>
  96. </div>
  97. <span>********************************</span>
  98. </div>
  99. <div>
  100. <lable>是否出***</lable>
  101. <input type="radio" name="f" value="1" checked>是 &nbsp;
  102. <input type="radio" name="f" value="2"><br>
  103. <button id="btn" style="border-radius: 3%;width: 56px;padding: 3px;" onclick="prn1_preview()">打印</button>
  104. </div>
  105. <script type="text/javascript" language="javascript">
  106. var LODOP; //声明为全局变量
  107. function prn1_preview() {
  108. var fp = $("input[name='f']:checked").val();
  109. if (fp ==1){
  110. $("#f").html("已出***&nbsp;&nbsp;&nbsp;")
  111. }else{
  112. $("#f").html("未出***&nbsp;&nbsp;&nbsp;")
  113. }
  114. CreateOneFormPage();
  115. LODOP.PREVIEW(); // 打印预览
  116. // LODOP.PRINT(); // 直接打印
  117. };
  118. function CreateOneFormPage(){
  119. LODOP=getLodop();
  120. LODOP.PRINT_INIT(); // 打印初始化
  121. LODOP.SET_PRINT_STYLE("FontSize",15); // 设置打印字体
  122. LODOP.SET_PRINT_STYLE("Bold",1); // 设置加粗
  123. LODOP.SET_PRINT_PAGESIZE(3,800,45,""); // 设置纸张大小
  124. LODOP.SET_PRINT_MODE("PRINT_PAGE_PERCENT",'90%'); // 设置打印缩放
  125. LODOP.ADD_PRINT_HTM(10,20,'100%','100%',document.getElementById("form1").innerHTML); // 设置打印内容
  126. };
  127. </script>
  128. </body>
  129. </html>
声明:本文内容转载自脚本之家,由网友自发贡献,版权归原作者所有,如您发现涉嫌抄袭侵权,请联系admin@php.cn 核实处理。
全部评论
文明上网理性发言,请遵守新闻评论服务协议