From 0d2024eabd0f07bc4ab3341dddc10464d31938f8 Mon Sep 17 00:00:00 2001 From: skyouc Date: 星期六, 21 十二月 2024 18:47:12 +0800 Subject: [PATCH] #新增订单筛选物料界面 --- common/bluetooth.js | 620 ++++++++++++++++++++++++++++---------------------------- 1 files changed, 310 insertions(+), 310 deletions(-) diff --git a/common/bluetooth.js b/common/bluetooth.js index de8025a..9ca67fc 100644 --- a/common/bluetooth.js +++ b/common/bluetooth.js @@ -1,310 +1,310 @@ -import Vue from 'vue'; -let main, Context, BManager, BluetoothAdapter, BAdapter, BluetoothDevice, IntentFilter; -import {SET_INFODATA,SET_CONNECTBLEDATA} from '@/store/actionsType.js'; -import {GET_CONNECTBLEDATA} from '@/store/gettersType.js'; -/** - * 钃濈墮鍒濆鍖栧拰娉ㄥ唽 - */ -Vue.prototype.$init_bluetooth = function(){ - console.log('钃濈墮鍒濆鍖�'); - let _this = this; - //鑾峰彇android搴旂敤Activity娲诲姩瀵硅薄 - main = plus.android.runtimeMainActivity(); - //寮曞叆Context绫� - Context = plus.android.importClass("android.content.Context"); - // Context.BLUETOOTH_SERVICE 鑾峰彇Context绫荤殑闈欐�佸父閲�(钃濈墮鏈嶅姟锛岃幏鍙朆luetoothManager锛屼互浣跨敤钃濈墮) - BManager = main.getSystemService(Context.BLUETOOTH_SERVICE); - //鑾峰彇钃濈墮閫傞厤鍣ㄥ璞$被 - BluetoothAdapter = plus.android.importClass("android.bluetooth.BluetoothAdapter"); - //钃濈墮鏈湴閫傞厤鍣�(瀵硅薄) - BAdapter = BluetoothAdapter.getDefaultAdapter(); - //寮曞叆钃濈墮璁惧绫�(鍒涘缓涓庣浉搴旇澶囩殑杩炴帴鎴栨煡璇㈡湁鍏宠璁惧鐨勪俊鎭紝渚嬪鍚嶇О锛屽湴鍧�锛岀被鍜岀粦瀹氱姸鎬�) - BluetoothDevice = plus.android.importClass('android.bluetooth.BluetoothDevice'); - //寮曞叆杩囨护鍣ㄧ被 (IntentFilter鍙互鍖归厤Intent涓殑鍔ㄤ綔,绫诲埆,鏁版嵁) - IntentFilter = plus.android.importClass('android.content.IntentFilter'); -} -/** - * 妫�鏌ヨ摑鐗欐槸鍚﹀紑鍚� - * 1.鐢ㄦ埛娌℃湁寮�鍚�,鎻愮ず寮�鍚� - * 2.鐢ㄦ埛钃濈墮宸茬粡寮�鍚� - */ -Vue.prototype.$check_bluetooth_open = function(){ - let _this = this; - /** - * BAdapter.isEnabled(); 鍒ゆ柇钃濈墮鏄惁鎵撳紑 - * BAdapter.enable(); //寮�鍚摑鐗� - * BAdapter.disable(); //鍏抽棴钃濈墮 - */ - return new Promise((resolve,reject)=>{ - if (!BAdapter.isEnabled()) { - //钃濈墮鏈墦寮� - uni.showModal({ - title:"鎻愮ず", - content:"钃濈墮鏈紑鍚�,鏄惁寮�鍚摑鐗檦", - success:function(res){ - if (res.confirm) { - //寮�鍚摑鐗� - BAdapter.enable(); - resolve(true); - }else if(res.cancel){ - resolve(false); - } - } - }) - // 鍚庣画鎻愮ず妗嗘彁绀烘垨鐢ㄦ埛鎵嬪姩鎵撳紑 - } else { - //钃濈墮宸叉墦寮� - resolve(true); - } - }) -} - -/** - * 妫�娴嬫墜鏈烘槸鍚﹀凡缁忚繛鎺ヨ摑鐗欒澶� - */ -Vue.prototype.$check_bluetooth_connect = function(){ - let _this = this; - // 鍏堟竻绌簐uex鍘熸潵宸叉湁鐨勬暟鎹� - _this.$store.dispatch(SET_CONNECTBLEDATA,[]); - return new Promise((resolve,reject)=>{ - // 鑾峰彇android搴旂敤宸查厤瀵圭殑钃濈墮璁惧绫� - let lists = BAdapter.getBondedDevices(); - // 寮曞叆绫� - plus.android.importClass(lists); - // 鑾峰彇宸查厤瀵硅摑鐗欒澶囩殑涓暟 - let len = lists.size(); - // iterator() 鎶婁竴涓鍣ㄧ殑鎵�鏈夊璞★紝鍋氭垚涓�涓嚎鎬ц〃锛圠ist锛夛紝鑰宨terator鏈韩鏄竴涓寚閽� - let iterator = lists.iterator(); - // console.log(iterator.hasNext()); - plus.android.importClass(iterator); - /** - * iterator.hasNext() true濡傛灉杩唬鍏锋湁鏇村鍏冪礌 - * iterator.next() 鏀惧洖杩唬涓殑涓嬩竴涓厓绱� - * iterator.remove() 浠庡熀纭�闆嗗悎涓Щ闄ゆ杩唬鍣ㄨ繑鍥炵殑鏈�鍚庝竴涓厓绱�(鍙�夋搷浣�) - */ - while (iterator.hasNext()) { - let d = iterator.next(); - plus.android.importClass(d); - let matchList = { - name: d.getName(), - mac: d.getAddress() - } - console.log(matchList); - _this.$store.dispatch(SET_CONNECTBLEDATA,matchList); - resolve({code:true,msg:matchList}); - } - - //鑾峰彇涓�涓凡杩炴帴鐨勮澶� - // plus.android.importClass(BManager); //寮曞叆鐩稿叧鐨刴ethod鍑芥暟 - // //钃濈墮閫傞厤鍣� - // let BAdapter = BManager.getAdapter(); - // // console.log(BAdapter); - // plus.android.importClass(BAdapter); //寮曞叆鐩稿叧鐨刴ethod鍑芥暟锛岃繖鏍蜂箣鍚庢墠浼氭湁isEna; - // let lists = BAdapter.getBondedDevices(); - // // console.log(lists); - // plus.android.importClass(lists); - // let iterator = lists.iterator(); - // // console.log(iterator); - // plus.android.importClass(iterator); - // // console.log(iterator.hasNext()); - // if(iterator.hasNext()){ //鍒ゆ柇涓嬩竴涓厓绱犵殑鏈夋棤 - // let d = iterator.next(); - // plus.android.importClass(d); - // //宸茶繛鎺ヨ摑鐗欑殑鏁版嵁 - // // console.log(d.getAddress()); - // console.log(d.getAddress() + "----" + d.getName()); - // // _this.match_list = { - // // name: d.getName(), - // // mac: d.getAddress() - // // }; - // let matchList = { - // name: d.getName(), - // mac: d.getAddress() - // } - // _this.$store.dispatch(SET_CONNECTBLEDATA,matchList); - // // console.log(_this.$store.getters.GET_CONNECTBLEDATA) - // /** - // * 杩炴帴鎵撳嵃鏈� - // */ - // resolve({code:true,msg:matchList}); - // }else{ - // resolve({code:false}) - // } - }) -} -/** - * 鎵撳紑钃濈墮 - */ -Vue.prototype.$open_bluetooth = function(){ - let _this = this; - return new Promise((resolve,reject)=>{ - if (!BAdapter.isEnabled()) { - BAdapter.enable(); //鍚姩钃濈墮 - uni.showToast({ - icon: "none", - title: '钃濈墮宸叉墦寮�', - duration: 3000 - }) - resolve(true); - } - }) -} -/** - * 鍏抽棴钃濈墮 - */ -Vue.prototype.$close_bluetooth = function (){ - let _this = this; - if (BAdapter.isEnabled()) { - BAdapter.disable(); //鍏抽棴钃濈墮 - uni.showToast({ - icon: "none", - title: '钃濈墮宸插叧闂�', - duration: 2000 - }) - } else { - uni.showToast({ - icon: "none", - title: '钃濈墮宸插叧闂�', - duration: 2000 - }) - } -} -/** - * 鎼滅储钃濈墮璁惧 - */ -Vue.prototype.$search_bluetooth = function(){ - let _this = this; - let obj = {}; - return new Promise((resolve,reject)=>{ - // console.log(BAdapter.isEnabled()); - // console.log(JSON.stringify(_this.$store.getters)); - // BAdapter.isconnect("DC:1D:30:7C:74:96"); - //鍒ゆ柇钃濈墮鏄惁寮�鍚� - if(!BAdapter.isEnabled()) { - uni.showModal({ - title:"鎻愮ず", - content:"钃濈墮鏈紑鍚�,鏄惁寮�鍚摑鐗檦", - success:function(res){ - if (res.confirm) { - console.log('鐢ㄦ埛鐐瑰嚮纭畾'); - obj.code = false; //鐢ㄦ埛鐐瑰嚮纭畾,寮�鍚摑鐗� - obj.msg = "钃濈墮鏈紑鍚�"; - resolve(obj); - // _this.$open_bluetooth(); - }else if(res.cancel){ - // resolve() - obj.code = null; - resolve(obj); - } - } - }) - }else{ - obj.code = true; - obj.msg = "寮�鍚悳绱㈣摑鐗�"; - resolve(obj); - } - }) -} -/** - * 鐩戝惉钃濈墮璁惧淇℃伅 - */ -Vue.prototype.$search_pipei=function(){ - let timer = null; - let _this = this; - //鎻愮ず钃濈墮寮�鍚潈闄愯闂� - uni.openBluetoothAdapter({ - success(res) { - if (res.errMsg === "openBluetoothAdapter:ok") { - //杩欓噷鏄紑鍚摑鐗欐悳瀵� - uni.startBluetoothDevicesDiscovery({ - success: (res) => { - console.log('startBluetoothDevicesDiscovery success', res) - uni.showLoading({ - title: "钃濈墮鎼滅储涓�...", - mask: true - }) - //姣忔鎼滅储閮芥妸涔嬪墠鐨勬竻绌� - // _this.bArray = []; - // _this.no_match_list = []; - _this.$store.dispatch(SET_INFODATA,[]); - let bArray = []; //鐢ㄤ簬钃濈墮鍘婚噸 - let filter = new IntentFilter(); //瀹炰緥鍖栬繃婊ゅ櫒绫� - let BDevice = new BluetoothDevice(); //瀹炰緥鍖栬摑鐗欒澶囩被 - // let connect = _this.$store.state.Bluetooth.connectBLEData; - // console.log("宸茶繛鎺�:" + JSON.stringify(connect)); - BAdapter.startDiscovery(); //寮�鍚悳绱� - let receiver = plus.android.implements('io.dcloud.android.content.BroadcastReceiver', { - onReceive: function(context, intent) { //鍥炶皟 - try { - plus.android.importClass(intent); - if (intent.getAction() == "android.bluetooth.adapter.action.DISCOVERY_FINISHED") { - main.unregisterReceiver(receiver); //鍙栨秷鐩戝惉 - } else { - // Intent涓幏鍙栬澶囧璞� - BDevice = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE); - console.log(BDevice.getName() + "---" + BDevice.getAddress()); - // 鍒ゆ柇濡傛灉钃濈墮娌℃湁鍚嶇О鍒欎笉鏄剧ず - if (BDevice.getName() !== null) { - //钃濈墮鍘婚噸 - let address = BDevice.getAddress(); - //宸茬粡杩炴帴鐨勮摑鐗� - if(bArray.indexOf(address) == -1){ - bArray.push(address); - _this.$store.dispatch(SET_INFODATA,{ - name: BDevice.getName(), - mac: BDevice.getAddress() - }) - } - } - //濡傛灉intent涓虹┖鍒欏彇娑堣摑鐗欑洃鍚� - if (BDevice == null) { - main.unregisterReceiver(receiver); //鍙栨秷鐩戝惉 - uni.hideLoading() - //鑾峰彇宸插尮閰嶇殑钃濈墮 - // that.bluetooth_list() - return; - } - if(timer != null){ - clearTimeout(timer); - } - timer = setTimeout(()=>{ - main.unregisterReceiver(receiver); //鍙栨秷鐩戝惉 - uni.hideLoading(); - },3000); - } - } catch (e) { - uni.showToast({ - icon: "none", - title: "钃濈墮鎼滃閿欒~", - duration: 3000, - mask: true - }) - } - } - }); - - filter.addAction(BDevice.ACTION_FOUND); //鍙彂鐜� - filter.addAction(BAdapter.ACTION_DISCOVERY_STARTED); - filter.addAction(BAdapter.ACTION_DISCOVERY_FINISHED); //鎼滅储缁撴灉 - filter.addAction(BAdapter.ACTION_STATE_CHANGED); - main.registerReceiver(receiver, filter); //娉ㄥ唽鐩戝惉 - }, - fail: (err) => { - uni.showToast({ - icon: "none", - title: "钃濈墮鎼滃澶辫触~", - duration: 3000, - mask: true - }) - } - }) - } - }, - fail(err) { - uni.showToast({ - icon: "none", - title: "钃濈墮鎼滅储澶辫触" - }) - } - }) -} +import Vue from 'vue'; +let main, Context, BManager, BluetoothAdapter, BAdapter, BluetoothDevice, IntentFilter; +import {SET_INFODATA,SET_CONNECTBLEDATA} from '@/store/actionsType.js'; +import {GET_CONNECTBLEDATA} from '@/store/gettersType.js'; +/** + * 钃濈墮鍒濆鍖栧拰娉ㄥ唽 + */ +Vue.prototype.$init_bluetooth = function(){ + console.log('钃濈墮鍒濆鍖�'); + let _this = this; + //鑾峰彇android搴旂敤Activity娲诲姩瀵硅薄 + main = plus.android.runtimeMainActivity(); + //寮曞叆Context绫� + Context = plus.android.importClass("android.content.Context"); + // Context.BLUETOOTH_SERVICE 鑾峰彇Context绫荤殑闈欐�佸父閲�(钃濈墮鏈嶅姟锛岃幏鍙朆luetoothManager锛屼互浣跨敤钃濈墮) + BManager = main.getSystemService(Context.BLUETOOTH_SERVICE); + //鑾峰彇钃濈墮閫傞厤鍣ㄥ璞$被 + BluetoothAdapter = plus.android.importClass("android.bluetooth.BluetoothAdapter"); + //钃濈墮鏈湴閫傞厤鍣�(瀵硅薄) + BAdapter = BluetoothAdapter.getDefaultAdapter(); + //寮曞叆钃濈墮璁惧绫�(鍒涘缓涓庣浉搴旇澶囩殑杩炴帴鎴栨煡璇㈡湁鍏宠璁惧鐨勪俊鎭紝渚嬪鍚嶇О锛屽湴鍧�锛岀被鍜岀粦瀹氱姸鎬�) + BluetoothDevice = plus.android.importClass('android.bluetooth.BluetoothDevice'); + //寮曞叆杩囨护鍣ㄧ被 (IntentFilter鍙互鍖归厤Intent涓殑鍔ㄤ綔,绫诲埆,鏁版嵁) + IntentFilter = plus.android.importClass('android.content.IntentFilter'); +} +/** + * 妫�鏌ヨ摑鐗欐槸鍚﹀紑鍚� + * 1.鐢ㄦ埛娌℃湁寮�鍚�,鎻愮ず寮�鍚� + * 2.鐢ㄦ埛钃濈墮宸茬粡寮�鍚� + */ +Vue.prototype.$check_bluetooth_open = function(){ + let _this = this; + /** + * BAdapter.isEnabled(); 鍒ゆ柇钃濈墮鏄惁鎵撳紑 + * BAdapter.enable(); //寮�鍚摑鐗� + * BAdapter.disable(); //鍏抽棴钃濈墮 + */ + return new Promise((resolve,reject)=>{ + if (!BAdapter.isEnabled()) { + //钃濈墮鏈墦寮� + uni.showModal({ + title:"鎻愮ず", + content:"钃濈墮鏈紑鍚�,鏄惁寮�鍚摑鐗檦", + success:function(res){ + if (res.confirm) { + //寮�鍚摑鐗� + BAdapter.enable(); + resolve(true); + }else if(res.cancel){ + resolve(false); + } + } + }) + // 鍚庣画鎻愮ず妗嗘彁绀烘垨鐢ㄦ埛鎵嬪姩鎵撳紑 + } else { + //钃濈墮宸叉墦寮� + resolve(true); + } + }) +} + +/** + * 妫�娴嬫墜鏈烘槸鍚﹀凡缁忚繛鎺ヨ摑鐗欒澶� + */ +Vue.prototype.$check_bluetooth_connect = function(){ + let _this = this; + // 鍏堟竻绌簐uex鍘熸潵宸叉湁鐨勬暟鎹� + _this.$store.dispatch(SET_CONNECTBLEDATA,[]); + return new Promise((resolve,reject)=>{ + // 鑾峰彇android搴旂敤宸查厤瀵圭殑钃濈墮璁惧绫� + let lists = BAdapter.getBondedDevices(); + // 寮曞叆绫� + plus.android.importClass(lists); + // 鑾峰彇宸查厤瀵硅摑鐗欒澶囩殑涓暟 + let len = lists.size(); + // iterator() 鎶婁竴涓鍣ㄧ殑鎵�鏈夊璞★紝鍋氭垚涓�涓嚎鎬ц〃锛圠ist锛夛紝鑰宨terator鏈韩鏄竴涓寚閽� + let iterator = lists.iterator(); + // console.log(iterator.hasNext()); + plus.android.importClass(iterator); + /** + * iterator.hasNext() true濡傛灉杩唬鍏锋湁鏇村鍏冪礌 + * iterator.next() 鏀惧洖杩唬涓殑涓嬩竴涓厓绱� + * iterator.remove() 浠庡熀纭�闆嗗悎涓Щ闄ゆ杩唬鍣ㄨ繑鍥炵殑鏈�鍚庝竴涓厓绱�(鍙�夋搷浣�) + */ + while (iterator.hasNext()) { + let d = iterator.next(); + plus.android.importClass(d); + let matchList = { + name: d.getName(), + mac: d.getAddress() + } + console.log(matchList); + _this.$store.dispatch(SET_CONNECTBLEDATA,matchList); + resolve({code:true,msg:matchList}); + } + + //鑾峰彇涓�涓凡杩炴帴鐨勮澶� + // plus.android.importClass(BManager); //寮曞叆鐩稿叧鐨刴ethod鍑芥暟 + // //钃濈墮閫傞厤鍣� + // let BAdapter = BManager.getAdapter(); + // // console.log(BAdapter); + // plus.android.importClass(BAdapter); //寮曞叆鐩稿叧鐨刴ethod鍑芥暟锛岃繖鏍蜂箣鍚庢墠浼氭湁isEna; + // let lists = BAdapter.getBondedDevices(); + // // console.log(lists); + // plus.android.importClass(lists); + // let iterator = lists.iterator(); + // // console.log(iterator); + // plus.android.importClass(iterator); + // // console.log(iterator.hasNext()); + // if(iterator.hasNext()){ //鍒ゆ柇涓嬩竴涓厓绱犵殑鏈夋棤 + // let d = iterator.next(); + // plus.android.importClass(d); + // //宸茶繛鎺ヨ摑鐗欑殑鏁版嵁 + // // console.log(d.getAddress()); + // console.log(d.getAddress() + "----" + d.getName()); + // // _this.match_list = { + // // name: d.getName(), + // // mac: d.getAddress() + // // }; + // let matchList = { + // name: d.getName(), + // mac: d.getAddress() + // } + // _this.$store.dispatch(SET_CONNECTBLEDATA,matchList); + // // console.log(_this.$store.getters.GET_CONNECTBLEDATA) + // /** + // * 杩炴帴鎵撳嵃鏈� + // */ + // resolve({code:true,msg:matchList}); + // }else{ + // resolve({code:false}) + // } + }) +} +/** + * 鎵撳紑钃濈墮 + */ +Vue.prototype.$open_bluetooth = function(){ + let _this = this; + return new Promise((resolve,reject)=>{ + if (!BAdapter.isEnabled()) { + BAdapter.enable(); //鍚姩钃濈墮 + uni.showToast({ + icon: "none", + title: '钃濈墮宸叉墦寮�', + duration: 3000 + }) + resolve(true); + } + }) +} +/** + * 鍏抽棴钃濈墮 + */ +Vue.prototype.$close_bluetooth = function (){ + let _this = this; + if (BAdapter.isEnabled()) { + BAdapter.disable(); //鍏抽棴钃濈墮 + uni.showToast({ + icon: "none", + title: '钃濈墮宸插叧闂�', + duration: 2000 + }) + } else { + uni.showToast({ + icon: "none", + title: '钃濈墮宸插叧闂�', + duration: 2000 + }) + } +} +/** + * 鎼滅储钃濈墮璁惧 + */ +Vue.prototype.$search_bluetooth = function(){ + let _this = this; + let obj = {}; + return new Promise((resolve,reject)=>{ + // console.log(BAdapter.isEnabled()); + // console.log(JSON.stringify(_this.$store.getters)); + // BAdapter.isconnect("DC:1D:30:7C:74:96"); + //鍒ゆ柇钃濈墮鏄惁寮�鍚� + if(!BAdapter.isEnabled()) { + uni.showModal({ + title:"鎻愮ず", + content:"钃濈墮鏈紑鍚�,鏄惁寮�鍚摑鐗檦", + success:function(res){ + if (res.confirm) { + console.log('鐢ㄦ埛鐐瑰嚮纭畾'); + obj.code = false; //鐢ㄦ埛鐐瑰嚮纭畾,寮�鍚摑鐗� + obj.msg = "钃濈墮鏈紑鍚�"; + resolve(obj); + // _this.$open_bluetooth(); + }else if(res.cancel){ + // resolve() + obj.code = null; + resolve(obj); + } + } + }) + }else{ + obj.code = true; + obj.msg = "寮�鍚悳绱㈣摑鐗�"; + resolve(obj); + } + }) +} +/** + * 鐩戝惉钃濈墮璁惧淇℃伅 + */ +Vue.prototype.$search_pipei=function(){ + let timer = null; + let _this = this; + //鎻愮ず钃濈墮寮�鍚潈闄愯闂� + uni.openBluetoothAdapter({ + success(res) { + if (res.errMsg === "openBluetoothAdapter:ok") { + //杩欓噷鏄紑鍚摑鐗欐悳瀵� + uni.startBluetoothDevicesDiscovery({ + success: (res) => { + console.log('startBluetoothDevicesDiscovery success', res) + uni.showLoading({ + title: "钃濈墮鎼滅储涓�...", + mask: true + }) + //姣忔鎼滅储閮芥妸涔嬪墠鐨勬竻绌� + // _this.bArray = []; + // _this.no_match_list = []; + _this.$store.dispatch(SET_INFODATA,[]); + let bArray = []; //鐢ㄤ簬钃濈墮鍘婚噸 + let filter = new IntentFilter(); //瀹炰緥鍖栬繃婊ゅ櫒绫� + let BDevice = new BluetoothDevice(); //瀹炰緥鍖栬摑鐗欒澶囩被 + // let connect = _this.$store.state.Bluetooth.connectBLEData; + // console.log("宸茶繛鎺�:" + JSON.stringify(connect)); + BAdapter.startDiscovery(); //寮�鍚悳绱� + let receiver = plus.android.implements('io.dcloud.android.content.BroadcastReceiver', { + onReceive: function(context, intent) { //鍥炶皟 + try { + plus.android.importClass(intent); + if (intent.getAction() == "android.bluetooth.adapter.action.DISCOVERY_FINISHED") { + main.unregisterReceiver(receiver); //鍙栨秷鐩戝惉 + } else { + // Intent涓幏鍙栬澶囧璞� + BDevice = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE); + console.log(BDevice.getName() + "---" + BDevice.getAddress()); + // 鍒ゆ柇濡傛灉钃濈墮娌℃湁鍚嶇О鍒欎笉鏄剧ず + if (BDevice.getName() !== null) { + //钃濈墮鍘婚噸 + let address = BDevice.getAddress(); + //宸茬粡杩炴帴鐨勮摑鐗� + if(bArray.indexOf(address) == -1){ + bArray.push(address); + _this.$store.dispatch(SET_INFODATA,{ + name: BDevice.getName(), + mac: BDevice.getAddress() + }) + } + } + //濡傛灉intent涓虹┖鍒欏彇娑堣摑鐗欑洃鍚� + if (BDevice == null) { + main.unregisterReceiver(receiver); //鍙栨秷鐩戝惉 + uni.hideLoading() + //鑾峰彇宸插尮閰嶇殑钃濈墮 + // that.bluetooth_list() + return; + } + if(timer != null){ + clearTimeout(timer); + } + timer = setTimeout(()=>{ + main.unregisterReceiver(receiver); //鍙栨秷鐩戝惉 + uni.hideLoading(); + },3000); + } + } catch (e) { + uni.showToast({ + icon: "none", + title: "钃濈墮鎼滃閿欒~", + duration: 3000, + mask: true + }) + } + } + }); + + filter.addAction(BDevice.ACTION_FOUND); //鍙彂鐜� + filter.addAction(BAdapter.ACTION_DISCOVERY_STARTED); + filter.addAction(BAdapter.ACTION_DISCOVERY_FINISHED); //鎼滅储缁撴灉 + filter.addAction(BAdapter.ACTION_STATE_CHANGED); + main.registerReceiver(receiver, filter); //娉ㄥ唽鐩戝惉 + }, + fail: (err) => { + uni.showToast({ + icon: "none", + title: "钃濈墮鎼滃澶辫触~", + duration: 3000, + mask: true + }) + } + }) + } + }, + fail(err) { + uni.showToast({ + icon: "none", + title: "钃濈墮鎼滅储澶辫触" + }) + } + }) +} -- Gitblit v1.9.1