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

网站底部图标wordpress打赏按钮

网站底部图标,wordpress打赏按钮,重庆网站推广平台,两岸统一最新消息模拟的是蓝牙设备签到/签出#xff1a; 获取指定蓝牙设备蓝牙初始搜索次数限制#xff0c;超过限制就停止搜索蓝牙连接失败次数限制#xff0c;超过限制标识蓝牙连接失败#xff08;离开蓝牙范围或其他原因#xff09;自动重连指定蓝牙 const device refany(nu…模拟的是蓝牙设备签到/签出 获取指定蓝牙设备蓝牙初始搜索次数限制超过限制就停止搜索蓝牙连接失败次数限制超过限制标识蓝牙连接失败离开蓝牙范围或其他原因自动重连指定蓝牙 const device refany(null); // 设备信息 const crpBlueList refany[]([]); // 扫描到的蓝牙信息列表 const linkStatus ref(false); // 连接状态 const searchTimes ref(0); // 搜索次数 const searchLimit 5; // 搜索次数限制 const linkTimes ref(0); // 扫描次数 const failTimes ref(0); // 失败次数 const failLimit 5; // 失败次数限制 const blueName zo-crp; // 指定蓝牙设备的名称前缀 let isSignIn false; // 是否签到 // 签到 const signIn () {searchTimes.value 0;uni.showLoading({title: 蓝牙搜索中...,mask: true});openBluetoothAdapter(() {startBluetoothDeviceDiscovery();}); }; // 签出 const logout () {closeBlueTooth(device.value, () {isSignIn false;device.value null;linkStatus.value false;searchTimes.value 0;linkTimes.value 0;failTimes.value 0;crpBlueList.value [];uni.showToast({title: 已签出});}); }; // 初始化蓝牙 const openBluetoothAdapter (callback: Function) {uni.openBluetoothAdapter({//打开蓝牙适配器接口success: (res) {//已打开callback();},fail: (err) {uni.hideLoading();uni.showModal({title: ,content: 该操作需要蓝牙支持请打开蓝牙,showCancel: false,success: (res) {if (res.confirm) {// #ifdef APPlet main plus.android.runtimeMainActivity();let Intent plus.android.importClass(android.content.Intent);let mIntent new Intent(android.settings.BLUETOOTH_SETTINGS);main.startActivity(mIntent);// #endif} else {navigateBack();}},complete: () {}});}}); }; // 搜索蓝牙 const startBluetoothDeviceDiscovery () {if (searchTimes.value searchLimit - 1) {uni.showModal({content:没有找到指定的蓝牙设备请确认所在位置周边有指定蓝牙设备且手机已开启位置信息并授权,confirmText: 重试,success: (res) {if (res.confirm) {signIn();} else {stopBluetoothDevicesDiscovery(() {uni.closeBluetoothAdapter({complete: () {navigateBack();}});});}}});return;}searchTimes.value 1;uni.startBluetoothDevicesDiscovery({success: (res) {// 发现外围设备onBluetoothDeviceFound();},fail: (err) {console.log(err, 开始搜索蓝牙设备备错误信息);}}); }; // 发现设备 const onBluetoothDeviceFound () {let t: any setTimeout(() {clearTimeout(t);t null;stopBluetoothDevicesDiscovery(() {// 停止搜索蓝牙uni.getBluetoothDevices({success: (res) {const blueList res.devices.filter((item: any) item.name.toLowerCase().startsWith(blueName)).sort((a: any, b: any) b.RSSI - a.RSSI);crpBlueList.value blueList;if (!blueList.length) {startBluetoothDeviceDiscovery();return;}const Device: any blueList[0];isSignIn true;// 获取电量const serviceData Array.prototype.map.call(new Uint8Array(Device.serviceData[Object.keys(Device.serviceData)[0]]), (bit) bit.toString(16)).join();const Electric parseInt(serviceData.slice(-2), 16);// 获取uuidconst UUID Array.prototype.map.call(new Uint8Array(Device.advertisData), (bit) (00 bit.toString(16)).slice(-2)).join().substring(8, 40).toUpperCase();device.value {name: Device.name,deviceId: Device.deviceId,electric: Electric,RSSI: Device.RSSI,UUID: UUID};linkStatus.value true;createBLEConnection(Device);}});});}, 2000); }; // 连接设备 const createBLEConnection (item: any) {uni.showLoading({title: 连接中请稍等,mask: true});linkTimes.value 1;uni.createBLEConnection({deviceId: item.deviceId,success(res) {linkStatus.value true;failTimes.value 0;uni.showToast({title: 蓝牙已连接,mask: true});onBLEConnectionStateChange(item);},fail(res) {linkStatus.value false;plus.device.vibrate(500);if (failTimes.value failLimit) {failTimes.value 1;uni.showToast({title: item.name 蓝牙连接失败,icon: none});reLink(item);} else {closeBlueTooth(item, () {uni.showToast({title: item.name 蓝牙连接失败取消连接,icon: none});});}}}); }; // 监听蓝牙状态 const onBLEConnectionStateChange (item: any) {uni.onBLEConnectionStateChange((res) {m_Debounce(() {if (!res.connected isSignIn) {reLink(item);}}, 500);}); }; // 蓝牙重连 const reLink (item: any) {closeBlueTooth(item, () {let t: any setTimeout(() {clearTimeout(t);t null;openBluetoothAdapter(() {createBLEConnection(item);});}, 1000);}); };// 关闭连接关闭蓝牙模块 const closeBlueTooth (item: any, callback: Function) {// 关闭连接uni.closeBLEConnection({deviceId: item.deviceId,complete: () {// 关闭蓝牙模块uni.closeBluetoothAdapter({complete: () {callback();}});}}); };// 停止搜索 const stopBluetoothDevicesDiscovery (callback: Function) {uni.stopBluetoothDevicesDiscovery({complete: (e) {callback();},fail: (e) {console.log(停止搜索蓝牙设备失败错误码 e.errCode);}}); }; // 后退 const navigateBack () {uni.navigateBack({delta: 1,fail: () {uni.reLaunch({url: /pages/home/home});}}); };
http://www.tj-hxxt.cn/news/133394.html

