123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278 |
- <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 class="info_plate">
- <text>收费车型</text>
- <text>{{ fileDataStrings.vehicleClassStr }}</text>
- </view>
- </view>
- <view class="up_btn" v-if="state.showBtn">
- <button aria-disabled="true" @click="btn" v-if="!state.isSuccess"
- :class="state.disabled?'button':'hui'">
- 点击开始激活
- </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,
- formatTime2,
- 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 {
- getVehiclePlateColor
- } from "@/datas/vehiclePlateColor";
- import {
- searchVehicleInfoQuery
- } from "@/subpackage/after-sale/js/publicRequest";
- import {
- channelId
- } from "@/utils/network/difference";
- const state = reactive({
- orderId: "",
- id: "",
- cardStatus: "",
- obuStatus: "",
- isSuccess: false, //是否激活成功
- showPopup: false,
- transfer: 0, //0 是原来的激活 1 是过户激活
- showBtn: true,
- disabled: true
- })
- let snums = 0
-
- 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: ""
- });
- 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: "",
- wheelCount: 0, //车轮数
- vehicleIdNo: "", //车牌号
- vehiclePlateColorStr: "",
- customerTel: "",
- customerId: "",
- orderId: "",
- vehicleClassStr:""
- });
-
- function cmdResult() {
- uni.showToast({
- title: '正在激活,请等待',
- mask: true,
- duration:10000,
- icon:"loading"
- });
- const options = {
- type: 2, //type: 2,JSON格式提交数据(默认表单形式提交)
- data: {
- orderId: orderInfo.orderId,
- issueType: state.transfer?2:1 //1正常激活 2 过户激活
- }, //请求参数
- method: "POST", //提交方式(默认POST)
- };
- console.log("options==",options)
- //BDS-二发指令申请
- request('4b001421f5354c248a7759971881b52f', options)
- .then((res) => {
- console.log("在线激活 请求");
- console.log(stringToJson(res.bizContent));
- const datas = stringToJson(res.bizContent).data;
- console.log("datas===",datas)
- bluetoothUtil.transCmd(datas.cmd.split(','), datas.cmdType=='CARD'?'10':'20', function(res) {
- console.log("res申请",res)
- implementCmd(datas.transOrderId,datas.cmd,res.toString(),datas.stepNo)
- }, () => {
- showModals('在线激活异常')
- // tools.hideLoadingAlert();
- uni.hideToast()
- });
- })
- .catch((err) => {
- console.log(err);
- // tools.hideLoadingAlert();
- uni.hideToast()
- console.log("Yin")
- });
- }
-
- function implementCmd(transOrderId, cmd, cmdResult, stepNo) {
- uni.showToast({
- title: '正在激活,请等待',
- mask: true,
- duration:5000,
- icon:"loading"
- });
- const options = {
- type: 2, //type: 2,JSON格式提交数据(默认表单形式提交)
- data: {
- transOrderId, //步骤号
- cmd,
- cmdResult,
- stepNo
- }, //请求参数
- method: "POST", //提交方式(默认POST)
- };
- console.log("options2222",options)
- //BDS-二发指令回传
- request('88d98f2db7df4f06b22d58b507db7854', options)
- .then((res) => {
- console.log(stringToJson(res.bizContent));
- const datas = stringToJson(res.bizContent).data;
- console.log("在线激活 请求",datas);
- if (datas.stepNo == 100) {
- state.disabled = true
- // tools.hideLoadingAlert();
- uni.hideToast()
- msg("激活成功",{'icon':'success','duration':3000})
- setTimeout(() => {
- uni.navigateTo({
- url: "/subpackage/after-sale/deviceInfo/deviceInfo",
- });
- }, 3000)
- } else {
- console.log("datas.stepNo",datas.stepNo)
- bluetoothUtil.transCmd(datas.cmd.split(','), datas.cmdType=='CARD'?'10':'20', function(res) {
- implementCmd(transOrderId,datas.cmd,res.toString(),datas.stepNo)
- }, () => {
- showModals('在线激活异常')
- // tools.hideLoadingAlert();
- uni.hideToast()
- });
- }
- })
- .catch((err) => {
- console.log(err);
- // tools.hideLoadingAlert();
- uni.hideToast()
- });
- }
-
- //开始激活 按钮事件
- const btn = () => {
- state.disabled = false
-
- console.log('orderInfo参数', orderInfo, state.disabled)
- cmdResult()
- };
-
- //获取订单详情
- const getOrderDetails = (id) => {
- console.log('======获取订单信息======')
- const options = {
- type: 2,
- data: {
- id: id,
- },
- method: "POST",
- showLoading: true,
- };
- state.disabled = false
- 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.cardId = orderInfo.cardId;
- fileDataStrings.packageNum = orderInfo.packageNum;
- fileDataStrings.obuId = orderInfo.obuId;
- fileDataStrings.customerTel = orderInfo.customerTel;
- fileDataStrings.customerId = orderInfo.customerId;
- fileDataStrings.orderId = orderInfo.orderId;
- fileDataStrings.vehiclePlateColorStr = getVehiclePlateColor(orderInfo
- .vehiclePlateColor);
- fileDataStrings.vehiclePlate = orderInfo.vehiclePlate; //车牌
- fileDataStrings.vehicleClassStr = orderInfo.vehicleClassStr;
- cancelOrderRequest(orderInfo.orderId)
- }
- });
-
-
- getObuId();
- };
- //更换设备 去注销前订单的 卡签
- 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") {
- state.disabled = true
- obu.obuId = res[1].substring(20, 36);
- console.log(containsEnglishCharacters(card.obuId), '获取OBU号执行结果=========' + obu.obuId)
- 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);
- state.showBtn = true
- } else {
- showModals('获取设备信息错误!')
- }
- }, () => {
- showModals('获取设备信息错误')
- });
- };
-
- //获取fileData
- const getFileData = (fun) => {
- searchVehicleInfoQuery(orderInfo.vehiclePlate + "_" + orderInfo.vehiclePlateColor, cmdRandNum).then((
- orderInfo) => {
- console.log("orderInfo==", orderInfo, orderInfo.fileData)
- fun(orderInfo.fileData);
- })
- };
-
- function containsEnglishCharacters(str) {
- // // 使用正则表达式匹配英文字母
- // const regex = /[a-zA-Z]/;
- // return regex.test(str);
-
- // 使用正则表达式匹配纯数字
- const regex = /^\d+$/;
- return regex.test(str);
- }
-
-
- /**
- * 获取卡号 读卡
- */
- 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); //卡号
-
- if (!containsEnglishCharacters(card.cardId)) {
- if (snums > 2) {
- showModals('获取卡信息错误')
- return
- }
- snums++
- getCardId()
- return
- }
-
- 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();
- }
- } else {
- showModals('获取卡信息错误!')
- }
- console.error("CMD_READBINARY指令长度不符" + res[2])
- tools.hideLoadingAlert();
- }, () => {
- showModals('获取卡信息错误')
- });
- };
-
- function showModals(msg) {
- uni.showModal({
- title: '提示',
- content: msg,
- showCancel: false,
- success: function(res) {
- if (res.confirm) {
- uni.navigateBack()
- console.log('用户点击确定1');
- } else if (res.cancel) {
- console.log('用户点击取消1');
- }
- }
- });
- }
-
- // *------------------------------------*
- // 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());
- }, () => {
- showModals('写卡指令信息错误!')
- });
- })
- };
-
- /**
- * 写卡指令返回 请求
- */
- 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);
- }, () => {
- showModals('写卡指令返回错误!')
- })
- } 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: formatTime2(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("加载中");
-
- console.log('获取OBU号执行结果=========' + obu.obuId)
- 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]);
- }
- }, () => {
- showModals('修改系统信息错误')
- })
- }
- }, () => {
- showModals('修改系统信息错误!')
- });
- }
- })
- .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,
- obuSerailNo: obu.obuId,
- 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();
- }
- }
- }, () => {
- showModals('修改车辆信息错误')
- });
- }
- })
- };
-
- /**
- * 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]);
- }
- }, () => {
- showModals('安装申请异常')
- })
- })
- };
-
- /**
- * 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 - 安装失败
- }
- }, () => {
- showModals('在线激活异常')
- });
- })
- .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);
- }, () => {
- showModals('卡签绑定异常!')
- });
- })
- .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);
- }, () => {
- showModals('卡签绑定返回异常!')
- });
- } else {
- state.disabled = true
- // #ifdef MP-ALIPAY
- uni.closeBluetoothAdapter({
- success(res) {
-
- }
- })
- msg("激活成功")
- state.showPopup = true
- state.isSuccess = true
-
- // #endif
-
- DataSynchronizationRequest();
-
-
- // #ifdef MP-WEIXIN
- msg("激活成功",{'icon':'success','duration':2000})
- 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());
- }
- }, () => {
- showModals('设备升级异常!')
- })
- }
- })
- };
- /**
- * 写卡指令返回 请求
- */
- 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);
- }, () => {
- showModals('写卡异常!')
- });
- } 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;
- }
-
- .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;
- }
-
- .hui {
- width: 100%;
- height: 80rpx;
- line-height: 80rpx;
- color: white;
- font-size: 32rpx;
- text-align: center;
- background: linear-gradient(to left, #b9b9b9 0%, #e7e7e7 100%) !important;
- 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>
|