Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

bluetooth.vue 22KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840
  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. }
  465. // else if (device.name.includes("JY")) {
  466. // console.log("进来了JY",device.name.includes("JY"))
  467. // jyApiEtc.connectDevice(
  468. // device,
  469. // function (res) {
  470. // preDevice(res);
  471. // },
  472. // function (res) {
  473. // listenStatus(res);
  474. // }
  475. // );
  476. // }
  477. break;
  478. case "JY":
  479. jyApi.connectDevice(
  480. device,
  481. function (res) {
  482. connectSuccess(res);
  483. },
  484. function (res) {
  485. listenStatus(res);
  486. }
  487. );
  488. break;
  489. case "AT":
  490. atApi.connectDevice(
  491. device,
  492. function (res) {
  493. connectSuccess(res);
  494. },
  495. function (res) {
  496. listenStatus(res);
  497. }
  498. );
  499. break;
  500. case "JT":
  501. console.info("连接的是=====123" + prefixName, device);
  502. jtApi.connectDevice(
  503. device,
  504. function (res) {
  505. console.log('设备链接1', res)
  506. connectSuccess(res);
  507. },
  508. function (res) {
  509. console.log('设备链接2', res)
  510. listenStatus(res);
  511. }
  512. );
  513. break;
  514. case "WQ":
  515. wqApi.connectDevice(
  516. device,
  517. function (res) {
  518. connectSuccess(res);
  519. },
  520. function (res) {
  521. listenStatus(res);
  522. }
  523. );
  524. break;
  525. case "CG":
  526. cgApi.connectDevice(
  527. device,
  528. function (res) {
  529. connectSuccess(res);
  530. },
  531. function (res) {
  532. listenStatus(res);
  533. }
  534. );
  535. break;
  536. case "TD":
  537. tdApi.connectDevice(
  538. device,
  539. function (res) {
  540. connectSuccess(res)
  541. }, function (res) {
  542. listenStatus(res);
  543. }
  544. );
  545. break;
  546. case "ZZ":
  547. zzApi.connectDevice(
  548. device,
  549. function (res) {
  550. connectSuccess(res);
  551. },
  552. function (res) {
  553. listenStatus(res);
  554. }
  555. );
  556. break;
  557. default: //未找到设备, 请重新搜索
  558. linkFail();
  559. break;
  560. }
  561. },
  562. fail: function (res) {
  563. console.log(res);
  564. linkFail(); //未找到设备, 请重新搜索
  565. },
  566. });
  567. };
  568. /**
  569. * 未找到设备, 请重新搜索
  570. */
  571. const linkFail = () => {
  572. datas.setData("bluLinkStatus", false);
  573. datas.setData("connectPrefixName", "");
  574. tools.showModalAlert("未找到设备, 请重新搜索", function successFunc() {
  575. load();
  576. });
  577. };
  578. /**
  579. * 连接成功
  580. */
  581. const connectSuccess = (res) => {
  582. console.log("连接回调函数func1");
  583. console.log(res);
  584. if (res.code == 0) {
  585. console.log("连接成功");
  586. tools.hideLoadingAlert(); //关闭加载框
  587. datas.setData("bluLinkStatus", true);
  588. datas.setData("connectPrefixName", connectPrefixName.value);
  589. oks();
  590. } else {
  591. alertF(res.msg);
  592. }
  593. };
  594. function oks() {
  595. //routeType 1.激活(订单来) 2.圈存 (/pages/recharge/recharge来)3.ping码解锁 4.信息读取 5从哪里来回哪里去监听bluetoothLink 7消费明细去圈存 8单位账户圈存 9对公账户修复
  596. if (routeType.value == "1") {
  597. uni.navigateTo({
  598. url: `/subpackage/after-sale/activation/activate?transfer=${state.transfer}`,
  599. });
  600. } else if (routeType.value == "2") {
  601. uni.navigateTo({
  602. url: `/subpackage/carPark/recharge/recharge-weixin?connectSuccess=${state.connectSuccess}`,
  603. });
  604. } else if (routeType.value == "3") {
  605. uni.navigateTo({
  606. url: "/subpackage/after-sale/pin-code-deblocking/pin-code-confirm?state=true&id=" + state.id,
  607. });
  608. } else if (routeType.value == "4") {
  609. uni.navigateTo({
  610. url: "/subpackage/after-sale/deviceInfo/deviceInfo",
  611. });
  612. } else if (routeType.value == "5") {
  613. // #ifdef MP-ALIPAY
  614. uni.navigateTo({
  615. url: "/subpackage/after-sale/activation-once-again/activation-once-again-ali?state=true&id=" + state.id,
  616. });
  617. // #endif
  618. // #ifdef MP-WEIXIN
  619. if (state.difference == "1") {
  620. uni.navigateTo({
  621. url: `/subpackage/after-sale/activation-once-again/activation-once-again?status=true&state=true&vehicleId=${state.vehicleId}&vehPosImgUrl=${state.vehPosImgUrl}&vehNegImgUrl=${state.vehNegImgUrl}`,
  622. });
  623. } else if (state.difference == "2") {
  624. uni.navigateTo({
  625. url: `/subpackage/after-sale/refund-order-balance/refund-order-balance?status=true&state=true&vehicleId=${state.vehicleId}&&id=${state.id}&&refundBalance=${state.refundBalance}`,
  626. });
  627. } else {
  628. uni.$emit('bluetoothLink', { status: true })
  629. uni.navigateBack({
  630. delta: 1
  631. })
  632. }
  633. // #endif
  634. } else if (routeType.value == "6") {
  635. uni.navigateTo({
  636. url: "/subpackage/after-sale/activation-once-again/activation-once-again?state=true&id=" + state.id
  637. });
  638. } else if (routeType.value == "7") {
  639. uni.navigateTo({
  640. url: `/subpackage/personal-center/trapping-and-repairing/recharge-two?rechargeMoney=${state.rechargeMoney}&&orderNum=${state.orderNum}&&payMoney=${state.payMoney}`,
  641. });
  642. } else if (routeType.value == "8") {
  643. uni.navigateTo({
  644. url: `/subpackage/after-sale/account-recharge/recharge-weixin?accountId=${state.accountId}`,
  645. });
  646. } else if (routeType.value == "9") {
  647. uni.navigateTo({
  648. url: `/subpackage/personal-center/trapping-and-repairing-account/recharge-two?rechargeMoney=${state.rechargeMoney}&&orderNum=${state.orderNum}&&payMoney=${state.payMoney}&&accountId=${state.accountId}`,
  649. });
  650. } else {
  651. return;
  652. }
  653. }
  654. /**
  655. * 前装设备
  656. */
  657. const preDevice = (res) => {
  658. console.log("连接成功1111=====", res.code);
  659. if (res.code == 0) {
  660. console.log("连接成功=====");
  661. datas.setData("bluLinkStatus", true);
  662. datas.setData("connectPrefixName", connectPrefixName.value);
  663. etcOks()
  664. } else {
  665. alertF(res.msg);
  666. console.log(res.msg);
  667. }
  668. };
  669. function etcOks() {
  670. if (routeType.value == "4") {
  671. uni.navigateTo({
  672. url: "/subpackage/carPark/etc/etcDeviceInfo",
  673. });
  674. }
  675. }
  676. /**
  677. * 监听蓝牙状态
  678. */
  679. const listenStatus = (res) => {
  680. console.log("时时监听蓝牙状态func2", connectPrefixName.value, res.code);
  681. console.log(res);
  682. if (res.code == 0) {
  683. datas.setData("bluLinkStatus", true);
  684. datas.setData("connectPrefixName", connectPrefixName.value);
  685. // oks();
  686. } else {
  687. //断开蓝牙
  688. bluetoothUtil.disconnectDevice();
  689. datas.setData("bluLinkStatus", false);
  690. datas.setData("connectPrefixName", "");
  691. tools.showToastAlert("蓝牙已断开");
  692. // #ifdef MP-ALIPAY
  693. my.closeBluetoothAdapter({
  694. success(res) {
  695. // 关闭蓝牙适配器成功
  696. },
  697. fail(err) {
  698. // 处理关闭蓝牙适配器失败的情况
  699. }
  700. })
  701. // #endif
  702. }
  703. };
  704. /**
  705. * 提示加关蓝牙
  706. */
  707. const alertF = (msg : string) => {
  708. //隐藏加载框
  709. tools.hideLoadingAlert();
  710. //断开蓝牙
  711. bluetoothUtil.disconnectDevice();
  712. //提示对话框
  713. tools.showModalAlert(msg);
  714. };
  715. </script>
  716. <style>
  717. page {
  718. background-color: #f3f3f3;
  719. }
  720. :deep(.u-mode-center-box) {
  721. border-radius: 20rpx;
  722. }
  723. </style>
  724. <style lang="scss" scoped>
  725. .devices {
  726. .device {
  727. width: calc(100% - 30rpx);
  728. margin-left: 30rpx;
  729. display: flex;
  730. flex-direction: row;
  731. align-items: center;
  732. margin-top: 30rpx;
  733. background: white;
  734. padding: 25rpx 20rpx;
  735. border-top-left-radius: 20rpx;
  736. border-bottom-left-radius: 20rpx;
  737. box-shadow: 0px 10px 10rpx 10rpx rgba(223, 223, 223, 0.3);
  738. .head {
  739. width: 120rpx;
  740. height: 120rpx;
  741. border-radius: 10rpx;
  742. background-color: #f3f3f3;
  743. }
  744. .center {
  745. flex: 1;
  746. margin-left: 30rpx;
  747. margin-right: 30rpx;
  748. .name {
  749. font-size: 30rpx;
  750. color: #333333;
  751. }
  752. .desc {
  753. font-size: 26rpx;
  754. color: #666666;
  755. margin-top: 25rpx;
  756. }
  757. }
  758. .icon {
  759. width: 43rpx;
  760. height: 43rpx;
  761. margin-right: 10rpx;
  762. }
  763. }
  764. .hint {
  765. margin: 60rpx 30rpx 0px;
  766. .orange-txt {
  767. font-size: 26rpx;
  768. color: #ff8000;
  769. image {
  770. width: 30rpx;
  771. height: 30rpx;
  772. margin-right: 10rpx;
  773. }
  774. }
  775. .grey-txt {
  776. font-size: 26rpx;
  777. color: #666666;
  778. line-height: 40rpx;
  779. margin-top: 16rpx;
  780. }
  781. }
  782. .btn {
  783. margin: 70rpx 40rpx;
  784. }
  785. }
  786. .red {
  787. display: inline-block;
  788. color: red;
  789. background-color: red;
  790. width: 26rpx;
  791. height: 26rpx;
  792. border-radius: 100%;
  793. }
  794. </style>