Page({
data: {
hasStartError: false,
startError: '',//初始化错误提示
system: '', //版本号
platform: '', //系统 android
wifiListError: false, //wifi列表错误显示开关
wifiListErrorInfo: '',//wifi列表错误详细
list: [],
listLength: '',
},
onLoad: function () {
var _this = this;
//检测手机型号
wx.getSystemInfo({
success: function (res) {
var system = '';
if (res.platform == 'android') system = parseInt(res.system.substr(8));
if (res.platform == 'ios') system = parseInt(res.system.substr(4));
if (res.platform == 'android' && system < 6) {
_this.setData({ hasStartError: true });
_this.setData({ startError: '手机版本暂时不支持' }); return
}
if (res.platform == 'ios' && system < 11) {
_this.setData({ hasStartError: true });
_this.setData({ startError: '手机版本暂时不支持' }); return
}
_this.setData({ platform: res.platform });
}
})
},
getWifiList: function () {
var _this = this;
//安卓执行方法
if (_this.data.platform == 'android') {
//请求获取 Wi-Fi 列表
wx.getWifiList({
success: function (res) {
//安卓执行方法
_this.AndroidList(_this);
},
fail: function (res) {
_this.setData({ wifiListError: true });
_this.setData({ wifiListErrorInfo: res.errMsg });
}
})
}
//IOS执行方法
if (_this.data.platform == 'ios') {
_this.IosList(_this);
}
},
AndroidList: function (_this) {
//监听获取到 Wi-Fi 列表数据
wx.onGetWifiList(function (res) { //获取列表
if (res.wifiList.length) {
_this.setData({ wifiListError: false });
_this.setData({list: res.wifiList});
}
else {
_this.setData({ wifiListError: true });
_this.setData({ wifiListErrorInfo: '未查询到设置的wifi' });
}
})
},
IosList: function (_this) {
_this.setData({ wifiListError: true });
_this.setData({ wifiListErrorInfo: 'IOS暂不支持' });
},
clear: function () {
this.setData({
hasStartError: false,
startError: '',
wifiListError: true,
wifiListErrorInfo: '',
list: []
})
}
})
没有合适的资源?快使用搜索试试~ 我知道了~
微信小程序操作WIFI和蓝牙
共51个文件
wxss:13个
wxml:12个
js:12个
1星 需积分: 50 41 下载量 58 浏览量
2018-05-03
21:39:23
上传
评论 3
收藏 90KB ZIP 举报
温馨提示
微信小程序操作WIFI和蓝牙,实现所有函数调用。微信小程序操作WIFI和蓝牙,实现所有函数调用。
资源推荐
资源详情
资源评论
收起资源包目录
wifi-bluetooth.zip (51个子文件)
wifi-bluetooth
project.config.json 573B
pages
common
index.wxss 2KB
lib
weui.wxss 21KB
head.wxml 230B
foot.wxml 225B
bluetooth
pages
openBt
openBt.js 2KB
openBt.wxml 1004B
openBt.json 49B
openBt.wxss 320B
getBtList
getBtList.wxml 1KB
getBtList.js 856B
getBtList.json 55B
getBtList.wxss 471B
closeBt
closeBt.wxss 248B
closeBt.json 55B
closeBt.js 473B
closeBt.wxml 539B
index.wxss 31B
index.json 46B
index.wxml 479B
index.js 719B
wifi
pages
connectWifi
connectWifi.json 47B
connectWifi.wxss 248B
connectWifi.js 988B
connectWifi.wxml 2KB
getWifiList
getWifiList.wxml 1KB
getWifiList.js 2KB
getWifiList.json 64B
getWifiList.wxss 471B
getCurrentWifi
getCurrentWifi.js 639B
getCurrentWifi.wxss 248B
getCurrentWifi.wxml 2KB
getCurrentWifi.json 53B
startWifi
startWifi.wxml 813B
startWifi.json 50B
startWifi.js 420B
startWifi.wxss 162B
closeWifi
closeWifi.wxss 248B
closeWifi.wxml 539B
closeWifi.json 53B
closeWifi.js 458B
index.wxss 31B
index.json 41B
index.wxml 479B
index.js 872B
utils
util.js 472B
images
bluetooth.png 22KB
wifi.png 38KB
app.js 1KB
app.json 1KB
app.wxss 4KB
共 51 条
- 1
资源评论
- 架构和框架2019-06-26垃圾中的战斗机
NRlovestudy
- 粉丝: 212
- 资源: 8
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功