1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144 |
- <template>
- <view class="containers">
- <view class="sec_info">
- <view class="info_txt">信息确认</view>
- <view class="info_plate">
- <text>车牌号码</text>
- <text>{{ fileDataStrings.vehiclePlate }}</text>
- </view>
- <view class="info_plate">
- <text>车牌颜色</text>
- <text>{{ fileDataStrings.vehiclePlateColorStr }}</text>
- </view>
- <view class="info_plate">
- <text>手机号码</text>
- <text>{{ fileDataStrings.customerTel }}</text>
- </view>
- <view class="info_plate" style="border: none">
- <text>卡号</text>
- <text>{{ fileDataStrings.cardId }}</text>
- </view>
- <view class="info_plate">
- <text>OBU号</text>
- <text>{{ fileDataStrings.obuId }}</text>
- </view>
- </view>
- <view class="up_btn">
- <button aria-disabled="true" @click="btn" :disabled="disabled" v-if="!state.isSuccess">
- 点击开始激活
- </button>
- <button aria-disabled="true" @click="back" v-else>
- 点击返回首页
- </button>
- </view>
- </view>
- <!-- 激活成功popup -->
- <u-popup v-model="state.showPopup" mode="center">
- <active-success @cancel="state.showPopup = false"></active-success>
- </u-popup>
- </template>
-
- <script setup>
- import {
- reactive,
- ref
- } from "vue";
- import {
- formatTime,
- expireDate,
- expireDate2,
- getFormatDate,
- msg
- } from "@/utils/utils";
- import {
- onLoad
- } from '@dcloudio/uni-app'
- import {
- getItem
- } from "@/utils/storage";
- import {
- request
- } from "@/utils/network/request.js";
- import {
- IntegerToHexString,
- AsciToHexString,
- } from "@/utils/util/fileData.js";
- import {
- stringToJson
- } from "@/utils/network/encryption.js";
- import * as IFCODE from "@/utils/network/api.js";
- import {
- agentId
- } from "@/utils/network/difference";
- const cmd = require("../../../static/etcUtil/cmdConfig.js");
- const tools = require("../../../static/etcUtil/tools.js");
- const bluetoothUtil = require("../../../static/etcUtil/index.js");
- import activeSuccess from "./components/popup-device-active-success";
- import {
- channelId
- } from "@/utils/network/difference";
- const state = reactive({
- orderId: "",
- id: "",
- cardStatus: "",
- obuStatus: "",
- isSuccess: false, //是否激活成功
- showPopup: false,
- transfer: 0 //0 是原来的激活 1 是过户激活
- })
- onLoad((option) => {
- //读取传入 存储的数据orderInfo
- let orderData = getItem("orderInfo");
- state.id = orderData.id;
- state.orderId = orderData.orderId;
- console.log(state);
- state.transfer = Number(option.transfer)
- //获取订单详情
- getOrderDetails(state.id);
- console.log("state.transfer", state.transfer, state.transfer == 0, state.transfer == 1)
- })
-
- const card = reactive({
- cardId: "",
- netId: "",
- cardType: "",
- startTime: "",
- endTime: "",
- userName: "",
- idNum: "",
- vehiclePlate: "",
- vehiclePlateColor: "",
- color: "",
- version: "",
- type: "",
- favourable: "",
- money: "",
- v_userType: "",
- });
- const obu = reactive({
- obuId: "",
- startTime: "",
- endTime: "",
- version: "",
- approvedCount: "",
- axleCount: "",
- axleDistance: "",
- engineNum: "",
- type: "",
- userType: "",
- contractNo: "",
- vehiclePlate: "",
- vehiclePlateColor: "",
- vin: "",
- wheelCount: 0,
- isJH: ""
- });
- const disabled = ref(false);
- let cmdRandNum = '';
- let orderInfo = {};
-
- const fileDataStrings = reactive({
- approvedCount: 0, //核载人数
- cardId: "", //卡号
- obuId: "", //obu号
- obuId: "", //obu号
- packageNum: "", //套餐编号
- axleCount: 0, //轴数
- axleDistance: "", //轴距
- engineNum: "", //发动机
- vehicleVin: "",
- vehicleEngineNum: "",
- cardStatus: "",
- obuStatus: "",
- type: 0, //类型
- userType: 0, //用户类型
- vehiclePlate: "", //车牌
- vehiclePlateColor: 0, //车牌颜色
- vehicleDimensions: "",
- outlineL: 0, //外廓 长
- outlineW: 0, //外廓 宽
- outlineH: 0, //外廓 高
- wheelCount: 0, //车轮数
- vehicleIdNo: "", //车牌号
- vehiclePlateColorStr: "",
- customerTel: "",
- customerId: "",
- orderId: ""
- });
-
- //开始激活 按钮事件
- const btn = () => {
- console.log('orderInfo参数', orderInfo)
- if (state.transfer) {
- // 获取cardId
- getCardId()
- // 过户激活 1
- // 1. 过户激活申请 2.设备升级 3.过户升级(跟过户升级一样) 4.79(BDS-安装申请)(后台数据)-
- // >76(VFJ-OBU在线激活)(指令接口)->80(BDS-安装确认)->73(BDS-卡签绑定)(指令接口)->51(BDS-写卡指令返回)(指令接口)
- } else {
- console.log("=================================")
- if (orderInfo) {
- //根据订单详情走相应的断步功能
- const cardId = orderInfo.cardId;
- const cardStatus = orderInfo.cardStatus != null ? orderInfo.cardStatus : '0'
- const obuId = orderInfo.obuId;
- const obuStatus = orderInfo.obuStatus != null ? orderInfo.obuStatus : '9'
- console.log('当前卡签状态', cardId, obuId, cardStatus, obuStatus)
- console.log('输出内容', obu.obuId, '=======', fileDataStrings.obuId, obu.obuId != fileDataStrings.obuId)
- if (fileDataStrings.obuId) {
- if (obu.obuId + '' != fileDataStrings.obuId + '') {
- tools.showModalAlert("订单设备号信息与当前设备号信息不符!");
- return
- }
- }
- if (!cardId) { //卡发行
- getCardId()
- } else if (cardId && cardStatus == '0') { //卡发行
- getCardId()
- } else if (!obuId) { //OBU发行
- getObuApply();
- } else if (obuId && obuStatus == '9') { //OBU发行
- getObuApply();
- } else if (cardId && obuId && (obuStatus == '1' || obuStatus == '11' || obuStatus ==
- '0')) {
- getInstallApply(); //激活
- } else {
- getCardId()
- }
- }
- }
-
- };
-
- //获取订单详情
- const getOrderDetails = (id) => {
- console.log('======获取订单信息======')
- const options = {
- type: 2,
- data: {
- id: id,
- },
- method: "POST",
- showLoading: true,
- };
- request(IFCODE.orderDetail, options).then((res) => {
- orderInfo = JSON.parse(res.bizContent);
- console.log("orderInfo", orderInfo);
- console.log("orderInfores", res);
- if (orderInfo) {
- fileDataStrings.userType = orderInfo.userType; //用户类型
- fileDataStrings.approvedCount = parseInt(orderInfo.vehicleApprovedCount); //核载人数
- fileDataStrings.cardId = orderInfo.cardId;
- fileDataStrings.packageNum = orderInfo.packageNum;
- fileDataStrings.obuId = orderInfo.obuId;
- fileDataStrings.vehicleVin = orderInfo.vehicleVin;
- fileDataStrings.vehicleEngineNum = orderInfo.vehicleEngineNum;
- fileDataStrings.axleCount = parseInt(orderInfo.vehicleAxleCount); //轴数
- fileDataStrings.engineNum = orderInfo.vehicleVin; //发动机
- fileDataStrings.type = parseInt(orderInfo.type); //类型
- fileDataStrings.vehiclePlate = orderInfo.vehiclePlate; //车牌
- fileDataStrings.vehiclePlateColor = orderInfo.vehiclePlateColor; //车牌颜色
- fileDataStrings.vehicleDimensions = orderInfo.vehicleDimensions;
- let arr = orderInfo.vehicleDimensions.split("X");
- fileDataStrings.outlineL = parseInt(arr[0]); //外廓 长
- fileDataStrings.outlineW = parseInt(arr[1]); //外廓 宽
- fileDataStrings.outlineH = parseInt(arr[2].substring(0, arr[2].length - 2)); //外廓 高
- fileDataStrings.vehicleIdNo = orderInfo.vehicleEngineNum; //车编号
- fileDataStrings.vehiclePlateColorStr = orderInfo.vehiclePlateColorStr;
- fileDataStrings.customerTel = orderInfo.customerTel;
- fileDataStrings.customerId = orderInfo.customerId;
- fileDataStrings.orderId = orderInfo.orderId;
- getObuId();
- cancelOrderRequest(orderInfo.orderId)
- }
- });
- };
- //更换设备 去注销前订单的 卡签
- const cancelOrderRequest = (orderId) => {
- console.log('======更换设备 去注销前订单的 卡签 ======')
- const options = {
- type: 2,
- data: {
- orderId: orderId,
- },
- method: "POST",
- showLoading: true,
- };
- request(IFCODE.cancelOrderApi, options).then((res) => {
-
- })
- }
-
- /**
- * 获取OBU号 读OBU
- */
- const getObuId = () => {
- console.log('======获取OBU号======')
- let cmdArray = [cmd.HOME_DIRECTORY, cmd.OBU_SYSTEM_FILE, cmd.RANDOM_NUMBER];
- tools.showLoadingAlert("正在执行指令");
- bluetoothUtil.transCmd(cmdArray, "20", function(res) {
- tools.hideLoadingAlert();
- var status = res[1].substring(res[1].length - 4, res[1].length);
-
- console.log('获取OBU号执行结果' + status, res)
- //第一次获取随机数
- if (status == "9000") {
- obu.obuId = res[1].substring(20, 36);
- console.log("obu.obuId===========", obu.obuId, res[1].substring(20, 36))
- obu.vin = res[1].substring(18, 20);
- obu.version = res[1].substring(18, 19) >= 4 ? "4x" : "2x";
- cmdRandNum = res[2].substring(0, res[2].length - 4);
- }
- });
- };
-
- //获取fileData
- const getFileData = (fun) => {
- //调用方式
- request('6ed853e432fb4811a3c0d7d27034bd39', {
- type: 2, //type: 2,JSON格式提交数据(默认表单形式提交)
- data: {
- fileData: fileDataStrings.vehiclePlate,
- nLen: 24
- }, //请求参数
- method: "POST", //提交方式(默认POST)
- showLoading: true, //是否显示加载中(默认显示)
- }).then((les) => {
- let result = stringToJson(les.bizContent);
- let res1 = result.gbkFileData; //车牌号
- let res2 = IntegerToHexString(fileDataStrings.vehiclePlateColor, 4); //车牌颜色
-
- let res3 = IntegerToHexString(fileDataStrings.type, 2); //类型
- let userTypeNumber = fileDataStrings.userType == 'PERSONAL_USER' ? 1 : 2
- let res4 = IntegerToHexString(userTypeNumber, 2); //用户类型
- let res5 = IntegerToHexString(fileDataStrings.outlineL, 4); //车辆尺寸 长
- let res6 = IntegerToHexString(fileDataStrings.outlineW, 2); //车辆尺寸 宽
- let res7 = IntegerToHexString(fileDataStrings.outlineH, 2); //车辆尺寸 高
- let res8 = IntegerToHexString(4, 2); //获取轮数
- let res9 = IntegerToHexString(fileDataStrings.axleCount, 2); //轴数
-
- let res10 = IntegerToHexString(null, 4); //轴距32
- let res11 = IntegerToHexString(fileDataStrings.approvedCount, 6); //核载人数
-
- let res12 = AsciToHexString(fileDataStrings.vehicleVin, 32); //车编号
-
- // let res12 = JSON.parse(res.bizContent).gbkFileData; //车编号
- let res13 = AsciToHexString(fileDataStrings.vehicleEngineNum, 32); //发动机
- console.log(les, '=========123', )
- fun(res1 + res2 + res3 + res4 + res5 + res6 + res7 + res8 + res9 + res10 + res11 + res12 + res13);
- })
- };
-
- /**
- * 获取卡号 读卡
- */
- const getCardId = () => {
- console.log('======获取卡信息======')
- let cmdArr = [
- cmd.HOME_DIRECTORY,
- //选择主目
- cmd.APPLICATION_DIRECTORY,
- //选择文件1001--DF01联网收费应用目录
- cmd.CMD_READBINARY,
- //15文件--卡片发行基本数据文件
- cmd.CMD_GETBALANCE
- //钱包
- ];
- tools.showLoadingAlert("正在执行指令");
- bluetoothUtil.transCmd(cmdArr, "10", function(res) {
- tools.hideLoadingAlert();
- //10:写卡 20:写OBU
- let str = res[2].substring(res[2].length - 4, res[2].length);
- let str3 = res[3].substring(res[3].length - 4, res[3].length);
- if (str == "9000" || str3 == "9000") {
- if (res[2].length > 86 || res[3] >= 12) {
- card.cardId = res[2].substring(20, 40); //卡号
- card.startTime = res[2].substring(40, 48); //启用
- card.endTime = res[2].substring(48, 56);
- card.version = res[2].substring(18, 19) >= 4 ? "4x" : "2x";
- card.netId = res[2].substring(20, 24);
- card.cardType = res[2].substring(28, 30) == 23 ? 1 : 2; //23记账卡 非 23储值卡 1:记账卡 2:储值卡
- card.vehiclePlateColor = parseInt(res[2].substring(82, 84), 16);
- console.log('======卡信息======', card.cardId, fileDataStrings.cardId)
- if (fileDataStrings.cardId) {
- if (card.cardId != fileDataStrings.cardId) {
- tools.showModalAlert("订单卡号与当前设备卡号信息不符!");
- return
- }
- }
- if (!state.transfer) {
- console.log("正常", state.transfer)
- getCardApply()
- } else {
- console.log("过户", !state.transfer, state.transfer)
- transferApplyRequest()
- }
- } else {
- console.error("CMD_READBINARY指令长度不符" + res[2])
- tools.hideLoadingAlert();
- }
- }
- console.error("CMD_READBINARY指令长度不符" + res[2])
- tools.hideLoadingAlert();
- });
- };
-
- // *------------------------------------*
- // OBU开卡模块
- // *------------------------------------*
-
- /**
- * 写卡指令申请 请求
- */
- const getCardApply = () => {
- console.log('======写卡指令申请======')
- tools.showLoadingAlert("加载中");
- let options = {
- type: 2, //type: 2,JSON格式提交数据(默认表单形式提交)
- data: {
- cardId: card.cardId,
- orderId: fileDataStrings.orderId,
- cardType: card.cardType,
- userId: fileDataStrings.customerId,
- vehicleId: fileDataStrings.vehiclePlate + "_" + fileDataStrings.vehiclePlateColor,
- cosProvider: "1",
- enableTime: getFormatDate(new Date(), "yyyyMMdd"),
- expireTime: expireDate2(new Date())
- }, //请求参数
- method: "POST", //提交方式(默认POST)
- showLoading: true, //是否显示加载中(默认显示)
- };
- //调用方式
- request(IFCODE.writeCardApply, options)
- .then((res) => {
- tools.hideLoadingAlert();
- let result = stringToJson(res.bizContent);
- tools.showLoadingAlert("执行指令中");
- console.log('写卡指令', result.command)
- bluetoothUtil.transCmd(result.command.split(","), "10", function(res) {
- tools.hideLoadingAlert();
- getCommandBack(result.command, result.cosRecordId, res.toString());
- });
- })
- };
-
- /**
- * 写卡指令返回 请求
- */
- const getCommandBack = (command, cosRecordId, response) => {
- console.log('======循环写卡指令中======')
- tools.showLoadingAlert("加载中");
- let options = {
- type: 2, //type: 2,JSON格式提交数据(默认表单形式提交)
- data: {
- cardId: card.cardId,
- orderId: fileDataStrings.orderId,
- command: command,
- response: response,
- cosRecordId: cosRecordId,
- cosType: "1"
- }, //请求参数
- method: "POST", //提交方式(默认POST)
- showLoading: true, //是否显示加载中(默认显示)
- };
-
- //调用方式
- request(IFCODE.writeCardBack, options)
- .then((res) => {
- tools.hideLoadingAlert();
- let result = JSON.parse(res.bizContent);
- console.log("写卡指令============", result)
- if (result.orderStatus == 1 || result.orderStatus == "1") {
- tools.showLoadingAlert("执行指令中");
- bluetoothUtil.transCmd(result.command.split(","), "10", function(res) {
- tools.hideLoadingAlert();
- let response = res.toString();
- getCommandBack(result.command, cosRecordId, response);
- });
- } else {
- getWriteCard();
- }
- })
- };
-
- /**
- * 写卡确认 请求
- */
- const getWriteCard = () => {
- tools.showLoadingAlert("请求中");
- console.log('======写卡确认======')
- let options = {
- type: 2, //type: 2,JSON格式提交数据(默认表单形式提交)
- data: {
- cardId: card.cardId,
- orderId: fileDataStrings.orderId,
- netId: card.netId,
- packageNum: fileDataStrings.packageNum,
- cardType: card.cardType == 1 ? "111" : "211",
- brand: "3",
- model: "0",
- enableTime: formatTime(new Date()),
- expireTime: formatTime(new Date()),
- accountOrganization: "",
- accountCardNo: "",
- cosRecordId: "",
- openId: getItem('openId')
- }, //请求参数
- method: "POST", //提交方式(默认POST)
- showLoading: true, //是否显示加载中(默认显示)
- };
- //调用方式
- request(IFCODE.writeCardConfirm, options)
- .then((res) => {
- tools.hideLoadingAlert();
- console.log(stringToJson(res.bizContent));
- //OBU发行申请 请求
- // getObuApply()
- const cardId = orderInfo.cardId;
- const cardStatus = orderInfo.cardStatus != null ? orderInfo.cardStatus : '0'
- const obuId = orderInfo.obuId;
- const obuStatus = orderInfo.obuStatus != null ? orderInfo.obuStatus : '9'
- if (!obuId) { //OBU发行
- getObuApply();
- } else if (obuId && obuStatus == '9') { //OBU发行
- getObuApply();
- } else if (cardId && obuId && (obuStatus == '1' || obuStatus == '11' || obuStatus ==
- '0')) {
- getInstallApply(); //激活
- }
- })
- .catch((err) => {
- console.log(err);
- });
- };
-
- // *------------------------------------*
- // OBU 发行模块
- // *------------------------------------*
-
- /**
- * OBU发行申请 请求
- */
- const getObuApply = () => {
- console.log('======OBU发行申请======')
- tools.showLoadingAlert("加载中");
- let options = {
- type: 2, //type: 2,JSON格式提交数据(默认表单形式提交)
- data: {
- obuId: obu.obuId,
- userId: fileDataStrings.customerId,
- vehicleId: fileDataStrings.vehiclePlate + "_" + fileDataStrings.vehiclePlateColor
- }, //请求参数
- method: "POST", //提交方式(默认POST)
- showLoading: true, //是否显示加载中(默认显示)
- };
- //调用方式
- request(IFCODE.writeObuApply, options)
- .then(() => {
- tools.hideLoadingAlert();
- modifyFileInfo()
- })
- };
-
- /**
- * 修改系统信息 请求
- */
- const modifyFileInfo = () => {
- console.log('======修改系统信息请求======')
- var datetime = new Date();
- var year = datetime.getFullYear();
- var year1 = datetime.getFullYear() + 10;
- var month = datetime.getMonth() + 1 < 10 ? "0" + (datetime.getMonth() + 1) : datetime.getMonth() + 1;
- var date = datetime.getDate() < 10 ? "0" + datetime.getDate() : datetime.getDate();
- tools.showLoadingAlert("加载中");
- let options = {
- type: 2, //type: 2,JSON格式提交数据(默认表单形式提交)
- data: {
- obuSerailNo: obu.obuId, //OBU号
- obuVersion: obu.vin, //OBU版本号
- effTime: year + "" + month + "" + date, //启用时间
- expIime: year1 + "" + month + "" + date, //结束时间
- plateNo: fileDataStrings.vehiclePlate,
- pColor: fileDataStrings.vehiclePlateColor,
- random: cmdRandNum
- }, //请求参数
- method: "POST", //提交方式(默认POST)
- showLoading: true, //是否显示加载中(默认显示)
- };
- //调用方式
- request(IFCODE.modifyObuSysInfo, options)
- .then((res) => {
- tools.hideLoadingAlert();
- const datas = stringToJson(res.bizContent);
- tools.showLoadingAlert("执行指令");
- //如果存在APDU->穿透指令
- if (datas.data.APDU) {
- bluetoothUtil.transCmd([datas.data.APDU], "20", function(res) {
- tools.hideLoadingAlert();
- if (res[0] == "9000") {
- tools.showLoadingAlert("执行指令");
- //再次获取随机数
- let cmdArr = [cmd.HOME_DIRECTORY, cmd.OBU_DF01, cmd.OBU_EF01, cmd
- .RANDOM_NUMBER
- ];
- bluetoothUtil.transCmd(cmdArr, '20', function(res) {
- var str = res[3].substring(res[3].length - 4, res[3].length);
- if (str == "9000") {
- cmdRandNum = res[3].substring(0, res[3].length - 4);
- getFileData((demos) => {
- modifyVehicle(demos);
- })
- } else {
- tools.alertF("RANDOM_NUMBER指令长度不符" + res[1]);
- }
- })
-
- }
- });
- }
- })
- .catch((err) => {
- console.log(err);
- });
- };
-
- /**
- * 修改车辆信息 请求
- */
- const modifyVehicle = (ites) => {
- tools.showLoadingAlert("加载中");
- console.log('======修改车辆信息======', ites)
- let options = {
- type: 2, //type: 2,JSON格式提交数据(默认表单形式提交)
- data: {
- Status: "0",
- random: cmdRandNum, //5202192509222239
- obuSerailNo: obu.obuId, //5202192509551922
- fileData: ites,
- orderId: fileDataStrings.orderId,
- }, //请求参数
- method: "POST", //提交方式(默认POST)
- showLoading: true, //是否显示加载中(默认显示)
- };
- //调用方式
- request(IFCODE.modifyObuVehicleInfo, options)
- .then((res) => {
- tools.hideLoadingAlert();
- const datas = stringToJson(res.bizContent);
- tools.showLoadingAlert("正在执行指令");
- if (datas.data.APDU) {
- bluetoothUtil.transCmd([datas.data.APDU], "20", function(res) {
- console.log('执行指令结果', res)
- tools.hideLoadingAlert();
- if (res[0] == "9000") {
- if (!state.transfer) {
- // 正常激活 走obu发行
- getObuConfirm();
- } else {
- transferSureRequest();
- }
- }
- });
- }
- })
- };
-
- /**
- * OBU确认发行 请求
- */
- const getObuConfirm = () => {
- console.log('======OBU确认发行======')
- tools.showLoadingAlert("加载中");
- let options = {
- type: 2, //type: 2,JSON格式提交数据(默认表单形式提交)
- data: {
- obuId: obu.obuId,
- orderId: fileDataStrings.orderId,
- netId: obu.obuId.substring(0, 4),
- brand: obu.brand,
- model: obu.version,
- enableTime: formatTime(new Date()),
- expireTime: expireDate(new Date())
- }, //请求参数
- method: "POST", //提交方式(默认POST)
- showLoading: true, //是否显示加载中(默认显示)
- };
- //调用方式
- request(IFCODE.obuConfirm, options)
- .then((res) => {
- tools.hideLoadingAlert();
- let datas = stringToJson(res.bizContent);
- if (datas.obuId) {
- getInstallApply()
- }
- })
- .catch((err) => {
- console.log(err);
- });
- };
-
- // *------------------------------------*
- // 设备发行模块
- // *------------------------------------*
-
- /**
- * BDS-安装申请 请求
- */
- const getInstallApply = () => {
- console.log('======安装申请======')
- tools.showLoadingAlert("加载中");
- let options = {
- type: 2, //type: 2,JSON格式提交数据(默认表单形式提交)
- data: {
- obuId: obu.obuId,
- vehicleId: fileDataStrings.vehiclePlate + "_" + fileDataStrings.vehiclePlateColor,
- orderId: fileDataStrings.orderId,
- agentId: agentId,
- channelId: channelId,
- channelType: "1",
- staffId: "opId",
- terminalId: "999999999",
- }, //请求参数
- method: "POST", //提交方式(默认POST)
- showLoading: true, //是否显示加载中(默认显示)
- };
- //调用方式
- request(IFCODE.installApply, options)
- .then(() => {
- tools.hideLoadingAlert();
-
- //再次获取随机数
- let cmdArr = [cmd.HOME_DIRECTORY, cmd.RANDOM_NUMBER];
- bluetoothUtil.transCmd(cmdArr, '20', function(res) {
- var str = res[1].substring(res[1].length - 4, res[1].length);
- if (str == "9000") {
- cmdRandNum = res[1].substring(0, res[1].length - 4);
- getObuActivation();
- } else {
- tools.alertF("RANDOM_NUMBER指令长度不符" + res[1]);
- }
- })
- })
- };
-
- /**
- * VFJ-OBU在线激活 请求
- */
- const getObuActivation = () => {
- console.log('======VFJ-OBU在线激活======')
- tools.showLoadingAlert("加载中");
- let options = {
- type: 2, //type: 2,JSON格式提交数据(默认表单形式提交)
- data: {
- random: cmdRandNum,
- obuSerailNo: obu.obuId,
- orderId: fileDataStrings.orderId,
- }, //请求参数
- method: "POST", //提交方式(默认POST)
- showLoading: true, //是否显示加载中(默认显示)
- };
- //调用方式
- request(IFCODE.obuActivation, options)
- .then((res) => {
- tools.hideLoadingAlert();
- console.log("在线激活 请求");
- console.log(stringToJson(res.bizContent));
- const datas = stringToJson(res.bizContent);
- tools.showLoadingAlert("执行指令");
- bluetoothUtil.transCmd([datas.data.APDU], "20", function(res) {
- tools.hideLoadingAlert();
- console.log(res);
- if (res[0] == "9000") {
- console.log("在线激活执行指令88888 请求", res);
- getObuInstall(0, ""); //status 0 - 安装成功 || 1 - 安装失败
- }
- });
- })
- .catch((err) => {
- console.log(err);
- });
- };
-
- /**
- * BDS-安装确认 请求
- */
- const getObuInstall = (status, reason) => {
- console.log('======OBU安装确认======')
- tools.showLoadingAlert("加载中");
- let options = {
- type: 2, //type: 2,JSON格式提交数据(默认表单形式提交)
- data: {
- installStatus: status,
- failReason: reason,
- installType: "1",
- installChannelId: channelId,
- obuId: obu.obuId,
- orderId: fileDataStrings.orderId,
- openId: getItem('openId')
- }, //请求参数
- method: "POST", //提交方式(默认POST)
- showLoading: true, //是否显示加载中(默认显示)
- };
- //调用方式
- request(IFCODE.obuInstall, options)
- .then(() => {
- tools.hideLoadingAlert();
- bindCardAndObu();
-
- });
- };
- /**
- * 卡签绑定 请求
- */
- const bindCardAndObu = () => {
- console.log('======卡签绑定======')
- tools.showLoadingAlert("加载中");
- let options = {
- type: 2, //type: 2,JSON格式提交数据(默认表单形式提交)
- data: {
- obuId: obu.obuId,
- cardId: card.cardId ? card.cardId : fileDataStrings.cardId,
- }, //请求参数
- method: "POST", //提交方式(默认POST)
- showLoading: true, //是否显示加载中(默认显示)
- };
- //调用方式
- request(IFCODE.bindCardAndObu, options)
- .then((res) => {
- tools.hideLoadingAlert();
- let result = JSON.parse(res.bizContent);
- console.log("写卡指令============", result)
- tools.showLoadingAlert("执行指令中");
- bluetoothUtil.transCmd(result.command.split(","), "10", function(res) {
- tools.hideLoadingAlert();
- let response = res.toString();
- getCommandBackEnd(result.command, result.cosRecordId, response);
- });
- })
- .catch((err) => {
- console.log(err);
- });
- };
- /**
- * 卡签绑定写卡指令返回 请求
- */
- const getCommandBackEnd = (command, cosRecordId, response) => {
- console.log('======卡签绑定循环写卡指令中======')
- tools.showLoadingAlert("加载中");
- let options = {
- type: 2, //type: 2,JSON格式提交数据(默认表单形式提交)
- data: {
- cardId: card.cardId ? card.cardId : fileDataStrings.cardId,
- orderId: fileDataStrings.orderId,
- command: command,
- response: response,
- cosRecordId: cosRecordId,
- cosType: "4"
- }, //请求参数
- method: "POST", //提交方式(默认POST)
- showLoading: true, //是否显示加载中(默认显示)
- };
-
- //调用方式
- request(IFCODE.writeCardBack, options)
- .then((res) => {
- tools.hideLoadingAlert();
- let result = JSON.parse(res.bizContent);
- console.log("写卡指令============", result)
- if (result.orderStatus == 1 || result.orderStatus == "1") {
- tools.showLoadingAlert("执行指令中");
- bluetoothUtil.transCmd(result.command.split(","), "10", function(res) {
- tools.hideLoadingAlert();
- let response = res.toString();
- getCommandBackEnd(result.command, cosRecordId, response);
- });
- } else {
- // #ifdef MP-ALIPAY
- uni.closeBluetoothAdapter({
- success(res) {
-
- }
- })
- msg("激活成功")
- state.showPopup = true
- state.isSuccess = true
-
- // #endif
-
- DataSynchronizationRequest();
-
-
- // #ifdef MP-WEIXIN
- msg("激活成功")
- setTimeout(() => {
- uni.navigateTo({
- url: "/subpackage/after-sale/deviceInfo/deviceInfo",
- });
- }, 2000)
-
- // #endif
- }
- })
- };
- const DataSynchronizationRequest = () => {
- const options = {
- type: 2,
- data: {
- orderId: fileDataStrings.orderId
- },
- method: "POST",
- showLoading: false,
- };
- request(IFCODE.DataSynchronizationApi, options).then((res) => {
-
- })
- }
- const back = () => {
- uni.switchTab({
- url: "/pages/index/index"
- });
- }
-
- // 过户激活申请
- const transferApplyRequest = () => {
- const options = {
- type: 2,
- data: {
- orderId: fileDataStrings.orderId
- },
- method: "POST",
- showLoading: false,
- };
- request(IFCODE.transferApply, options).then((res) => {
- // 设备升级
- getDeviceUpgrade()
- })
- }
- // 过户激活确认
- const transferSureRequest = () => {
- const options = {
- type: 2,
- data: {
- orderId: fileDataStrings.orderId
- },
- method: "POST",
- showLoading: false,
- };
- request(IFCODE.transferSure, options).then((res) => {
- // 设备升级
- getInstallApply()
- })
- }
- //设备升级 请求
- const getDeviceUpgrade = () => {
- const options = {
- type: 2,
- data: {
- cardId: fileDataStrings.cardId,
- orderId: fileDataStrings.orderId,
- isTransfer: state.transfer
- },
- method: "POST",
- showLoading: true,
- };
- request(IFCODE.deviceUpgrade, options).then((res) => {
- tools.hideLoadingAlert();
- let result = stringToJson(res.bizContent);
- console.log("&&&&&&&&&&&&", result);
-
- let cmdArray = result.command ? result.command.split(",") : "";
-
- if (cmdArray.length > 0) {
- tools.showLoadingAlert("正在执行指令");
- bluetoothUtil.transCmd(cmdArray, "10", function(res) {
- tools.hideLoadingAlert();
- let status = res[cmdArray.length - 1].substring(res[cmdArray.length - 1].length -
- 4, res[cmdArray.length - 1].length);
- if (status == "9000") {
- getCommandBackUp(result.command, result.cosRecordId, res.toString());
- }
- })
- }
- })
- };
- /**
- * 写卡指令返回 请求
- */
- const getCommandBackUp = (command, cosRecordId, response) => {
- console.log('======循环写卡指令中======')
- tools.showLoadingAlert("加载中");
- let options = {
- type: 2, //type: 2,JSON格式提交数据(默认表单形式提交)
- data: {
- cardId: fileDataStrings.cardId,
- orderId: fileDataStrings.orderId,
- command: command,
- response: response,
- cosRecordId: cosRecordId,
- cosType: 2
- }, //请求参数
- method: "POST", //提交方式(默认POST)
- showLoading: true, //是否显示加载中(默认显示)
- };
-
- //调用方式
- request(IFCODE.writeCardBack, options)
- .then((res) => {
- tools.hideLoadingAlert();
- let result = JSON.parse(res.bizContent);
- if (result.orderStatus == 1 || result.orderStatus == "1") {
- tools.showLoadingAlert("执行指令中");
- bluetoothUtil.transCmd(result.command.split(","), "10", function(res) {
- tools.hideLoadingAlert();
- let response = res.toString();
- getCommandBackUp(result.command, cosRecordId, response);
- });
- } else {
- obuWriteAgainRequest();
- }
- })
- };
- /**
- * 修改系统信息 请求
- */
- const obuWriteAgainRequest = () => {
- let cmdArray1 = [cmd.HOME_DIRECTORY, cmd.OBU_SYSTEM_FILE, cmd.RANDOM_NUMBER];
- tools.showLoadingAlert("正在执行指令");
- bluetoothUtil.transCmd(cmdArray1, "20", function(res) {
- tools.hideLoadingAlert();
- var str = res[2].substring(res[2].length - 4, res[2].length);
- if (str == "9000") {
- cmdRandNum = res[2].substring(0, res[2].length - 4);
- const options = {
- type: 2,
- data: {
- obuId: fileDataStrings.obuId,
- random: cmdRandNum
- },
- method: "POST",
- showLoading: true,
- };
- request(IFCODE.obuWriteAgain, options).then((res) => {
- let datas = stringToJson(res.bizContent);
- console.log("899", datas, datas.data.APDU);
- if (datas.data.APDU) {
- tools.showLoadingAlert("正在执行指令");
- bluetoothUtil.transCmd([datas.data.APDU], "20", function(res) {
- tools.hideLoadingAlert();
- console.log("res=====", res, res[0])
- let cmdArr = [cmd.HOME_DIRECTORY, cmd.OBU_DF01, cmd.OBU_EF01, cmd
- .RANDOM_NUMBER
- ];
- bluetoothUtil.transCmd(cmdArr, "20", function(res) {
- console.log("chelaing======", res)
- var str = res[3].substring(res[3].length - 4, res[3]
- .length);
- if (str == "9000") {
- cmdRandNum = res[3].substring(0, res[3].length -
- 4);
- console.log("0000000000000000000000000")
- getFileData((demos) => {
- modifyVehicle(demos);
- })
- } else {
- tools.alertF("RANDOM_NUMBER指令长度不符" + res[1]);
- }
- })
-
- })
- }
- })
- } else {
- tools.alertF("RANDOM_NUMBER指令长度不符" + res[1]);
- }
- })
-
- };
- </script>
-
- <style>
- .containers {
- height: 100%;
- display: flex;
- flex-direction: column;
- align-items: center;
- justify-content: space-between;
- box-sizing: border-box;
- }
-
- .sec_info {
- width: 90%;
- height: auto;
- margin: 0 auto;
- box-shadow: 0rpx 6rpx 25rpx 0rpx rgba(0, 0, 0, 0.2);
- margin-top: 50rpx;
- border-radius: 20rpx;
- }
-
- .info_txt {
- width: 100%;
- height: 120rpx;
- line-height: 120rpx;
- text-align: center;
- color: #000;
- font-size: 36rpx;
- margin-bottom: 20rpx;
- }
-
- .info_plate {
- display: flex;
- flex-direction: row;
- width: 94%;
- height: 100rpx;
- margin: 0 auto;
-
- border-bottom: 2rpx solid #f2f2f2;
- }
-
- .info_plate text:nth-child(1) {
- height: 100rpx;
- text-align: left;
- line-height: 100rpx;
- font-size: 32rpx;
- color: #999;
- }
-
- .info_plate text:nth-child(2) {
- flex: 1;
- height: 100rpx;
- line-height: 100rpx;
- font-size: 32rpx;
- color: #333;
- margin-left: 50rpx;
- text-align: right;
- }
-
- /*提交按钮样式*/
- .up_btn {
- width: 85%;
- height: 100rpx;
- margin: 0 auto;
- margin-top: 50rpx;
- margin-bottom: 100rpx;
- }
-
- .up_btn button {
- width: 100%;
- height: 80rpx;
- line-height: 80rpx;
- color: white;
- font-size: 32rpx;
- text-align: center;
- background: linear-gradient(to left, #43a1e0 0%, #13e7c1 100%);
- border-radius: 40rpx;
- outline: none;
- border: #4cd95f;
- }
-
- .up_btn button[disabled] {
- background-color: rgba(0, 191, 112, 0.5);
- color: white;
- font-size: 34rpx;
- border-radius: 20rpx;
- }
- </style>
|