相关文章:

  • 漳州网站建设哪家好天津免费建网站
  • 做年报的网站怎么登不上去了互联网企业公司简介
  • 网站建设首选九零后网络昆明网页建站平台
  • 免费舆情网站下载大全最新版大连工业大学研究生院官网
  • 网站建设合同验收标准什么企业时候做网站
  • 佛山市外贸企业高端网站设计学做网站赚钱方法
  • 网站维护属于什么专业网站流量seo
  • 阿里云服务器多个网站专科学什么专业好就业前景好
  • 网站建设申报书wordpress 仿京东主题
  • 专业装修别墅徐州网站优化
  • 做网站的网络公司厨师培训
  • cnetos 7 wordpress车辆优化管理专业网站
  • 近一周的热点新闻seo免费优化网址软件
  • 搜讯网站开发微信建微网站
  • 西安哪个公司做网站WordPress主题会包含木马吗
  • 湛江网站建设哪家优惠多网站文章要求
  • 免费网站建设免代码wordpress官方响应式主题
  • 网站开发 如何备案一小时学会网站建设
  • html 医药网站模板那里网站建设好
  • 外贸那些网站好用镇江网站制作教程
  • 南梁红色景区建设管理局网站做网站贵
  • 找网站开发项目秦皇岛海三建设一分公司
  • 如何对网站做镜像wordpress 默认相册
  • 做一个公司网站免费的网站推广
  • 性男女做视频网站网络推广和网络运营
  • 在国内可以做国外的网站吗海口最新新闻消息
  • 龙岗建设企业网站wordpress 内容 主题
  • 网站建设营销公司南京建设企业
  • 百度网站解封wordpress免费电子商务插件
  • 北京 网站建设托管公司网站 建设ppt模板