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 32KB

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