|
@@ -220,34 +220,25 @@ export default {
|
|
|
// 判断新的标识值
|
|
|
$this.code = $code[1].toUpperCase();
|
|
|
console.log("头环码", $code);
|
|
|
- //打开蓝牙设备
|
|
|
- wx.getSystemInfo({
|
|
|
+ //打开蓝牙设备
|
|
|
+
|
|
|
+
|
|
|
+ wx.openBluetoothAdapter({
|
|
|
+ mode: "peripheral",
|
|
|
success(res) {
|
|
|
- console.log("获取系统信息:", res);
|
|
|
- if (res.platform == "ios") {
|
|
|
- } else {
|
|
|
- wx.openBluetoothAdapter({
|
|
|
- success(res) {
|
|
|
- console.log("初始化蓝牙模块res信息:", res);
|
|
|
- //判断已经打开连接了
|
|
|
- if (res["errMsg"] == "openBluetoothAdapter:ok") {
|
|
|
- $this.startBluetoothDevicesDiscovery();
|
|
|
- }
|
|
|
- },
|
|
|
- fail(err) {
|
|
|
- if (err["errCode"] == 10001) {
|
|
|
- Toast.fail({
|
|
|
- message: "请打开蓝牙和位置信息!",
|
|
|
- });
|
|
|
- } else {
|
|
|
- Toast.fail({
|
|
|
- message: "蓝牙连接失败",
|
|
|
- });
|
|
|
- }
|
|
|
- },
|
|
|
- });
|
|
|
+ //判断已经打开连接了
|
|
|
+ if (res["errMsg"] == "openBluetoothAdapter:ok") {
|
|
|
+ $this.startBluetoothDevicesDiscovery();
|
|
|
}
|
|
|
},
|
|
|
+ fail(err) {
|
|
|
+ let $msg = bluetooth.GetopenBluetoothAdapterError(
|
|
|
+ err["errCode"]
|
|
|
+ );
|
|
|
+ Toast.fail({
|
|
|
+ message: $msg,
|
|
|
+ });
|
|
|
+ },
|
|
|
});
|
|
|
|
|
|
// wx.openBluetoothAdapter({
|