You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

10 lines
7.3 KiB

(global["webpackJsonp"]=global["webpackJsonp"]||[]).push([["components/kk-printer/index"],{"0024":function(e,t,i){"use strict";(function(e,n){var c=i("47a9"),o=i("3b2d");Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var a=c(i("2df0"));(function(e,t){if(!t&&e&&e.__esModule)return e;if(null===e||"object"!==o(e)&&"function"!==typeof e)return{default:e};var i=r(t);if(i&&i.has(e))return i.get(e);var n={},c=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var a in e)if("default"!==a&&Object.prototype.hasOwnProperty.call(e,a)){var s=c?Object.getOwnPropertyDescriptor(e,a):null;s&&(s.get||s.set)?Object.defineProperty(n,a,s):n[a]=e[a]}n.default=e,i&&i.set(e,n)})(i("769c")),c(i("60b9"));function r(e){if("function"!==typeof WeakMap)return null;var t=new WeakMap,i=new WeakMap;return(r=function(e){return e?i:t})(e)}var s={data:function(){return{isPrinting:!1,isSearching:!1,isShowSearch:!1,filterName:"",filterRSSI:-95,devicesList:[],picWaitTime:0,deviceId:"",services:"",serviceId:"",writeId:"",readId:"",iosNo:!1,deviceType:"ios"}},props:{defaultText:{type:String,default:"打印"},printingText:{type:String,default:"打印中..."},bufferData:{type:Array,require:!0},roomcode:{type:String,require:!0},CustName:{type:String,require:!0},roomid:{type:String,require:!0}},mounted:function(){},onLoad:function(){},beforeDestroy:function(){this.stopSearchBtnTap()},methods:{doNothing:function(){},handlePrintTap:function(){var t=this;e.showLoading({mask:!0,title:"打印中..."}),e.getSystemInfo({success:function(e){t.deviceType=e.osName},fail:function(e){}}),n.openBluetoothAdapter({mode:"central",success:function(e){t.sousuo()},fail:function(i){"10001"==i.errCode?e.showToast({duration:2e3,title:"请打开蓝牙后,再进行连接",icon:"none",mask:!0}):(t.tui.toast("连接失败,请重启蓝牙或删除小程序重新进入-1"),t.isShowSearch=!0),setTimeout((function(t){e.hideLoading()}),2e3)}})},sousuo:function(){var t=this;this.devicesList=[],n.startBluetoothDevicesDiscovery({success:function(e){t.jiantingshebei()},fail:function(i){t.tui.toast("连接失败,请重启蓝牙或删除小程序重新进入-2",i),n.closeBLEConnection({deviceId:e.getStorageSync("deviceId"),success:function(e){},fail:function(e){}}),n.closeBluetoothAdapter({success:function(e){},fail:function(e){}}),e.removeStorageSync("deviceId"),t.handlePrintTap(),t.isShowSearch=!0,setTimeout((function(t){e.hideLoading()}),2e3)}})},stopSearchBtnTap:function(){n.stopBluetoothDevicesDiscovery()},jiantingshebei:function(){var t=this;e.getStorageSync("deviceId")?t.lianejieshebei(e.getStorageSync("deviceId")):(e.hideLoading(),t.isShowSearch=!0,n.onBluetoothDeviceFound((function(e){e.devices.forEach((function(e){(e.name||e.localName)&&t.devicesList.push(e)}))})))},lianejieshebei:function(t){var i=this;e.showLoading({mask:!0,title:"加载中..."});var c=setTimeout((function(){n.closeBLEConnection({deviceId:t,success:function(e){},fail:function(e){}}),n.closeBluetoothAdapter({success:function(e){},fail:function(e){}}),e.removeStorageSync("deviceId"),i.handlePrintTap(),i.isShowSearch=!0}),5e3);n.createBLEConnection({deviceId:t,success:function(){clearTimeout(c),i.isShowSearch=!1,i.huoqufuwu(t)},fail:function(e){clearTimeout(c),"1509007"==e.errno&&i.huoqufuwu(t),"1509003"==e.errno&&i.lianejieshebei(t)}})},huoqufuwu:function(t){var i=this;n.getBLEDeviceServices({deviceId:t,success:function(e){i.duxietezhengzhi(t,e)},fail:function(t){i.tui.toast("连接失败,请重启蓝牙或删除小程序重新进入-4",t),n.closeBLEConnection({deviceId:e.getStorageSync("deviceId"),success:function(e){}}),e.removeStorageSync("deviceId"),i.sousuo(),i.isShowSearch=!0,setTimeout((function(t){e.hideLoading()}),2e3)}})},duxietezhengzhi:function(t,i){var c=this;n.getBLEDeviceCharacteristics({deviceId:t,serviceId:i.services[0].uuid,success:function(n){for(var o=0;o<n.characteristics.length;o++){var a=n.characteristics[o];if(c.startNoticeBle(t,i.services[0].uuid,n.characteristics[2].uuid),a.properties.write)return e.setStorageSync("deviceId",t),e.setStorageSync("serviceId",i.services[0].uuid),e.setStorageSync("characteristicId",a.uuid),void c.xierushuju()}},fail:function(t){c.tui.toast("连接失败,请重启蓝牙或删除小程序重新进入-5",t),n.closeBLEConnection({deviceId:e.getStorageSync("deviceId"),success:function(e){}}),e.removeStorageSync("deviceId"),c.sousuo(),c.isShowSearch=!0,setTimeout((function(t){e.hideLoading()}),2e3)}})},startNoticeBle:function(t,i,n){var c=this;e.notifyBLECharacteristicValueChange({state:!0,deviceId:t,serviceId:i,characteristicId:n,success:function(e){c.GetDataFromBle()},fail:function(e){}})},GetDataFromBle:function(){var t=this;e.onBLECharacteristicValueChange((function(i){t.bleData=t.ab2hex(i.value),e.hideLoading(),setTimeout((function(t){e.closeBLEConnection({deviceId:e.getStorageSync("deviceId"),success:function(e){},fail:function(e){}})}),t.picWaitTime)}))},ab2hex:function(e){var t=Array.prototype.map.call(new Uint8Array(e),(function(e){return("00"+e.toString(16)).slice(-2)}));return t.join("")},xierushuju:function(){var e=this;"打印小票"==this.defaultText?e.$emit("onPrintSmall"):"确认打印"==this.defaultText?e.$emit("goPrint"):"小标签"==this.defaultText?e.$emit("onPrintSmall1"):e.$emit("onPrint"),e.$nextTick((function(){for(var t="",i=0;i<e.bufferData.length;i++)t+=e.bufferData[i];var n="android"==e.deviceType?20:180,c="android"==e.deviceType?20:180,o=a.default.strToGBKByte(t);-1!=t.indexOf("EG ")&&(e.picWaitTime=o.byteLength+200);for(var r=0,s=0,u=o.byteLength;r<u;r+=n,s++){var d=o.slice(r,r+n<=u?r+n:u);setTimeout(e._writeBLECharacteristicValue,s*c,d)}}))},_writeBLECharacteristicValue:function(t){var i=this;n.writeBLECharacteristicValue({deviceId:e.getStorageSync("deviceId"),serviceId:e.getStorageSync("serviceId"),characteristicId:e.getStorageSync("characteristicId"),value:t,success:function(e){},fail:function(t){n.closeBLEConnection({deviceId:e.getStorageSync("deviceId"),success:function(e){}}),e.getStorageSync("deviceId")||i.jiantingshebei(),e.hideLoading()}})},handleSearchClose:function(){n.closeBluetoothAdapter({success:function(e){}}),this.isShowSearch=!1}}};t.default=s}).call(this,i("df3c")["default"],i("3223")["default"])},"06da":function(e,t,i){"use strict";i.r(t);var n=i("0024"),c=i.n(n);for(var o in n)["default"].indexOf(o)<0&&function(e){i.d(t,e,(function(){return n[e]}))}(o);t["default"]=c.a},"4af3":function(e,t,i){"use strict";i.r(t);var n=i("9acb"),c=i("06da");for(var o in c)["default"].indexOf(o)<0&&function(e){i.d(t,e,(function(){return c[e]}))}(o);i("5f94");var a=i("828b"),r=Object(a["a"])(c["default"],n["b"],n["c"],!1,null,"4002e4a2",null,!1,n["a"],void 0);t["default"]=r.exports},"5f94":function(e,t,i){"use strict";var n=i("71a4"),c=i.n(n);c.a},"71a4":function(e,t,i){},"9acb":function(e,t,i){"use strict";i.d(t,"b",(function(){return n})),i.d(t,"c",(function(){return c})),i.d(t,"a",(function(){}));var n=function(){var e=this.$createElement,t=(this._self._c,this.devicesList.length);this.$mp.data=Object.assign({},{$root:{g0:t}})},c=[]}}]);
;(global["webpackJsonp"] = global["webpackJsonp"] || []).push([
'components/kk-printer/index-create-component',
{
'components/kk-printer/index-create-component':(function(module, exports, __webpack_require__){
__webpack_require__('df3c')['createComponent'](__webpack_require__("4af3"))
})
},
[['components/kk-printer/index-create-component']]
]);