Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

activation-once-again.vue 32KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291
  1. <template>
  2. <view class="selectCar-box">
  3. <view class="details">
  4. <view class="title"> 基础信息 </view>
  5. <view class="details-item">
  6. <view> 订单编号: </view>
  7. <text>{{ orderInfos.orderId }}</text>
  8. </view>
  9. <view class="details-item">
  10. <view> 用户名称: </view>
  11. <text>{{ orderInfos.ownerName }}</text>
  12. </view>
  13. <view class="details-item">
  14. <view> 用户证件类型: </view>
  15. <text>{{ getCodeName('CERTIFICATE_TYPE',orderInfos.ownerIdtype) }}</text>
  16. </view>
  17. <view class="details-item">
  18. <view> 用户证件号: </view>
  19. <text>{{ orderInfos.ownerIdnum }}</text>
  20. </view>
  21. <view class="details-item">
  22. <view> 订单车牌号: </view>
  23. <text style="color: #00b38b">{{ orderInfos.vehiclePlate }}</text>
  24. </view>
  25. <view class="details-item">
  26. <view> 车牌颜色: </view>
  27. <text style="color: #00b38b">{{
  28. orderInfos.vehiclePlateColorStr
  29. }}</text>
  30. </view>
  31. <view class="details-item">
  32. <view> 收费车型: </view>
  33. <text>{{ orderInfos.vehicleType }}</text>
  34. </view>
  35. <view class="details-item">
  36. <view> 重新激活次数: </view>
  37. <text>{{ state.activationNum }}次</text>
  38. <text class="record" style="color:#00b38b" @click="goActivationRecord">OBU重新激活记录</text>
  39. </view>
  40. </view>
  41. <view class="title"> 卡信息 </view>
  42. <view class="card">
  43. <view class="card-left">
  44. <image :src="`${$imgUrl}card2.png`" mode=""></image>
  45. <view class="card-center">
  46. <view class="card-center-head"> {{orderInfos.cardId}} </view>
  47. <view class="tips">
  48. <text>储蓄卡</text>
  49. <text class="tips-card">{{getCodeName('CARD_STATE_TYPE',orderInfos.cardStatus)}}</text>
  50. </view>
  51. <!-- <view class="choose-item"> 有效期:xxxx-xx-xx </view> -->
  52. </view>
  53. </view>
  54. </view>
  55. <view class="title"> OBU设备信息 </view>
  56. <view class="card">
  57. <view class="card-left">
  58. <image :src="`${$imgUrl}card1.png`" mode=""></image>
  59. <view class="card-center">
  60. <view class="card-center-head"> {{orderInfos.obuId}} </view>
  61. <view class="tips">
  62. <!-- <text>储蓄卡</text> -->
  63. <text class="tips-card">{{getCodeName('OBU_STATE_TYPE',orderInfos.obuStatus)}}</text>
  64. </view>
  65. <!-- <view class="choose-item"> 有效期:xxxx-xx-xx </view> -->
  66. </view>
  67. </view>
  68. </view>
  69. <view class="picture-wrapper" @click="takePhotoMode('3')">
  70. <view class="bg">
  71. <view class="">
  72. <view class="name"> 行驶证主页 </view>
  73. <view class="value"> 上传行驶证的主页 </view>
  74. <view class="tip">
  75. <view class="tip-value"> 拍摄规范 </view>
  76. </view>
  77. </view>
  78. <image v-if="!state.form.vehPosImgUrl" class="icon" :src="`${$imgUrl}applyCard/car-zhu.png`">
  79. </image>
  80. <image v-else class="icon" :src="strReplace(state.form.vehPosImgUrl)"></image>
  81. </view>
  82. </view>
  83. <view class="picture-wrapper" @click="takePhotoMode('4')">
  84. <view class="bg">
  85. <view class="">
  86. <view class="name"> 行驶证副页 </view>
  87. <view class="value"> 上传行驶证的副页 </view>
  88. <view class="tip">
  89. <view class="tip-value"> 拍摄规范 </view>
  90. </view>
  91. </view>
  92. <image v-if="!state.form.vehNegImgUrl" class="icon" :src="`${$imgUrl}applyCard/car-fu.png`">
  93. </image>
  94. <image v-else class="icon" :src="strReplace(state.form.vehNegImgUrl)"></image>
  95. </view>
  96. </view>
  97. <button class="submit" @click="toPage">再次激活</button>
  98. <view class="mask" v-show="state.showPopup">
  99. <view class="main">
  100. <view class="top">
  101. <image class="icon-close" :src="`${$imgUrl}common/icon-close.png`" @click="cancel"></image>
  102. </view>
  103. <image class="icon-success" :src="`${$imgUrl}bluetooth/device-active-success.png`"></image>
  104. <view class="title">设备激活成功!</view>
  105. </view>
  106. </view>
  107. </view>
  108. <view class="choice-takePhoto-wrap" v-if="state.isTakePhotoModeShow" @click="cancle">
  109. <view class="choice-takePhoto">
  110. <view @click.stop="takePhoto(state.choiceIndex)" style="border-radius: 20rpx 20rpx 0 0;">拍照</view>
  111. <view @click.stop="xiangce(state.choiceIndex)">从手机相册选择</view>
  112. <view @click.stop="cancle">取消</view>
  113. </view>
  114. </view>
  115. <viewfinder v-if="state.phoneType" :phoneType="state.phoneType" :images="state.images"
  116. :showStartPhoto="state.showImg" @confirmReturn="confirmReturn" @camera="camera"></viewfinder>
  117. </template>
  118. <script lang="ts" setup>
  119. // #ifdef MP-ALIPAY
  120. import viewfinder from "@/components/viewfinder.vue"
  121. import {
  122. reactive,
  123. ref
  124. } from "vue";
  125. import {
  126. formatTime,
  127. expireDate,
  128. expireDate2,
  129. getFormatDate,
  130. msg,
  131. navTo,
  132. strReplace,
  133. uploadFile
  134. } from "@/utils/utils";
  135. import {
  136. onLoad, onShow
  137. } from '@dcloudio/uni-app'
  138. import {
  139. request
  140. } from "@/utils/network/request.js";
  141. import {
  142. stringToJson
  143. } from "@/utils/network/encryption.js";
  144. import activeSuccess from "./components/popup-device-active-success";
  145. import * as IFCODE from "@/utils/network/api.js";
  146. import {
  147. channelId
  148. } from "@/utils/network/difference";
  149. const cmd = require("../../../static/etcUtil/cmdConfig.js");
  150. const tools = require("../../../static/etcUtil/tools.js");
  151. const bluetoothUtil = require("../../../static/etcUtil/index.js");
  152. import {
  153. getCodeName
  154. } from "@/datas/queryKey.js";
  155. import { agentId } from "@/utils/network/difference";
  156. const state = reactive({
  157. phoneType: 0, // 1 身份证正面 2 身份证反面 3行驶证正面 4行驶证反面
  158. choiceIndex: 1, // 1 身份证正面 2 身份证反面
  159. isTakePhotoModeShow: false, //选择拍照方式是否出来
  160. changeColor: false,
  161. showImg: true,
  162. images: '',
  163. showPopup: false,
  164. form: {
  165. vehPosImgUrl: "",
  166. vehNegImgUrl: "",
  167. vehicleIdNum: ""
  168. },
  169. activationNum: "",//激活次数
  170. })
  171. //订单
  172. const orderInfos = reactive({
  173. orderId: "",
  174. ownerName: "",
  175. ownerIdtype: "",
  176. ownerIdnum: "",
  177. vehiclePlate: "",
  178. vehiclePlateColorStr: "",
  179. vehiclePlateColor: "",
  180. vehicleType: "",
  181. cardId: "",
  182. cardStatus: "",
  183. obuId: "",
  184. obuStatus: "",
  185. outlineL: 0,
  186. outlineW: 0,
  187. outlineH: 0,
  188. type: 0,
  189. axleCount: 0,
  190. approvedCount: 0,
  191. vehicleVin: "",
  192. vehicleEngineNum: "",
  193. });
  194. //OBU
  195. const obu = reactive({
  196. obuId: "",
  197. startTime: "",
  198. endTime: "",
  199. version: "",
  200. approvedCount: "",
  201. axleCount: "",
  202. axleDistance: "",
  203. engineNum: "",
  204. type: "",
  205. userType: "",
  206. contractNo: "",
  207. vehiclePlate: "",
  208. vehiclePlateColor: "",
  209. vin: "",
  210. wheelCount: "",
  211. isJH: ""
  212. });
  213. let cmdRandNum = '';
  214. let ids = '';
  215. onLoad((option) => {
  216. console.log('======重新激活开始======', option);
  217. ids = option.id;
  218. //请求订单详情
  219. queryOrderDetail(option.id);
  220. // uni.$on('bluetoothLink', res => {
  221. // console.log(res,'===========123');
  222. // if (res.status) {
  223. // // getCardRenewal()
  224. // setTimeout(()=>{
  225. // getObuId()
  226. // })
  227. // }
  228. // //移除监听
  229. // console.log('======移除监听======', res)
  230. // // uni.$off('bluetoothLink')
  231. // })
  232. if (opn.state) {
  233. getObuId()
  234. }
  235. });
  236. onShow((option) => {
  237. })
  238. const cancel = () => {
  239. state.showPopup = false;
  240. uni.navigateBack({
  241. delta: 2
  242. })
  243. };
  244. const toPage = () => {
  245. if (!state.form.vehPosImgUrl) {
  246. msg("请上传行驶证主页")
  247. return;
  248. }
  249. if (!state.form.vehNegImgUrl) {
  250. msg("请上传行驶证副页")
  251. return;
  252. }
  253. console.log("state.form.vehicleIdNum", state.form.vehicleIdNum, orderInfos.vehiclePlate)
  254. if (state.form.vehicleIdNum == orderInfos.vehiclePlate) {
  255. activationRecordQuery().then((val) => {
  256. console.log("激活次数", val)
  257. if (val.limit) {
  258. navTo("/pages/bluetooth/bluetooth?routeType=5&id=" + ids);
  259. } else {
  260. msg("一年内到达激活次数上限5次")
  261. }
  262. });
  263. } else {
  264. msg("请上传正确行驶证")
  265. }
  266. // navTo("/pages/bluetooth/bluetooth?routeType=6&id=" + ids);
  267. };
  268. //获取订单详情
  269. const queryOrderDetail = (id : string) => {
  270. const options = {
  271. type: 2,
  272. data: {
  273. id: id,
  274. },
  275. method: "POST",
  276. showLoading: true,
  277. };
  278. request(IFCODE.orderDetail, options).then((res) => {
  279. let orderInfo = JSON.parse(res.bizContent);
  280. console.log(orderInfo);
  281. orderInfos.orderId = orderInfo.orderId;
  282. orderInfos.ownerName = orderInfo.ownerName;
  283. orderInfos.ownerIdtype = orderInfo.ownerIdtype;
  284. orderInfos.ownerIdnum = orderInfo.ownerIdnum;
  285. orderInfos.vehiclePlate = orderInfo.vehiclePlate;
  286. orderInfos.vehiclePlateColorStr = orderInfo.vehiclePlateColorStr;
  287. orderInfos.vehiclePlateColor = orderInfo.vehiclePlateColor;
  288. orderInfos.vehicleType = orderInfo.vehicleType;
  289. orderInfos.cardId = orderInfo.cardId;
  290. orderInfos.cardStatus = orderInfo.cardStatus;
  291. orderInfos.obuId = orderInfo.obuId;
  292. orderInfos.obuStatus = orderInfo.obuStatus;
  293. let arr = orderInfo.vehicleDimensions.split("X");
  294. orderInfos.outlineL = parseInt(arr[0]); //外廓 长
  295. orderInfos.outlineW = parseInt(arr[1]); //外廓 宽
  296. orderInfos.outlineH = parseInt(arr[2].substring(0, arr[2].length - 2)); //外廓 高
  297. orderInfos.type = orderInfo.type;
  298. orderInfos.axleCount = orderInfo.vehicleAxleCount;
  299. orderInfos.approvedCount = orderInfo.vehicleApprovedCount;
  300. orderInfos.vehicleVin = orderInfo.vehicleVin;
  301. orderInfos.vehicleEngineNum = orderInfo.vehicleEngineNum;
  302. activationRecordQuery().then((val) => {
  303. console.log("jihuo", val)
  304. state.activationNum = val.num
  305. // getObuId()
  306. });
  307. });
  308. };
  309. /**
  310. * 获取OBU号 读OBU
  311. */
  312. const getObuId = () => {
  313. console.log('======获取OBU号======')
  314. let cmdArray = [cmd.HOME_DIRECTORY, cmd.OBU_SYSTEM_FILE, cmd.RANDOM_NUMBER];
  315. tools.showLoadingAlert("正在执行指令");
  316. bluetoothUtil.transCmd(cmdArray, "20", function (res) {
  317. tools.hideLoadingAlert();
  318. var status = res[1].substring(res[1].length - 4, res[1].length);
  319. console.log('获取OBU号执行结果' + status)
  320. //第一次获取随机数
  321. if (status == "9000") {
  322. obu.obuId = res[1].substring(20, 36);
  323. obu.vin = res[1].substring(18, 20);
  324. obu.version = res[1].substring(18, 19) >= 4 ? "4x" : "2x";
  325. cmdRandNum = res[2].substring(0, res[2].length - 4);
  326. console.log("obu.obuId===========", obu.obuId, res[1].substring(20, 36), cmdRandNum)
  327. getInstallApply()
  328. }
  329. });
  330. // getInstallApply()
  331. };
  332. /**
  333. * BDS-安装申请 请求
  334. */
  335. const getInstallApply = () => {
  336. console.log('======安装申请======')
  337. tools.showLoadingAlert("加载中");
  338. let options = {
  339. type: 2, //type: 2,JSON格式提交数据(默认表单形式提交)
  340. data: {
  341. obuId: obu.obuId,
  342. vehicleId: orderInfos.vehiclePlate + "_" + orderInfos.vehiclePlateColor,
  343. orderId: orderInfos.orderId,
  344. agentId: agentId,
  345. channelId: channelId,
  346. channelType: "1",
  347. staffId: "opId",
  348. terminalId: "999999999",
  349. }, //请求参数
  350. method: "POST", //提交方式(默认POST)
  351. showLoading: true, //是否显示加载中(默认显示)
  352. };
  353. //调用方式
  354. request(IFCODE.installApply, options)
  355. .then(() => {
  356. tools.hideLoadingAlert();
  357. //再次获取随机数
  358. getObuActivation(cmdRandNum);
  359. })
  360. };
  361. /**
  362. * VFJ-OBU在线激活 请求
  363. */
  364. const getObuActivation = (cmdRandNum : string) => {
  365. console.log('======VFJ-OBU在线激活======')
  366. tools.showLoadingAlert("加载中");
  367. let options = {
  368. type: 2, //type: 2,JSON格式提交数据(默认表单形式提交)
  369. data: {
  370. random: cmdRandNum,
  371. obuSerailNo: obu.obuId,
  372. orderId: orderInfos.orderId,
  373. }, //请求参数
  374. method: "POST", //提交方式(默认POST)
  375. showLoading: true, //是否显示加载中(默认显示)
  376. };
  377. //调用方式
  378. request(IFCODE.obuActivation, options)
  379. .then((res) => {
  380. tools.hideLoadingAlert();
  381. console.log("在线激活 请求");
  382. console.log(stringToJson(res.bizContent));
  383. const datas = stringToJson(res.bizContent);
  384. tools.showLoadingAlert("执行指令");
  385. bluetoothUtil.transCmd([datas.data.APDU], "20", function (res) {
  386. tools.hideLoadingAlert();
  387. console.log(res);
  388. if (res[0] == "9000") {
  389. console.log("在线激活执行指令88888 请求", res);
  390. getObuInstall(0, ""); //status 0 - 安装成功 || 1 - 安装失败
  391. }
  392. });
  393. })
  394. .catch((err) => {
  395. console.log(err);
  396. });
  397. };
  398. /**
  399. * BDS-安装确认 请求
  400. */
  401. const getObuInstall = (status : number, reason : string) => {
  402. console.log('======OBU安装确认======')
  403. tools.showLoadingAlert("加载中");
  404. let options = {
  405. type: 2, //type: 2,JSON格式提交数据(默认表单形式提交)
  406. data: {
  407. installStatus: status,
  408. failReason: reason,
  409. installType: "1",
  410. installChannelId: channelId,
  411. obuId: obu.obuId,
  412. orderId: orderInfos.orderId
  413. }, //请求参数
  414. method: "POST", //提交方式(默认POST)
  415. showLoading: true, //是否显示加载中(默认显示)
  416. };
  417. //调用方式
  418. request(IFCODE.obuInstall, options)
  419. .then(() => {
  420. tools.hideLoadingAlert();
  421. state.showPopup = true;
  422. submitVehicleQuery()
  423. });
  424. };
  425. const xiangce = (val) => {
  426. console.log("val", val)
  427. if (state.choiceIndex == 3) {
  428. var imageType = 1;
  429. } else {
  430. var imageType = 2;
  431. }
  432. state.changeColor = true;
  433. uni.chooseImage({
  434. count: 1, //只能选取一张照片
  435. sizeType: ["original", "compressed"], //可以指定是原图还是压缩图,默认二者都有
  436. sourceType: ["album"], //从相册选择
  437. success: function (res) {
  438. console.log("tempFilePaths[0].startsWith('file://')", res.tempFilePaths[0], res.tempFilePaths[0].startsWith('file://'))
  439. if (state.choiceIndex == 3 || state.choiceIndex == 4) {
  440. state.showImg = false
  441. state.images = res.tempFilePaths[0]
  442. state.phoneType = state.choiceIndex
  443. state.isTakePhotoModeShow = false
  444. return
  445. }
  446. },
  447. })
  448. }
  449. const takePhoto = (val) => {
  450. console.log("拍照", val)
  451. state.phoneType = val;
  452. state.showImg = true;
  453. }
  454. const confirmReturn = (val) => {
  455. if (state.choiceIndex == 3) {
  456. var imageType = 1;
  457. } else {
  458. var imageType = 2;
  459. }
  460. state.changeColor = true;
  461. state.phoneType = 0
  462. state.isTakePhotoModeShow = false
  463. uploadFile(val.tempImagePath, imageType, IFCODE.etcCarOcrCard).then((data : any) => {
  464. // uploadFile(val.tempImagePath, state.choiceIndex, ocrAllQuery).then((data) => {
  465. console.log('输出内容=====================', state.choiceIndex)
  466. if (state.choiceIndex == "3") {
  467. if (data.plate_a.length > 8) {
  468. state.form.vehicleIdNum = data.plate_a.substring(0, 8);
  469. } else {
  470. state.form.vehicleIdNum = data.plate_a;
  471. }
  472. state.form.vehPosImgUrl = data.imageUrl;
  473. } else {
  474. state.form.vehNegImgUrl = data.imageUrl;
  475. console.log('=====================', state.form.vehNegImgUrl, state)
  476. }
  477. state.isTakePhotoModeShow = false
  478. })
  479. console.log("图片地址val", val.tempImagePath)
  480. }
  481. const takePhotoMode = (index) => {
  482. console.log("index", index)
  483. state.isTakePhotoModeShow = true
  484. state.choiceIndex = index
  485. }
  486. const cancle = () => {
  487. state.isTakePhotoModeShow = false
  488. }
  489. const camera = () => {
  490. state.phoneType = 0
  491. }
  492. // 查询重新激活记录
  493. const activationRecordQuery = () => {
  494. const options = {
  495. type: 2,
  496. data: {
  497. cardId: orderInfos.cardId,
  498. obuId: orderInfos.obuId,
  499. },
  500. method: "POST",
  501. showLoading: true,
  502. };
  503. return new Promise(async (resolve, reject) => {
  504. const res = await request(IFCODE.activationRecordApi, options);
  505. const data = stringToJson(res.bizContent);
  506. resolve(data);
  507. }).catch((error) => {
  508. reject(error);
  509. });
  510. }
  511. // 提交车辆信息
  512. const submitVehicleQuery = () => {
  513. const options = {
  514. type: 2,
  515. data: {
  516. cardId: orderInfos.cardId,
  517. obuId: orderInfos.obuId,
  518. vehPosImgUrl: state.form.vehPosImgUrl,
  519. vehNegImgUrl: state.form.vehNegImgUrl,
  520. vehiclePlate: orderInfos.vehiclePlate
  521. },
  522. method: "POST",
  523. };
  524. console.log("提交车辆信息成功", options)
  525. request(IFCODE.submitVehicleApi, options).then(() => {
  526. console.log("提交车辆信息成功")
  527. });
  528. }
  529. const goActivationRecord = () => {
  530. uni.navigateTo({
  531. url: `/subpackage/after-sale/activation-once-again/activation-once-again-record?obuId=${orderInfos.obuId}&&cardId=${orderInfos.cardId}`
  532. })
  533. }
  534. // #endif
  535. // #ifdef MP-WEIXIN
  536. import viewfinder from "@/components/viewfinder.vue"
  537. import {
  538. reactive,
  539. ref
  540. } from "vue";
  541. import {
  542. formatTime,
  543. expireDate,
  544. expireDate2,
  545. getFormatDate,
  546. msg,
  547. navTo,
  548. strReplace,
  549. uploadFile
  550. } from "@/utils/utils";
  551. import {
  552. onLoad, onShow
  553. } from '@dcloudio/uni-app'
  554. import {
  555. request
  556. } from "@/utils/network/request.js";
  557. import {
  558. stringToJson
  559. } from "@/utils/network/encryption.js";
  560. import activeSuccess from "./components/popup-device-active-success";
  561. import * as IFCODE from "@/utils/network/api.js";
  562. import {
  563. channelId
  564. } from "@/utils/network/difference";
  565. const cmd = require("../../../static/etcUtil/cmdConfig.js");
  566. const tools = require("../../../static/etcUtil/tools.js");
  567. const bluetoothUtil = require("../../../static/etcUtil/index.js");
  568. import {
  569. getCodeName
  570. } from "@/datas/queryKey.js";
  571. import { agentId } from "@/utils/network/difference";
  572. const state = reactive({
  573. phoneType: 0, // 1 身份证正面 2 身份证反面 3行驶证正面 4行驶证反面
  574. choiceIndex: 1, // 1 身份证正面 2 身份证反面
  575. isTakePhotoModeShow: false, //选择拍照方式是否出来
  576. changeColor: false,
  577. showImg: true,
  578. images: '',
  579. showPopup: false,
  580. form: {
  581. vehPosImgUrl: "",
  582. vehNegImgUrl: "",
  583. vehicleIdNum: "",
  584. vehicleIdNumB: ''
  585. },
  586. activationNum: "",//激活次数
  587. })
  588. //订单
  589. const orderInfos = reactive({
  590. orderId: "",
  591. ownerName: "",
  592. ownerIdtype: "",
  593. ownerIdnum: "",
  594. vehiclePlate: "",
  595. vehiclePlateColorStr: "",
  596. vehiclePlateColor: "",
  597. vehicleType: "",
  598. cardId: "",
  599. cardStatus: "",
  600. obuId: "",
  601. obuStatus: "",
  602. outlineL: 0,
  603. outlineW: 0,
  604. outlineH: 0,
  605. type: 0,
  606. axleCount: 0,
  607. approvedCount: 0,
  608. vehicleVin: "",
  609. vehicleEngineNum: "",
  610. });
  611. //OBU
  612. const obu = reactive({
  613. obuId: "",
  614. startTime: "",
  615. endTime: "",
  616. version: "",
  617. approvedCount: "",
  618. axleCount: "",
  619. axleDistance: "",
  620. engineNum: "",
  621. type: "",
  622. userType: "",
  623. contractNo: "",
  624. vehiclePlate: "",
  625. vehiclePlateColor: "",
  626. vin: "",
  627. wheelCount: "",
  628. isJH: ""
  629. });
  630. onLoad((option) => {
  631. console.log('======重新激活开始======', option);
  632. //请求订单详情
  633. queryOrderDetail(option.id);
  634. });
  635. onShow((option) => {
  636. uni.$on('bluetoothLink', res => {
  637. console.log(res);
  638. if (res.status) {
  639. // getCardRenewal()
  640. getObuId()
  641. }
  642. //移除监听
  643. console.log('======移除监听======', res)
  644. // uni.$off('bluetoothLink')
  645. })
  646. })
  647. const cancel = () => {
  648. state.showPopup = false;
  649. uni.navigateBack({
  650. delta: 2
  651. })
  652. };
  653. const toPage = () => {
  654. if (!state.form.vehPosImgUrl) {
  655. msg("请上传行驶证主页")
  656. return;
  657. }
  658. if (!state.form.vehNegImgUrl) {
  659. msg("请上传行驶证副页")
  660. return;
  661. }
  662. console.log("state.form.vehicleIdNum", state.form.vehicleIdNum, orderInfos.vehiclePlate)
  663. if (state.form.vehicleIdNum == orderInfos.vehiclePlate) {
  664. if (state.form.vehicleIdNumB == orderInfos.vehiclePlate) {
  665. activationRecordQuery().then((val) => {
  666. console.log("激活次数", val)
  667. if (val.limit) {
  668. navTo("/pages/bluetooth/bluetooth?routeType=5");
  669. } else {
  670. msg("一年内到达激活次数上限5次")
  671. }
  672. });
  673. } else {
  674. msg("请上传正确行驶证副页")
  675. }
  676. } else {
  677. msg("请上传正确行驶证")
  678. }
  679. };
  680. //获取订单详情
  681. const queryOrderDetail = (id : string) => {
  682. const options = {
  683. type: 2,
  684. data: {
  685. id: id,
  686. },
  687. method: "POST",
  688. showLoading: true,
  689. };
  690. request(IFCODE.orderDetail, options).then((res) => {
  691. let orderInfo = JSON.parse(res.bizContent);
  692. console.log(orderInfo);
  693. orderInfos.orderId = orderInfo.orderId;
  694. orderInfos.ownerName = orderInfo.ownerName;
  695. orderInfos.ownerIdtype = orderInfo.ownerIdtype;
  696. orderInfos.ownerIdnum = orderInfo.ownerIdnum;
  697. orderInfos.vehiclePlate = orderInfo.vehiclePlate;
  698. orderInfos.vehiclePlateColorStr = orderInfo.vehiclePlateColorStr;
  699. orderInfos.vehiclePlateColor = orderInfo.vehiclePlateColor;
  700. orderInfos.vehicleType = orderInfo.vehicleType;
  701. orderInfos.cardId = orderInfo.cardId;
  702. orderInfos.cardStatus = orderInfo.cardStatus;
  703. orderInfos.obuId = orderInfo.obuId;
  704. orderInfos.obuStatus = orderInfo.obuStatus;
  705. let arr = orderInfo.vehicleDimensions.split("X");
  706. orderInfos.outlineL = parseInt(arr[0]); //外廓 长
  707. orderInfos.outlineW = parseInt(arr[1]); //外廓 宽
  708. orderInfos.outlineH = parseInt(arr[2].substring(0, arr[2].length - 2)); //外廓 高
  709. orderInfos.type = orderInfo.type;
  710. orderInfos.axleCount = orderInfo.vehicleAxleCount;
  711. orderInfos.approvedCount = orderInfo.vehicleApprovedCount;
  712. orderInfos.vehicleVin = orderInfo.vehicleVin;
  713. orderInfos.vehicleEngineNum = orderInfo.vehicleEngineNum;
  714. activationRecordQuery().then((val) => {
  715. console.log("jihuo", val)
  716. state.activationNum = val.num
  717. });
  718. });
  719. };
  720. /**
  721. * 获取OBU号 读OBU
  722. */
  723. const getObuId = () => {
  724. console.log('======获取OBU号======')
  725. let cmdArray = [cmd.HOME_DIRECTORY, cmd.OBU_SYSTEM_FILE, cmd.RANDOM_NUMBER];
  726. tools.showLoadingAlert("正在执行指令");
  727. bluetoothUtil.transCmd(cmdArray, "20", function (res) {
  728. tools.hideLoadingAlert();
  729. var status = res[1].substring(res[1].length - 4, res[1].length);
  730. console.log('获取OBU号执行结果' + status)
  731. //第一次获取随机数
  732. if (status == "9000") {
  733. obu.obuId = res[1].substring(20, 36);
  734. obu.vin = res[1].substring(18, 20);
  735. obu.version = res[1].substring(18, 19) >= 4 ? "4x" : "2x";
  736. getInstallApply()
  737. // cmdRandNum = res[2].substring(0, res[2].length - 4);
  738. }
  739. });
  740. };
  741. /**
  742. * BDS-安装申请 请求
  743. */
  744. const getInstallApply = () => {
  745. console.log('======安装申请======')
  746. tools.showLoadingAlert("加载中");
  747. let options = {
  748. type: 2, //type: 2,JSON格式提交数据(默认表单形式提交)
  749. data: {
  750. obuId: obu.obuId,
  751. vehicleId: orderInfos.vehiclePlate + "_" + orderInfos.vehiclePlateColor,
  752. orderId: orderInfos.orderId,
  753. agentId: agentId,
  754. channelId: channelId,
  755. channelType: "1",
  756. staffId: "opId",
  757. terminalId: "999999999",
  758. }, //请求参数
  759. method: "POST", //提交方式(默认POST)
  760. showLoading: true, //是否显示加载中(默认显示)
  761. };
  762. //调用方式
  763. request(IFCODE.installApply, options)
  764. .then(() => {
  765. tools.hideLoadingAlert();
  766. //再次获取随机数
  767. let cmdArr = [cmd.HOME_DIRECTORY, cmd.RANDOM_NUMBER];
  768. bluetoothUtil.transCmd(cmdArr, '20', function (res) {
  769. var str = res[1].substring(res[1].length - 4, res[1].length);
  770. if (str == "9000") {
  771. let cmdRandNum = res[1].substring(0, res[1].length - 4);
  772. getObuActivation(cmdRandNum);
  773. } else {
  774. tools.alertF("RANDOM_NUMBER指令长度不符" + res[1]);
  775. }
  776. })
  777. })
  778. };
  779. /**
  780. * VFJ-OBU在线激活 请求
  781. */
  782. const getObuActivation = (cmdRandNum : string) => {
  783. console.log('======VFJ-OBU在线激活======')
  784. tools.showLoadingAlert("加载中");
  785. let options = {
  786. type: 2, //type: 2,JSON格式提交数据(默认表单形式提交)
  787. data: {
  788. random: cmdRandNum,
  789. obuSerailNo: obu.obuId,
  790. orderId: orderInfos.orderId,
  791. }, //请求参数
  792. method: "POST", //提交方式(默认POST)
  793. showLoading: true, //是否显示加载中(默认显示)
  794. };
  795. //调用方式
  796. request(IFCODE.obuActivation, options)
  797. .then((res) => {
  798. tools.hideLoadingAlert();
  799. console.log("在线激活 请求");
  800. console.log(stringToJson(res.bizContent));
  801. const datas = stringToJson(res.bizContent);
  802. tools.showLoadingAlert("执行指令");
  803. bluetoothUtil.transCmd([datas.data.APDU], "20", function (res) {
  804. tools.hideLoadingAlert();
  805. console.log(res);
  806. if (res[0] == "9000") {
  807. console.log("在线激活执行指令88888 请求", res);
  808. getObuInstall(0, ""); //status 0 - 安装成功 || 1 - 安装失败
  809. }
  810. });
  811. })
  812. .catch((err) => {
  813. console.log(err);
  814. });
  815. };
  816. /**
  817. * BDS-安装确认 请求
  818. */
  819. const getObuInstall = (status : number, reason : string) => {
  820. console.log('======OBU安装确认======')
  821. tools.showLoadingAlert("加载中");
  822. let options = {
  823. type: 2, //type: 2,JSON格式提交数据(默认表单形式提交)
  824. data: {
  825. installStatus: status,
  826. failReason: reason,
  827. installType: "1",
  828. installChannelId: channelId,
  829. obuId: obu.obuId,
  830. orderId: orderInfos.orderId
  831. }, //请求参数
  832. method: "POST", //提交方式(默认POST)
  833. showLoading: true, //是否显示加载中(默认显示)
  834. };
  835. //调用方式
  836. request(IFCODE.obuInstall, options)
  837. .then(() => {
  838. tools.hideLoadingAlert();
  839. state.showPopup = true;
  840. submitVehicleQuery()
  841. });
  842. };
  843. const xiangce = (val) => {
  844. console.log("val", val)
  845. if (state.choiceIndex == 3) {
  846. var imageType = 1;
  847. } else {
  848. var imageType = 2;
  849. }
  850. state.changeColor = true;
  851. uni.chooseImage({
  852. count: 1, //只能选取一张照片
  853. sizeType: ["original", "compressed"], //可以指定是原图还是压缩图,默认二者都有
  854. sourceType: ["album"], //从相册选择
  855. success: function (res) {
  856. console.log("tempFilePaths[0].startsWith('file://')", res.tempFilePaths[0], res.tempFilePaths[0].startsWith('file://'))
  857. if (state.choiceIndex == 3 || state.choiceIndex == 4) {
  858. state.showImg = false
  859. state.images = res.tempFilePaths[0]
  860. state.phoneType = state.choiceIndex
  861. state.isTakePhotoModeShow = false
  862. return
  863. }
  864. },
  865. })
  866. }
  867. const takePhoto = (val) => {
  868. console.log("拍照", val)
  869. state.phoneType = val;
  870. state.showImg = true;
  871. }
  872. const confirmReturn = (val) => {
  873. if (state.choiceIndex == 3) {
  874. var imageType = 1;
  875. } else {
  876. var imageType = 2;
  877. }
  878. state.changeColor = true;
  879. state.phoneType = 0
  880. state.isTakePhotoModeShow = false
  881. uploadFile(val.tempImagePath, imageType, IFCODE.etcCarOcrCard).then((data) => {
  882. // uploadFile(val.tempImagePath, state.choiceIndex, ocrAllQuery).then((data) => {
  883. console.log('输出内容=====================', state.choiceIndex)
  884. if (state.choiceIndex === "3") {
  885. if (data.plate_a.length > 8) {
  886. state.form.vehicleIdNum = data.plate_a.substring(0, 8);
  887. } else {
  888. state.form.vehicleIdNum = data.plate_a;
  889. }
  890. state.form.vehPosImgUrl = data.imageUrl;
  891. } else {
  892. state.form.vehNegImgUrl = data.imageUrl;
  893. state.form.vehicleIdNumB = data.plate_a;
  894. console.log('=====================', state.form.vehNegImgUrl, state)
  895. }
  896. state.isTakePhotoModeShow = false
  897. })
  898. console.log("图片地址val", val.tempImagePath)
  899. }
  900. const takePhotoMode = (index) => {
  901. console.log("index", index)
  902. state.isTakePhotoModeShow = true
  903. state.choiceIndex = index
  904. }
  905. const cancle = () => {
  906. state.isTakePhotoModeShow = false
  907. }
  908. const camera = () => {
  909. state.phoneType = 0
  910. }
  911. // 查询重新激活记录
  912. const activationRecordQuery = () => {
  913. const options = {
  914. type: 2,
  915. data: {
  916. cardId: orderInfos.cardId,
  917. obuId: orderInfos.obuId,
  918. },
  919. method: "POST",
  920. showLoading: true,
  921. };
  922. return new Promise(async (resolve, reject) => {
  923. const res = await request(IFCODE.activationRecordApi, options);
  924. const data = stringToJson(res.bizContent);
  925. resolve(data);
  926. }).catch((error) => {
  927. reject(error);
  928. });
  929. }
  930. // 提交车辆信息
  931. const submitVehicleQuery = () => {
  932. const options = {
  933. type: 2,
  934. data: {
  935. cardId: orderInfos.cardId,
  936. obuId: orderInfos.obuId,
  937. vehPosImgUrl: state.form.vehPosImgUrl,
  938. vehNegImgUrl: state.form.vehNegImgUrl,
  939. vehiclePlate: orderInfos.vehiclePlate
  940. },
  941. method: "POST",
  942. };
  943. console.log("提交车辆信息成功", options)
  944. request(IFCODE.submitVehicleApi, options).then(() => {
  945. console.log("提交车辆信息成功")
  946. });
  947. }
  948. const goActivationRecord = () => {
  949. uni.navigateTo({
  950. url: `/subpackage/after-sale/activation-once-again/activation-once-again-record?obuId=${orderInfos.obuId}&&cardId=${orderInfos.cardId}`
  951. })
  952. }
  953. // #endif
  954. </script>
  955. <style>
  956. page {
  957. width: 100%;
  958. height: 100%;
  959. background-color: #fff;
  960. }
  961. </style>
  962. <style lang="scss" scoped>
  963. .mask {
  964. background: rgba(0, 0, 0, .35);
  965. position: fixed;
  966. left: 0;
  967. top: 0;
  968. bottom: 0;
  969. right: 0;
  970. }
  971. .main {
  972. width: 560rpx;
  973. padding: 25rpx 20rpx 55rpx;
  974. text-align: center;
  975. background: #fff;
  976. position: absolute;
  977. left: 50%;
  978. top: 50%;
  979. transform: translate(-50%, -50%);
  980. border-radius: 20rpx;
  981. .top {
  982. text-align: right;
  983. .icon-close {
  984. width: 48rpx;
  985. height: 48rpx;
  986. }
  987. }
  988. .icon-success {
  989. width: 500rpx;
  990. height: 320rpx;
  991. margin-top: 22rpx;
  992. }
  993. .title {
  994. color: #333333;
  995. font-size: 40rpx;
  996. font-weight: 600;
  997. text-align: center;
  998. margin-top: 55rpx;
  999. }
  1000. }
  1001. .selectCar-box {
  1002. // width: 100%;
  1003. // height: 100%;
  1004. padding: 30rpx;
  1005. .title {
  1006. font-size: 30rpx;
  1007. font-family: Microsoft YaHei UI;
  1008. font-weight: 400;
  1009. color: #333333;
  1010. margin-bottom: 30rpx;
  1011. }
  1012. .details {
  1013. .title {
  1014. font-size: 30rpx;
  1015. font-family: Microsoft YaHei UI;
  1016. font-weight: 400;
  1017. color: #333333;
  1018. margin-bottom: 30rpx;
  1019. }
  1020. .details-item {
  1021. display: flex;
  1022. font-size: 26rpx;
  1023. font-family: Noto Sans S Chinese;
  1024. font-weight: 400;
  1025. color: #999999;
  1026. margin-bottom: 30rpx;
  1027. text {
  1028. font-size: 26rpx;
  1029. font-family: Noto Sans S Chinese;
  1030. font-weight: 400;
  1031. color: #333333;
  1032. }
  1033. }
  1034. }
  1035. .card {
  1036. height: 150rpx;
  1037. background: #ffffff;
  1038. box-shadow: 0rpx 4rpx 13rpx 3rpx rgba(223, 223, 223, 0.8);
  1039. border-radius: 20rpx;
  1040. padding: 30rpx;
  1041. display: flex;
  1042. justify-content: space-between;
  1043. align-items: center;
  1044. margin-bottom: 60rpx;
  1045. .card-left {
  1046. display: flex;
  1047. align-items: center;
  1048. image {
  1049. width: 100rpx;
  1050. height: 90rpx;
  1051. }
  1052. .card-center {
  1053. margin-left: 30rpx;
  1054. .card-center-head {
  1055. font-size: 32rpx;
  1056. font-family: Noto Sans S Chinese;
  1057. font-weight: 400;
  1058. color: #333333;
  1059. }
  1060. .tips {
  1061. font-size: 26rpx;
  1062. font-family: Noto Sans S Chinese;
  1063. font-weight: 400;
  1064. color: #666666;
  1065. .tips-card {
  1066. width: 70rpx;
  1067. height: 40rpx;
  1068. background: #d3f2ef;
  1069. border-radius: 6rpx;
  1070. font-size: 20rpx;
  1071. font-family: Noto Sans S Chinese;
  1072. font-weight: 400;
  1073. color: #0a8f8a;
  1074. padding: 5rpx 10rpx;
  1075. margin-left: 20rpx;
  1076. }
  1077. }
  1078. }
  1079. }
  1080. .choose-item {
  1081. margin-right: 20rpx;
  1082. border-radius: 50%;
  1083. font-size: 25rpx;
  1084. .active {
  1085. width: 38rpx;
  1086. height: 38rpx;
  1087. background: #00b38b;
  1088. border-radius: 50%;
  1089. }
  1090. }
  1091. }
  1092. .remark {
  1093. font-size: 26rpx;
  1094. font-family: Microsoft YaHei UI;
  1095. font-weight: 400;
  1096. color: #666666;
  1097. text-indent: 30rpx;
  1098. margin-bottom: 30rpx;
  1099. }
  1100. .submit {
  1101. margin-top: 100rpx;
  1102. margin-bottom: 30rpx;
  1103. width: 670rpx;
  1104. height: 80rpx;
  1105. background: linear-gradient(-90deg, #43a1e0 0%, #13e7c1 100%);
  1106. border-radius: 40rpx;
  1107. font-size: 32rpx;
  1108. font-family: Noto Sans S Chinese;
  1109. font-weight: 400;
  1110. color: #ffffff;
  1111. line-height: 80rpx;
  1112. }
  1113. }
  1114. .picture-wrapper {
  1115. margin-top: 40rpx;
  1116. .bg {
  1117. background: #ffffff;
  1118. box-shadow: 0rpx 4rpx 13rpx 3rpx rgba(223, 223, 223, 0.8);
  1119. border-radius: 20rpx;
  1120. padding: 40rpx;
  1121. display: flex;
  1122. // align-items: center;
  1123. justify-content: space-between;
  1124. .name {
  1125. font-size: 34rpx;
  1126. font-family: Microsoft YaHei;
  1127. font-weight: 400;
  1128. color: #000000;
  1129. line-height: 34rpx;
  1130. }
  1131. .value {
  1132. margin-top: 20rpx;
  1133. font-size: 24rpx;
  1134. font-family: Microsoft YaHei;
  1135. font-weight: 400;
  1136. color: #999999;
  1137. line-height: 24rpx;
  1138. }
  1139. .tip {
  1140. margin-top: 20rpx;
  1141. text-align: center;
  1142. width: 110rpx;
  1143. height: 40rpx;
  1144. background: rgba(33, 190, 177, 0.2);
  1145. border-radius: 6rpx;
  1146. .tip-value {
  1147. font-size: 20rpx;
  1148. font-family: Microsoft YaHei;
  1149. font-weight: 400;
  1150. color: #0a8f8a;
  1151. line-height: 40rpx;
  1152. opacity: 1;
  1153. }
  1154. }
  1155. }
  1156. .icon {
  1157. width: 294rpx;
  1158. height: 188rpx;
  1159. }
  1160. }
  1161. .choice-takePhoto {
  1162. position: absolute;
  1163. bottom: 0;
  1164. background-color: white;
  1165. width: 100%;
  1166. border-radius: 20rpx 20rpx 0 0;
  1167. }
  1168. .choice-takePhoto>view:first-child {
  1169. text-align: center;
  1170. height: 80rpx;
  1171. line-height: 80rpx;
  1172. border-bottom: 1rpx solid rgba(127, 127, 127, 0.3);
  1173. background-color: white;
  1174. }
  1175. .choice-takePhoto>view:last-child {
  1176. text-align: center;
  1177. height: 80rpx;
  1178. line-height: 80rpx;
  1179. border-top: 6rpx solid rgba(127, 127, 127, 0.1);
  1180. background-color: white;
  1181. }
  1182. .choice-takePhoto>view {
  1183. text-align: center;
  1184. height: 80rpx;
  1185. line-height: 80rpx;
  1186. background-color: white;
  1187. }
  1188. .choice-takePhoto-wrap {
  1189. width: 100%;
  1190. height: 100vh;
  1191. background-color: rgba(127, 127, 127, 0.2);
  1192. position: fixed;
  1193. left: 0;
  1194. top: 0;
  1195. z-index: 11111;
  1196. }
  1197. .record {
  1198. height: 40rpx;
  1199. background: #d3f2ef;
  1200. border-radius: 6rpx;
  1201. font-size: 20rpx;
  1202. font-family: Noto Sans S Chinese;
  1203. font-weight: 400;
  1204. color: #0a8f8a;
  1205. padding: 5rpx 10rpx;
  1206. margin-left: 60rpx;
  1207. }
  1208. </style>