Page({
data:{
devices:[{name:’’}]
},
onLoad:function(options){
// 页面初始化 options为页面跳转所带来的参数
// this.onBluetoothAdapterStateChange();
// this.onBluetoothDeviceFound();
},
startTest:function(){
this.showMessage(“开始搜索外围蓝牙设备…”,1500);
this.setData({
devices:[{name:’’}]
})
this.openBluetooth();
},
showMessage:function(info,dur){
wx.showToast({
title:info,
icon: ‘loading’,
duration:dur
})
},
showModal:function(content){
wx.showModal({
title: ‘提示’,
content: content
})
},
//初始化蓝牙适配器
openBluetooth:function(){
var that = this;
console.log(“开始初始化蓝牙适配器!”,that);
wx.openBluetoothAdapter({
success: function (res) {
console.log(res)
}
})
},