|
@@ -236,11 +236,13 @@ export default {
|
|
$this.toy_id = $toy.id
|
|
$this.toy_id = $toy.id
|
|
let $hex = $toy["hex"].substr($toy["hex"].length - 2, 2);
|
|
let $hex = $toy["hex"].substr($toy["hex"].length - 2, 2);
|
|
let toy_hex = "0x" + $hex;
|
|
let toy_hex = "0x" + $hex;
|
|
- game_store.setters.setToyHex(toy_hex)
|
|
|
|
-
|
|
|
|
|
|
+ // game_store.setters.setToyHex(toy_hex)
|
|
//连接玩具
|
|
//连接玩具
|
|
// 打开数据帧
|
|
// 打开数据帧
|
|
- bluetooth.sendConnect(toy_hex, $this._deviceId, bluetooth.serviceId, bluetooth.cid, Toast, $this)
|
|
|
|
|
|
+ let $serviceId = game_store.getters.getServiceId()
|
|
|
|
+ let $charateristic = game_store.getters.getCharacterId()
|
|
|
|
+
|
|
|
|
+ bluetooth.sendConnect(toy_hex, $this._deviceId, $serviceId, $charateristic, Toast, $this)
|
|
},
|
|
},
|
|
//修改玩具连接状态
|
|
//修改玩具连接状态
|
|
change_toy_connect_status($status = 0) {
|
|
change_toy_connect_status($status = 0) {
|
|
@@ -299,11 +301,12 @@ export default {
|
|
try {
|
|
try {
|
|
setTimeout(() => {
|
|
setTimeout(() => {
|
|
if (!$this.device.deviceId) {
|
|
if (!$this.device.deviceId) {
|
|
- $this.stopBluetoothDevicesDiscovery();
|
|
|
|
|
|
+ wx.offBluetoothDeviceFound();
|
|
|
|
+ wx.stopBluetoothDevicesDiscovery();
|
|
$this.change_device_status(0)
|
|
$this.change_device_status(0)
|
|
Toast.fail("未连接到设备");
|
|
Toast.fail("未连接到设备");
|
|
}
|
|
}
|
|
- }, 7000);
|
|
|
|
|
|
+ }, 5000);
|
|
wx.onBluetoothDeviceFound((res) => {
|
|
wx.onBluetoothDeviceFound((res) => {
|
|
res.devices.forEach((device) => {
|
|
res.devices.forEach((device) => {
|
|
if (!device.name && !device.localName) {
|
|
if (!device.name && !device.localName) {
|
|
@@ -312,7 +315,6 @@ export default {
|
|
if (device.localName && (device.localName != '')) {
|
|
if (device.localName && (device.localName != '')) {
|
|
device.name = device.localName
|
|
device.name = device.localName
|
|
}
|
|
}
|
|
- console.log(device["name"].toUpperCase());
|
|
|
|
if (device["name"].toUpperCase() == $this.code) {
|
|
if (device["name"].toUpperCase() == $this.code) {
|
|
$this.stopBluetoothDevicesDiscovery();
|
|
$this.stopBluetoothDevicesDiscovery();
|
|
$this.device = device;
|
|
$this.device = device;
|
|
@@ -372,11 +374,6 @@ export default {
|
|
game_store.setters.setToyList($this.toy_list)
|
|
game_store.setters.setToyList($this.toy_list)
|
|
});
|
|
});
|
|
},
|
|
},
|
|
-
|
|
|
|
- // 开始游戏的方法
|
|
|
|
- game_start() {
|
|
|
|
- console.log("device.vue", $this._deviceId);
|
|
|
|
- },
|
|
|
|
},
|
|
},
|
|
mounted() {
|
|
mounted() {
|
|
$this.get_toy_list();
|
|
$this.get_toy_list();
|
|
@@ -423,6 +420,7 @@ export default {
|
|
}
|
|
}
|
|
},
|
|
},
|
|
onLoad(options) {
|
|
onLoad(options) {
|
|
|
|
+
|
|
// 原有的code
|
|
// 原有的code
|
|
let $_code = wx.getStorageSync("code");
|
|
let $_code = wx.getStorageSync("code");
|
|
if (options.q) {
|
|
if (options.q) {
|
|
@@ -610,7 +608,7 @@ export default {
|
|
<style scoped>
|
|
<style scoped>
|
|
#device_container {
|
|
#device_container {
|
|
position: relative;
|
|
position: relative;
|
|
- top: -65px;
|
|
|
|
|
|
+ bottom: 80px;
|
|
}
|
|
}
|
|
|
|
|
|
.head .line {
|
|
.head .line {
|