scanBtn.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649
  1. <template>
  2. <view class="container-view">
  3. <view class="cabinet-bottom">
  4. <view @tap="navToGuild" class="guide-view flex-row">
  5. <img class="battery-img" src="https://qiniu.bms16.com/FkJlBRAxbGzR85wOO8WB_bAUTp-i" alt="">
  6. <view class="guide-text">{{$t('电池换电指南')}}</view>
  7. <img class="arrow-img" src="https://qiniu.bms16.com/FtC9Hb8y1QEOidsI2UySz85iUQHy" alt="">
  8. </view>
  9. <view class="scan-btn-view">
  10. <view v-if="num>0" class="free-num-view">
  11. {{$t('免费换电')}}<text class="free-num"> {{num}} </text>次
  12. </view>
  13. <view @tap="sacnBtn" class="scan-btn"><text>{{$t('扫码换电')}}</text></view>
  14. </view>
  15. </view>
  16. <!-- 购买换电次数弹窗 -->
  17. <view v-if="isShowToBuy" class="modal-group">
  18. <view class="fee-rules-main">
  19. <view class="fee-rules-top flex-row">
  20. <view @tap="claseShowToBuy" class="fee-rules-close">
  21. <img class="close-icon" src="https://qiniu.bms16.com/FtoTEHOJiUf_gjPCJGGHMsAtHI5M" alt="">
  22. </view>
  23. <view class="pay-moneu-view">
  24. <view class="pay-money-text">{{$t('付款金额')}}/¥</view>
  25. <view class="pay-money">{{free_price}}</view>
  26. </view>
  27. </view>
  28. <view class="fee-rules-view">
  29. <view class="fee-rules flex-row flex-between">
  30. <view class="fee-rules-title flex-row">
  31. <img class="fee-rules-icon" src="https://qiniu.bms16.com/FjJ70vT8ydLEGfeABSFYWFe-zosV"
  32. alt="">
  33. <text style="margin-left:16rpx;">{{$t('换电收费规则')}}</text>
  34. </view>
  35. <view class="fee-rules-money-view">
  36. <text class="fee-rules-money">¥{{free_price}}</text>
  37. <text>/1次</text>
  38. </view>
  39. </view>
  40. <view class="open-result-tip">{{$t('您的免费换电次数已用完,后续换电需要支付')}}</view>
  41. </view>
  42. <view class="pay-type-view">
  43. <!-- #ifdef MP-WEIXIN -->
  44. <view class="pay-view flex-row">
  45. <img class="pay-icon" src="https://qiniu.bms16.com/FkmtlfJrmGfAh9n1138KC1WloQkZ" alt="">
  46. <view class="pay-view-text">{{$t('微信支付')}}</view>
  47. <img @tap="changePayType" :data-type="0" class="wx-pay-icon"
  48. :src="payType==0?'https://qiniu.bms16.com/FhWimtmWybKlYMB6mgIReVWArbfq':'https://qiniu.bms16.com/FkmDjxBNZhFGFU5inza2usdtDlX8'"
  49. alt="">
  50. </view>
  51. <!-- #endif -->
  52. <!-- #ifdef MP-ALIPAY-->
  53. <view class="pay-view flex-row">
  54. <img class="pay-icon" src="https://qiniu.bms16.com/Fk4YmG_RbdH0LNo1s8qHKDtpCTXl" alt="">
  55. <view class="pay-view-text">{{$t('支付宝支付')}}</view>
  56. <img @tap="changePayType" :data-type="2" class="wx-pay-icon"
  57. :src="payType==2?'https://qiniu.bms16.com/FhWimtmWybKlYMB6mgIReVWArbfq':'https://qiniu.bms16.com/FkmDjxBNZhFGFU5inza2usdtDlX8'"
  58. alt="">
  59. </view>
  60. <!-- #endif -->
  61. <view class="pay-view flex-row">
  62. <img class="pay-icon" src=" https://qiniu.bms16.com/FiGNLQ5lqhEK5im_mUVgRrE8PJMB" alt="">
  63. <view class="pay-view-text">{{$t('钱包余额支付')}}(¥{{wallet_money}})</view>
  64. <img @tap="changePayType" :data-type="9" class="wx-pay-icon"
  65. :src="payType==9?'https://qiniu.bms16.com/FhWimtmWybKlYMB6mgIReVWArbfq':'https://qiniu.bms16.com/FkmDjxBNZhFGFU5inza2usdtDlX8'"
  66. alt="">
  67. </view>
  68. </view>
  69. <view class="over-btn-view">
  70. <view class="over-btn flex-row" @tap="toPayOrFreeExchange">{{$t('立即支付')}}</view>
  71. </view>
  72. </view>
  73. </view>
  74. <!-- 打开蓝牙连接弹窗 -->
  75. <view v-if="isOpenBluetooth" class="modal-group">
  76. <view class="def-alert-bluetooth">
  77. <view class="close-view flex-row"><img @tap="close" class="close-icon"
  78. src="https://qiniu.bms16.com/FtoTEHOJiUf_gjPCJGGHMsAtHI5M" alt=""></view>
  79. <view class="bluetooth-view flex-row"><img class="bluetooth-icon"
  80. src="https://qiniu.bms16.com/FjWK8ZBtxCmspiOtHJWrNEoPRA0M" alt=""></view>
  81. <view class="need-bluetooth-text">{{$t('本次换电需要连接蓝牙')}}</view>
  82. <view class="need-bluetooth-tip">{{$t('请开启手机蓝牙,点击 (蓝牙换电) 按钮')}}</view>
  83. <view class="bluetooth-connect-view">
  84. <view class="bluetooth-connect-btn" @tap="tapOpenBluetooth">{{$t('蓝牙换电')}}</view>
  85. </view>
  86. </view>
  87. </view>
  88. </view>
  89. </template>
  90. <script>
  91. var http = require('../../common/http.js');
  92. var config = require('../../common/config.js');
  93. var common = require('../../common/common.js');
  94. var storage = require('../../common/storage.js')
  95. var user = require('../../common/user.js');
  96. var bluetooth = require('../../common/bluetooth.js');
  97. const DF_CAB_INFO_DONE = 10000; //机柜信息传输完成
  98. export default {
  99. props: {
  100. car_info: {
  101. type: Array,
  102. required: true //必填项
  103. },
  104. },
  105. data() {
  106. return {
  107. blueInfo:{},//连接蓝牙需要数据
  108. isBluetooth:false,//缓存蓝牙连接状态
  109. cabinetInfo:{},//机柜信息
  110. num:0,//免费换电次数
  111. payType:0,//支付方式
  112. scan_dev_id:'',//扫码机柜编号
  113. online_status:'',//机柜在线状态
  114. isOpenBluetooth:false,
  115. license_plate_number:'',
  116. isShowToBuy:false,
  117. wallet_money:0,
  118. payResp:{},
  119. myLocations:{},
  120. orderInfo:{},
  121. carInfo:{}
  122. }
  123. }
  124. /**
  125. * 生命周期函数--监听页面加载
  126. */
  127. ,
  128. mounted: function(options) {
  129. const car_list = uni.getStorageSync('user_car_list') || null
  130. const storedLocation = uni.getStorageSync('user_current_location');
  131. if (car_list){
  132. this.license_plate_number=car_list.plate_number
  133. this.carInfo=car_list
  134. }
  135. if (storedLocation && storedLocation.longitude && storedLocation.latitude) {
  136. // 如果本地有存储的定位信息,则直接使用
  137. this.setData({
  138. myLocations: storedLocation,
  139. license_plate_number:car_list.plate_number
  140. });
  141. }
  142. //#ifdef MP-ALIPAY
  143. this.payType=2
  144. //#endif
  145. //#ifdef MP-WEIXIN
  146. this.payType=0
  147. //#endif
  148. bluetooth.initBluetooth()
  149. this.bluetoothClose()
  150. this.loadExchangeInfo()
  151. },
  152. /**
  153. * 生命周期函数--监听页面显示
  154. */
  155. onShow: function() {
  156. },
  157. methods: {
  158. navToGuild() {
  159. uni.navigateTo({
  160. url: '/pages/exchangeGuide/exchangeGuide'
  161. });
  162. },
  163. sacnBtn() {
  164. const me = this
  165. uni.scanCode({
  166. onlyFromCamera: true,
  167. scanType: [],
  168. success: function(res) {
  169. var cabinet_dev_id = '';
  170. me.loadGeneralQRData(res)
  171. if ('path' in res && res.path) {
  172. if (res.path.split('%26devid%3D').length > 1) {
  173. cabinet_dev_id = res.path.split('%26devid%3D')[1].split('%26')[0];
  174. } else if (res.path.split('&devid=').length > 1) {
  175. cabinet_dev_id = res.path.split('&devid=')[1].split('&')[0];
  176. }
  177. }
  178. if (cabinet_dev_id != '') {
  179. me.scan_dev_id = cabinet_dev_id
  180. if(me.carInfo.battery_sn&&me.carInfo.remain){
  181. me.loadNowCabinetDetail(cabinet_dev_id)
  182. }else if(!me.carInfo.battery_sn){
  183. common.simpleToast(me.$t('车辆未绑定电池'))
  184. }else if(!me.carInfo.remain){
  185. common.simpleToast(me.$t('车辆已到期,请及时前往续费'))
  186. }
  187. }
  188. },
  189. fail: function(res) {},
  190. complete: function(res) {}
  191. });
  192. },
  193. loadGeneralQRData(options, stash_sn) {
  194. let qrCode = getApp().globalData.qrCode;
  195. var url = ''
  196. if (qrCode.indexOf("https://zx.uwenya.cc/xcx/s") != -1) {
  197. getApp().globalData.qrCode = ''
  198. url = qrCode
  199. }
  200. if (('result' in options) && options.result.indexOf("https://zx.uwenya.cc/xcx/s") != -1) {
  201. url = decodeURIComponent(options.result);
  202. }
  203. if (url == '') return
  204. var obj = this.getUrlParams(url)
  205. if (('t' in obj) && ('d' in obj)) {
  206. if (obj.t == 1) {
  207. this.scan_dev_id = obj.d
  208. this.loadNowCabinetDetail(obj.d)
  209. }
  210. }
  211. },
  212. getUrlParams(url) {
  213. // 通过 ? 分割获取后面的参数字符串
  214. let urlStr = url.split('?')[1]
  215. // 创建空对象存储参数
  216. let obj = {};
  217. // 再通过 & 将每一个参数单独分割出来
  218. let paramsArr = urlStr.split('&')
  219. for (let i = 0, len = paramsArr.length; i < len; i++) {
  220. // 再通过 = 将每一个参数分割为 key:value 的形式
  221. let arr = paramsArr[i].split('=')
  222. obj[arr[0]] = arr[1];
  223. }
  224. return obj
  225. },
  226. loadNowCabinetDetail(dev_id){
  227. const timeNow=Date.now()
  228. this.scan_dev_id=dev_id
  229. //扫码机柜信息
  230. const me=this
  231. const pData={
  232. longitude:this.myLocations.longitude,
  233. latitude:this.myLocations.latitude,
  234. dev_id:dev_id||'',
  235. time:timeNow
  236. }
  237. http.postApi(config.API_DAYHIRE_CABINRT_CABINRT_INFO,pData,(resp) => {
  238. if(resp.data.code === 200) {
  239. this.online_status=resp.data.data.cabinetInfo.online_status
  240. const device = {
  241. device_type: "LSCabinet",
  242. bt_type: "",
  243. mac_id: resp.data.data.cabinetInfo.bt_mac,
  244. btid: resp.data.data.cabinetInfo.bt_mac,
  245. dev_id: resp.data.data.cabinetInfo.dev_id,
  246. key: me.decodeKey(resp.data.data.cabinetInfo.bt_sec),
  247. btkey: resp.data.data.cabinetInfo.bt_mac,
  248. bt_sec:me.decodeKey(resp.data.data.cabinetInfo.bt_sec),
  249. bt_mac:resp.data.data.cabinetInfo.bt_mac
  250. }
  251. me.setData({
  252. blueInfo: device,
  253. cabinetInfo:resp.data.data.cabinetInfo
  254. })
  255. me.bluetoothClose()
  256. if(me.online_status == 1){
  257. if(me.num==0){
  258. me.setData({
  259. isShowToBuy:true
  260. })
  261. me.walletInfo()
  262. }else{
  263. me.toPayOrFreeExchange()
  264. }
  265. }else{
  266. me.setData({
  267. isOpenBluetooth:true
  268. })
  269. }
  270. }else{
  271. common.simpleToast(resp.data.msg)
  272. }
  273. })
  274. },
  275. walletInfo() {
  276. const me = this
  277. http.postApi(config.API_DAYHIRE_USER_WALLET_INFO, {}, function(resp) {
  278. if (resp.data.code === 200) {
  279. // me.wallet_money = (resp.data.data.balance / 100).toFixed(2)
  280. if(me.free_price <= (resp.data.data.balance / 100).toFixed(2)){
  281. me.payType=9
  282. }
  283. me.setData({
  284. wallet_money:(resp.data.data.balance / 100).toFixed(2)
  285. })
  286. } else {
  287. common.simpleToast(resp.data.msg)
  288. }
  289. })
  290. },
  291. toPayOrFreeExchange(){
  292. //购买单次换电次数进行换电或者有免费次数直接换电
  293. const me=this
  294. //#ifdef MP-ALIPAY
  295. const from = 'ali'
  296. //#endif
  297. //#ifdef MP-WEIXIN
  298. const from = 'wx'
  299. //#endif
  300. const pData={
  301. dev_id:this.scan_dev_id,
  302. license_plate_number:this.license_plate_number,
  303. pay_type:this.payType,
  304. from:from
  305. }
  306. //如果在线用机柜换电 不在线用蓝牙换电
  307. const url = this.online_status == 1 ? config.API_DAYHIRE_CABINRT_CHANGE_BATTERY : config.API_DAYHIRE_CABINRT_BLUETOOTH_EXCHANGE
  308. http.postApi(url,pData,(resp) => {
  309. if(resp.data.code === 200) {
  310. // 钱包支付不需要支付直接换电 有换电次数可以直接换电
  311. if (!resp.data.data.need_pay) {
  312. me.orderInfo = {
  313. order_sn: resp.data.data.order_sn,
  314. empty_door_id: resp.data.data.empty_door_id,
  315. full_door_id: resp.data.data.full_door_id,
  316. cabbatterysn: resp.data.data.rtn_battery_sn||''
  317. };
  318. me.navOpenCabinet(me.orderInfo)
  319. }
  320. else {
  321. me.setData({
  322. isShowToBuy:false
  323. })
  324. me.wxPayPrice=resp.data.data.price
  325. me.payResp=resp
  326. me.doPayBattery({})
  327. }
  328. }else{
  329. common.simpleToast(resp.data.msg)
  330. }
  331. })
  332. },
  333. doPayBattery: function (pData) {
  334. const me = this
  335. //#ifdef MP-WEIXIN
  336. var payParams = JSON.parse(this.payResp.data.data.payParams);
  337. var order_sn = this.payResp.data.data.order_sn;
  338. user.wxPay(order_sn, payParams, function (isSuccess) {
  339. if (isSuccess) {
  340. common.simpleToast(me.$t('支付成功'))
  341. //跳转换电流程页面
  342. me.orderInfo = {
  343. order_sn: me.payResp.data.data.order_sn,
  344. empty_door_id: me.payResp.data.data.empty_door_id,
  345. full_door_id: me.payResp.data.data.full_door_id,
  346. cabbatterysn: me.payResp.data.data.rtn_battery_sn||''
  347. };
  348. me.navOpenCabinet(me.orderInfo)
  349. }
  350. else {
  351. user.cancelHirePay(order_sn)
  352. // 取消支付
  353. }
  354. });
  355. //#endif
  356. //#ifdef MP-ALIPAY
  357. my.tradePay({
  358. tradeNO: me.payResp.data.data.trade_no,
  359. success: function(res) {
  360. if (res.resultCode == 9000) {
  361. common.simpleToast(me.$t('支付成功'))
  362. me.orderInfo = {
  363. order_sn: me.payResp.data.data.order_sn,
  364. empty_door_id: me.payResp.data.data.empty_door_id,
  365. full_door_id: me.payResp.data.data.full_door_id,
  366. cabbatterysn: me.payResp.data.data.rtn_battery_sn||''
  367. };
  368. me.navOpenCabinet(me.orderInfo)
  369. } else {
  370. user.cancelHirePay(order_sn)
  371. }
  372. },
  373. });
  374. //#endif
  375. },
  376. tapOpenBluetooth(time = null) {
  377. const me = this
  378. const device = me.blueInfo
  379. // 蓝牙换电按钮 加载蓝牙
  380. this.loadBluetooth()
  381. },
  382. loadBluetooth() {
  383. const me = this;
  384. const device = this.blueInfo;
  385. if (bluetooth.acceptDevice(device)) {
  386. // 打开蓝牙连接
  387. bluetooth.openBluetoothAdapter((res) => {
  388. common.loading()
  389. bluetooth.connectDevice(device,() => {
  390. bluetooth.onCharacteristicStateChange(device.mac_id, 'index', (data) => {
  391. if (JSON.stringify(data) != '{}') {
  392. if (data.state === DF_CAB_INFO_DONE) {
  393. me.reportCabintInfo(me.cabinetInfo.dev_id, data.commandList);
  394. uni.hideLoading();
  395. common.simpleToast(me.$t('蓝牙连接成功'))
  396. me.setData({
  397. isOpenBluetooth: false,
  398. isBluetooth:true
  399. });
  400. // 进行机柜蓝牙换电 API_DAYHIRE_CABINRT_BLUETOOTH_CHANGE_BATTERY
  401. if(me.num==0){
  402. me.setData({
  403. isShowToBuy:true
  404. })
  405. me.walletInfo()
  406. }else{
  407. me.toPayOrFreeExchange()
  408. }
  409. }
  410. }
  411. });
  412. bluetooth.onConnectionStateChange(device.mac_id, 'index', (res) => {
  413. uni.hideLoading();
  414. if (!res.connected) {
  415. // 蓝牙未连接
  416. // common.simpleToast('蓝牙连接断开',2000)
  417. me.setData({
  418. isOpenBluetooth: true,
  419. isBluetooth:false
  420. });
  421. } else {
  422. common.simpleToast(me.$t('蓝牙连接成功'),2000)
  423. // 蓝牙已连接
  424. me.setData({
  425. isOpenBluetooth: false,
  426. isBluetooth:true
  427. });
  428. if(me.num==0){
  429. me.setData({
  430. isShowToBuy:true
  431. })
  432. me.walletInfo()
  433. }else{
  434. me.toPayOrFreeExchange()
  435. }
  436. }
  437. });
  438. bluetooth.sendGetCabinetInfoCommand(
  439. device.mac_id,
  440. device,
  441. (res) => {
  442. common.loading();
  443. },
  444. (res) => {
  445. me.setData({
  446. isOpenBluetooth: false
  447. });
  448. uni.showModal({
  449. title: me.$t('提示'),
  450. confirmText: me.$t('重新连接'),
  451. content: me.$t('连接失败,请尝试重新连接'),
  452. success: function(res) {
  453. if (res.confirm) {
  454. me.loadBluetooth();
  455. } else {
  456. // uni.navigateBack({
  457. // delta: 1
  458. // });
  459. }
  460. }
  461. });
  462. }
  463. );
  464. },
  465. (res) => {
  466. uni.hideLoading();
  467. var showContent = ""
  468. if (res && ("errCode" in res)) {
  469. if (res.errCode == 9000001) {
  470. var showContent= me.$t('观察周围是否有其他骑手连接,请等待对方完成') + me.$t('或') + me.$t('微信是否开启了蓝牙权限')!!
  471. }else{
  472. var showContent= me.$t('连接失败,请尝试重新连接')
  473. }
  474. }
  475. else {
  476. var showContent= me.$t('连接失败,请尝试重新连接')
  477. }
  478. me.setData({
  479. isOpenBluetooth: false,
  480. isBluetooth:false
  481. });
  482. uni.showModal({
  483. title: me.$t('提示'),
  484. confirmText: me.$t('重新连接'),
  485. content: showContent,
  486. success: function(res) {
  487. if (res.confirm) {
  488. me.loadBluetooth();
  489. } else {
  490. // uni.navigateBack({
  491. // delta: 1
  492. // });
  493. }
  494. }
  495. });
  496. },(res) => {
  497. uni.hideLoading();
  498. me.setData({
  499. isOpenBluetooth: false
  500. });
  501. uni.showModal({
  502. title: me.$t('提示'),
  503. confirmText: me.$t('我知道了'),
  504. content: me.$t('蓝牙未打开或请在右上角设置授权小程序使用蓝牙'),
  505. success: function(res) {
  506. if (res.confirm) {
  507. me.loadBluetooth();
  508. } else {
  509. // uni.navigateBack({
  510. // delta: 1
  511. // });
  512. }
  513. }
  514. });
  515. }
  516. );
  517. },
  518. );
  519. } else {
  520. //蓝牙连接未成功
  521. uni.hideLoading();
  522. uni.showModal({
  523. confirmText: me.$t('我知道了'),
  524. content: me.$t('当前机柜未找到符合的蓝牙类型'),
  525. showCancel: false,
  526. title: me.$t('提示'),
  527. complete: (res) => {
  528. // uni.navigateBack({
  529. // delta: 1
  530. // });
  531. }
  532. });
  533. }
  534. },
  535. reportCabintInfo(dev_id, list){
  536. var pushList = []
  537. for (var i = 0; list.length > i; i++) {
  538. var sublist = []
  539. for (var j = 0; list[i].length > j; j++) {
  540. sublist.push(parseInt(list[i][j]))
  541. }
  542. pushList.push(sublist)
  543. }
  544. const pData = {
  545. dev_id: dev_id,
  546. data: JSON.stringify(pushList)
  547. }
  548. const me = this
  549. http.postApi(config.API_CABINET_BLUETOOTH_INFO, pData, function (response) {
  550. if (response.data.code === 200) {
  551. // me.setData({
  552. // cabinetInfo: response.data.data.cabinetInfo
  553. // })
  554. } else {
  555. simpleToast(response.data.msg)
  556. }
  557. })
  558. },
  559. navOpenCabinet(pdata){
  560. const me=this
  561. const paramsString = JSON.stringify(pdata)
  562. const cabinetInfoString = JSON.stringify(me.cabinetInfo)
  563. // 跳转机柜换电页面-展示换电流程和结果
  564. uni.navigateTo({
  565. url: '/pages/openCabinet/openCabinet?pdata=' + encodeURIComponent(paramsString)+ '&cabinet_info=' + encodeURIComponent(cabinetInfoString),
  566. success: function(res) {},
  567. fail: function(res) {},
  568. complete: function(res) {},
  569. })
  570. },
  571. loadExchangeInfo() {
  572. // 查询免费换电次数/换电价格
  573. const pData = {
  574. license_plate_number: this.license_plate_number
  575. }
  576. http.postApi(config.API_DAYHIRE_CABINRT_BATTERY_EXCHANGE_INFO, pData, (resp) => {
  577. if (resp.data.code === 200) {
  578. this.setData({
  579. num: resp.data.data.last_free_number,
  580. free_price: (resp.data.data.price / 100).toFixed(2),
  581. })
  582. } else {
  583. common.simpleToast(resp.data.msg)
  584. }
  585. })
  586. },
  587. bluetoothClose: function() {
  588. bluetooth.closeBluetoothAdapter();
  589. bluetooth.closeDevice(
  590. this.cabinetInfo.bt_mac,
  591. () => {
  592. // this.setData({
  593. // bt_loading: false
  594. // });
  595. },
  596. () => {}
  597. );
  598. bluetooth.offCharacteristicStateChange(this.cabinetInfo.bt_mac, 'home');
  599. bluetooth.offConnectionStateChange(this.cabinetInfo.bt_mac, 'home');
  600. },
  601. changePayType(e){
  602. const type = e.currentTarget.dataset.type
  603. if(this.wallet_money<this.free_price){
  604. common.simpleToast(this.$t('钱包余额不足'))
  605. return
  606. }
  607. this.setData({
  608. payType: type
  609. })
  610. },
  611. close() {
  612. this.setData({
  613. isOpenBluetooth:false
  614. })
  615. },
  616. claseShowToBuy() {
  617. this.setData({
  618. isShowToBuy:false
  619. })
  620. },
  621. decodeKey(str) {
  622. var val = []
  623. for (var i = 0; i < str.length / 2; i++) {
  624. val.push(parseInt(str.substring(0 + i * 2, 2 + i * 2), 16))
  625. }
  626. var str = ""
  627. for (var i = 0; val.length > i; i++) {
  628. str += String.fromCharCode(~val[i] & 0xff)
  629. }
  630. return str
  631. },
  632. }
  633. };
  634. </script>
  635. <style>
  636. @import './scanBtn.css';
  637. </style>