Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914
  1. <!--设备选择 -->
  2. <template>
  3. <view class="devices">
  4. <view class="device" v-for="(item, index) in deviceList" :key="index" @click="connectDevice(item)">
  5. <image :src="`${$imgUrl}bluetooth/card1s.png`" class="head" mode="aspectFill"></image>
  6. <view class="center">
  7. <view class="name">{{ item._name }}</view>
  8. <view class="desc">编号 {{ item.name }}</view>
  9. </view>
  10. <image :src=" item.selected ? selectedUrl : unSelectedUrl" class="icon" mode="aspectFill"></image>
  11. </view>
  12. <view class="hint">
  13. <view class="txt">
  14. <image :src="`${$imgUrl}bluetooth/waring.png`" mode="aspectFill" class="imgs"></image>
  15. <view>温馨提示:</view>
  16. </view>
  17. <view class="grey-txt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  18. 指令执行过程中,请勿关闭蓝牙,勿将手机远离电子标签,以免导致写卡、写签失败。</view>
  19. </view>
  20. <!-- <view class="btn">
  21. <submit-button title="点击重新搜索蓝牙" @submit="load"></submit-button>
  22. </view> -->
  23. <view class="action">
  24. <button type="default" class="ui-btn" @click="load">
  25. 点击重新搜索蓝牙
  26. </button>
  27. </view>
  28. </view>
  29. </template>
  30. <script setup lang="ts">
  31. import { ref, reactive } from "vue";
  32. import { onLoad, onReady } from "@dcloudio/uni-app";
  33. import { fileURL } from "@/datas/fileURL.js";
  34. const cmd = require("../../static/etcUtil/cmdConfig.js");
  35. const imgURL = `${fileURL}image/`;
  36. const selectedUrl = imgURL + "bluetooth/select-icons.png";
  37. const unSelectedUrl = imgURL + "bluetooth/unselected_xin.png";
  38. const jyApi = require("../../static/etc/JYAPI/GenvictBleUtil.js");
  39. const jlQZApi = require("../../static/etc/JLQZAPI/JLObuSDK.js");
  40. const atApi = require("../../static/etc/ATAPI/ArtcBleUtil.js");
  41. const wqApi = require("../../static/etc/WQAPI/WCDObuSdk.js");
  42. const cgApi = require("../../static/etc/CGAPI/cguBle.js");
  43. const tools = require("../../static/etcUtil/tools.js");
  44. const datas = require("../../static/etcUtil/datas.js");
  45. const bluetoothUtil = require("../../static/etcUtil/index.js");
  46. // 微信小程序
  47. let jlApi = require("../../static/etc/JLAPI/JLObuSDK.js"); //聚力SDK
  48. let wjApi = require("../../static/etc/WJAPI/wjBleAPI");
  49. let tdApi = require("../../static/etc/TDAPI/TDRObuSDK.js");
  50. let zzApi = require("../../static/etc/WJAPI/wjBleAPI.js");
  51. let jtApi = require("../../static/etc/JTAPI/BleUtil.js");
  52. let kcApi = require("../../static/etc/kcBle/kcBleAPI.js");
  53. // let jyApiEtc = require("../../static/etc/JYAPI-ETC/jy-bluetooth-obu-wechatmp.js"); //前装-金溢
  54. // 9901
  55. let wjApi9901 = require("../../static/etc/WJSDK9901/wjTools.js");
  56. let ArtcBleUtilApi = require("../../static/etc/ArtcBleAPI/ArtcGuiZhouAPI.js");//艾特斯 ETC- 5201
  57. // #ifdef MP-ALIPAY
  58. // 这部分代码将仅在支付宝小程序平台下执行
  59. jlApi = require("../../static/etc/JLObuSDK/JLObuSDK.js");
  60. wjApi = require("../../static/etc/wjBle/WJBleAPI");
  61. zzApi = require("../../static/etc/wjBle/WJBleAPI");
  62. tdApi = require("../../static/etc/TDRAPI/TDRObuSDK.js");
  63. jtApi = require("../../static/etc/JTAPIS/BleUtil.js");
  64. // 执行支付宝小程序的特定功能
  65. // #endif
  66. const state = reactive({
  67. fee: "",
  68. id: "",
  69. cardId: "",
  70. showPopup: false, //显示激活成功提示
  71. curDeviceId: "", //当前选中的设备ID
  72. deviceList: [
  73. //设备列表
  74. {
  75. id: "1",
  76. image: imgURL + "bluetooth/card1.png`",
  77. _name: "聚力",
  78. name: "235564444558855",
  79. },
  80. ],
  81. connectSuccess: 1,
  82. transfer: 0,
  83. rechargeMoney: "",//消费明细圈存传过来的金额
  84. orderNum: 0,//消费明细 传orderNum说明去支付
  85. payMoney: 0,//0 修复 1 支付
  86. accountId: "",//对公账户名称
  87. difference: "",//区分routeType5 1二次激活 2余额补领
  88. vehicleId: "",
  89. refundBalance: "",
  90. vehPosImgUrl: "",
  91. vehNegImgUrl: "",
  92. isAfter: '',
  93. backIndex:"",//1返回首页 ""返回订单列表
  94. cardNo:""
  95. });
  96. const deviceList = ref([]);
  97. const connectPrefixName = ref(null);
  98. const routeType = ref(null); //来源 1激活 2圈存 3信息重写 4信息读取 10车辆信息变更预检
  99. interface DeviceType {
  100. name : string; //设备名称
  101. deviceId : string; //uuid
  102. prefixName : string; //前缀名称
  103. selected : boolean; //判断点击次数
  104. _name : string; //中文名称
  105. }
  106. let device : DeviceType = reactive({
  107. name: "", //设备名称
  108. deviceId: "", //uuid
  109. prefixName: "", //前缀名称
  110. selected: false, //判断点击次数
  111. _name: "", //中文名称
  112. });
  113. onReady(() => {
  114. load();
  115. });
  116. onLoad((option) => {
  117. routeType.value = option.routeType ? option.routeType : "1";
  118. state.cardId = option.cardId;
  119. if (option.fee) {
  120. state.fee = option.fee;
  121. }
  122. if (option.id) {
  123. state.id = option.id;
  124. }
  125. if (option.transfer) {
  126. state.transfer = option.transfer;
  127. }
  128. if (option.rechargeMoney) {
  129. state.rechargeMoney = option.rechargeMoney
  130. }
  131. if (option.orderNum) {
  132. state.orderNum = option.orderNum
  133. }
  134. if (option.payMoney) {
  135. state.payMoney = option.payMoney
  136. }
  137. if (option.accountId) {
  138. state.accountId = option.accountId
  139. }
  140. if (option.difference) {
  141. state.difference = option.difference;
  142. }
  143. if (option.vehicleId) {
  144. state.vehicleId = option.vehicleId;
  145. }
  146. if (option.refundBalance) {
  147. state.refundBalance = option.refundBalance;
  148. }
  149. if (option.vehPosImgUrl) {
  150. state.vehPosImgUrl = option.vehPosImgUrl;
  151. }
  152. if (option.vehNegImgUrl) {
  153. state.vehNegImgUrl = option.vehNegImgUrl;
  154. }
  155. if (option.isAfter) {
  156. state.isAfter = option.isAfter;
  157. }
  158. if (option.backIndex) {
  159. state.backIndex = option.backIndex;
  160. }
  161. console.log("传过来的参数", option)
  162. });
  163. /*
  164. * 蓝牙初始化
  165. */
  166. const load = () => {
  167. deviceList.value = [];
  168. console.log("****************蓝牙getsetting******************");
  169. uni.getSetting({
  170. success(res) {
  171. console.log("****************成功******************");
  172. console.log("scopebluetooth:" + res.authSetting["scope.bluetooth"]);
  173. console.log("成功结果:" + JSON.stringify(res));
  174. if (res.authSetting["scope.bluetooth"] == undefined) {
  175. //没有授权使用蓝牙功能,提示用户授权使用
  176. // #ifdef MP-WEIXIN
  177. uni.authorize({
  178. scope: "scope.bluetooth",
  179. success() {
  180. openBluetooth();
  181. },
  182. fail(err) {
  183. console.log('蓝牙授权失败', err)
  184. uni.showToast({
  185. title: "蓝牙授权失败",
  186. icon: "error",
  187. duration: 1500,
  188. });
  189. }
  190. });
  191. // #endif
  192. // #ifdef MP-ALIPAY
  193. openBluetooth();
  194. // #endif
  195. } else if (!res.authSetting["scope.bluetooth"]) {
  196. //false
  197. uni.showModal({
  198. title: "是否授权读取蓝牙",
  199. content: "需要获取你的蓝牙,请确认授权,否则无法获取蓝牙",
  200. success: function (mres) {
  201. if (mres.confirm) {
  202. uni.openSetting({
  203. success(authData) {
  204. if (authData.authSetting["scope.bluetooth"] == true) {
  205. tools.showLoadingAlert("扫描蓝牙中");
  206. openBluetooth();
  207. } else {
  208. uni.closeBluetoothAdapter();
  209. uni.showToast({
  210. title: "蓝牙授权失败",
  211. icon: "error",
  212. duration: 1500,
  213. });
  214. }
  215. },
  216. });
  217. } else if (mres.cancel) {
  218. uni.showToast({
  219. title: "蓝牙授权失败",
  220. icon: "error",
  221. duration: 1000,
  222. });
  223. }
  224. },
  225. });
  226. } else {
  227. tools.showLoadingAlert("扫描蓝牙中");
  228. openBluetooth();
  229. }
  230. },
  231. fail(res) {
  232. console.log("****************失败******************");
  233. console.log("失败结果:" + JSON.stringify(res));
  234. },
  235. });
  236. };
  237. /*
  238. * 打开蓝牙
  239. */
  240. const openBluetooth = () => {
  241. tools.hideLoadingAlert();
  242. let foundDevices = []; //扫描到的蓝牙列表
  243. uni.closeBluetoothAdapter(); //先关闭蓝牙
  244. console.log('执行断开蓝牙方法')
  245. //打开蓝牙
  246. uni.openBluetoothAdapter({
  247. success: function (item : any) {
  248. console.log('初始化蓝牙模块', item)
  249. tools.showLoadingAlert("扫描蓝牙中...");
  250. //开始搜索附近的蓝牙设备
  251. uni.startBluetoothDevicesDiscovery({
  252. success: function (res) {
  253. console.log('开始搜寻附近的蓝牙外围设备', res);
  254. //监听搜索到新设备的事件
  255. uni.onBluetoothDeviceFound(function (res) {
  256. console.log('监听寻找到新设备的事件', res, res.devices);
  257. for (let i = 0; i < res.devices.length; i++) {
  258. let name = res.devices[i]["name"];
  259. let prefixName = "";
  260. let deviceId = res.devices[i]["deviceId"];
  261. console.log("res.devices[i]", res.devices[i]["name"]);
  262. if (name != "" && name != undefined && name != "undefined") {
  263. if (name.indexOf("G-WJ") != -1 || name.indexOf("ETC") != -1 || name.indexOf("G-JL") != -1) {
  264. //前装设备
  265. prefixName = "ETC";
  266. } else {
  267. //聚力临时设备
  268. if (name.indexOf("5201121") != -1) {
  269. prefixName = "JL";
  270. } else {
  271. prefixName = name.substring(0, 2);
  272. }
  273. }
  274. prefixName = prefixName.toUpperCase();
  275. console.log("prefixName====", prefixName, name)
  276. if (
  277. prefixName == "WJ" ||
  278. prefixName == "JL" ||
  279. prefixName == "JY" ||
  280. prefixName == "AT" ||
  281. prefixName == "JT" ||
  282. prefixName == "WQ" ||
  283. prefixName == "CG" ||
  284. prefixName == "TD" ||
  285. prefixName == "ZZ" ||
  286. prefixName == "ETC"
  287. ) {
  288. // //隐藏加载框
  289. tools.hideLoadingAlert();
  290. device.name = name;
  291. datas.setData("deviceName", device.name);
  292. device.deviceId = deviceId;
  293. device.prefixName = prefixName;
  294. device.selected = false; //防止重复点击
  295. let _name = "";
  296. switch (prefixName) {
  297. case "ETC":
  298. if (name.split("-")[1] == "KC" || name.split("-")[1].indexOf('C') > 0 || name.split("-")[1].indexOf('K') > 0) {
  299. _name = "前装-科畅";
  300. console.log("前装-科畅")
  301. } else if (name.split("-")[1] == "JL") {
  302. _name = "前装-聚力"; //共用
  303. } else if (name.split("-")[1] == "WJ") {
  304. _name = "前装-万集"; //共用
  305. } else if (name.split("-")[1] == "JY") {
  306. _name = "前装-金溢";
  307. }
  308. break;
  309. case "WJ":
  310. _name = "万集";
  311. break;
  312. case "JL":
  313. _name = "聚利";
  314. break;
  315. case "JY":
  316. _name = "金溢";
  317. break;
  318. case "AT":
  319. _name = "埃特斯";
  320. break;
  321. case "JT":
  322. _name = "建投";
  323. break;
  324. case "WQ":
  325. _name = "握奇";
  326. break;
  327. case "CG":
  328. _name = "成谷";
  329. break;
  330. case "TD":
  331. _name = "天地融";
  332. break;
  333. case "ZZ":
  334. _name = "智载";
  335. break;
  336. default:
  337. _name = "未知";
  338. break;
  339. }
  340. device._name = _name;
  341. if (deviceList.value.length == 0) {
  342. // #ifdef MP-ALIPAY
  343. if (device._name == '聚利' || device._name == '万集' || device._name == '天地融' || device._name == '建投') {
  344. foundDevices.push(device);
  345. }
  346. // #endif
  347. // #ifdef MP-WEIXIN
  348. foundDevices.push(device);
  349. // #endif
  350. } else {
  351. let isHave = false;
  352. for (let j = 0; j < foundDevices.length; j++) {
  353. if (name == foundDevices[j].deviceId) {
  354. isHave = true;
  355. break;
  356. }
  357. }
  358. if (!isHave) {
  359. foundDevices.push(device);
  360. }
  361. }
  362. deviceList.value = foundDevices;
  363. foundDevices = [];
  364. console.log("deviceList.value", deviceList.value);
  365. }
  366. }
  367. }
  368. });
  369. },
  370. fail: function (res) {
  371. console.log(res);
  372. tools.hideLoadingAlert();
  373. },
  374. });
  375. },
  376. fail: function (res) {
  377. console.log(res);
  378. alertF("手机蓝牙未打开或不支持蓝牙");
  379. },
  380. });
  381. };
  382. /**
  383. * 连接蓝牙
  384. */
  385. const connectDevice = (e) => {
  386. console.log(e);
  387. let item = e;
  388. //停止扫描蓝牙
  389. console.info("停止搜寻附近的蓝牙外围设备");
  390. uni.stopBluetoothDevicesDiscovery({
  391. success: function (res) {
  392. console.log(device);
  393. if (item.selected == false) {
  394. console.log("第一次点击了");
  395. item.selected = true;
  396. setTimeout(function () {
  397. if (device.selected == undefined) {
  398. console.info("selected is undefined");
  399. linkFail(); //未找到设备, 请重新搜索
  400. return;
  401. }
  402. item.selected = false;
  403. }, 4000);
  404. } else {
  405. console.log("第二次点击了");
  406. return;
  407. }
  408. if (
  409. item.prefixName == undefined ||
  410. item.prefixName == "undefined" ||
  411. item.prefixName == ""
  412. ) {
  413. console.info("device.prefixName is undefined");
  414. linkFail(); //未找到设备, 请重新搜索
  415. return;
  416. }
  417. let prefixName = item.prefixName;
  418. connectPrefixName.value = item.prefixName;
  419. console.log(item);
  420. // datas.setData("connectPrefixName", connectPrefixName.value);
  421. // //断开蓝牙
  422. // bluetoothUtil.disconnectDevice();
  423. tools.showLoadingAlert("蓝牙连接中");
  424. console.info("连接的是" + prefixName, device);
  425. switch (prefixName) {
  426. case "ETC":
  427. console.log("device.name=====", device.name, device.name.includes("KC"), device.name.includes("JY"), device.name.includes("KC") || device.name.includes("K") || device.name.includes("C"))
  428. if (device.name.includes("KC") || device.name.includes("K")) {
  429. kcApi.connectDevice(
  430. device,
  431. function (res) {
  432. preDevice(res);
  433. },
  434. function (res) {
  435. listenStatus(res);
  436. }
  437. );
  438. } else if (device.name.includes("JL")) {
  439. jlQZApi.connectDevice(
  440. device,
  441. function (res) {
  442. preDevice(res);
  443. },
  444. function (res) {
  445. listenStatus(res);
  446. }
  447. );
  448. } else if (device.name.includes("WJ")) {
  449. wjApi9901.connectDevice(
  450. device,
  451. function (res) {
  452. preDevice(res);
  453. },
  454. function (res) {
  455. listenStatus(res);
  456. }
  457. );
  458. }
  459. // else if (device.name.includes("JY")) {
  460. // console.log("进来了JY",device.name.includes("JY"))
  461. // jyApiEtc.connectDevice(
  462. // device,
  463. // function (res) {
  464. // preDevice(res);
  465. // },
  466. // function (res) {
  467. // listenStatus(res);
  468. // }
  469. // );
  470. // }
  471. break;
  472. case "WJ":
  473. wjApi.connectDevice(
  474. device,
  475. function (res) {
  476. connectSuccess(res);
  477. },
  478. function (res) {
  479. listenStatus(res);
  480. }
  481. );
  482. break;
  483. case "JL":
  484. jlApi.connectDevice(
  485. device,
  486. function (res) {
  487. console.log('设备链接1', res)
  488. connectSuccess(res);
  489. },
  490. function (res) {
  491. console.log('设备链接2', res)
  492. listenStatus(res);
  493. }
  494. );
  495. break;
  496. case "JY":
  497. jyApi.connectDevice(
  498. device,
  499. function (res) {
  500. connectSuccess(res);
  501. },
  502. function (res) {
  503. listenStatus(res);
  504. }
  505. );
  506. break;
  507. case "AT":
  508. atApi.connectDevice(
  509. device,
  510. function (res) {
  511. connectSuccess(res);
  512. },
  513. function (res) {
  514. listenStatus(res);
  515. }
  516. );
  517. break;
  518. case "JT":
  519. console.info("连接的是=====123" + prefixName, device);
  520. jtApi.connectDevice(
  521. device,
  522. function (res) {
  523. console.log('设备链接1', res)
  524. connectSuccess(res);
  525. },
  526. function (res) {
  527. console.log('设备链接2', res)
  528. listenStatus(res);
  529. }
  530. );
  531. break;
  532. case "WQ":
  533. wqApi.connectDevice(
  534. device,
  535. function (res) {
  536. connectSuccess(res);
  537. },
  538. function (res) {
  539. listenStatus(res);
  540. }
  541. );
  542. break;
  543. case "CG":
  544. cgApi.connectDevice(
  545. device,
  546. function (res) {
  547. connectSuccess(res);
  548. },
  549. function (res) {
  550. listenStatus(res);
  551. }
  552. );
  553. break;
  554. case "TD":
  555. tdApi.connectDevice(
  556. device,
  557. function (res) {
  558. connectSuccess(res)
  559. }, function (res) {
  560. listenStatus(res);
  561. }
  562. );
  563. break;
  564. case "ZZ":
  565. zzApi.connectDevice(
  566. device,
  567. function (res) {
  568. connectSuccess(res);
  569. },
  570. function (res) {
  571. listenStatus(res);
  572. }
  573. );
  574. break;
  575. default: //未找到设备, 请重新搜索
  576. linkFail();
  577. break;
  578. }
  579. },
  580. fail: function (res) {
  581. console.log(res);
  582. linkFail(); //未找到设备, 请重新搜索
  583. },
  584. });
  585. };
  586. /**
  587. * 未找到设备, 请重新搜索
  588. */
  589. const linkFail = () => {
  590. datas.setData("bluLinkStatus", false);
  591. datas.setData("connectPrefixName", "");
  592. tools.showModalAlert("未找到设备, 请重新搜索", function successFunc() {
  593. load();
  594. });
  595. };
  596. /**
  597. * 连接成功
  598. */
  599. const connectSuccess = (res) => {
  600. console.log("连接回调函数func1");
  601. console.log(res);
  602. if (res.code == 0) {
  603. console.log("连接成功");
  604. tools.hideLoadingAlert(); //关闭加载框
  605. datas.setData("bluLinkStatus", true);
  606. datas.setData("connectPrefixName", connectPrefixName.value);
  607. oks();
  608. } else {
  609. alertF(res.msg);
  610. }
  611. };
  612. function oks() {
  613. //routeType 1.激活(订单来) 2.圈存 (/pages/recharge/recharge来)3.ping码解锁 4.信息读取 5从哪里来回哪里去监听bluetoothLink 7消费明细去圈存 8单位账户圈存 9对公账户修复
  614. if (routeType.value == "1") {
  615. if (state.isAfter == '1') {
  616. uni.navigateTo({
  617. url: `/subpackage/after-sale/activation/activate-SH`,
  618. });
  619. } else {
  620. uni.navigateTo({
  621. url: `/subpackage/after-sale/activation/activate?transfer=${state.transfer}`,
  622. });
  623. }
  624. } else if (routeType.value == "2") {
  625. uni.navigateTo({
  626. url: `/subpackage/carPark/recharge/recharge-weixin?connectSuccess=${state.connectSuccess}`,
  627. });
  628. } else if (routeType.value == "3") {
  629. uni.navigateTo({
  630. url: "/subpackage/after-sale/pin-code-deblocking/pin-code-confirm?state=true&id=" + state.id,
  631. });
  632. } else if (routeType.value == "4") {
  633. uni.navigateTo({
  634. url: `/subpackage/after-sale/deviceInfo/deviceInfo?backIndex=${state.backIndex}`,
  635. });
  636. } else if (routeType.value == "5") {
  637. // #ifdef MP-ALIPAY
  638. uni.navigateTo({
  639. url: "/subpackage/after-sale/activation-once-again/activation-once-again-ali?state=true&id=" + state.id,
  640. });
  641. // #endif
  642. // #ifdef MP-WEIXIN
  643. if (state.difference == "1") {
  644. uni.navigateTo({
  645. url: `/subpackage/after-sale/activation-once-again/activation-once-again?status=true&state=true&vehicleId=${state.vehicleId}&vehPosImgUrl=${state.vehPosImgUrl}&vehNegImgUrl=${state.vehNegImgUrl}`,
  646. });
  647. } else if (state.difference == "2") {
  648. uni.navigateTo({
  649. url: `/subpackage/after-sale/refund-order-balance/refund-order-balance?status=true&state=true&vehicleId=${state.vehicleId}&&id=${state.id}&&refundBalance=${state.refundBalance}`,
  650. });
  651. } else {
  652. uni.$emit('bluetoothLink', { status: true })
  653. uni.navigateBack({
  654. delta: 1
  655. })
  656. }
  657. // #endif
  658. } else if (routeType.value == "6") {
  659. uni.navigateTo({
  660. url: "/subpackage/after-sale/activation-once-again/activation-once-again?state=true&id=" + state.id
  661. });
  662. } else if (routeType.value == "7") {
  663. uni.navigateTo({
  664. url: `/subpackage/personal-center/trapping-and-repairing/recharge-two?rechargeMoney=${state.rechargeMoney}&&orderNum=${state.orderNum}&&payMoney=${state.payMoney}`,
  665. });
  666. } else if (routeType.value == "8") {
  667. uni.navigateTo({
  668. url: `/subpackage/after-sale/account-recharge/recharge-weixin?accountId=${state.accountId}`,
  669. });
  670. } else if (routeType.value == "9") {
  671. uni.navigateTo({
  672. url: `/subpackage/personal-center/trapping-and-repairing-account/recharge-two?rechargeMoney=${state.rechargeMoney}&&orderNum=${state.orderNum}&&payMoney=${state.payMoney}&&accountId=${state.accountId}`,
  673. });
  674. } else if (routeType.value == "10") {
  675. uni.navigateTo({
  676. url: `/subpackage/personal-center/car-message-change?vehicleId=${state.vehicleId}`,
  677. });
  678. } else {
  679. return;
  680. }
  681. }
  682. /**
  683. * 前装设备
  684. */
  685. const preDevice = (res) => {
  686. console.log("连接成功1111=====", res);
  687. if (res.code == 0 || res.serviceCode==0) {
  688. console.log("连接成功=====");
  689. datas.setData("bluLinkStatus", true);
  690. datas.setData("connectPrefixName", connectPrefixName.value);
  691. getCardId((cardNo) => {
  692. console.log("cardNo",cardNo);
  693. if(cardNo.includes('5201')){
  694. // 正常激活 前装 5201
  695. oks()
  696. }else{
  697. // 前装9901
  698. etcOks()
  699. }
  700. })
  701. } else {
  702. alertF(res.msg);
  703. console.log(res.msg);
  704. }
  705. };
  706. function getCardId(fun){
  707. //执行0015文件
  708. tools.showLoadingAlert("执行指令");
  709. let cmdArr = [cmd.HOME_DIRECTORY, cmd.APPLICATION_DIRECTORY, cmd.CMD_READBINARY];
  710. console.log(cmdArr);
  711. console.log(bluetoothUtil);
  712. bluetoothUtil.transCmd(cmdArr, '10', function(res) { //10:写卡 20:写OBU
  713. console.log("res====", res)
  714. var cardStr = res[2];
  715. if (cardStr == undefined || cardStr == "undefined" || cardStr == "") {
  716. tools.alertF("卡指令不符" + cardStr);
  717. return;
  718. }
  719. if (cardStr.length < 40) {
  720. tools.alertF("卡指令长度不符" + cardStr);
  721. return;
  722. }
  723. tools.hideLoadingAlert();
  724. fun(cardStr.substring(20, 40));
  725. })
  726. }
  727. function etcOks() {
  728. if (routeType.value == "4") {
  729. uni.navigateTo({
  730. url: "/subpackage/carPark/etc/etcDeviceInfo",
  731. });
  732. }
  733. }
  734. /**
  735. * 监听蓝牙状态
  736. */
  737. const listenStatus = (res) => {
  738. console.log("时时监听蓝牙状态func2", connectPrefixName.value, res.code);
  739. console.log(res);
  740. if (res.code == 0) {
  741. datas.setData("bluLinkStatus", true);
  742. datas.setData("connectPrefixName", connectPrefixName.value);
  743. // oks();
  744. } else {
  745. //断开蓝牙
  746. bluetoothUtil.disconnectDevice();
  747. datas.setData("bluLinkStatus", false);
  748. datas.setData("connectPrefixName", "");
  749. tools.showToastAlert("蓝牙已断开");
  750. // #ifdef MP-ALIPAY
  751. my.closeBluetoothAdapter({
  752. success(res) {
  753. // 关闭蓝牙适配器成功
  754. },
  755. fail(err) {
  756. // 处理关闭蓝牙适配器失败的情况
  757. }
  758. })
  759. // #endif
  760. }
  761. };
  762. /**
  763. * 提示加关蓝牙
  764. */
  765. const alertF = (msg : string) => {
  766. //隐藏加载框
  767. tools.hideLoadingAlert();
  768. //断开蓝牙
  769. bluetoothUtil.disconnectDevice();
  770. //提示对话框
  771. tools.showModalAlert(msg);
  772. };
  773. </script>
  774. <style>
  775. page {
  776. background-color: #f3f3f3;
  777. }
  778. :deep(.u-mode-center-box) {
  779. border-radius: 20rpx;
  780. }
  781. </style>
  782. <style lang="scss" scoped>
  783. .devices {
  784. min-height: 100vh;
  785. box-sizing: border-box;
  786. padding-bottom: 160rpx;
  787. position: relative;
  788. padding-top: 30rpx;
  789. background: #E9EDF0;
  790. .action {
  791. position: absolute;
  792. bottom: 0rpx;
  793. left: 0;
  794. height: 128rpx;
  795. background-color: #fff;
  796. border-radius: 30rpx 30rpx 0 0;
  797. width: 100vw;
  798. display: flex;
  799. align-items: center;
  800. justify-content: center;
  801. flex-direction: column;
  802. }
  803. .device {
  804. margin: 0 auto;
  805. width: 701rpx;
  806. display: flex;
  807. flex-direction: row;
  808. align-items: center;
  809. background: white;
  810. padding: 25rpx 20rpx;
  811. box-sizing: border-box;
  812. background: #FFFFFF;
  813. box-shadow: 2rpx 6rpx 6rpx 6rpx #DFDFDF;
  814. border-radius: 12rpx;
  815. .head {
  816. width: 120rpx;
  817. height: 120rpx;
  818. border-radius: 10rpx;
  819. background-color: #f3f3f3;
  820. }
  821. .center {
  822. flex: 1;
  823. margin-left: 30rpx;
  824. margin-right: 30rpx;
  825. .name {
  826. font-size: 30rpx;
  827. color: #333333;
  828. }
  829. .desc {
  830. font-size: 26rpx;
  831. color: #666666;
  832. margin-top: 25rpx;
  833. }
  834. }
  835. .icon {
  836. width: 38rpx;
  837. height: 38rpx;
  838. margin-right: 12rpx;
  839. }
  840. }
  841. .hint {
  842. margin: 60rpx 30rpx 0px;
  843. .txt {
  844. font-family: MicrosoftYaHei;
  845. font-size: 28rpx;
  846. color: #111111;
  847. line-height: 40rpx;
  848. display: flex;
  849. align-items: center;
  850. .imgs {
  851. width: 30rpx;
  852. height: 30rpx;
  853. margin-right: 10rpx;
  854. }
  855. }
  856. .grey-txt {
  857. font-size: 28rpx;
  858. color: #999;
  859. line-height: 40rpx;
  860. margin-top: 16rpx;
  861. }
  862. }
  863. .btn {
  864. margin: 70rpx 40rpx;
  865. }
  866. }
  867. </style>