let jtApi = require("../../static/etc/JTAPI/BleUtil.js"); | let jtApi = require("../../static/etc/JTAPI/BleUtil.js"); | ||||
let kcApi = require("../../static/etc/kcBle/kcBleAPI.js"); | let kcApi = require("../../static/etc/kcBle/kcBleAPI.js"); | ||||
// let jyApiEtc = require("../../static/etc/JYAPI-ETC/jy-bluetooth-obu-wechatmp.js"); //前装-金溢 | // let jyApiEtc = require("../../static/etc/JYAPI-ETC/jy-bluetooth-obu-wechatmp.js"); //前装-金溢 | ||||
// 9901 | |||||
let wjApi9901 = require("../../static/etc/WJSDK9901/wjTools.js"); | |||||
// #ifdef MP-ALIPAY | // #ifdef MP-ALIPAY | ||||
// 这部分代码将仅在支付宝小程序平台下执行 | // 这部分代码将仅在支付宝小程序平台下执行 | ||||
device.selected = false; //防止重复点击 | device.selected = false; //防止重复点击 | ||||
let _name = ""; | let _name = ""; | ||||
switch (prefixName) { | switch (prefixName) { | ||||
case "ETC": | |||||
if (name.split("-")[1] == "KC" || name.split("-")[1].indexOf('C') > 0 || name.split("-")[1].indexOf('K') > 0) { | |||||
_name = "前装-科畅"; | |||||
console.log("前装-科畅") | |||||
} else if (name.split("-")[1] == "JL") { | |||||
_name = "前装-聚力"; //共用 | |||||
} else if (name.split("-")[1] == "WJ") { | |||||
_name = "前装-万集"; //共用 | |||||
} else if (name.split("-")[1] == "JY") { | |||||
_name = "前装-金溢"; | |||||
} | |||||
break; | |||||
case "WJ": | case "WJ": | ||||
_name = "万集"; | _name = "万集"; | ||||
break; | break; | ||||
case "ZZ": | case "ZZ": | ||||
_name = "智载"; | _name = "智载"; | ||||
break; | break; | ||||
case "ETC": | |||||
if (name.split("-")[1] == "KC" || name.split("-")[1].indexOf('C') > 0 || name.split("-")[1].indexOf('K') > 0) { | |||||
_name = "前装-科畅"; | |||||
console.log("前装-科畅") | |||||
} else if (name.split("-")[1] == "JL") { | |||||
_name = "前装-聚力"; //共用 | |||||
} else if (name.split("-")[1] == "WJ") { | |||||
_name = "前装-万集"; //共用 | |||||
} else if (name.split("-")[1] == "JY") { | |||||
_name = "前装-金溢"; | |||||
} | |||||
break; | |||||
default: | default: | ||||
_name = "未知"; | _name = "未知"; | ||||
break; | break; | ||||
tools.showLoadingAlert("蓝牙连接中"); | tools.showLoadingAlert("蓝牙连接中"); | ||||
console.info("连接的是" + prefixName, device); | console.info("连接的是" + prefixName, device); | ||||
switch (prefixName) { | switch (prefixName) { | ||||
case "WJ": | |||||
wjApi.connectDevice( | |||||
device, | |||||
function (res) { | |||||
connectSuccess(res); | |||||
}, | |||||
function (res) { | |||||
listenStatus(res); | |||||
} | |||||
); | |||||
break; | |||||
case "JL": | |||||
jlApi.connectDevice( | |||||
device, | |||||
function (res) { | |||||
console.log('设备链接1', res) | |||||
connectSuccess(res); | |||||
}, | |||||
function (res) { | |||||
console.log('设备链接2', res) | |||||
listenStatus(res); | |||||
} | |||||
); | |||||
break; | |||||
case "ETC": | case "ETC": | ||||
console.log("device.name=====", device.name, device.name.includes("KC"), device.name.includes("JY"), device.name.includes("KC") || device.name.includes("K") || device.name.includes("C")) | console.log("device.name=====", device.name, device.name.includes("KC"), device.name.includes("JY"), device.name.includes("KC") || device.name.includes("K") || device.name.includes("C")) | ||||
if (device.name.includes("KC") || device.name.includes("K")) { | if (device.name.includes("KC") || device.name.includes("K")) { | ||||
} | } | ||||
); | ); | ||||
} else if (device.name.includes("WJ")) { | } else if (device.name.includes("WJ")) { | ||||
wjApi.connectDevice( | |||||
wjApi9901.connectDevice( | |||||
device, | device, | ||||
function (res) { | function (res) { | ||||
preDevice(res); | preDevice(res); | ||||
// ); | // ); | ||||
// } | // } | ||||
break; | break; | ||||
case "WJ": | |||||
wjApi.connectDevice( | |||||
device, | |||||
function (res) { | |||||
connectSuccess(res); | |||||
}, | |||||
function (res) { | |||||
listenStatus(res); | |||||
} | |||||
); | |||||
break; | |||||
case "JL": | |||||
jlApi.connectDevice( | |||||
device, | |||||
function (res) { | |||||
console.log('设备链接1', res) | |||||
connectSuccess(res); | |||||
}, | |||||
function (res) { | |||||
console.log('设备链接2', res) | |||||
listenStatus(res); | |||||
} | |||||
); | |||||
break; | |||||
case "JY": | case "JY": | ||||
jyApi.connectDevice( | jyApi.connectDevice( | ||||
device, | device, | ||||
* 前装设备 | * 前装设备 | ||||
*/ | */ | ||||
const preDevice = (res) => { | const preDevice = (res) => { | ||||
console.log("连接成功1111=====", res.code); | |||||
if (res.code == 0) { | |||||
console.log("连接成功1111=====", res); | |||||
if (res.code == 0 || res.serviceCode==0) { | |||||
console.log("连接成功====="); | console.log("连接成功====="); | ||||
datas.setData("bluLinkStatus", true); | datas.setData("bluLinkStatus", true); | ||||
datas.setData("connectPrefixName", connectPrefixName.value); | datas.setData("connectPrefixName", connectPrefixName.value); | ||||
function getCardId(fun){ | function getCardId(fun){ | ||||
//执行0015文件 | //执行0015文件 | ||||
tools.showLoadingAlert("执行指令"); | tools.showLoadingAlert("执行指令"); | ||||
let cmdArr = [cmd.HOME_DIRECTORY, cmd.APPLICATION_DIRECTORY, "00B095002B"]; | |||||
let cmdArr = [cmd.HOME_DIRECTORY, cmd.APPLICATION_DIRECTORY, cmd.CMD_READBINARY]; | |||||
console.log(cmdArr); | console.log(cmdArr); | ||||
console.log(bluetoothUtil); | console.log(bluetoothUtil); | ||||
bluetoothUtil.transCmd(cmdArr, '10', function(res) { //10:写卡 20:写OBU | bluetoothUtil.transCmd(cmdArr, '10', function(res) { //10:写卡 20:写OBU |
"use strict"; | |||||
var _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(e) { | |||||
return typeof e | |||||
} : function(e) { | |||||
return e && "function" == typeof Symbol && e.constructor === Symbol && e !== Symbol.prototype ? "symbol" : | |||||
typeof e | |||||
}, | |||||
_wjUtils = require("./wjUtils.js"), | |||||
_wjUtils2 = _interopRequireDefault(_wjUtils), | |||||
_wjService = require("./wjService.js"), | |||||
_wjService2 = _interopRequireDefault(_wjService), | |||||
_wjDataInteract = require("./wjDataInteract.js"), | |||||
_wjDataInteract2 = _interopRequireDefault(_wjDataInteract), | |||||
_wjDataAnalysis = require("./wjDataAnalysis.js"), | |||||
_wjDataAnalysis2 = _interopRequireDefault(_wjDataAnalysis), | |||||
_wjDataEncode = require("./wjDataEncode.js"), | |||||
_wjDataEncode2 = _interopRequireDefault(_wjDataEncode); | |||||
function _interopRequireDefault(e) { | |||||
return e && e.__esModule ? e : { | |||||
default: e | |||||
} | |||||
} | |||||
var timeID, TAG_FUNCTION = "function", | |||||
SDK_VERSION = "WJ_BLESDK_WX_WXCDAX_V2.0.1_20240605"; | |||||
function connectDevice(e, t) { | |||||
var i; | |||||
_wjService2.default.reallyConnect(e, function(e) { | |||||
console.log("设备连接", e), i = e, (void 0 === t ? "undefined" : _typeof(t)) == TAG_FUNCTION && t(i) | |||||
}) | |||||
} | |||||
function scanDevice(d) { | |||||
var c = {}, | |||||
l = []; | |||||
wx.openBluetoothAdapter({ | |||||
success: function(e) { | |||||
wx.startBluetoothDevicesDiscovery({ | |||||
services: [], | |||||
success: function(e) { | |||||
wx.onBluetoothDeviceFound(function(e) { | |||||
for (var t = 0; t < e.devices.length; t++) { | |||||
for (var i = !1, n = 0; n < l.length; n++) | |||||
if (e.devices[t].deviceId == l[n].deviceId) { | |||||
i = !0; | |||||
break | |||||
} var o = e.devices[t].name.toUpperCase(); | |||||
if (0 == i && null != o && (l.push(e.devices[t]), _wjUtils2 | |||||
.default.showLog("connectedDeviceName:" + o), o | |||||
.includes("WJ") || o.includes("WANJI") || o | |||||
.includes("ETC") || o.includes("3601") || o | |||||
.includes("YTK") || o.includes("HB") || o.includes( | |||||
"CQ") || o.includes("YUN") || o.includes( | |||||
"SH") || o.includes("HCZJ") || o.includes("NM") || o | |||||
.includes("SC") || o.includes("LJ") || o.includes( | |||||
"HN"))) { | |||||
null != timeID && (clearTimeout(timeID), timeID = null); | |||||
var a = e.devices[t].deviceId, | |||||
s = (_wjUtils2.default.showLog( | |||||
"connectedDeviceId:" + a), {}); | |||||
s.device_name = o, s.device_id = a, wx | |||||
.stopBluetoothDevicesDiscovery({ | |||||
success: function(e) { | |||||
wx.hideLoading(), _wjUtils2.default | |||||
.showLog("停止扫描,开始连接"), | |||||
connectDevice(s, function(e) { | |||||
console.log( | |||||
"serviceResult.serviceCode", | |||||
e.serviceCode), | |||||
console.log( | |||||
"connectDevice2", | |||||
e), 0 === e | |||||
.serviceCode ? (c | |||||
.serviceCode = | |||||
0, c | |||||
.serviceInfo = | |||||
"设备名称:" + s | |||||
.device_name + e | |||||
.serviceInfo, e | |||||
.serviceInfo, | |||||
console.log( | |||||
"设备名称:" + s | |||||
.device_name + | |||||
e | |||||
.serviceInfo | |||||
)) : (c | |||||
.serviceCode = e | |||||
.serviceCode, c | |||||
.serviceInfo = | |||||
"连接失败," + e, e | |||||
.serviceInfo), ( | |||||
void 0 === d ? | |||||
"undefined" : | |||||
_typeof(d)) == | |||||
TAG_FUNCTION && d(c) | |||||
}) | |||||
}, | |||||
fail: function(e) { | |||||
wx.hideLoading(), _wjUtils2.default | |||||
.showError( | |||||
"stopBluetoothDevicesDiscovery fail", | |||||
e) | |||||
} | |||||
}); | |||||
break | |||||
} | |||||
} | |||||
}), timeID = setTimeout(function() { | |||||
wx.closeBluetoothAdapter(), _wjUtils2.default.showError( | |||||
"conn timeout fail"), c.serviceCode = -1, c | |||||
.serviceData = "conn timeout fail", (void 0 === d ? | |||||
"undefined" : _typeof(d)) == TAG_FUNCTION && d(c), wx | |||||
.hideLoading() | |||||
}, 5e3) | |||||
}, | |||||
fail: function(e) { | |||||
_wjUtils2.default.showError("startBluetoothDevicesDiscovery fail", e), c | |||||
.serviceCode = -1, c.serviceData = | |||||
"startBluetoothDevicesDiscovery fail", (void 0 === d ? "undefined" : | |||||
_typeof(d)) == TAG_FUNCTION && d(c) | |||||
} | |||||
}) | |||||
}, | |||||
fail: function() { | |||||
wx.closeBluetoothAdapter({ | |||||
success: function(e) { | |||||
var t = "关闭蓝牙适配器"; | |||||
_wjUtils2.default.showError(t), c.serviceCode = -1, c.serviceData = t, ( | |||||
void 0 === d ? "undefined" : _typeof(d)) == TAG_FUNCTION && d(c) | |||||
} | |||||
}), wx.hideLoading(), wx.showModal({ | |||||
title: "提示", | |||||
content: "蓝牙开关未开启或者手机不支持蓝牙功能!" | |||||
}) | |||||
} | |||||
}) | |||||
} | |||||
function disConnectDevice(t) { | |||||
var i; | |||||
_wjService2.default.reallyDisConnect(function(e) { | |||||
i = e, (void 0 === t ? "undefined" : _typeof(t)) == TAG_FUNCTION && t(i) | |||||
}) | |||||
} | |||||
function init(e) { | |||||
var t = { | |||||
serviceCode: 0, | |||||
serviceInfo: SDK_VERSION | |||||
}; | |||||
console.log("SDK_VERSION", SDK_VERSION), (void 0 === e ? "undefined" : _typeof(e)) == TAG_FUNCTION && e(t) | |||||
} | |||||
function getDeviceInfo(t) { | |||||
var i = {}, | |||||
e = "", | |||||
n = _wjUtils2.default.getCMD_TYPE(); | |||||
0 == n ? e = "810100C0" : 1 == n ? e = "A501C0" : 2 == n && (e = "C5040080020200"), n = _wjDataEncode2.default | |||||
.encode(e), _wjDataInteract2.default._StartSendData(n.serviceData.dataEncode, function(e) { | |||||
i = (0 == e.serviceCode && (console.log("设备信息res", e), _wjUtils2.default.showLog("获取设备信息成功")), e), ( | |||||
void 0 === t ? "undefined" : _typeof(t)) == TAG_FUNCTION && t(i) | |||||
}) | |||||
} | |||||
function selectICDir(t, i) { | |||||
var n = {}, | |||||
e = "010700A4000002" + t, | |||||
o = "", | |||||
a = "", | |||||
s = (1 == _wjUtils2.default.getTRANSFER_TYPE() && (e = _wjUtils2.default.TPDU2APDU(e)), _wjUtils2.default | |||||
.getCMD_TYPE()); | |||||
0 == s ? (o = "10", a = "82") : 1 == s ? (o = "00", a = "A3") : 2 == s && (o = "01", a = "C2"), this | |||||
.transCommandPlain(e, o, a, function(e) { | |||||
0 == e.serviceCode ? (_wjUtils2.default.showLog("IC卡进目录成功"), (n = e).serviceInfo = "IC卡进" + t + | |||||
"目录成功") : n = e, (void 0 === i ? "undefined" : _typeof(i)) == TAG_FUNCTION && i(n) | |||||
}) | |||||
} | |||||
function getCardInfo(t) { | |||||
var i = {}, | |||||
e = "", | |||||
e = "010500B095002B0205805C000204", | |||||
n = "", | |||||
o = "", | |||||
a = (1 == _wjUtils2.default.getTRANSFER_TYPE() && (e = _wjUtils2.default.TPDU2APDU(e)), _wjUtils2.default | |||||
.getCMD_TYPE()); | |||||
0 == a ? (n = "10", o = "82") : 1 == a ? (n = "00", o = "A3") : 2 == a && (n = "01", o = "C2"), this | |||||
.transCommandPlain(e, n, o, function(e) { | |||||
i = 0 == e.serviceCode ? (_wjUtils2.default.showLog("获取卡片信息成功"), _wjDataAnalysis2.default | |||||
.analysisCardInfo(e.serviceData.dataBuff)) : e, (void 0 === t ? "undefined" : _typeof(t)) == | |||||
TAG_FUNCTION && t(i) | |||||
}) | |||||
} | |||||
function selectESAMDir(t, i) { | |||||
var n = {}, | |||||
e = "010700A4000002" + t, | |||||
o = "", | |||||
a = "", | |||||
s = (1 == _wjUtils2.default.getTRANSFER_TYPE() && (e = _wjUtils2.default.TPDU2APDU(e)), _wjUtils2.default | |||||
.getCMD_TYPE()); | |||||
0 == s ? (o = "20", a = "82") : 1 == s ? (o = "00", a = "A0") : 2 == s && (o = "02", a = "C2"), this | |||||
.transCommandPlain(e, o, a, function(e) { | |||||
0 == e.serviceCode ? (_wjUtils2.default.showLog("ESAM卡进" + t + "目录成功"), (n = e).serviceInfo = "ESAM卡进" + | |||||
t + "目录成功") : n = e, (void 0 === i ? "undefined" : _typeof(i)) == TAG_FUNCTION && i(n) | |||||
}) | |||||
} | |||||
function getObuSysInfo(t) { | |||||
var i = {}, | |||||
e = "010500B081001B", | |||||
n = "", | |||||
o = "", | |||||
a = (1 == _wjUtils2.default.getTRANSFER_TYPE() && (e = _wjUtils2.default.TPDU2APDU(e)), _wjUtils2.default | |||||
.getCMD_TYPE()); | |||||
0 == a ? (n = "20", o = "82") : 1 == a ? (n = "00", o = "A0") : 2 == a && (n = "02", o = "C2"), this | |||||
.transCommandPlain(e, n, o, function(e) { | |||||
i = 0 == e.serviceCode ? (_wjUtils2.default.showLog("获取系统信息成功"), _wjDataAnalysis2.default | |||||
.analysisgetObuSysInfo(e.serviceData.dataBuff)) : e, (void 0 === t ? "undefined" : _typeof( | |||||
t)) == TAG_FUNCTION && t(i) | |||||
}) | |||||
} | |||||
function getRand(t) { | |||||
var i = {}, | |||||
e = "01050084000004", | |||||
n = "", | |||||
o = "", | |||||
a = (1 == _wjUtils2.default.getTRANSFER_TYPE() && (e = _wjUtils2.default.TPDU2APDU(e)), _wjUtils2.default | |||||
.getCMD_TYPE()); | |||||
0 == a ? (n = "20", o = "82") : 1 == a ? (n = "00", o = "A0") : 2 == a && (n = "02", o = "C2"), this | |||||
.transCommandPlain(e, n, o, function(e) { | |||||
i = 0 == e.serviceCode ? (_wjUtils2.default.showLog("获取随机数成功"), _wjDataAnalysis2.default | |||||
.analysisGetRand(e.serviceData.dataBuff)) : e, (void 0 === t ? "undefined" : _typeof(t)) == | |||||
TAG_FUNCTION && t(i) | |||||
}) | |||||
} | |||||
function writeObuSysInfo(e, t) { | |||||
var i, n, o, a = {}; | |||||
null != e && 20 == e.length ? (e = "010A" + e, n = i = "", 1 == _wjUtils2.default.getTRANSFER_TYPE() && (e = | |||||
_wjUtils2.default.TPDU2APDU(e)), 0 == (o = _wjUtils2.default.getCMD_TYPE()) ? (i = "20", n = "82") : | |||||
1 == o ? (i = "00", n = "A0") : 2 == o && (i = "02", n = "C2"), this.transCommandPlain(e, i, n, function( | |||||
e) { | |||||
0 == e.serviceCode ? (_wjUtils2.default.showLog("OBU激活成功"), (a = e).serviceInfo = "OBU激活成功") : a = | |||||
e, (void 0 === t ? "undefined" : _typeof(t)) == TAG_FUNCTION && t(a) | |||||
})) : (a.serviceCode = -1, a.serviceInfo = "激活参数错误", (void 0 === t ? "undefined" : _typeof(t)) == | |||||
TAG_FUNCTION && t(a)) | |||||
} | |||||
function getVehCipherInfo(t) { | |||||
var i = {}, | |||||
e = "010F00B400000A01020304050607083B00", | |||||
n = "", | |||||
o = "", | |||||
a = (1 == _wjUtils2.default.getTRANSFER_TYPE() && (e = _wjUtils2.default.TPDU2APDU(e)), _wjUtils2.default | |||||
.getCMD_TYPE()); | |||||
0 == a ? (n = "20", o = "82") : 1 == a ? (n = "00", o = "A0") : 2 == a && (n = "02", o = "C2"), this | |||||
.transCommandPlain(e, n, o, function(e) { | |||||
i = 0 == e.serviceCode ? (_wjUtils2.default.showLog("获取车辆信息密文成功"), _wjDataAnalysis2.default | |||||
.analysisVehCipherInfo(e.serviceData.dataBuff)) : e, (void 0 === t ? "undefined" : _typeof( | |||||
t)) == TAG_FUNCTION && t(i) | |||||
}) | |||||
} | |||||
function transCommandPlain(e, t, i, n) { | |||||
var o = {}, | |||||
a = {}; | |||||
"01" == t || "02" == t || "00" == t ? (a = {}, a = _wjDataEncode2.default.encode(e, t, i), _wjDataInteract2.default | |||||
._StartSendData(a.serviceData.dataEncode, function(e) { | |||||
o = (0 == (o = e).serviceCode ? _wjUtils2.default.showLog("APDU透传指令成功") : _wjUtils2.default.showLog( | |||||
"APDU透传指令失败"), e), (void 0 === n ? "undefined" : _typeof(n)) == TAG_FUNCTION && n(o) | |||||
})) : (o.serviceCode = -1, o.serviceInfo = "command参数错误!", (void 0 === n ? "undefined" : _typeof(n)) == | |||||
TAG_FUNCTION && n(o)) | |||||
} | |||||
function transCommand(e, t, i) { | |||||
var n = {}; | |||||
e = _wjDataEncode2.default.encode(e, "00", t), _wjDataInteract2.default._StartSendData(e.serviceData.dataEncode, | |||||
function(e) { | |||||
n = (0 == (n = e).serviceCode ? _wjUtils2.default.showLog("APDU透传指令成功") : _wjUtils2.default.showLog( | |||||
"APDU透传指令失败"), e), (void 0 === i ? "undefined" : _typeof(i)) == TAG_FUNCTION && i(n) | |||||
}) | |||||
} | |||||
module.exports = { | |||||
scanDevice: scanDevice, | |||||
connectDevice: connectDevice, | |||||
init: init, | |||||
disConnectDevice: disConnectDevice, | |||||
getDeviceInfo: getDeviceInfo, | |||||
transCommand: transCommand | |||||
}; |
"use strict";var iPackageLen,_wjUtils=require("./wjUtils.js"),_wjUtils2=_interopRequireDefault(_wjUtils);function _interopRequireDefault(t){return t&&t.__esModule?t:{default:t}}var bleCount,rxCount=0,strTemData="",strRxBuffer="",isPagFinish=!0;function decode_GB(t){var e=_wjUtils2.default.getCMD_TYPE(),a=0,r={},t=_wjUtils2.default.byteArray2hexStr(t),s=(_wjUtils2.default.showLog("WJ当前接受包的数据:",t),_wjUtils2.default.hexStr2byteArray(t));if(1<s.byteLength?2==e?51==s[0]&&1==isPagFinish?(isPagFinish=!1,iPackageLen=s[3],strTemData=t):strTemData+=t:80==s[0]&&1==isPagFinish?(isPagFinish=!1,iPackageLen=s[3],strTemData=t):strTemData+=t:strTemData+=t,strTemData.length/2>=iPackageLen+5){rxCount+=1,isPagFinish=!0;var o=_wjUtils2.default.hexStr2byteArray(strTemData);if(_wjUtils2.default.showLog("接受完第",rxCount,"包数据,内容 ",strTemData),2==e)for(var i=1;i<iPackageLen+3;i++)a^=o[i];else for(i=0;i<iPackageLen+4;i++)a^=o[i];if(o[strTemData.length/2-1]!=a)return _wjUtils2.default.showError("WJ第",rxCount," 包校验bcc:Error!"),r.serviceCode=-1,r.serviceInfo="校验错误。。。",r;128==(128&o[1])&&(bleCount=((127&o[1])<<8)+o[2],_wjUtils2.default.showLog("总共:",bleCount,"大包")),_wjUtils2.default.showLog("WJ第",rxCount," 包校验bcc:ok!"),strRxBuffer+=strTemData.substring(8,strTemData.length-2)}return bleCount<=rxCount?(r.serviceCode=0,r.serviceInfo="数据接收完成!",r.serviceData={},r.serviceData.strData=strRxBuffer):(r.serviceCode=1,r.serviceInfo="数据接收中。。。"),r}function decode_WX(t){console.log("接受到的BUFFER数据",t);var e=0,a={},t=_wjUtils2.default.byteArray2hexStr(t),r=(_wjUtils2.default.showLog("WJ当前接受包的数据:",t),_wjUtils2.default.hexStr2byteArray(t));if(1<r.byteLength&&254==r[0]&&1==r[1]&&1==isPagFinish?(isPagFinish=!1,iPackageLen=(255&r[2])<<8,iPackageLen+=255&r[3],strTemData=t):strTemData+=t,strTemData.length/2>=iPackageLen){_wjUtils2.default.showLog("大包长度:",iPackageLen,strTemData.length),isPagFinish=!0,rxCount+=1;var s=_wjUtils2.default.hexStr2byteArray(strTemData),r={},o=0,i=0,u=0;for(r.FixHead={},r.FixHead.MagicNumber=strTemData.substr(2*o,2),r.FixHead.Ver=strTemData.substring(2*++o,2),r.FixHead.Len=(s[++o]<<8)+s[o+1],r.FixHead.CmdId=(s[o+=2]<<8)+s[o+1],r.FixHead.Seq=(s[o+=2]<<8)+s[o+1],o+=2,r.ProtoBuf={},r.ProtoBuf.BaseRequest={},r.ProtoBuf.BaseRequest.Mark=strTemData.substr(2*o,2),o++,u=i=0;128==(128&s[o]);)i+=(127&s[o])<<7*u,o++,u++;for(i+=(127&s[o])<<7*u,r.ProtoBuf.BaseRequest.Data=strTemData.substr(2*++o,2*i),o+=i,r.ProtoBuf.Data={},r.ProtoBuf.Data.Mark=strTemData.substr(2*o,2),o++,u=i=0;128==(128&s[o]);)i+=(127&s[o])<<7*u,o++,u++;for(i+=(127&s[o])<<7*u,r.ProtoBuf.Data.Data=strTemData.substr(2*++o,2*i),o+=i,r.ProtoBuf.DataType={},r.ProtoBuf.DataType.Mark=strTemData.substr(2*o,2),o++,u=i=0;128==(128&s[o]);)i+=(127&s[o])<<7*u,o++,u++;i+=(127&s[o])<<7*u,o++,r.ProtoBuf.DataType.Varint=i;for(var n=_wjUtils2.default.hexStr2byteArray(r.ProtoBuf.Data.Data),l=1;l<n.byteLength-1;l++)e^=n[l];if("fe01001a271100010a0018808004200128023a06"!=t&&!t.startsWith("5701")&&!t.startsWith("5348")&&"fe010013271300020a001201411a0400000000"!=t){if(n[n.byteLength-1]!=e)return _wjUtils2.default.showError("WJ第",rxCount," 包校验bcc:Error!"),a.serviceCode=-1,a.serviceInfo="校验错误。。。",a;2==_wjUtils2.default.getCMD_TYPE()?(128==(128&n[1])&&(bleCount=1+(127&n[1]),_wjUtils2.default.showLog("总共:",bleCount,"大包")),strRxBuffer+=r.ProtoBuf.Data.Data.substr(6,2*n[2])):(128==(128&n[2])&&(bleCount=1+(127&n[2]),_wjUtils2.default.showLog("总共:",bleCount,"大包")),strRxBuffer+=r.ProtoBuf.Data.Data.substr(8,2*n[3])),_wjUtils2.default.showLog("WJ第",rxCount," 包校验bcc:ok!")}_wjUtils2.default.showLog("接受完第",rxCount,"大包数据,内容 ",strTemData)}return console.log("rxCount",rxCount,"bleCount",bleCount),strTemData.startsWith("fe01001a271100010a0018808004200128023a06")&&52===strTemData.length||strTemData.startsWith("fe010013271300020a001201411a0400000000")?(a.serviceCode=0,a.serviceInfo="数据接收完成!",a.serviceData={},a.serviceData.strData=strTemData,console.log("握手指令")):bleCount<=rxCount?(console.log("接收数据完成"),a.serviceCode=0,a.serviceInfo="数据接收完成!",a.serviceData={},a.serviceData.strData=strRxBuffer,rxCount=0):(console.log("数据接收中"),a.serviceCode=1,a.serviceInfo="数据接收中。。。"),a}function init(){rxCount=iPackageLen=0,isPagFinish=!(strRxBuffer=strTemData="")}module.exports={decode_GB:decode_GB,decode_WX:decode_WX,init:init}; |
"use strict"; | |||||
var _wjUtils = require("./wjUtils.js"), | |||||
_wjUtils2 = _interopRequireDefault(_wjUtils); | |||||
function _interopRequireDefault(t) { | |||||
return t && t.__esModule ? t : { | |||||
default: t | |||||
} | |||||
} | |||||
function encode(t, e, a) { | |||||
var r = _wjUtils2.default.getProtocolType(), | |||||
t = getETCData(t, e, a), | |||||
e = {}; | |||||
return 0 == r ? e = encode_GB(t) : 1 == r && (e = encode_WX(t)), e | |||||
} | |||||
function getETCData(t, e, a) { | |||||
var r = "", | |||||
r = "A0" == a || "A3" == a || "A4" == a || "82" == a || "C2" == a || "AC" == a ? a + e + (r = getCommand(t)) : | |||||
"A1" == a ? a + (r = getCommand(t)) : t; | |||||
return _wjUtils2.default.showLog("组拼ETCData完毕:", r.length / 2, r), r | |||||
} | |||||
function getCommand(t) { | |||||
var e, a = t, | |||||
r = _wjUtils2.default.getDATA_TYPE(), | |||||
t = t.length / 2, | |||||
n = new ArrayBuffer(10), | |||||
s = new DataView(n); | |||||
return 0 == r ? (e = 256 < t ? (s.setInt8(0, 4 + t & 255), s.setInt8(1, 4 + t >> 8 & 255), s.setInt8(2, 128), s | |||||
.setInt8(3, 130), s.setInt8(4, t >> 8 & 255), s.setInt8(5, 255 & t), n.slice(0, 6)) : 128 < t && t <= | |||||
256 ? (s.setInt8(0, 3 + t & 255), s.setInt8(1, (3 + t & 255) >> 8), s.setInt8(2, 128), s.setInt8(3, 129), s | |||||
.setInt8(4, t), n.slice(0, 5)) : (s.setInt8(0, 2 + t & 255), s.setInt8(1, (2 + t & 255) >> 8), s | |||||
.setInt8(2, 128), s.setInt8(3, t), n.slice(0, 4)), a = _wjUtils2.default.byteArray2hexStr(e) + a) : 1 == | |||||
r && (s.setInt8(0, 255 & t), s.setInt8(1, t >> 8 & 255), e = n.slice(0, 2), a = _wjUtils2.default | |||||
.byteArray2hexStr(e) + a), a | |||||
} | |||||
function encode_GB(t) { | |||||
var e = {}, | |||||
a = _wjUtils2.default.getPagLenMax(), | |||||
r = parseInt(t.length / 2 / a), | |||||
n = (t.length / 2 % a != 0 && (r += 1), new ArrayBuffer(10)); | |||||
new DataView(n); | |||||
e.serviceCode = 0, e.serviceInfo = "encode ok", e.serviceData = {}, e.serviceData.dataEncode = new Array; | |||||
for (var s = 0; s < r - 1; s++) e.serviceData.dataEncode[s] = t.substr(s * a * 2, 2 * a), e.serviceData.dataEncode[ | |||||
s] = getGBFrame(e.serviceData.dataEncode[s], s, r); | |||||
return e.serviceData.dataEncode[r - 1] = t.substring((r - 1) * a * 2), e.serviceData.dataEncode[r - 1] = getGBFrame( | |||||
e.serviceData.dataEncode[r - 1], r - 1, r), e | |||||
} | |||||
function encode_WX(t) { | |||||
for (var e = {}, a = _wjUtils2.default.getPagLenMax(), r = parseInt(t.length / 2 / a), n = (t.length / 2 % a != 0 && | |||||
(r += 1), e.serviceCode = 0, e.serviceInfo = "encode ok", e.serviceData = {}, e.serviceData.dataEncode = | |||||
new Array, 0), n = 0; n < r - 1; n++) e.serviceData.dataEncode[n] = t.substr(n * a * 2, 2 * a), e | |||||
.serviceData.dataEncode[n] = getWXFrame(e.serviceData.dataEncode[n], n, r); | |||||
return e.serviceData.dataEncode[r - 1] = t.substring((r - 1) * a * 2), e.serviceData.dataEncode[r - 1] = getWXFrame( | |||||
e.serviceData.dataEncode[r - 1], r - 1, r), e | |||||
} | |||||
function getWXFrame(t, e, a) { | |||||
for (var r = _wjUtils2.default.getCMD_TYPE(), n = t, s = new ArrayBuffer(10), i = new DataView(s), l = "", d = 0, | |||||
t = t.length / 2, u = (0 == e ? i.setInt8(0, 128 + (a - 1 - e & 255)) : i.setInt8(0, a - 1 - e & 255), l = | |||||
_wjUtils2.default.byteArray2hexStr(s).substring(0, 2), n = 2 == r ? "33" + l + _wjUtils2.default | |||||
.byte2hexStr(255 & t) + n : "3301" + l + _wjUtils2.default.byte2hexStr(255 & t) + n, _wjUtils2.default | |||||
.hexStr2byteArray(n)), c = 1; c < u.length; c++) d ^= u[c]; | |||||
n += _wjUtils2.default.byte2hexStr(d); | |||||
var o, a = _wjUtils2.default.hexStr2byteArray(n).length; | |||||
return 127 < a ? (i.setInt8(0, 128 + (a % 128 & 255)), i.setInt8(1, a / 128 & 255), l = _wjUtils2.default | |||||
.byteArray2hexStr(s).substring(0, 4), i.setInt8(0, (o = a + 8 + 4 + 3) >> 8 & 255)) : (i.setInt8(0, 255 & | |||||
a), l = _wjUtils2.default.byteArray2hexStr(s).substring(0, 2), i.setInt8(0, (o = a + 8 + 4 + 2) >> 8 & 255) | |||||
), i.setInt8(1, 255 & o), n = "FE01" + _wjUtils2.default.byteArray2hexStr(s).substring(0, 4) + | |||||
"753100000A0012" + l + n + "1800" | |||||
} | |||||
function getGBFrame(t, e, a) { | |||||
var r = _wjUtils2.default.getCMD_TYPE(), | |||||
n = t, | |||||
s = new ArrayBuffer(10), | |||||
i = new DataView(s), | |||||
l = "", | |||||
d = 0, | |||||
t = t.length / 2; | |||||
if (2 == r) { | |||||
0 == e ? i.setInt8(0, a - 1 + 128) : i.setInt8(0, a - (e + 1) & 255), i.setInt8(1, 255 & t); | |||||
for (var n = "33" + (l = _wjUtils2.default.byteArray2hexStr(s).substring(0, 4)) + n, u = _wjUtils2.default | |||||
.hexStr2byteArray(n), c = 1; c < u.length - 1; c++) d ^= u[c] | |||||
} else { | |||||
0 == e ? (i.setInt8(0, 128 + (a >> 8 & 255)), i.setInt8(1, 255 & a)) : (i.setInt8(0, e + 1 >> 8 & 255), i | |||||
.setInt8(1, e + 1 & 255)), i.setInt8(2, 255 & t), l = _wjUtils2.default.byteArray2hexStr(s).substring(0, | |||||
6); | |||||
for (u = _wjUtils2.default.hexStr2byteArray(n = "50" + l + n), c = 0; c < u.length; c++) d ^= u[c] | |||||
} | |||||
return n += _wjUtils2.default.byte2hexStr(d) | |||||
} | |||||
module.exports = { | |||||
encode: encode | |||||
}; |
"use strict";var _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},_wjService=require("./wjService.js"),_wjService2=_interopRequireDefault(_wjService),_wjUtils=require("./wjUtils.js"),_wjUtils2=_interopRequireDefault(_wjUtils),_wjDataDecode=require("./wjDataDecode.js"),_wjDataDecode2=_interopRequireDefault(_wjDataDecode);function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}var TAG_FUNCTION="function",sendCallback=void 0,TimerID=null;function _StartSendData(o,e){var s={},c=0,u=0;null!=TimerID&&(clearTimeout(TimerID),TimerID=null),_wjDataDecode2.default.init(),TimerID=setTimeout(pro_timeout,1e4),_wjUtils2.default.showLog(TimerID,"开启时钟"),sendCallback=e,_wjService2.default._SetDataListenerCallBack(!0,datacallback),function t(){var e="";40*u>=o[c].length&&(c++,u=0);c<o.length&&(e=o[c].length>=40*(u+1)?o[c].substring(40*u,40*(u+1)):o[c].substring(40*u,o[c].length));if(""==e)_wjUtils2.default.showLog("数据发送完毕!");else{for(var a=_wjUtils2.default.hexStr2byteArray(e),l=new ArrayBuffer(a.byteLength),r=new DataView(l),i=0;i<a.byteLength;i++)r.setUint8(i,a[i]);_wjUtils2.default.showLog("发送数据:",e),_wjService2.default._writeBLECharacteristicValue(l,function(e){0==e.serviceCode?(u++,t()):(_wjUtils2.default.showError(TimerID,"数据发送失败,取消时钟"),null!=TimerID&&(clearTimeout(TimerID),TimerID=null),_wjService2.default._SetDataListenerCallBack(!1),s.serviceCode=-2,s.serviceInfo="数据发送失败",(void 0===sendCallback?"undefined":_typeof(sendCallback))==TAG_FUNCTION&&sendCallback(s))})}}()}function datacallback(e){_wjService2.default._SetDataListenerCallBack(!0,datacallback),_ReceiveData(e)}function pro_timeout(){var e={};_wjUtils2.default.showError(TimerID,"数据接收超时,取消时钟"),null!=TimerID&&(clearTimeout(TimerID),TimerID=null),_wjService2.default._SetDataListenerCallBack(!1),e.serviceCode=-3,e.serviceInfo="数据接收超时",(void 0===sendCallback?"undefined":_typeof(sendCallback))==TAG_FUNCTION&&sendCallback(e)}function _ReceiveData(e){var t,a={},l=_wjUtils2.default.getProtocolType();0==l?t=_wjDataDecode2.default.decode_GB(e):1==l&&(t=_wjDataDecode2.default.decode_WX(e)),0==t.serviceCode&&(l=t.serviceData.strData,"fe010013271300020a001201411a0400000000"==t.serviceData.strData?(null!=TimerID&&(clearTimeout(TimerID),TimerID=null),_wjService2.default._SetDataListenerCallBack(!1),a.serviceCode=0,a.serviceInfo="数据接收成功",a.serviceData=l):(e=PackageDecode(l),console.log("数据接受完成解析",t),null!=e?(_wjUtils2.default.showLog(TimerID,"接收数据成功,取消时钟"),null!=TimerID&&(clearTimeout(TimerID),TimerID=null),_wjService2.default._SetDataListenerCallBack(!1),a.serviceCode=0,a.serviceInfo="数据接收成功",a.serviceData={},a.serviceData.dataBuff=e,a.serviceData.rawData=t.serviceData.strData,console.log("result_DataInteract.serviceData.dataBuff",a.serviceData.dataBuff)):(_wjUtils2.default.showError(TimerID,"数据解析失败,取消时钟"),null!=TimerID&&(clearTimeout(TimerID),TimerID=null),_wjService2.default._SetDataListenerCallBack(!1),a.serviceCode=-1,a.serviceInfo="数据解析失败")),(void 0===sendCallback?"undefined":_typeof(sendCallback))==TAG_FUNCTION)&&sendCallback(a)}function PackageDecode(e){var t,a=_wjUtils2.default.getDATA_TYPE(),l=_wjUtils2.default.hexStr2byteArray(e),r=0,i=l[1],o=l[0];if(_wjUtils2.default.showLog("WJPackageDecode:",e),177==o)return c=_wjUtils2.default.byteArray2hexStr(t);if(0!=i)return _wjUtils2.default.showError("WJ结果码非00"),null;switch(o){case 146:case 176:case 179:case 180:case 178:case 188:return 0==a?(u=7,129==l[5]&&(129==l[6]?(r=255&l[7],u+=1):130==l[6]?(r=l[7]<<8,r+=255&l[8],u+=2):r=255&l[6]),t=l.slice(u,r+u),c=_wjUtils2.default.byteArray2hexStr(t)):1==a&&(t=l.slice(5),c=_wjUtils2.default.APDU2TPDU(_wjUtils2.default.byteArray2hexStr(t))),_wjUtils2.default.showLog("WJ有效数据长度:",c.length/2,c),_wjUtils2.default.showLog("操作类型ok",o),c;case 145:case 148:var s=(255&l[3])<<8,c=(s+=l[2],t=l.slice(4,s+4),_wjUtils2.default.byteArray2hexStr(t));return _wjUtils2.default.showLog("WJ有效数据长度:",s,_wjUtils2.default.byteArray2hexStr(t)),_wjUtils2.default.showLog("操作类型ok",o),c;case 181:var s=(255&l[3])<<8,u=(s=l[2],6);return 129==l[4]&&(129==l[5]?(r=255&l[6],u+=1):130==l[5]?(r=l[6]<<8,r+=255&l[7],u+=2):r=255&l[5]),t=l.slice(u,u+r),_wjUtils2.default.showLog("WJ有效数据长度:",r,_wjUtils2.default.byteArray2hexStr(t)),_wjUtils2.default.showLog("操作类型ok",o),_wjUtils2.default.byteArray2hexStr(t);default:return _wjUtils2.default.showError("WJ通道类型有误"),null}}module.exports={_StartSendData:_StartSendData,_ReceiveData:_ReceiveData}; |
"use strict"; | |||||
var _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(e) { | |||||
return typeof e | |||||
} : function(e) { | |||||
return e && "function" == typeof Symbol && e.constructor === Symbol && e !== Symbol.prototype ? "symbol" : | |||||
typeof e | |||||
}, | |||||
_wjUtils = require("./wjUtils.js"), | |||||
_wjUtils2 = _interopRequireDefault(_wjUtils), | |||||
_wjDataDecode = require("./wjDataDecode"), | |||||
_wjDataDecode2 = _interopRequireDefault(_wjDataDecode); | |||||
function _interopRequireDefault(e) { | |||||
return e && e.__esModule ? e : { | |||||
default: e | |||||
} | |||||
} | |||||
var reality_indicateServiceId, reality_notifyServiceId, reality_writeServiceId, reality_services, ListenFlag = void 0, | |||||
DataListenerCallBack = void 0, | |||||
connectedDeviceId = void 0, | |||||
timeID = void 0, | |||||
TAG_FUNCTION = "function", | |||||
sendCallback = void 0, | |||||
TimerID = null, | |||||
handshake = !1, | |||||
services = "0000FEE7-0000-1000-8000-00805F9B34FB", | |||||
retdata = ""; | |||||
function reallyScanConnect(n) { | |||||
var o = {}, | |||||
s = (_wjUtils2.default.showLog("/***********Runing :: Do reallyConnect() begin *************/"), []); | |||||
wx.openBluetoothAdapter({ | |||||
success: function(e) { | |||||
wx.startBluetoothDevicesDiscovery({ | |||||
services: [], | |||||
success: function(e) { | |||||
wx.onBluetoothDeviceFound(function(e) { | |||||
for (var t = 0; t < e.devices.length; t++) { | |||||
for (var i = !1, c = 0; c < s.length; c++) | |||||
if (e.devices[t].deviceId == s[c].deviceId) { | |||||
i = !0; | |||||
break | |||||
} if (_wjUtils2.default.showLog("connectedDeviceName", e | |||||
.devices[t].name), 0 == i) { | |||||
s.push(e.devices[t]); | |||||
var a = e.devices[t].name.toUpperCase(); | |||||
if (a.includes("WJ") || a.includes("WANJI") || a | |||||
.includes("ETC") || a.includes("3601") || a | |||||
.includes("YTK") || a.includes("HB") || a.includes( | |||||
"CQ") || a.includes("YUN") || a.includes( | |||||
"SH") || a.includes("HCZJ") || a.includes("NM") || a | |||||
.includes("SC") || a.includes("LJ") || a.includes( | |||||
"HN")) | |||||
if ("break" === function() { | |||||
connectedDeviceId = e.devices[t].deviceId, | |||||
_wjUtils2.default.showLog( | |||||
"connectedDeviceId:" + | |||||
connectedDeviceId); | |||||
var i = {}; | |||||
return i.device_name = a, i.device_id = | |||||
connectedDeviceId, wx | |||||
.stopBluetoothDevicesDiscovery({ | |||||
success: function(e) { | |||||
null != timeID && ( | |||||
clearTimeout( | |||||
timeID), | |||||
timeID = null), | |||||
_wjUtils2.default | |||||
.showLog( | |||||
"停止扫描,开始连接"), | |||||
reallyConnect(i, | |||||
function(e) { | |||||
(void 0 === | |||||
n ? | |||||
"undefined" : | |||||
_typeof( | |||||
n) | |||||
) == | |||||
TAG_FUNCTION | |||||
&& n(e) | |||||
}) | |||||
}, | |||||
fail: function(e) { | |||||
_wjUtils2.default | |||||
.showError( | |||||
"stopBluetoothDevicesDiscovery fail", | |||||
e), o | |||||
.serviceCode = 1103, | |||||
o.serviceInfo = | |||||
"stopBluetoothDevicesDiscovery fail", | |||||
(void 0 === n ? | |||||
"undefined" : | |||||
_typeof(n)) == | |||||
TAG_FUNCTION && n(o) | |||||
} | |||||
}), "break" | |||||
}()) break | |||||
} | |||||
} | |||||
}) | |||||
}, | |||||
fail: function(e) { | |||||
_wjUtils2.default.showError("startBluetoothDevicesDiscovery fail", e), o | |||||
.serviceCode = 1102, o.serviceInfo = | |||||
"startBluetoothDevicesDiscovery fail", (void 0 === n ? "undefined" : | |||||
_typeof(n)) == TAG_FUNCTION && n(o) | |||||
} | |||||
}) | |||||
}, | |||||
fail: function(e) { | |||||
_wjUtils2.default.showError("openBluetoothAdapter fail", e), o.serviceCode = 1101, o | |||||
.serviceInfo = "openBluetoothAdapter fail", (void 0 === n ? "undefined" : _typeof(n)) == | |||||
TAG_FUNCTION && n(o) | |||||
} | |||||
}), timeID = setTimeout(function() { | |||||
wx.closeBluetoothAdapter(), wx.stopBluetoothDevicesDiscovery(), _wjUtils2.default.showLog( | |||||
"scan timeout fail"), o.serviceCode = -13, o.serviceInfo = "scan timeout fail", (void 0 === n ? | |||||
"undefined" : _typeof(n)) == TAG_FUNCTION && n(o) | |||||
}, 5e3) | |||||
} | |||||
function reallyConnect(e, i) { | |||||
_wjUtils2.default.showLog("/***********Runing :: Do reallyConnect() begin *************/"); | |||||
var t = {}, | |||||
c = e.device_name.toUpperCase(); | |||||
_wjUtils2.default.showLog("name", c), c.includes("WJ") || c.includes("WANJI") || c.includes("ETC") || c.includes( | |||||
"3601") || c.includes("YTK") || c.includes("HB") || c.includes("CQ") || c.includes("YUN") || c.includes( | |||||
"SH") || c.includes("HCZJ") || c.includes("NM") || c.includes("SC") || c.includes("LJ") || c.includes( | |||||
"HN") ? (_onBLEConnectionStateChange(), connectedDeviceId = e.device_id, wx.createBLEConnection({ | |||||
deviceId: connectedDeviceId, | |||||
success: function(e) { | |||||
_wjUtils2.default.showLog("已连接,开始使能服务:" + connectedDeviceId), _enableService(function(e) { | |||||
0 == e.serviceCode ? setTimeout(function() { | |||||
_wjUtils2.default.showLog("已连接,并使能成功"), (t = e).serviceInfo = | |||||
"已连接,并使能成功!", (void 0 === i ? "undefined" : _typeof(i)) == | |||||
TAG_FUNCTION && i(t) | |||||
}, 1e3) : ((t = e).serviceInfo = "连接成功,但服务使能失败!", (void 0 === i ? | |||||
"undefined" : _typeof(i)) == TAG_FUNCTION && i(t)) | |||||
}) | |||||
}, | |||||
fail: function(e) { | |||||
_wjUtils2.default.showError("createBLEConnection fail", e), t.serviceCode = 1105, t | |||||
.serviceInfo = "createBLEConnection fail", (void 0 === i ? "undefined" : _typeof(i)) == | |||||
TAG_FUNCTION && i(t) | |||||
} | |||||
}), timeID = setTimeout(function() { | |||||
wx.closeBluetoothAdapter(), _wjUtils2.default.showError("conn timeout fail"), t.serviceCode = -13, | |||||
t.serviceInfo = "conn timeout fail!", (void 0 === i ? "undefined" : _typeof(i)) == | |||||
TAG_FUNCTION && i(t) | |||||
}, 5e3)) : (t.serviceCode = 1104, t.serviceInfo = "device name error", (void 0 === i ? "undefined" : _typeof( | |||||
i)) == TAG_FUNCTION && i(t)) | |||||
} | |||||
function _enableService(n) { | |||||
_wjUtils2.default.showLog("/***********Runing :: Do _enableService() begin *************/"); | |||||
var o = {}; | |||||
wx.getBLEDeviceServices({ | |||||
deviceId: connectedDeviceId, | |||||
success: function(e) { | |||||
for (var i = 0; i < e.services.length; i++) { | |||||
var t = e.services[i].uuid; | |||||
_wjUtils2.default.showLog("serviceuuid:" + t), t == services && (reality_services = t, wx | |||||
.getBLEDeviceCharacteristics({ | |||||
deviceId: connectedDeviceId, | |||||
serviceId: reality_services, | |||||
success: function(e) { | |||||
var i = 0; | |||||
reality_indicateServiceId = ""; | |||||
for (var t = 0; t < e.characteristics.length; t++) { | |||||
var c = e.characteristics[t].uuid, | |||||
a = e.characteristics[t].properties; | |||||
_wjUtils2.default.showLog("chauuid:" + c), a.indicate ? ( | |||||
reality_indicateServiceId = c, i++) : a.notify ? ( | |||||
reality_notifyServiceId = c, i++) : a.write && ( | |||||
reality_writeServiceId = c, i++) | |||||
} | |||||
"" == reality_indicateServiceId && (reality_indicateServiceId = | |||||
reality_notifyServiceId), i < 2 ? (o.serviceCode = 1110, o | |||||
.serviceInfo = "getBLEDeviceCharacteristics temp<2!", ( | |||||
void 0 === n ? "undefined" : _typeof(n)) == | |||||
TAG_FUNCTION && n(o)) : wx | |||||
.notifyBLECharacteristicValueChange({ | |||||
deviceId: connectedDeviceId, | |||||
serviceId: reality_services, | |||||
characteristicId: reality_indicateServiceId, | |||||
state: !0, | |||||
success: function(e) { | |||||
_SetDataListenerCallBack(!0, datacallback), | |||||
_onBLECharacteristicValueChange(), null != | |||||
timeID && (clearTimeout(timeID), timeID = | |||||
null); | |||||
var i = setInterval(function() { | |||||
handshake && (console.log("握手认证成功"), | |||||
handshake = !1, o | |||||
.serviceCode = 0, o | |||||
.serviceInfo = | |||||
"enable success!", | |||||
clearInterval(i), console | |||||
.log("握手成功之后", o | |||||
.serviceCode), ( | |||||
void 0 === n ? | |||||
"undefined" : _typeof(n) | |||||
) == TAG_FUNCTION) && n( | |||||
o) | |||||
}, 5) | |||||
}, | |||||
fail: function() { | |||||
o.serviceCode = 1109, o.serviceInfo = | |||||
"notifyBLECharacteristicValueChange fail!", | |||||
(void 0 === n ? "undefined" : _typeof(n)) == | |||||
TAG_FUNCTION && n(o) | |||||
} | |||||
}) | |||||
}, | |||||
fail: function() { | |||||
o.serviceCode = 1108, o.serviceInfo = | |||||
"getBLEDeviceCharacteristics fail!", (void 0 === n ? | |||||
"undefined" : _typeof(n)) == TAG_FUNCTION && n(o) | |||||
} | |||||
})) | |||||
} | |||||
}, | |||||
fail: function() { | |||||
o.serviceCode = 1107, o.serviceInfo = "getBLEDeviceServices fail!", (void 0 === n ? | |||||
"undefined" : _typeof(n)) == TAG_FUNCTION && n(o) | |||||
} | |||||
}) | |||||
} | |||||
function _onBLEConnectionStateChange() { | |||||
wx.onBLEConnectionStateChange(function(e) { | |||||
_wjUtils2.default.showLog("device " + e.deviceId + " state has changed, connected: " + e.connected), | |||||
0 == e.connected && (wx.closeBLEConnection({ | |||||
deviceId: e.deviceId, | |||||
success: function(e) { | |||||
_wjUtils2.default.showLog("closeBLEConnection:", e) | |||||
} | |||||
}), wx.closeBluetoothAdapter({ | |||||
success: function(e) { | |||||
_wjUtils2.default.showLog("closeBluetoothAdapter", e) | |||||
} | |||||
})) | |||||
}) | |||||
} | |||||
function reallyDisConnect(i) { | |||||
var t = {}; | |||||
null != connectedDeviceId && wx.closeBLEConnection({ | |||||
deviceId: connectedDeviceId, | |||||
success: function(e) { | |||||
_wjUtils2.default.showLog("closeBLEConnection:", e) | |||||
} | |||||
}), wx.closeBluetoothAdapter({ | |||||
success: function(e) { | |||||
_wjUtils2.default.showLog("closeBluetoothAdapter", e), t.serviceCode = 0, t.serviceInfo = | |||||
"断开蓝牙成功!", (void 0 === i ? "undefined" : _typeof(i)) == TAG_FUNCTION && i(t) | |||||
}, | |||||
fail: function(e) { | |||||
console.log(e), t.serviceCode = -1, t.serviceInfo = e.errMsg, (void 0 === i ? "undefined" : | |||||
_typeof(i)) == TAG_FUNCTION && i(t) | |||||
} | |||||
}) | |||||
} | |||||
function _writeBLECharacteristicValue(e, i) { | |||||
var t = {}; | |||||
wx.writeBLECharacteristicValue({ | |||||
deviceId: connectedDeviceId, | |||||
serviceId: reality_services, | |||||
characteristicId: reality_writeServiceId, | |||||
value: e, | |||||
success: function(e) { | |||||
_wjUtils2.default.showLog("writeBLECharacteristicValue success", e.errMsg), t.serviceCode = 0, t | |||||
.serviceInfo = e.errMsg, (void 0 === i ? "undefined" : _typeof(i)) == TAG_FUNCTION && i(t) | |||||
} | |||||
}) | |||||
} | |||||
function _onBLECharacteristicValueChange() { | |||||
wx.onBLECharacteristicValueChange(function(e) { | |||||
_wjUtils2.default.showLog(e.deviceId + " 'characteristic has changed"), console.log("rev:" + e), e | |||||
.characteristicId === reality_indicateServiceId && 1 == ListenFlag && (void 0 === | |||||
DataListenerCallBack ? "undefined" : _typeof(DataListenerCallBack)) == TAG_FUNCTION && | |||||
DataListenerCallBack(e.value) | |||||
}) | |||||
} | |||||
function _SetDataListenerCallBack(e, i) { | |||||
1 == e ? (ListenFlag = !0, DataListenerCallBack = i) : 0 == e && (ListenFlag = !1) | |||||
} | |||||
function datacallback(e) { | |||||
_SetDataListenerCallBack(!0, datacallback), _ReceiveData(e) | |||||
} | |||||
function _ReceiveData(e) { | |||||
var i, t = {}, | |||||
c = _wjUtils2.default.getProtocolType(); | |||||
0 == c ? i = _wjDataDecode2.default.decode_GB(e) : 1 == c && (i = _wjDataDecode2.default.decode_WX(e)), 0 === i | |||||
.serviceCode && (c = i.serviceData.strData, i.serviceData.strData.startsWith( | |||||
"fe01001a271100010a0018808004200128023a06") && 52 === i.serviceData.strData.length || | |||||
"fe010013271300020a001201411a0400000000" == i.serviceData.strData ? (i.serviceData.strData.startsWith( | |||||
"fe01001a271100010a0018808004200128023a06") && 52 === i.serviceData.strData.length && (handshake = ! | |||||
0), null != TimerID && (clearTimeout(TimerID), TimerID = null), _SetDataListenerCallBack(!1), t | |||||
.serviceCode = 0, t.serviceInfo = "数据接收成功", t.serviceData = c, console.log("result_DataInteract", t), | |||||
retdata = t.serviceData) : null != (e = PackageDecode(c)) ? (_wjUtils2.default.showLog(TimerID, | |||||
"接收数据成功,取消时钟"), null != TimerID && (clearTimeout(TimerID), TimerID = null), | |||||
_SetDataListenerCallBack(!1), t.serviceCode = 0, t.serviceInfo = "数据接收成功", t.serviceData = {}, t | |||||
.serviceData.dataBuff = e) : (_wjUtils2.default.showError(TimerID, "数据解析失败,取消时钟"), null != TimerID && ( | |||||
clearTimeout(TimerID), TimerID = null), wjService._SetDataListenerCallBack(!1), t.serviceCode = -1, | |||||
t.serviceInfo = "数据解析失败"), (void 0 === sendCallback ? "undefined" : _typeof(sendCallback)) == | |||||
TAG_FUNCTION) && sendCallback(t) | |||||
} | |||||
function PackageDecode(e) { | |||||
return _wjUtils2.default.showLog("WJPackageDecode:", e), null | |||||
} | |||||
function _StartSendData(o, e) { | |||||
var s = {}, | |||||
l = 0, | |||||
r = 0; | |||||
null != TimerID && (clearTimeout(TimerID), TimerID = null), _wjDataDecode2.default.init(), | |||||
"fe0100164e2300030a06080012024f4b100018002000" == o ? _SetDataListenerCallBack(!1) : (TimerID = setTimeout( | |||||
pro_timeout, 1e4), _wjUtils2.default.showLog(TimerID, "开启时钟"), _SetDataListenerCallBack(!0, | |||||
datacallback)), sendCallback = e, | |||||
function i() { | |||||
var e = ""; | |||||
40 * r >= o[l].length && (l++, r = 0); | |||||
console.log("currentsegment", r, "currentPackage", l, o); | |||||
l < o.length && (e = o[l].length >= 40 * (r + 1) ? o[l].substring(40 * r, 40 * (r + 1)) : o[l].substring( | |||||
40 * r, o[l].length)); | |||||
console.log("currentsegment", r, "currentPackage", l, o); | |||||
if ("" == e) _wjUtils2.default.showLog("数据发送完毕!"), "fe0100164e2300030a06080012024f4b100018002000" == o[s | |||||
.serviceCode = 0] && (void 0 === sendCallback ? "undefined" : _typeof(sendCallback)) == | |||||
TAG_FUNCTION && sendCallback(s); | |||||
else { | |||||
for (var t = _wjUtils2.default.hexStr2byteArray(e), c = new ArrayBuffer(t.byteLength), a = new DataView( | |||||
c), n = 0; n < t.byteLength; n++) a.setUint8(n, t[n]); | |||||
_wjUtils2.default.showLog("发送数据:", e), _writeBLECharacteristicValue(c, function(e) { | |||||
0 == e.serviceCode ? (r++, i()) : (_wjUtils2.default.showError(TimerID, "数据发送失败,取消时钟"), | |||||
null != TimerID && (clearTimeout(TimerID), TimerID = null), | |||||
_SetDataListenerCallBack(!1), s.serviceCode = -2, s.serviceInfo = "数据发送失败", ( | |||||
void 0 === sendCallback ? "undefined" : _typeof(sendCallback)) == | |||||
TAG_FUNCTION && sendCallback(s)) | |||||
}) | |||||
} | |||||
}() | |||||
} | |||||
function pro_timeout() { | |||||
var e = {}; | |||||
_wjUtils2.default.showError(TimerID, "数据接收超时,取消时钟"), null != TimerID && (clearTimeout(TimerID), TimerID = null), | |||||
_SetDataListenerCallBack(!1), e.serviceCode = -3, e.serviceInfo = "数据接收超时", (void 0 === sendCallback ? | |||||
"undefined" : _typeof(sendCallback)) == TAG_FUNCTION && sendCallback(e) | |||||
} | |||||
module.exports = { | |||||
reallyConnect: reallyConnect, | |||||
reallyScanConnect: reallyScanConnect, | |||||
reallyDisConnect: reallyDisConnect, | |||||
_writeBLECharacteristicValue: _writeBLECharacteristicValue, | |||||
_SetDataListenerCallBack: _SetDataListenerCallBack, | |||||
_enableService: _enableService | |||||
}; |
const wjApi = require("./wjBleAPI.js"); | |||||
export function disconnectDevice() { | |||||
wjApi.disConnectDevice((res) => { | |||||
if (res.serviceCode === 0) { | |||||
console.log('断开设备成功!') | |||||
} else { | |||||
console.log('断开设备失败!') | |||||
} | |||||
}) | |||||
} | |||||
export function connectDevice(d, f, e) { | |||||
d.device_id = d.deviceId | |||||
d.device_name = d.name | |||||
wjApi.connectDevice(d, function(serviceResult) { | |||||
console.log('serviceResult.serviceCode', serviceResult.serviceCode) | |||||
console.log("connectDevice2", serviceResult); | |||||
if (serviceResult.serviceCode === 0) { | |||||
f(serviceResult) | |||||
} else { | |||||
e(serviceResult) | |||||
} | |||||
}, function(serviceResult) { | |||||
e(serviceResult) | |||||
}) | |||||
} | |||||
//计算请求指令的长度并转为16进制 | |||||
function getLenth(request) { | |||||
let num = request.length / 2; | |||||
let paddedHexString = num.toString(16).padStart(2, '0'); | |||||
return paddedHexString; | |||||
} | |||||
let cmdArr = [] | |||||
/** | |||||
* @param {Object} request | |||||
* @param {Object} channel AC(ESAM)、A3(IC) | |||||
* @param {Object} callback | |||||
*/ | |||||
export function transCmd(request, cmdtype, callback) { | |||||
cmdArr = [] | |||||
sendCommand(0, request, cmdtype, callback) | |||||
} | |||||
function sendCommand(index, request, cmdtype, callback) { | |||||
let continueExecution = true; // 控制执行的标志 | |||||
console.log('======================', request.length > index, request.length, index) | |||||
if (request.length > index) { | |||||
if (continueExecution) { | |||||
console.log('执行内容', request[index], cmdtype == 10 ? 'A3' : 'AC') | |||||
wjApi.transCommand("01" + getLenth(request[index]) + request[index], cmdtype == 10 ? 'A3' : 'AC', function( | |||||
res) { | |||||
console.log(res, '输出内容失败:${res.serviceInfo};请看console日志', res.serviceInfo) | |||||
if (res.serviceCode === 0) { | |||||
cmdArr.push(res.serviceData.dataBuff.slice(4)) | |||||
sendCommand(index + 1, request, cmdtype, callback) | |||||
} else { | |||||
continueExecution = false | |||||
} | |||||
}) | |||||
} else { | |||||
console.log('---执行结果----', cmdArr) | |||||
callback({ | |||||
code: 1, | |||||
data: [] | |||||
}) | |||||
} | |||||
} else { | |||||
console.log({ | |||||
code: 0, | |||||
data: cmdArr | |||||
}, '---输出结果----', cmdArr) | |||||
callback({ | |||||
code: 0, | |||||
data: cmdArr | |||||
}) | |||||
} | |||||
} |
"use strict";var PROTOCOL_TYPE=1,PAGLENMAX=205,TRANSFER_TYPE=0,DATA_TYPE=0,CMD_TYPE=1;function showLog(){if(!(arguments.length<1)){for(var r=arguments[0],t=1;t<arguments.length;t++)r+=" "+arguments[t];console.log(r)}}function showError(){if(!(arguments.length<1)){for(var r=arguments[0],t=1;t<arguments.length;t++)r+=" "+arguments[t];console.error(r)}}function byteArray2hexStr(r){return Array.prototype.map.call(new Uint8Array(r),function(r){return("00"+r.toString(16)).slice(-2)}).join("")}function hexStr2byteArray(r){return new Uint8Array(r.match(/[\da-f]{2}/gi).map(function(r){return parseInt(r,16)}))}function byte2hexStr(r){var t="0123456789abcdef",e="";return(e+=t.charAt(r>>4))+t.charAt(15&r)}function getProtocolType(){return PROTOCOL_TYPE}function getPagLenMax(){return PAGLENMAX}function getTRANSFER_TYPE(){return TRANSFER_TYPE}function getDATA_TYPE(){return DATA_TYPE}function getCMD_TYPE(){return CMD_TYPE}function APDU2TPDU(r){var t=hexStr2byteArray(r),e="";if("01"==r.substring(0,2))e=r;else{for(var n=new Array,o=0,A=0;A<t[0];A++){var a=o+2,P=o+2+t[o+1];o+=1+t[o+1],n[A]=r.substring(2*a,2*P)}for(A=0;A<t[0];A++){var T=n[A].length/2;e+=byte2hexStr(A+1&255)+byte2hexStr(255&T)+n[A]}}return e}function TPDU2APDU(r){for(var t=hexStr2byteArray(r),e="",n=new Array,o=0,A=t.byteLength;o<A;){var a=t[o++],P=t[o++];n[a-1]=r.substring(2*o,2*(o+P)),o+=P}for(var e=byte2hexStr(255&n.length),T=0;T<n.length;T++)e+=byte2hexStr(n[T].length/2&255)+n[T];return e}module.exports={showLog:showLog,byteArray2hexStr:byteArray2hexStr,hexStr2byteArray:hexStr2byteArray,showError:showError,byte2hexStr:byte2hexStr,getProtocolType:getProtocolType,getPagLenMax:getPagLenMax,getTRANSFER_TYPE:getTRANSFER_TYPE,getDATA_TYPE:getDATA_TYPE,getCMD_TYPE:getCMD_TYPE,APDU2TPDU:APDU2TPDU,TPDU2APDU:TPDU2APDU}; |
const HOME_DIRECTORY = "00A40000023F00";//选择主目 | const HOME_DIRECTORY = "00A40000023F00";//选择主目 | ||||
const APPLICATION_DIRECTORY = "00A40000021001";//选择文件1001--DF01联网收费应用目录 | const APPLICATION_DIRECTORY = "00A40000021001";//选择文件1001--DF01联网收费应用目录 | ||||
const CMD_READBINARY = "00B0950000"; //15文件--卡片发行基本数据文件 | |||||
const CMD_READBINARY = "00B095002B"; //15文件--卡片发行基本数据文件 | |||||
const CMD_GETBALANCE = "805C000204"; //钱包 | const CMD_GETBALANCE = "805C000204"; //钱包 | ||||
const CMD_00B08E0000 ="00B08E0000";//读取卡是否有优惠 | const CMD_00B08E0000 ="00B08E0000";//读取卡是否有优惠 | ||||
const PERSONAL_INFORMATION ="00B0960000";//0016文件--卡片用户信息 | const PERSONAL_INFORMATION ="00B0960000";//0016文件--卡片用户信息 |
zzApi = require("../etc/wjBle/WJBleAPI.js"); | zzApi = require("../etc/wjBle/WJBleAPI.js"); | ||||
jtApi = require("../etc/JTAPIS/BleUtil.js"); | jtApi = require("../etc/JTAPIS/BleUtil.js"); | ||||
} | } | ||||
// 9901 | |||||
const wjApi9901 = require("../etc/WJSDK9901/wjTools.js"); | |||||
/** | /** | ||||
* 断开蓝牙 | * 断开蓝牙 | ||||
*/ | */ | ||||
var connectPrefixName = datas.getData("connectPrefixName"); | var connectPrefixName = datas.getData("connectPrefixName"); | ||||
console.log('断开蓝牙connectPrefixName', getItem('environment'), tdApi, datas.getData("connectPrefixName")) | console.log('断开蓝牙connectPrefixName', getItem('environment'), tdApi, datas.getData("connectPrefixName")) | ||||
switch (connectPrefixName) { | switch (connectPrefixName) { | ||||
case "WJ": | |||||
wjApi.disconnectDevice(function(res) { | |||||
datas.setData("bluLinkStatus", false); | |||||
datas.setData("connectPrefixName", ""); | |||||
}); | |||||
break; | |||||
case "JL": | |||||
jlApi.disconnectDevice(function(res) { | |||||
datas.setData("bluLinkStatus", false); | |||||
datas.setData("connectPrefixName", ""); | |||||
}); | |||||
break; | |||||
case "ETC": | case "ETC": | ||||
if (datas.getData("deviceName").includes("KC") || datas.getData("deviceName").includes("K")) { | if (datas.getData("deviceName").includes("KC") || datas.getData("deviceName").includes("K")) { | ||||
kcApi.disconnectDevice(function(res) { | kcApi.disconnectDevice(function(res) { | ||||
datas.setData("connectPrefixName", ""); | datas.setData("connectPrefixName", ""); | ||||
}); | }); | ||||
} else if (datas.getData("deviceName").includes("WJ")) { | } else if (datas.getData("deviceName").includes("WJ")) { | ||||
wjApi.disconnectDevice(function(res) { | |||||
wjApi9901.disconnectDevice(function(res) { | |||||
datas.setData("bluLinkStatus", false); | datas.setData("bluLinkStatus", false); | ||||
datas.setData("connectPrefixName", ""); | datas.setData("connectPrefixName", ""); | ||||
}); | }); | ||||
// datas.setData("connectPrefixName", ""); | // datas.setData("connectPrefixName", ""); | ||||
// }); | // }); | ||||
// } | // } | ||||
break; | |||||
case "WJ": | |||||
wjApi.disconnectDevice(function(res) { | |||||
datas.setData("bluLinkStatus", false); | |||||
datas.setData("connectPrefixName", ""); | |||||
}); | |||||
break; | |||||
case "JL": | |||||
jlApi.disconnectDevice(function(res) { | |||||
datas.setData("bluLinkStatus", false); | |||||
datas.setData("connectPrefixName", ""); | |||||
}); | |||||
break; | break; | ||||
case "JY": | case "JY": | ||||
jyApi.disconnectDevice(function(res) { | jyApi.disconnectDevice(function(res) { | ||||
datas.setData("bluLinkStatus", false); | datas.setData("bluLinkStatus", false); | ||||
var connectPrefixName = datas.getData("connectPrefixName"); | var connectPrefixName = datas.getData("connectPrefixName"); | ||||
console.log('指令执行内容1', datas.getData("connectPrefixName"), cmdArr, type) | console.log('指令执行内容1', datas.getData("connectPrefixName"), cmdArr, type) | ||||
switch (connectPrefixName) { | switch (connectPrefixName) { | ||||
case "WJ": | |||||
console.log('WJ执行内容====', cmdArr, type) | |||||
wjApi.transCmd(cmdArr, type, function(res) { | |||||
console.log('WJ执行内容====11111', res) | |||||
if (res.code == 0) { | |||||
func(res.data); | |||||
} else { | |||||
if (callBack != null) { | |||||
callBack(res.msg); | |||||
} else { | |||||
alertF(res.msg); | |||||
} | |||||
} | |||||
}); | |||||
break; | |||||
case "JL": | |||||
console.log('JL执行内容====', cmdArr, type) | |||||
jlApi.transCmd(cmdArr, type, function(res) { | |||||
console.log('JL执行内容====11111', res) | |||||
if (res.code == 0) { | |||||
func(res.data); | |||||
} else { | |||||
if (callBack != null) { | |||||
callBack(res.msg); | |||||
} else { | |||||
alertF(res.msg); | |||||
} | |||||
} | |||||
}); | |||||
break; | |||||
case "ETC": | case "ETC": | ||||
//-------------deviceName前装-科畅 | //-------------deviceName前装-科畅 | ||||
console.log("datas.-----",datas.getData("deviceName"),datas.getData("deviceName").includes("KC"),datas.getData("deviceName").includes("K")) | console.log("datas.-----",datas.getData("deviceName"),datas.getData("deviceName").includes("KC"),datas.getData("deviceName").includes("K")) | ||||
} | } | ||||
}); | }); | ||||
} else if (datas.getData("deviceName").includes("WJ")) { | } else if (datas.getData("deviceName").includes("WJ")) { | ||||
wjApi.transCmd(cmdArr, type, function(res) { | |||||
wjApi9901.transCmd(cmdArr, type, function(res) { | |||||
console.log('WJ执行内容====11111', res) | console.log('WJ执行内容====11111', res) | ||||
if (res.code == 0) { | if (res.code == 0) { | ||||
func(res.data); | func(res.data); | ||||
// } | // } | ||||
// }); | // }); | ||||
// } | // } | ||||
break; | |||||
case "WJ": | |||||
console.log('WJ执行内容====', cmdArr, type) | |||||
wjApi.transCmd(cmdArr, type, function(res) { | |||||
console.log('WJ执行内容====11111', res) | |||||
if (res.code == 0) { | |||||
func(res.data); | |||||
} else { | |||||
if (callBack != null) { | |||||
callBack(res.msg); | |||||
} else { | |||||
alertF(res.msg); | |||||
} | |||||
} | |||||
}); | |||||
break; | |||||
case "JL": | |||||
console.log('JL执行内容====', cmdArr, type) | |||||
jlApi.transCmd(cmdArr, type, function(res) { | |||||
console.log('JL执行内容====11111', res) | |||||
if (res.code == 0) { | |||||
func(res.data); | |||||
} else { | |||||
if (callBack != null) { | |||||
callBack(res.msg); | |||||
} else { | |||||
alertF(res.msg); | |||||
} | |||||
} | |||||
}); | |||||
break; | break; | ||||
case "JY": | case "JY": | ||||
jyApi.transCmd(cmdArr, type, function(res) { | jyApi.transCmd(cmdArr, type, function(res) { |
//执行0015文件 | //执行0015文件 | ||||
tools.showLoadingAlert("执行指令"); | tools.showLoadingAlert("执行指令"); | ||||
let cmdArr = [cmd.HOME_DIRECTORY, cmd.APPLICATION_DIRECTORY, cmd.CMD_READBINARY, cmd.CMD_GETBALANCE]; | |||||
// let cmdArr = [cmd.HOME_DIRECTORY, cmd.APPLICATION_DIRECTORY, cmd.CMD_READBINARY, cmd.CMD_GETBALANCE]; | |||||
let cmdArr = ['00A40000023F00','00B0960037']; | |||||
console.log(cmdArr); | console.log(cmdArr); | ||||
console.log(bluetoothUtil); | console.log(bluetoothUtil); | ||||
bluetoothUtil.transCmd(cmdArr, '10', function(res) { //10:写卡 20:写OBU | bluetoothUtil.transCmd(cmdArr, '10', function(res) { //10:写卡 20:写OBU |
requestNew(getOpenId, options).then((res) => { | requestNew(getOpenId, options).then((res) => { | ||||
const result = res; | const result = res; | ||||
console.log("获取微信小程序openid", result); | console.log("获取微信小程序openid", result); | ||||
const openidData = result.data; | |||||
const openidData = stringToJson(result.data); | |||||
state.openid = openidData.openid | state.openid = openidData.openid | ||||
}); | }); | ||||
// #endif | // #endif |
>{{item.amount / 100}}</text></view> | >{{item.amount / 100}}</text></view> | ||||
</view> | </view> | ||||
<view class="btns"> | <view class="btns"> | ||||
<view class="btn btn-normal"@click="gotoConfirmReceipt(item)" | |||||
<view class="btn btn-primary"@click="gotoConfirmReceipt(item)" | |||||
v-if="item.status==2">确认收货</view> | v-if="item.status==2">确认收货</view> | ||||
<view class="btn btn-primary"@click="gotoActiveOrder(item)" | <view class="btn btn-primary"@click="gotoActiveOrder(item)" | ||||
v-if="item.status==1">去激活</view> | v-if="item.status==1">去激活</view> |