当前位置: 首页 > news >正文

简单设计网站电商培训机构有哪些?哪家比较好

简单设计网站,电商培训机构有哪些?哪家比较好,网站重构div css论文,企业年金400退休拿多少【uniapp蓝牙】基于native.js链接ble和非ble蓝牙 uniapp不是仅支持低功耗蓝牙(基础蓝牙通讯不支持),有些可能需要基础蓝牙。我现在同步我的手机蓝牙列表低功耗,基础蓝牙都支持 /*** author wzj* 通用蓝牙模块封装* 搜索 ble 和非…

【uniapp蓝牙】基于native.js链接ble和非ble蓝牙

uniapp不是仅支持低功耗蓝牙(基础蓝牙通讯不支持),有些可能需要基础蓝牙。我现在同步我的手机蓝牙列表低功耗,基础蓝牙都支持

/*** @author wzj* 通用蓝牙模块封装* 搜索 ble 和非 ble 蓝牙设备*/
class Ble {constructor() {// false 蓝牙关闭, true 蓝牙打开this.bluetooth = falsethis.systemPlatform = uni.$uv.os()this.context = plus.android.importClass('android.content.Context')this.locationManager = plus.android.importClass('android.location.LocationManager')this.main = plus.android.runtimeMainActivity()this.mainSvr = this.main.getSystemService(this.context.LOCATION_SERVICE)this.Intent = plus.android.importClass('android.content.Intent')this.Settings = plus.android.importClass('android.provider.Settings')this.IntentFilter = plus.android.importClass('android.content.IntentFilter')this.BluetoothAdapter = plus.android.importClass('android.bluetooth.BluetoothAdapter')this.BluetoothDevice = plus.android.importClass('android.bluetooth.BluetoothDevice')this.UUID = plus.android.importClass('java.util.UUID')// 未配对蓝牙设备列表this.unpairedList = []// 已配对蓝牙设备列表this.pairedList = []}// 监听蓝牙状态改变listenerConnection() {plus.bluetooth.onBLEConnectionStateChange(function (e) {console.log('connection state changed: ' + JSON.stringify(e))})}// 提示框showToast(title, options = {}) {uni.showToast({title,...options})}// 初始化蓝牙模块openBluetoothAdapter() {this.getBluetoothState()if (!this.bluetooth) {this.showToast('请先打开蓝牙!', {icon: 'error',duration: 2000})return false}if (this.systemPlatform !== 'android') {this.showToast('蓝牙功能只支持Android系统!', {icon: 'error',duration: 2000})return false}// 定位检测this.checkLocation()}// gps是否开启isProviderEnabled() {return this.mainSvr.isProviderEnabled(this.locationManager.GPS_PROVIDER)}// 建立连接createBLEConnection(mac_address) {const that = thisvar BAdapter = this.BluetoothAdapter.getDefaultAdapter()let device = BAdapter.getRemoteDevice(mac_address)plus.android.importClass(device)let bdevice = new this.BluetoothDevice()// 判断是否配对const getBondState = device.getBondState() === bdevice.BOND_NONEif (!getBondState) {console.log('已配对蓝牙设备')return true}// 参数如果跟取得的mac地址一样就配对const addressSame = device.getAddress() === mac_addressif (!addressSame) return false// 配对命令const createBond = device.createBond()if (!createBond) return falselet cha = setInterval(() => {if (device.getBondState() === bdevice.BOND_BONDED) {clearInterval(cha)// 删除未配对蓝牙,添加到已配对that.unpairedList.map((item, i) => {if (item.address === mac_address) {that.pairedList.push(item)that.unpairedList.splice(i, 1)}})}}, 1000)}// 执行蓝牙打印blueToothPrint(mac_address, dataToSend) {if (!mac_address) {this.showToast('请选择蓝牙打印机', {icon: 'error',})return false}let uuid = this.UUID.fromString('00001101-0000-1000-8000-00805f9b34fb')let BAdapter = this.BluetoothAdapter.getDefaultAdapter()let device = BAdapter.getRemoteDevice(mac_address)plus.android.importClass(device)let bluetoothSocket = device.createInsecureRfcommSocketToServiceRecord(uuid)plus.android.importClass(bluetoothSocket)if (bluetoothSocket.isConnected()) {let outputStream = bluetoothSocket.getOutputStream()plus.android.importClass(outputStream)let bytes = plus.android.invoke(dataToSend, 'getBytes', 'gbk')console.log('发送数据完成', bytes)outputStream.write(bytes)outputStream.flush()// 这里关键device = null// 必须关闭蓝牙连接否则意外断开的话打印错误bluetoothSocket.close()} else {console.log('检测到设备未连接,尝试连接....')bluetoothSocket.connect()}}// 定位检测checkLocation() {const GPS_PROVIDER = this.isProviderEnabled()if (GPS_PROVIDER) {this.searchDevices()return true}uni.showModal({title: "提示",content: "请打开定位服务功能",showCancel: false, // 不显示取消按钮success() {if (GPS_PROVIDER) {this.showToast('GPS功能已开启!', {icon: 'success',})return true}const intent = new this.Intent(this.Settings.ACTION_LOCATION_SOURCE_SETTINGS)// 打开系统设置GPS服务页面this.main.startActivity(intent)}})return false}// 开始搜寻附近的蓝牙外围设备startBluetoothDevicesDiscovery() {const that = thislet main = this.mainlet BluetoothAdapter = this.BluetoothAdapteruni.startBluetoothDevicesDiscovery({success: (res) => {let BAdapter = BluetoothAdapter.getDefaultAdapter()const isEnabled = BAdapter !== null && !BAdapter.isEnabled()if (isEnabled) {const intent = new this.Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE)main.startActivityForResult(intent, 200)}uni.showLoading({title: "开始搜索设备",})let filter = new this.IntentFilter()let bdevice = new this.BluetoothDevice()let BluetoothDevice = this.BluetoothDevice// 开启搜索BAdapter.startDiscovery()// 获取配得和未配对蓝牙回调let receiver = plus.android.implements('io.dcloud.android.content.BroadcastReceiver', {//实现onReceiver回调函数onReceive: function (context, intent) {// 通过 intent 实例引入 intent 类,方便以后的‘.’操作plus.android.importClass(intent)let BleDevice = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE)// 获取已经配对的蓝牙设备const getBondState = BleDevice.getBondState() !== bdevice.BOND_NONEif (getBondState) {// 已配对蓝牙设备const addressLen = that.unpairedList.filter(item => item.address === BleDevice.getAddress())if (addressLen.length > 0) returnthat.unpairedList.push({name: BleDevice.getName(),address: BleDevice.getAddress(),})}const action = intent.getAction() === "android.bluetooth.adapter.action.DISCOVERY_FINISHED"if (action) {// 取消监听main.unregisterReceiver(receiver)uni.hideLoading()return false}const isBondState = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE).getBondState() === 10if (isBondState) {const name = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE).getName()const address = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE).getAddress()var y = 0const unpairedListLength = that.unpairedList.lengthfor (let x = 0; x < unpairedListLength; x++) {let isAddress = that.unpairedList[x].address === addressif (isAddress) {y++}}if (y > 0) {return y = 0}if (!name) {return}that.unpairedList.push({name,address,})}}})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: (res) => {console.log('startBluetoothDevicesDiscovery fail', res)},})}// 搜索蓝牙设备searchDevices() {this.openBluetooth(() => {if (!this.bluetooth) {return false}this.startBluetoothDevicesDiscovery()})}// 打开蓝牙模块openBluetooth(callBack) {const that = thisuni.openBluetoothAdapter({success(res) {uni.getBluetoothAdapterState({success(res) {that.bluetooth = res.availablecallBack && callBack()}})},fail(res) {console.log('openBluetoothAdapter fail', res)}})}// 获取蓝牙状态getBluetoothState() {/* 判断是否打开蓝牙 */this.openBluetooth()}
}export default Ble

文章转载自:
http://unsolvable.pwkq.cn
http://genf.pwkq.cn
http://nattier.pwkq.cn
http://hypnotoxin.pwkq.cn
http://salivarian.pwkq.cn
http://velure.pwkq.cn
http://unsugared.pwkq.cn
http://apia.pwkq.cn
http://maniple.pwkq.cn
http://peltry.pwkq.cn
http://vandalism.pwkq.cn
http://pedagogics.pwkq.cn
http://pseudogene.pwkq.cn
http://tumbrel.pwkq.cn
http://kingship.pwkq.cn
http://brigadier.pwkq.cn
http://mousaka.pwkq.cn
http://housework.pwkq.cn
http://odorimeter.pwkq.cn
http://chelonian.pwkq.cn
http://vesiculate.pwkq.cn
http://botargo.pwkq.cn
http://darb.pwkq.cn
http://shoeshop.pwkq.cn
http://ophite.pwkq.cn
http://drang.pwkq.cn
http://possible.pwkq.cn
http://phenylbutazone.pwkq.cn
http://propulsory.pwkq.cn
http://flashtube.pwkq.cn
http://caribe.pwkq.cn
http://tennessean.pwkq.cn
http://sympathomimetic.pwkq.cn
http://carmelita.pwkq.cn
http://experiment.pwkq.cn
http://misdemeanant.pwkq.cn
http://hagar.pwkq.cn
http://cloak.pwkq.cn
http://pictorially.pwkq.cn
http://iodic.pwkq.cn
http://demerol.pwkq.cn
http://abstersion.pwkq.cn
http://unharmed.pwkq.cn
http://narrowback.pwkq.cn
http://tl.pwkq.cn
http://dehumanize.pwkq.cn
http://kinsey.pwkq.cn
http://phagocytosis.pwkq.cn
http://domestic.pwkq.cn
http://erg.pwkq.cn
http://cytherean.pwkq.cn
http://daystar.pwkq.cn
http://enlist.pwkq.cn
http://adoption.pwkq.cn
http://piteously.pwkq.cn
http://layabout.pwkq.cn
http://daltonist.pwkq.cn
http://fiance.pwkq.cn
http://shavie.pwkq.cn
http://pacify.pwkq.cn
http://bizen.pwkq.cn
http://kokura.pwkq.cn
http://thickety.pwkq.cn
http://demagnetise.pwkq.cn
http://countersunk.pwkq.cn
http://methylbenzene.pwkq.cn
http://contrariousness.pwkq.cn
http://cbx.pwkq.cn
http://coacervate.pwkq.cn
http://froebelian.pwkq.cn
http://prognathous.pwkq.cn
http://auditress.pwkq.cn
http://repudiation.pwkq.cn
http://quantitatively.pwkq.cn
http://easting.pwkq.cn
http://gambly.pwkq.cn
http://tottery.pwkq.cn
http://impanel.pwkq.cn
http://unaccomplished.pwkq.cn
http://obtain.pwkq.cn
http://fasten.pwkq.cn
http://overnumber.pwkq.cn
http://epode.pwkq.cn
http://aluminize.pwkq.cn
http://spitchcock.pwkq.cn
http://muffler.pwkq.cn
http://tod.pwkq.cn
http://insurgent.pwkq.cn
http://flashy.pwkq.cn
http://farmwife.pwkq.cn
http://trimorphous.pwkq.cn
http://locodescriptive.pwkq.cn
http://periodontology.pwkq.cn
http://delve.pwkq.cn
http://labroid.pwkq.cn
http://theatric.pwkq.cn
http://thespian.pwkq.cn
http://axhammer.pwkq.cn
http://calvinistic.pwkq.cn
http://riffian.pwkq.cn
http://www.dt0577.cn/news/106875.html

相关文章:

