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

bluetooth.vue 22KB

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