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
8.1 KiB
10 lines
8.1 KiB
(global["webpackJsonp"]=global["webpackJsonp"]||[]).push([["components/kk-printer/index"],{"6e81":function(e,t,i){"use strict";i.r(t);var o=i("948c"),n=i("c10b");for(var c in n)["default"].indexOf(c)<0&&function(e){i.d(t,e,(function(){return n[e]}))}(c);i("e7aa");var s=i("828b"),a=Object(s["a"])(n["default"],o["b"],o["c"],!1,null,"33497e73",null,!1,o["a"],void 0);t["default"]=a.exports},"948c":function(e,t,i){"use strict";i.d(t,"b",(function(){return o})),i.d(t,"c",(function(){return n})),i.d(t,"a",(function(){}));var o=function(){var e=this.$createElement,t=(this._self._c,this.devicesList.length);this.$mp.data=Object.assign({},{$root:{g0:t}})},n=[]},"9f09":function(e,t,i){"use strict";(function(e,o){var n=i("47a9"),c=i("3b2d");Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var s=n(i("301e"));(function(e,t){if(!t&&e&&e.__esModule)return e;if(null===e||"object"!==c(e)&&"function"!==typeof e)return{default:e};var i=a(t);if(i&&i.has(e))return i.get(e);var o={},n=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var s in e)if("default"!==s&&Object.prototype.hasOwnProperty.call(e,s)){var r=n?Object.getOwnPropertyDescriptor(e,s):null;r&&(r.get||r.set)?Object.defineProperty(o,s,r):o[s]=e[s]}o.default=e,i&&i.set(e,o)})(i("b37f")),n(i("3cc2"));function a(e){if("function"!==typeof WeakMap)return null;var t=new WeakMap,i=new WeakMap;return(a=function(e){return e?i:t})(e)}var r={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(){console.log("doNothing")},handlePrintTap:function(){var t=this;e.showLoading({mask:!0,title:"打印中..."}),e.getSystemInfo({success:function(e){t.deviceType=e.osName},fail:function(e){console.log("getSystemInfo",e)}}),o.openBluetoothAdapter({mode:"central",success:function(e){console.log("wx.openBluetoothAdapter"),t.sousuo()},fail:function(i){console.log("初始化失败",i),"10001"==i.errCode?(console.log("蓝牙未打开",i),e.showToast({duration:2e3,title:"请打开蓝牙后,再进行连接",icon:"none",mask:!0})):(t.tui.toast("连接失败,请重启蓝牙或删除小程序重新进入-1"),console.log("连接失败----11"),t.isShowSearch=!0),setTimeout((function(t){e.hideLoading()}),2e3)}})},sousuo:function(){var t=this;this.devicesList=[],o.startBluetoothDevicesDiscovery({success:function(e){console.log("sousuo"),t.jiantingshebei()},fail:function(i){t.tui.toast("连接失败,请重启蓝牙或删除小程序重新进入-2",i),console.log("连接失败----22"),o.closeBLEConnection({deviceId:e.getStorageSync("deviceId"),success:function(e){},fail:function(e){console.log("closeBLEConnection",e)}}),o.closeBluetoothAdapter({success:function(e){console.log(e)},fail:function(e){console.log("closeBluetoothAdapter",e)}}),e.removeStorageSync("deviceId"),t.handlePrintTap(),t.isShowSearch=!0,setTimeout((function(t){e.hideLoading()}),2e3)}})},stopSearchBtnTap:function(){o.stopBluetoothDevicesDiscovery()},jiantingshebei:function(){var t=this;e.getStorageSync("deviceId")?(console.log("监听到lianejieshebei"),t.lianejieshebei(e.getStorageSync("deviceId"))):(e.hideLoading(),t.isShowSearch=!0,o.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 n=setTimeout((function(){o.closeBLEConnection({deviceId:t,success:function(e){},fail:function(e){console.log("lianejieshebei--closeBLEConnection",e)}}),o.closeBluetoothAdapter({success:function(e){console.log(e)},fail:function(e){console.log("lianejieshebei--closeBluetoothAdapter",e)}}),e.removeStorageSync("deviceId"),i.handlePrintTap(),i.isShowSearch=!0}),5e3);console.log("有deviceId吗?",t),o.createBLEConnection({deviceId:t,success:function(){clearTimeout(n),i.isShowSearch=!1,i.huoqufuwu(t)},fail:function(e){console.log("createBLEConnection",e),clearTimeout(n),"1509007"==e.errno&&i.huoqufuwu(t),"1509003"==e.errno&&i.lianejieshebei(t)}})},huoqufuwu:function(t){var i=this;o.getBLEDeviceServices({deviceId:t,success:function(e){i.duxietezhengzhi(t,e)},fail:function(t){i.tui.toast("连接失败,请重启蓝牙或删除小程序重新进入-4",t),console.log("连接失败---44"),o.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 n=this;o.getBLEDeviceCharacteristics({deviceId:t,serviceId:i.services[0].uuid,success:function(o){console.log("characteristics",o.characteristics);for(var c=0;c<o.characteristics.length;c++){var s=o.characteristics[c];if(n.startNoticeBle(t,i.services[0].uuid,o.characteristics[2].uuid),s.properties.write)return e.setStorageSync("deviceId",t),e.setStorageSync("serviceId",i.services[0].uuid),e.setStorageSync("characteristicId",s.uuid),void n.xierushuju()}},fail:function(t){n.tui.toast("连接失败,请重启蓝牙或删除小程序重新进入-5",t),console.log("连接失败----55"),o.closeBLEConnection({deviceId:e.getStorageSync("deviceId"),success:function(e){}}),e.removeStorageSync("deviceId"),n.sousuo(),n.isShowSearch=!0,setTimeout((function(t){e.hideLoading()}),2e3)}})},startNoticeBle:function(t,i,o){var n=this;e.notifyBLECharacteristicValueChange({state:!0,deviceId:t,serviceId:i,characteristicId:o,success:function(e){console.log("监听成功===",e.errMsg,"deviceId===",t),n.GetDataFromBle()},fail:function(e){console.log("开启监听失败",e)}})},GetDataFromBle:function(){var t=this;e.onBLECharacteristicValueChange((function(i){console.log("返回的十六进制",t.ab2hex(i.value)),t.bleData=t.ab2hex(i.value),e.hideLoading(),setTimeout((function(t){e.closeBLEConnection({deviceId:e.getStorageSync("deviceId"),success:function(e){console.log("断开")},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 o="android"==e.deviceType?20:180,n="android"==e.deviceType?20:180,c=s.default.strToGBKByte(t);-1!=t.indexOf("EG ")&&(e.picWaitTime=c.byteLength+200);for(var a=0,r=0,u=c.byteLength;a<u;a+=o,r++){var l=c.slice(a,a+o<=u?a+o:u);setTimeout(e._writeBLECharacteristicValue,r*n,l)}}))},_writeBLECharacteristicValue:function(t){var i=this;o.writeBLECharacteristicValue({deviceId:e.getStorageSync("deviceId"),serviceId:e.getStorageSync("serviceId"),characteristicId:e.getStorageSync("characteristicId"),value:t,success:function(e){},fail:function(t){o.closeBLEConnection({deviceId:e.getStorageSync("deviceId"),success:function(e){}}),e.getStorageSync("deviceId")||i.jiantingshebei(),e.hideLoading()}})},handleSearchClose:function(){o.closeBluetoothAdapter({success:function(e){console.log("999",e)}}),this.isShowSearch=!1}}};t.default=r}).call(this,i("df3c")["default"],i("3223")["default"])},a654:function(e,t,i){},c10b:function(e,t,i){"use strict";i.r(t);var o=i("9f09"),n=i.n(o);for(var c in o)["default"].indexOf(c)<0&&function(e){i.d(t,e,(function(){return o[e]}))}(c);t["default"]=n.a},e7aa:function(e,t,i){"use strict";var o=i("a654"),n=i.n(o);n.a}}]);
|
|
;(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__("6e81"))
|
|
})
|
|
},
|
|
[['components/kk-printer/index-create-component']]
|
|
]);
|
|
|