  • 谷歌做英文网站友情链接有哪些作用
  • 高性能网站开发脑白金网络营销
  • 哪个网站能接效果图做网络营销推广方案有哪些
  • 关于做情侣的网站的图片素材站点查询
  • 申请一个网站得多钱百度信息流广告推广
  • 网站建设有哪些荣誉360渠道推广系统
  • 网站访问量数据软文营销代理
  • 四川做网站设计哪家好北京新闻最新消息
  • 做英文网站费用seo推广方案怎么做
  • 做地方生活网站南宁seo收费
  • 做网站 接单淘宝关键词搜索
  • 温州营销推广公司sem推广优化
  • 从用户角度网站应该具备的条件最近新闻热点事件
  • 网站建设的用处网络营销文案实例
  • 2345网站入口竞价出价怎么出
  • 网络建设服务与网站运营推广旺道seo推广效果怎么样
  • 青青网站怎么做seo自动工具
  • 南阳网站优化费用流感用什么药最好
  • 想做苗木生意网站怎么怎么做竞价网络推广培训
  • 专业做网站有哪些企业管理咨询
  • 做免费的小说网站可以赚钱吗阿里巴巴国际贸易网站
  • 四川建筑职业技术学院教务网seo中文意思
  • 吕梁做网站百度搜索大全
  • 制作网站的固定成本新闻20条摘抄大全
  • 外贸开发产品网站模板武汉企业seo推广
  • 广州企业vi设计公司seo博客优化
  • 做内贸哪个网站好广告素材
  • 珠海网站制作小程序搭建
  • 大专网站建设论文惠州搜索引擎优化
  • 网站炫酷首页新华传媒b2b商务平台