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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906
  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. }else if (name.split("-")[1] == "ATS") {
  308. _name = "前装-埃特斯";
  309. }
  310. break;
  311. case "WJ":
  312. _name = "万集";
  313. break;
  314. case "JL":
  315. _name = "聚利";
  316. break;
  317. case "JY":
  318. _name = "金溢";
  319. break;
  320. case "AT":
  321. _name = "埃特斯";
  322. break;
  323. case "JT":
  324. _name = "建投";
  325. break;
  326. case "WQ":
  327. _name = "握奇";
  328. break;
  329. case "CG":
  330. _name = "成谷";
  331. break;
  332. case "TD":
  333. _name = "天地融";
  334. break;
  335. case "ZZ":
  336. _name = "智载";
  337. break;
  338. default:
  339. _name = "未知";
  340. break;
  341. }
  342. device._name = _name;
  343. if (deviceList.value.length == 0) {
  344. // #ifdef MP-ALIPAY
  345. if (device._name == '聚利' || device._name == '万集' || device._name == '天地融' || device._name == '建投') {
  346. foundDevices.push(device);
  347. }
  348. // #endif
  349. // #ifdef MP-WEIXIN
  350. foundDevices.push(device);
  351. // #endif
  352. } else {
  353. let isHave = false;
  354. for (let j = 0; j < foundDevices.length; j++) {
  355. if (name == foundDevices[j].deviceId) {
  356. isHave = true;
  357. break;
  358. }
  359. }
  360. if (!isHave) {
  361. foundDevices.push(device);
  362. }
  363. }
  364. deviceList.value = foundDevices;
  365. foundDevices = [];
  366. console.log("deviceList.value", deviceList.value);
  367. }
  368. }
  369. }
  370. });
  371. },
  372. fail: function (res) {
  373. console.log(res);
  374. tools.hideLoadingAlert();
  375. },
  376. });
  377. },
  378. fail: function (res) {
  379. console.log(res);
  380. alertF("手机蓝牙未打开或不支持蓝牙");
  381. },
  382. });
  383. };
  384. /**
  385. * 连接蓝牙
  386. */
  387. const connectDevice = (e) => {
  388. console.log(e);
  389. let item = e;
  390. //停止扫描蓝牙
  391. console.info("停止搜寻附近的蓝牙外围设备");
  392. uni.stopBluetoothDevicesDiscovery({
  393. success: function (res) {
  394. console.log(device);
  395. if (item.selected == false) {
  396. console.log("第一次点击了");
  397. item.selected = true;
  398. setTimeout(function () {
  399. if (device.selected == undefined) {
  400. console.info("selected is undefined");
  401. linkFail(); //未找到设备, 请重新搜索
  402. return;
  403. }
  404. item.selected = false;
  405. }, 4000);
  406. } else {
  407. console.log("第二次点击了");
  408. return;
  409. }
  410. if (
  411. item.prefixName == undefined ||
  412. item.prefixName == "undefined" ||
  413. item.prefixName == ""
  414. ) {
  415. console.info("device.prefixName is undefined");
  416. linkFail(); //未找到设备, 请重新搜索
  417. return;
  418. }
  419. let prefixName = item.prefixName;
  420. connectPrefixName.value = item.prefixName;
  421. console.log(item);
  422. // datas.setData("connectPrefixName", connectPrefixName.value);
  423. // //断开蓝牙
  424. // bluetoothUtil.disconnectDevice();
  425. tools.showLoadingAlert("蓝牙连接中");
  426. console.info("连接的是" + prefixName, device);
  427. switch (prefixName) {
  428. case "ETC":
  429. 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"))
  430. let obj = ""
  431. if (device.name.includes("KC") || device.name.includes("K")) {
  432. obj=kcApi
  433. } else if (device.name.includes("JL")) {
  434. obj=jlQZApi
  435. } else if (device.name.includes("WJ")) {
  436. obj=wjApi9901
  437. }else if (device.name.includes("ATS")) {
  438. obj=ArtcBleUtilApi
  439. }
  440. console.log("新")
  441. obj.connectDevice(
  442. device,
  443. function (res) {
  444. preDevice(res);
  445. },
  446. function (res) {
  447. listenStatus(res);
  448. }
  449. );
  450. // else if (device.name.includes("JY")) {
  451. // console.log("进来了JY",device.name.includes("JY"))
  452. // jyApiEtc.connectDevice(
  453. // device,
  454. // function (res) {
  455. // preDevice(res);
  456. // },
  457. // function (res) {
  458. // listenStatus(res);
  459. // }
  460. // );
  461. // }
  462. break;
  463. case "WJ":
  464. console.log("旧")
  465. wjApi.connectDevice(
  466. device,
  467. function (res) {
  468. connectSuccess(res);
  469. },
  470. function (res) {
  471. listenStatus(res);
  472. }
  473. );
  474. break;
  475. case "JL":
  476. jlApi.connectDevice(
  477. device,
  478. function (res) {
  479. console.log('设备链接1', res)
  480. connectSuccess(res);
  481. },
  482. function (res) {
  483. console.log('设备链接2', res)
  484. listenStatus(res);
  485. }
  486. );
  487. break;
  488. case "JY":
  489. jyApi.connectDevice(
  490. device,
  491. function (res) {
  492. connectSuccess(res);
  493. },
  494. function (res) {
  495. listenStatus(res);
  496. }
  497. );
  498. break;
  499. case "AT":
  500. atApi.connectDevice(
  501. device,
  502. function (res) {
  503. connectSuccess(res);
  504. },
  505. function (res) {
  506. listenStatus(res);
  507. }
  508. );
  509. break;
  510. case "JT":
  511. console.info("连接的是=====123" + prefixName, device);
  512. jtApi.connectDevice(
  513. device,
  514. function (res) {
  515. console.log('设备链接1', res)
  516. connectSuccess(res);
  517. },
  518. function (res) {
  519. console.log('设备链接2', res)
  520. listenStatus(res);
  521. }
  522. );
  523. break;
  524. case "WQ":
  525. wqApi.connectDevice(
  526. device,
  527. function (res) {
  528. connectSuccess(res);
  529. },
  530. function (res) {
  531. listenStatus(res);
  532. }
  533. );
  534. break;
  535. case "CG":
  536. cgApi.connectDevice(
  537. device,
  538. function (res) {
  539. connectSuccess(res);
  540. },
  541. function (res) {
  542. listenStatus(res);
  543. }
  544. );
  545. break;
  546. case "TD":
  547. tdApi.connectDevice(
  548. device,
  549. function (res) {
  550. connectSuccess(res)
  551. }, function (res) {
  552. listenStatus(res);
  553. }
  554. );
  555. break;
  556. case "ZZ":
  557. zzApi.connectDevice(
  558. device,
  559. function (res) {
  560. connectSuccess(res);
  561. },
  562. function (res) {
  563. listenStatus(res);
  564. }
  565. );
  566. break;
  567. default: //未找到设备, 请重新搜索
  568. linkFail();
  569. break;
  570. }
  571. },
  572. fail: function (res) {
  573. console.log(res);
  574. linkFail(); //未找到设备, 请重新搜索
  575. },
  576. });
  577. };
  578. /**
  579. * 未找到设备, 请重新搜索
  580. */
  581. const linkFail = () => {
  582. datas.setData("bluLinkStatus", false);
  583. datas.setData("connectPrefixName", "");
  584. tools.showModalAlert("未找到设备, 请重新搜索", function successFunc() {
  585. load();
  586. });
  587. };
  588. /**
  589. * 连接成功
  590. */
  591. const connectSuccess = (res) => {
  592. console.log("连接回调函数func1");
  593. console.log(res);
  594. if (res.code == 0) {
  595. console.log("连接成功");
  596. tools.hideLoadingAlert(); //关闭加载框
  597. datas.setData("bluLinkStatus", true);
  598. datas.setData("connectPrefixName", connectPrefixName.value);
  599. oks();
  600. } else {
  601. alertF(res.msg);
  602. }
  603. };
  604. function oks() {
  605. //routeType 1.激活(订单来) 2.圈存 (/pages/recharge/recharge来)3.ping码解锁 4.信息读取 5从哪里来回哪里去监听bluetoothLink 7消费明细去圈存 8单位账户圈存 9对公账户修复
  606. if (routeType.value == "1") {
  607. if (state.isAfter == '1') {
  608. uni.navigateTo({
  609. url: `/subpackage/after-sale/activation/activate-SH`,
  610. });
  611. } else {
  612. uni.navigateTo({
  613. url: `/subpackage/after-sale/activation/activate?transfer=${state.transfer}`,
  614. });
  615. }
  616. } else if (routeType.value == "2") {
  617. uni.navigateTo({
  618. url: `/subpackage/carPark/recharge/recharge-weixin?connectSuccess=${state.connectSuccess}`,
  619. });
  620. } else if (routeType.value == "3") {
  621. uni.navigateTo({
  622. url: "/subpackage/after-sale/pin-code-deblocking/pin-code-confirm?state=true&id=" + state.id,
  623. });
  624. } else if (routeType.value == "4") {
  625. uni.navigateTo({
  626. url: `/subpackage/after-sale/deviceInfo/deviceInfo?backIndex=${state.backIndex}`,
  627. });
  628. } else if (routeType.value == "5") {
  629. // #ifdef MP-ALIPAY
  630. uni.navigateTo({
  631. url: "/subpackage/after-sale/activation-once-again/activation-once-again-ali?state=true&id=" + state.id,
  632. });
  633. // #endif
  634. // #ifdef MP-WEIXIN
  635. if (state.difference == "1") {
  636. uni.navigateTo({
  637. url: `/subpackage/after-sale/activation-once-again/activation-once-again?status=true&state=true&vehicleId=${state.vehicleId}&vehPosImgUrl=${state.vehPosImgUrl}&vehNegImgUrl=${state.vehNegImgUrl}`,
  638. });
  639. } else if (state.difference == "2") {
  640. uni.navigateTo({
  641. url: `/subpackage/after-sale/refund-order-balance/refund-order-balance?status=true&state=true&vehicleId=${state.vehicleId}&&id=${state.id}&&refundBalance=${state.refundBalance}`,
  642. });
  643. } else {
  644. uni.$emit('bluetoothLink', { status: true })
  645. uni.navigateBack({
  646. delta: 1
  647. })
  648. }
  649. // #endif
  650. } else if (routeType.value == "6") {
  651. uni.navigateTo({
  652. url: "/subpackage/after-sale/activation-once-again/activation-once-again?state=true&id=" + state.id
  653. });
  654. } else if (routeType.value == "7") {
  655. uni.navigateTo({
  656. url: `/subpackage/personal-center/trapping-and-repairing/recharge-two?rechargeMoney=${state.rechargeMoney}&&orderNum=${state.orderNum}&&payMoney=${state.payMoney}`,
  657. });
  658. } else if (routeType.value == "8") {
  659. uni.navigateTo({
  660. url: `/subpackage/after-sale/account-recharge/recharge-weixin?accountId=${state.accountId}`,
  661. });
  662. } else if (routeType.value == "9") {
  663. uni.navigateTo({
  664. url: `/subpackage/personal-center/trapping-and-repairing-account/recharge-two?rechargeMoney=${state.rechargeMoney}&&orderNum=${state.orderNum}&&payMoney=${state.payMoney}&&accountId=${state.accountId}`,
  665. });
  666. } else if (routeType.value == "10") {
  667. uni.navigateTo({
  668. url: `/subpackage/personal-center/car-message-change?vehicleId=${state.vehicleId}`,
  669. });
  670. } else {
  671. return;
  672. }
  673. }
  674. /**
  675. * 前装设备
  676. */
  677. const preDevice = (res) => {
  678. console.log("连接成功1111=====", res);
  679. if (res.code == 0 || res.serviceCode==0) {
  680. console.log("连接成功=====");
  681. datas.setData("bluLinkStatus", true);
  682. datas.setData("connectPrefixName", connectPrefixName.value);
  683. getCardId((cardNo) => {
  684. console.log("cardNo",cardNo);
  685. if(cardNo.includes('5201')){
  686. // 正常激活 前装 5201
  687. oks()
  688. }else{
  689. // 前装9901
  690. etcOks()
  691. }
  692. })
  693. } else {
  694. alertF(res.msg);
  695. console.log(res.msg);
  696. }
  697. };
  698. function getCardId(fun){
  699. //执行0015文件
  700. tools.showLoadingAlert("执行指令");
  701. let cmdArr = [cmd.HOME_DIRECTORY, cmd.APPLICATION_DIRECTORY, cmd.CMD_READBINARY];
  702. console.log(cmdArr);
  703. console.log(bluetoothUtil);
  704. bluetoothUtil.transCmd(cmdArr, '10', function(res) { //10:写卡 20:写OBU
  705. console.log("res====", res)
  706. var cardStr = res[2];
  707. if (cardStr == undefined || cardStr == "undefined" || cardStr == "") {
  708. tools.alertF("卡指令不符" + cardStr);
  709. return;
  710. }
  711. if (cardStr.length < 40) {
  712. tools.alertF("卡指令长度不符" + cardStr);
  713. return;
  714. }
  715. tools.hideLoadingAlert();
  716. fun(cardStr.substring(20, 40));
  717. })
  718. }
  719. function etcOks() {
  720. if (routeType.value == "4") {
  721. uni.navigateTo({
  722. url: "/subpackage/carPark/etc/etcDeviceInfo",
  723. });
  724. }
  725. }
  726. /**
  727. * 监听蓝牙状态
  728. */
  729. const listenStatus = (res) => {
  730. console.log("时时监听蓝牙状态func2", connectPrefixName.value, res.code);
  731. console.log(res);
  732. if (res.code == 0) {
  733. datas.setData("bluLinkStatus", true);
  734. datas.setData("connectPrefixName", connectPrefixName.value);
  735. // oks();
  736. } else {
  737. //断开蓝牙
  738. bluetoothUtil.disconnectDevice();
  739. datas.setData("bluLinkStatus", false);
  740. datas.setData("connectPrefixName", "");
  741. tools.showToastAlert("蓝牙已断开");
  742. // #ifdef MP-ALIPAY
  743. my.closeBluetoothAdapter({
  744. success(res) {
  745. // 关闭蓝牙适配器成功
  746. },
  747. fail(err) {
  748. // 处理关闭蓝牙适配器失败的情况
  749. }
  750. })
  751. // #endif
  752. }
  753. };
  754. /**
  755. * 提示加关蓝牙
  756. */
  757. const alertF = (msg : string) => {
  758. //隐藏加载框
  759. tools.hideLoadingAlert();
  760. //断开蓝牙
  761. bluetoothUtil.disconnectDevice();
  762. //提示对话框
  763. tools.showModalAlert(msg);
  764. };
  765. </script>
  766. <style>
  767. page {
  768. background-color: #f3f3f3;
  769. }
  770. :deep(.u-mode-center-box) {
  771. border-radius: 20rpx;
  772. }
  773. </style>
  774. <style lang="scss" scoped>
  775. .devices {
  776. min-height: 100vh;
  777. box-sizing: border-box;
  778. padding-bottom: 160rpx;
  779. position: relative;
  780. padding-top: 30rpx;
  781. background: #E9EDF0;
  782. .action {
  783. position: absolute;
  784. bottom: 0rpx;
  785. left: 0;
  786. height: 128rpx;
  787. background-color: #fff;
  788. border-radius: 30rpx 30rpx 0 0;
  789. width: 100vw;
  790. display: flex;
  791. align-items: center;
  792. justify-content: center;
  793. flex-direction: column;
  794. }
  795. .device {
  796. margin: 0 auto;
  797. width: 701rpx;
  798. display: flex;
  799. flex-direction: row;
  800. align-items: center;
  801. background: white;
  802. padding: 25rpx 20rpx;
  803. box-sizing: border-box;
  804. background: #FFFFFF;
  805. box-shadow: 2rpx 6rpx 6rpx 6rpx #DFDFDF;
  806. border-radius: 12rpx;
  807. .head {
  808. width: 120rpx;
  809. height: 120rpx;
  810. border-radius: 10rpx;
  811. background-color: #f3f3f3;
  812. }
  813. .center {
  814. flex: 1;
  815. margin-left: 30rpx;
  816. margin-right: 30rpx;
  817. .name {
  818. font-size: 30rpx;
  819. color: #333333;
  820. }
  821. .desc {
  822. font-size: 26rpx;
  823. color: #666666;
  824. margin-top: 25rpx;
  825. }
  826. }
  827. .icon {
  828. width: 38rpx;
  829. height: 38rpx;
  830. margin-right: 12rpx;
  831. }
  832. }
  833. .hint {
  834. margin: 60rpx 30rpx 0px;
  835. .txt {
  836. font-family: MicrosoftYaHei;
  837. font-size: 28rpx;
  838. color: #111111;
  839. line-height: 40rpx;
  840. display: flex;
  841. align-items: center;
  842. .imgs {
  843. width: 30rpx;
  844. height: 30rpx;
  845. margin-right: 10rpx;
  846. }
  847. }
  848. .grey-txt {
  849. font-size: 28rpx;
  850. color: #999;
  851. line-height: 40rpx;
  852. margin-top: 16rpx;
  853. }
  854. }
  855. .btn {
  856. margin: 70rpx 40rpx;
  857. }
  858. }
  859. </style>