|
|
@@ -67,7 +67,7 @@ |
|
|
|
getItem |
|
|
|
} from "@/utils/storage"; |
|
|
|
import { |
|
|
|
requestNew |
|
|
|
requestNew,corefn |
|
|
|
} from "@/utils/network/request.js"; |
|
|
|
import { |
|
|
|
IntegerToHexString, |
|
|
@@ -119,7 +119,10 @@ |
|
|
|
transfer: 0, //0 是原来的激活 1 是过户激活 |
|
|
|
showBtn: true, |
|
|
|
disabled: true, |
|
|
|
progressNum: 0 |
|
|
|
progressNum: 0, |
|
|
|
CardVersion: "", |
|
|
|
ObuVersion: "", |
|
|
|
ChipSn: "" |
|
|
|
}) |
|
|
|
|
|
|
|
onLoad((option) => { |
|
|
@@ -230,14 +233,14 @@ |
|
|
|
method: "POST", //提交方式(默认POST) |
|
|
|
}; |
|
|
|
console.log("options==", options) |
|
|
|
console.log("二发指令申请==前,/iaw/issue/order/issueApply",new Date(),options) |
|
|
|
console.log("二发指令申请==前,/iaw/issue/order/issueApply", new Date(), options) |
|
|
|
//BDS-二发指令申请 |
|
|
|
requestNew(issueApply, options) |
|
|
|
.then((res) => { |
|
|
|
console.log("在线激活 请求"); |
|
|
|
console.log(res); |
|
|
|
const datas = res; |
|
|
|
console.log("二发指令申请==后,/iaw/issue/order/issueApply",new Date(),res) |
|
|
|
console.log("二发指令申请==后,/iaw/issue/order/issueApply", new Date(), res) |
|
|
|
bluetoothUtil.transCmd(datas.cmd.split(','), datas.cmdType == 'CARD' ? '10' : '20', function(res) { |
|
|
|
implementCmd(datas.transOrderId, datas.cmd, res.toString(), datas.stepNo) |
|
|
|
}, (err) => { |
|
|
@@ -273,13 +276,13 @@ |
|
|
|
method: "POST", //提交方式(默认POST) |
|
|
|
}; |
|
|
|
console.log("options2222", options) |
|
|
|
console.log("二发指令回传==前,/iaw/issue/order/issueCallback",new Date(),options) |
|
|
|
console.log("二发指令回传==前,/iaw/issue/order/issueCallback", new Date(), options) |
|
|
|
//BDS-二发指令回传 |
|
|
|
requestNew(issueCallback, options) |
|
|
|
.then((res) => { |
|
|
|
console.log("BDS-二发指令回传 ", res); |
|
|
|
const datas = res; |
|
|
|
console.log("二发指令回传==后,/iaw/issue/order/issueCallback",new Date(),res) |
|
|
|
console.log("二发指令回传==后,/iaw/issue/order/issueCallback", new Date(), res) |
|
|
|
console.log("在线激活 请求", datas); |
|
|
|
if (datas.stepNo == 100) { |
|
|
|
state.disabled = true |
|
|
@@ -323,13 +326,23 @@ |
|
|
|
if (!state.disabled) { |
|
|
|
return; |
|
|
|
} |
|
|
|
if (state.CardVersion == '48' || state.CardVersion == '49' || state.ObuVersion == '48' || state.ObuVersion == |
|
|
|
'49') { |
|
|
|
// 是48,49 先密钥升级再激活 |
|
|
|
obuUpdate(); |
|
|
|
} else { |
|
|
|
// 不是48,49直接激活 |
|
|
|
activateQuqet() |
|
|
|
} |
|
|
|
|
|
|
|
}; |
|
|
|
const activateQuqet = () => { |
|
|
|
state.disabled = false |
|
|
|
state.showPopup = true |
|
|
|
console.log('orderInfo参数', orderInfo, state.disabled) |
|
|
|
stopHeartbeat(); |
|
|
|
cmdResult1() |
|
|
|
}; |
|
|
|
|
|
|
|
} |
|
|
|
//获取订单详情 |
|
|
|
const getOrderDetails = (orderId) => { |
|
|
|
console.log('======获取订单信息======') |
|
|
@@ -377,7 +390,9 @@ |
|
|
|
state.disabled = true |
|
|
|
obu.obuId = res[1].substring(20, 36); |
|
|
|
obu.vin = res[1].substring(18, 20); |
|
|
|
obu.version = res[1].substring(18, 19) >= 4 ? "4x" : "2x"; |
|
|
|
obu.version = res[1].substring(18, 20); |
|
|
|
state.ObuVersion = res[1].substring(18, 20) |
|
|
|
state.ChipSn = res[1].substring(0, 8) |
|
|
|
cmdRandNum = res[2].substring(0, res[2].length - 4); |
|
|
|
getCardId() |
|
|
|
} else { |
|
|
@@ -422,7 +437,8 @@ |
|
|
|
if (str == "9000" || str3 == "9000") { |
|
|
|
if (res[2].length > 86 || res[3] >= 12) { |
|
|
|
card.cardId = res[2].substring(20, 40); |
|
|
|
tools.hideLoadingAlert(); |
|
|
|
state.CardVersion = res[2].substring(18, 20), |
|
|
|
tools.hideLoadingAlert(); |
|
|
|
state.showBtn = true |
|
|
|
startHeartbeat() |
|
|
|
} else { |
|
|
@@ -514,7 +530,7 @@ |
|
|
|
|
|
|
|
|
|
|
|
decryptCardVehicleInformation(res[1].substring(44, 108), function( |
|
|
|
res) { |
|
|
|
res) { |
|
|
|
card.idNum = res; //身份证号码 |
|
|
|
card.idNumStr = res.replace(/^\d{14}/, '**************') |
|
|
|
}); |
|
|
@@ -724,14 +740,168 @@ |
|
|
|
}; |
|
|
|
//提示对话框 |
|
|
|
const alertF = (msg) => { |
|
|
|
|
|
|
|
|
|
|
|
//隐藏加载框 |
|
|
|
tools.hideLoadingAlert(); |
|
|
|
|
|
|
|
|
|
|
|
//提示对话框 |
|
|
|
tools.showModalAlert(msg); |
|
|
|
stopHeartbeat(); |
|
|
|
} |
|
|
|
async function obuUpdate() { |
|
|
|
tools.showLoadingAlert('升级中'); |
|
|
|
//升级类OBU |
|
|
|
const applyData = await apply4Upgrade({ |
|
|
|
contractSn: obu.obuId, //OBU合同序列号 16位 |
|
|
|
chipSn: state.ChipSn, //OBU晶片序列号 8位 |
|
|
|
issueMode: 'UPG', //发行模式 |
|
|
|
issueType: 'SCOBU', //发行发行类型 |
|
|
|
cardVersion: state.CardVersion, //卡版本号 |
|
|
|
obuVersion: state.ObuVersion //OBU版本号 |
|
|
|
}); |
|
|
|
if (!applyData) return false; |
|
|
|
console.log("applyData", applyData) |
|
|
|
if (state.CardVersion == '48' || state.CardVersion == '49') { |
|
|
|
const updateEsDat = await updateEs('GEN_OBEIC_UPG', applyData); |
|
|
|
if (!updateEsDat) return false; |
|
|
|
} |
|
|
|
if (state.ObuVersion == '48' || state.ObuVersion == '49') { |
|
|
|
const updateEsDatTwo = await updateEs('GEN_OBESAM_UPG', applyData); |
|
|
|
if (!updateEsDatTwo) return false; |
|
|
|
} |
|
|
|
const upgradeDoneData = await upgradeDone({ |
|
|
|
issueSerialNo: applyData.issueSerialNo, //发行订单号 |
|
|
|
}); |
|
|
|
if (!upgradeDoneData) return false; |
|
|
|
connectPrefixName = datas.getData("connectPrefixName"); |
|
|
|
console.log(connectPrefixName); |
|
|
|
activateQuqet(); |
|
|
|
} |
|
|
|
function apply4Upgrade(params) { |
|
|
|
return new Promise((resolve) => { |
|
|
|
corefn('IF01001202504281152', params, function(res) { |
|
|
|
console.log("成功1", res) |
|
|
|
if (res.rc != "00") { |
|
|
|
tools.alertF(res.rm); |
|
|
|
return; |
|
|
|
} |
|
|
|
console.log("成功", res) |
|
|
|
resolve(res.rd) |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
//获取发行脚本指令 |
|
|
|
async function updateEs(type, applyData) { |
|
|
|
tools.showLoadingAlert('升级中'); |
|
|
|
//获取发行脚本指令 |
|
|
|
const getCommanData = await getCommands({ |
|
|
|
cardNo: applyData.cardNo, //卡片序列号 |
|
|
|
wareId: type, //OBU的物料代码 OBE-SAM通道 GEN_OBESAM_UPG OBE-IC通道 GEN_OBEIC_UPG |
|
|
|
issueSerialNo: applyData.issueSerialNo, //发行订单号 |
|
|
|
}); |
|
|
|
if (!getCommanData) return false; |
|
|
|
//指令解析 |
|
|
|
const result = getCommanData.commands; |
|
|
|
const array = result.split('~'); |
|
|
|
const cmdType = type == 'GEN_OBESAM_UPG' ? '20' : '10'; |
|
|
|
for (const element of array) { |
|
|
|
tools.showLoadingAlert('升级中'); |
|
|
|
// 让出主线程,确保UI更新 |
|
|
|
await new Promise(resolve => setTimeout(resolve, 0)); |
|
|
|
console.log("进来了", element.charAt(0), ) |
|
|
|
if (element.charAt(0) === 'D' || element.charAt(0) === 'R') { |
|
|
|
await processDirectCommand(element, cmdType); |
|
|
|
} else if (element.charAt(0) === 'K') { |
|
|
|
await processKeyExchange(element, cmdType, applyData); |
|
|
|
} else if (element.charAt(0) === 'E') { |
|
|
|
await processExtAuth(element, cmdType, applyData); |
|
|
|
} |
|
|
|
} |
|
|
|
return true; |
|
|
|
} |
|
|
|
function getCommands(params) { |
|
|
|
return new Promise((resolve, reject) => { |
|
|
|
corefn('IF01001202504281153', params, function(res) { |
|
|
|
console.log("成功1", res) |
|
|
|
if (res.rc != "00") { |
|
|
|
tools.alertF(res.rm); |
|
|
|
return; |
|
|
|
} |
|
|
|
console.log("成功", res) |
|
|
|
resolve(res.rd) |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
// 提取出来的子函数 |
|
|
|
async function processDirectCommand(element, cmdType) { |
|
|
|
// 添加随机延迟,避免连续请求 |
|
|
|
return bluetoothUtil.transCmdArrAfter(element.substring(1), cmdType); |
|
|
|
} |
|
|
|
async function processKeyExchange(element, cmdType, applyData) { |
|
|
|
const ranData = await bluetoothUtil.transCmdArrAfter('0084000004', cmdType); |
|
|
|
console.log("ranData", ranData) |
|
|
|
const exchangeKeyData = await exchangeKey({ |
|
|
|
key: element.substring(1), |
|
|
|
random: ranData['0084000004'][0].substring(0, 8), |
|
|
|
issueSerialNo: applyData.issueSerialNo |
|
|
|
}); |
|
|
|
|
|
|
|
if (!exchangeKeyData) throw new Error('密钥置换失败'); |
|
|
|
console.log("exchangeKeyData", exchangeKeyData) |
|
|
|
return bluetoothUtil.transCmdArrAfter(exchangeKeyData.apdu, cmdType); |
|
|
|
} |
|
|
|
async function processExtAuth(element, cmdType, applyData) { |
|
|
|
const ranData = await bluetoothUtil.transCmdArrAfter('0084000004', cmdType); |
|
|
|
|
|
|
|
const extAuth4IssData = await extAuth4Iss({ |
|
|
|
keyType: element.substring(1), |
|
|
|
random: ranData['0084000004'][0].substring(0, 8), |
|
|
|
issueSerialNo: applyData.issueSerialNo, |
|
|
|
}); |
|
|
|
console.log("extAuth4IssData", extAuth4IssData) |
|
|
|
if (!extAuth4IssData) throw new Error('外部认证失败'); |
|
|
|
return bluetoothUtil.transCmdArrAfter(extAuth4IssData.apdu, cmdType); |
|
|
|
} |
|
|
|
function extAuth4Iss(params) { |
|
|
|
console.log("params", params) |
|
|
|
return new Promise((resolve) => { |
|
|
|
corefn('IF01001202504281156', params, function(res) { |
|
|
|
console.log("成功1", res) |
|
|
|
if (res.rc != "00") { |
|
|
|
tools.alertF(res.rm); |
|
|
|
return; |
|
|
|
} |
|
|
|
console.log("成功", res) |
|
|
|
resolve(res.rd) |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
function exchangeKey(params) { |
|
|
|
return new Promise((resolve) => { |
|
|
|
corefn('IF01001202504281154', params, function(res) { |
|
|
|
console.log("成功1", res) |
|
|
|
if (res.rc != "00") { |
|
|
|
tools.alertF(res.rm); |
|
|
|
return; |
|
|
|
} |
|
|
|
console.log("成功", res) |
|
|
|
resolve(res.rd) |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
function upgradeDone(params) { |
|
|
|
return new Promise((resolve) => { |
|
|
|
corefn('IF01001202504281155', params, function(res) { |
|
|
|
console.log("成功1", res) |
|
|
|
if (res.rc != "00") { |
|
|
|
tools.alertF(res.rm); |
|
|
|
return; |
|
|
|
} |
|
|
|
console.log("成功", res) |
|
|
|
resolve(res.rd) |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
</script> |
|
|
|
|
|
|
|
<style> |