You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

activation-once-again.vue 35KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285
  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(option.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. },
  585. activationNum: "",//激活次数
  586. })
  587. //订单
  588. const orderInfos = reactive({
  589. orderId: "",
  590. ownerName: "",
  591. ownerIdtype: "",
  592. ownerIdnum: "",
  593. vehiclePlate: "",
  594. vehiclePlateColorStr: "",
  595. vehiclePlateColor: "",
  596. vehicleType: "",
  597. cardId: "",
  598. cardStatus: "",
  599. obuId: "",
  600. obuStatus: "",
  601. outlineL: 0,
  602. outlineW: 0,
  603. outlineH: 0,
  604. type: 0,
  605. axleCount: 0,
  606. approvedCount: 0,
  607. vehicleVin: "",
  608. vehicleEngineNum: "",
  609. });
  610. //OBU
  611. const obu = reactive({
  612. obuId: "",
  613. startTime: "",
  614. endTime: "",
  615. version: "",
  616. approvedCount: "",
  617. axleCount: "",
  618. axleDistance: "",
  619. engineNum: "",
  620. type: "",
  621. userType: "",
  622. contractNo: "",
  623. vehiclePlate: "",
  624. vehiclePlateColor: "",
  625. vin: "",
  626. wheelCount: "",
  627. isJH: ""
  628. });
  629. onLoad((option) => {
  630. console.log('======重新激活开始======', option);
  631. //请求订单详情
  632. queryOrderDetail(option.id);
  633. });
  634. onShow((option) => {
  635. uni.$on('bluetoothLink', res => {
  636. console.log(res);
  637. if (res.status) {
  638. // getCardRenewal()
  639. getObuId()
  640. }
  641. //移除监听
  642. console.log('======移除监听======', res)
  643. // uni.$off('bluetoothLink')
  644. })
  645. })
  646. const cancel = () => {
  647. state.showPopup = false;
  648. uni.navigateBack({
  649. delta: 2
  650. })
  651. };
  652. const toPage = () => {
  653. if (!state.form.vehPosImgUrl) {
  654. msg("请上传行驶证主页")
  655. return;
  656. }
  657. if (!state.form.vehNegImgUrl) {
  658. msg("请上传行驶证副页")
  659. return;
  660. }
  661. console.log("state.form.vehicleIdNum", state.form.vehicleIdNum, orderInfos.vehiclePlate)
  662. if (state.form.vehicleIdNum == orderInfos.vehiclePlate) {
  663. activationRecordQuery().then((val) => {
  664. console.log("激活次数", val)
  665. if (val.limit) {
  666. navTo("/pages/bluetooth/bluetooth?routeType=5");
  667. } else {
  668. msg("一年内到达激活次数上限5次")
  669. }
  670. });
  671. } else {
  672. msg("请上传正确行驶证")
  673. }
  674. };
  675. //获取订单详情
  676. const queryOrderDetail = (id : string) => {
  677. const options = {
  678. type: 2,
  679. data: {
  680. id: id,
  681. },
  682. method: "POST",
  683. showLoading: true,
  684. };
  685. request(IFCODE.orderDetail, options).then((res) => {
  686. let orderInfo = JSON.parse(res.bizContent);
  687. console.log(orderInfo);
  688. orderInfos.orderId = orderInfo.orderId;
  689. orderInfos.ownerName = orderInfo.ownerName;
  690. orderInfos.ownerIdtype = orderInfo.ownerIdtype;
  691. orderInfos.ownerIdnum = orderInfo.ownerIdnum;
  692. orderInfos.vehiclePlate = orderInfo.vehiclePlate;
  693. orderInfos.vehiclePlateColorStr = orderInfo.vehiclePlateColorStr;
  694. orderInfos.vehiclePlateColor = orderInfo.vehiclePlateColor;
  695. orderInfos.vehicleType = orderInfo.vehicleType;
  696. orderInfos.cardId = orderInfo.cardId;
  697. orderInfos.cardStatus = orderInfo.cardStatus;
  698. orderInfos.obuId = orderInfo.obuId;
  699. orderInfos.obuStatus = orderInfo.obuStatus;
  700. let arr = orderInfo.vehicleDimensions.split("X");
  701. orderInfos.outlineL = parseInt(arr[0]); //外廓 长
  702. orderInfos.outlineW = parseInt(arr[1]); //外廓 宽
  703. orderInfos.outlineH = parseInt(arr[2].substring(0, arr[2].length - 2)); //外廓 高
  704. orderInfos.type = orderInfo.type;
  705. orderInfos.axleCount = orderInfo.vehicleAxleCount;
  706. orderInfos.approvedCount = orderInfo.vehicleApprovedCount;
  707. orderInfos.vehicleVin = orderInfo.vehicleVin;
  708. orderInfos.vehicleEngineNum = orderInfo.vehicleEngineNum;
  709. activationRecordQuery().then((val) => {
  710. console.log("jihuo", val)
  711. state.activationNum = val.num
  712. });
  713. });
  714. };
  715. /**
  716. * 获取OBU号 读OBU
  717. */
  718. const getObuId = () => {
  719. console.log('======获取OBU号======')
  720. let cmdArray = [cmd.HOME_DIRECTORY, cmd.OBU_SYSTEM_FILE, cmd.RANDOM_NUMBER];
  721. tools.showLoadingAlert("正在执行指令");
  722. bluetoothUtil.transCmd(cmdArray, "20", function (res) {
  723. tools.hideLoadingAlert();
  724. var status = res[1].substring(res[1].length - 4, res[1].length);
  725. console.log('获取OBU号执行结果' + status)
  726. //第一次获取随机数
  727. if (status == "9000") {
  728. obu.obuId = res[1].substring(20, 36);
  729. obu.vin = res[1].substring(18, 20);
  730. obu.version = res[1].substring(18, 19) >= 4 ? "4x" : "2x";
  731. getInstallApply()
  732. // cmdRandNum = res[2].substring(0, res[2].length - 4);
  733. }
  734. });
  735. };
  736. /**
  737. * BDS-安装申请 请求
  738. */
  739. const getInstallApply = () => {
  740. console.log('======安装申请======')
  741. tools.showLoadingAlert("加载中");
  742. let options = {
  743. type: 2, //type: 2,JSON格式提交数据(默认表单形式提交)
  744. data: {
  745. obuId: obu.obuId,
  746. vehicleId: orderInfos.vehiclePlate + "_" + orderInfos.vehiclePlateColor,
  747. orderId: orderInfos.orderId,
  748. agentId: agentId,
  749. channelId: channelId,
  750. channelType: "1",
  751. staffId: "opId",
  752. terminalId: "999999999",
  753. }, //请求参数
  754. method: "POST", //提交方式(默认POST)
  755. showLoading: true, //是否显示加载中(默认显示)
  756. };
  757. //调用方式
  758. request(IFCODE.installApply, options)
  759. .then(() => {
  760. tools.hideLoadingAlert();
  761. //再次获取随机数
  762. let cmdArr = [cmd.HOME_DIRECTORY, cmd.RANDOM_NUMBER];
  763. bluetoothUtil.transCmd(cmdArr, '20', function (res) {
  764. var str = res[1].substring(res[1].length - 4, res[1].length);
  765. if (str == "9000") {
  766. let cmdRandNum = res[1].substring(0, res[1].length - 4);
  767. getObuActivation(cmdRandNum);
  768. } else {
  769. tools.alertF("RANDOM_NUMBER指令长度不符" + res[1]);
  770. }
  771. })
  772. })
  773. };
  774. /**
  775. * VFJ-OBU在线激活 请求
  776. */
  777. const getObuActivation = (cmdRandNum : string) => {
  778. console.log('======VFJ-OBU在线激活======')
  779. tools.showLoadingAlert("加载中");
  780. let options = {
  781. type: 2, //type: 2,JSON格式提交数据(默认表单形式提交)
  782. data: {
  783. random: cmdRandNum,
  784. obuSerailNo: obu.obuId,
  785. orderId: orderInfos.orderId,
  786. }, //请求参数
  787. method: "POST", //提交方式(默认POST)
  788. showLoading: true, //是否显示加载中(默认显示)
  789. };
  790. //调用方式
  791. request(IFCODE.obuActivation, options)
  792. .then((res) => {
  793. tools.hideLoadingAlert();
  794. console.log("在线激活 请求");
  795. console.log(stringToJson(res.bizContent));
  796. const datas = stringToJson(res.bizContent);
  797. tools.showLoadingAlert("执行指令");
  798. bluetoothUtil.transCmd([datas.data.APDU], "20", function (res) {
  799. tools.hideLoadingAlert();
  800. console.log(res);
  801. if (res[0] == "9000") {
  802. console.log("在线激活执行指令88888 请求", res);
  803. getObuInstall(0, ""); //status 0 - 安装成功 || 1 - 安装失败
  804. }
  805. });
  806. })
  807. .catch((err) => {
  808. console.log(err);
  809. });
  810. };
  811. /**
  812. * BDS-安装确认 请求
  813. */
  814. const getObuInstall = (status : number, reason : string) => {
  815. console.log('======OBU安装确认======')
  816. tools.showLoadingAlert("加载中");
  817. let options = {
  818. type: 2, //type: 2,JSON格式提交数据(默认表单形式提交)
  819. data: {
  820. installStatus: status,
  821. failReason: reason,
  822. installType: "1",
  823. installChannelId: channelId,
  824. obuId: obu.obuId,
  825. orderId: orderInfos.orderId
  826. }, //请求参数
  827. method: "POST", //提交方式(默认POST)
  828. showLoading: true, //是否显示加载中(默认显示)
  829. };
  830. //调用方式
  831. request(IFCODE.obuInstall, options)
  832. .then(() => {
  833. tools.hideLoadingAlert();
  834. state.showPopup = true;
  835. submitVehicleQuery()
  836. });
  837. };
  838. const xiangce = (val) => {
  839. console.log("val", val)
  840. if (state.choiceIndex == 3) {
  841. var imageType = 1;
  842. } else {
  843. var imageType = 2;
  844. }
  845. state.changeColor = true;
  846. uni.chooseImage({
  847. count: 1, //只能选取一张照片
  848. sizeType: ["original", "compressed"], //可以指定是原图还是压缩图,默认二者都有
  849. sourceType: ["album"], //从相册选择
  850. success: function (res) {
  851. console.log("tempFilePaths[0].startsWith('file://')", res.tempFilePaths[0], res.tempFilePaths[0].startsWith('file://'))
  852. if (state.choiceIndex == 3 || state.choiceIndex == 4) {
  853. state.showImg = false
  854. state.images = res.tempFilePaths[0]
  855. state.phoneType = state.choiceIndex
  856. state.isTakePhotoModeShow = false
  857. return
  858. }
  859. },
  860. })
  861. }
  862. const takePhoto = (val) => {
  863. console.log("拍照", val)
  864. state.phoneType = val;
  865. state.showImg = true;
  866. }
  867. const confirmReturn = (val) => {
  868. if (state.choiceIndex == 3) {
  869. var imageType = 1;
  870. } else {
  871. var imageType = 2;
  872. }
  873. state.changeColor = true;
  874. state.phoneType = 0
  875. state.isTakePhotoModeShow = false
  876. uploadFile(val.tempImagePath, imageType, IFCODE.etcCarOcrCard).then((data) => {
  877. // uploadFile(val.tempImagePath, state.choiceIndex, ocrAllQuery).then((data) => {
  878. console.log('输出内容=====================', state.choiceIndex)
  879. if (state.choiceIndex === "3") {
  880. if (data.plate_a.length > 8) {
  881. state.form.vehicleIdNum = data.plate_a.substring(0, 8);
  882. } else {
  883. state.form.vehicleIdNum = data.plate_a;
  884. }
  885. state.form.vehPosImgUrl = data.imageUrl;
  886. } else {
  887. state.form.vehNegImgUrl = data.imageUrl;
  888. console.log('=====================', state.form.vehNegImgUrl, state)
  889. }
  890. state.isTakePhotoModeShow = false
  891. })
  892. console.log("图片地址val", val.tempImagePath)
  893. }
  894. const takePhotoMode = (index) => {
  895. console.log("index", index)
  896. state.isTakePhotoModeShow = true
  897. state.choiceIndex = index
  898. }
  899. const cancle = () => {
  900. state.isTakePhotoModeShow = false
  901. }
  902. const camera = () => {
  903. state.phoneType = 0
  904. }
  905. // 查询重新激活记录
  906. const activationRecordQuery = () => {
  907. const options = {
  908. type: 2,
  909. data: {
  910. cardId: orderInfos.cardId,
  911. obuId: orderInfos.obuId,
  912. },
  913. method: "POST",
  914. showLoading: true,
  915. };
  916. return new Promise(async (resolve, reject) => {
  917. const res = await request(IFCODE.activationRecordApi, options);
  918. const data = stringToJson(res.bizContent);
  919. resolve(data);
  920. }).catch((error) => {
  921. reject(error);
  922. });
  923. }
  924. // 提交车辆信息
  925. const submitVehicleQuery = () => {
  926. const options = {
  927. type: 2,
  928. data: {
  929. cardId: orderInfos.cardId,
  930. obuId: orderInfos.obuId,
  931. vehPosImgUrl: state.form.vehPosImgUrl,
  932. vehNegImgUrl: state.form.vehNegImgUrl,
  933. vehiclePlate: orderInfos.vehiclePlate
  934. },
  935. method: "POST",
  936. };
  937. console.log("提交车辆信息成功", options)
  938. request(IFCODE.submitVehicleApi, options).then(() => {
  939. console.log("提交车辆信息成功")
  940. });
  941. }
  942. const goActivationRecord = () => {
  943. uni.navigateTo({
  944. url: `/subpackage/after-sale/activation-once-again/activation-once-again-record?obuId=${orderInfos.obuId}&&cardId=${orderInfos.cardId}`
  945. })
  946. }
  947. // #endif
  948. </script>
  949. <style>
  950. page {
  951. width: 100%;
  952. height: 100%;
  953. background-color: #fff;
  954. }
  955. </style>
  956. <style lang="scss" scoped>
  957. .mask {
  958. background: rgba(0, 0, 0, .35);
  959. position: fixed;
  960. left: 0;
  961. top: 0;
  962. bottom: 0;
  963. right: 0;
  964. }
  965. .main {
  966. width: 560rpx;
  967. padding: 25rpx 20rpx 55rpx;
  968. text-align: center;
  969. background: #fff;
  970. position: absolute;
  971. left: 50%;
  972. top: 50%;
  973. transform: translate(-50%, -50%);
  974. border-radius: 20rpx;
  975. .top {
  976. text-align: right;
  977. .icon-close {
  978. width: 48rpx;
  979. height: 48rpx;
  980. }
  981. }
  982. .icon-success {
  983. width: 500rpx;
  984. height: 320rpx;
  985. margin-top: 22rpx;
  986. }
  987. .title {
  988. color: #333333;
  989. font-size: 40rpx;
  990. font-weight: 600;
  991. text-align: center;
  992. margin-top: 55rpx;
  993. }
  994. }
  995. .selectCar-box {
  996. // width: 100%;
  997. // height: 100%;
  998. padding: 30rpx;
  999. .title {
  1000. font-size: 30rpx;
  1001. font-family: Microsoft YaHei UI;
  1002. font-weight: 400;
  1003. color: #333333;
  1004. margin-bottom: 30rpx;
  1005. }
  1006. .details {
  1007. .title {
  1008. font-size: 30rpx;
  1009. font-family: Microsoft YaHei UI;
  1010. font-weight: 400;
  1011. color: #333333;
  1012. margin-bottom: 30rpx;
  1013. }
  1014. .details-item {
  1015. display: flex;
  1016. font-size: 26rpx;
  1017. font-family: Noto Sans S Chinese;
  1018. font-weight: 400;
  1019. color: #999999;
  1020. margin-bottom: 30rpx;
  1021. text {
  1022. font-size: 26rpx;
  1023. font-family: Noto Sans S Chinese;
  1024. font-weight: 400;
  1025. color: #333333;
  1026. }
  1027. }
  1028. }
  1029. .card {
  1030. height: 150rpx;
  1031. background: #ffffff;
  1032. box-shadow: 0rpx 4rpx 13rpx 3rpx rgba(223, 223, 223, 0.8);
  1033. border-radius: 20rpx;
  1034. padding: 30rpx;
  1035. display: flex;
  1036. justify-content: space-between;
  1037. align-items: center;
  1038. margin-bottom: 60rpx;
  1039. .card-left {
  1040. display: flex;
  1041. align-items: center;
  1042. image {
  1043. width: 100rpx;
  1044. height: 90rpx;
  1045. }
  1046. .card-center {
  1047. margin-left: 30rpx;
  1048. .card-center-head {
  1049. font-size: 32rpx;
  1050. font-family: Noto Sans S Chinese;
  1051. font-weight: 400;
  1052. color: #333333;
  1053. }
  1054. .tips {
  1055. font-size: 26rpx;
  1056. font-family: Noto Sans S Chinese;
  1057. font-weight: 400;
  1058. color: #666666;
  1059. .tips-card {
  1060. width: 70rpx;
  1061. height: 40rpx;
  1062. background: #d3f2ef;
  1063. border-radius: 6rpx;
  1064. font-size: 20rpx;
  1065. font-family: Noto Sans S Chinese;
  1066. font-weight: 400;
  1067. color: #0a8f8a;
  1068. padding: 5rpx 10rpx;
  1069. margin-left: 20rpx;
  1070. }
  1071. }
  1072. }
  1073. }
  1074. .choose-item {
  1075. margin-right: 20rpx;
  1076. border-radius: 50%;
  1077. font-size: 25rpx;
  1078. .active {
  1079. width: 38rpx;
  1080. height: 38rpx;
  1081. background: #00b38b;
  1082. border-radius: 50%;
  1083. }
  1084. }
  1085. }
  1086. .remark {
  1087. font-size: 26rpx;
  1088. font-family: Microsoft YaHei UI;
  1089. font-weight: 400;
  1090. color: #666666;
  1091. text-indent: 30rpx;
  1092. margin-bottom: 30rpx;
  1093. }
  1094. .submit {
  1095. margin-top: 100rpx;
  1096. margin-bottom: 30rpx;
  1097. width: 670rpx;
  1098. height: 80rpx;
  1099. background: linear-gradient(-90deg, #43a1e0 0%, #13e7c1 100%);
  1100. border-radius: 40rpx;
  1101. font-size: 32rpx;
  1102. font-family: Noto Sans S Chinese;
  1103. font-weight: 400;
  1104. color: #ffffff;
  1105. line-height: 80rpx;
  1106. }
  1107. }
  1108. .picture-wrapper {
  1109. margin-top: 40rpx;
  1110. .bg {
  1111. background: #ffffff;
  1112. box-shadow: 0rpx 4rpx 13rpx 3rpx rgba(223, 223, 223, 0.8);
  1113. border-radius: 20rpx;
  1114. padding: 40rpx;
  1115. display: flex;
  1116. // align-items: center;
  1117. justify-content: space-between;
  1118. .name {
  1119. font-size: 34rpx;
  1120. font-family: Microsoft YaHei;
  1121. font-weight: 400;
  1122. color: #000000;
  1123. line-height: 34rpx;
  1124. }
  1125. .value {
  1126. margin-top: 20rpx;
  1127. font-size: 24rpx;
  1128. font-family: Microsoft YaHei;
  1129. font-weight: 400;
  1130. color: #999999;
  1131. line-height: 24rpx;
  1132. }
  1133. .tip {
  1134. margin-top: 20rpx;
  1135. text-align: center;
  1136. width: 110rpx;
  1137. height: 40rpx;
  1138. background: rgba(33, 190, 177, 0.2);
  1139. border-radius: 6rpx;
  1140. .tip-value {
  1141. font-size: 20rpx;
  1142. font-family: Microsoft YaHei;
  1143. font-weight: 400;
  1144. color: #0a8f8a;
  1145. line-height: 40rpx;
  1146. opacity: 1;
  1147. }
  1148. }
  1149. }
  1150. .icon {
  1151. width: 294rpx;
  1152. height: 188rpx;
  1153. }
  1154. }
  1155. .choice-takePhoto {
  1156. position: absolute;
  1157. bottom: 0;
  1158. background-color: white;
  1159. width: 100%;
  1160. border-radius: 20rpx 20rpx 0 0;
  1161. }
  1162. .choice-takePhoto>view:first-child {
  1163. text-align: center;
  1164. height: 80rpx;
  1165. line-height: 80rpx;
  1166. border-bottom: 1rpx solid rgba(127, 127, 127, 0.3);
  1167. background-color: white;
  1168. }
  1169. .choice-takePhoto>view:last-child {
  1170. text-align: center;
  1171. height: 80rpx;
  1172. line-height: 80rpx;
  1173. border-top: 6rpx solid rgba(127, 127, 127, 0.1);
  1174. background-color: white;
  1175. }
  1176. .choice-takePhoto>view {
  1177. text-align: center;
  1178. height: 80rpx;
  1179. line-height: 80rpx;
  1180. background-color: white;
  1181. }
  1182. .choice-takePhoto-wrap {
  1183. width: 100%;
  1184. height: 100vh;
  1185. background-color: rgba(127, 127, 127, 0.2);
  1186. position: fixed;
  1187. left: 0;
  1188. top: 0;
  1189. z-index: 11111;
  1190. }
  1191. .record {
  1192. height: 40rpx;
  1193. background: #d3f2ef;
  1194. border-radius: 6rpx;
  1195. font-size: 20rpx;
  1196. font-family: Noto Sans S Chinese;
  1197. font-weight: 400;
  1198. color: #0a8f8a;
  1199. padding: 5rpx 10rpx;
  1200. margin-left: 60rpx;
  1201. }
  1202. </style>