您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

activation-once-again.vue 32KB

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