|
@@ -23,10 +23,7 @@
|
|
|
</div>
|
|
|
|
|
|
<!-- 已链接 -->
|
|
|
- <div
|
|
|
- class="connected_box"
|
|
|
- v-if="connect_show"
|
|
|
- >
|
|
|
+ <div class="connected_box" v-if="connect_show">
|
|
|
<device_connected
|
|
|
@open_choose_toy="open_choose_toy"
|
|
|
@change_brain_status="change_device_status"
|
|
@@ -74,10 +71,7 @@
|
|
|
</div>
|
|
|
<!-- 内容 -->
|
|
|
<div class="padding toy_list">
|
|
|
- <van-row
|
|
|
- gutter="14"
|
|
|
- class="toy_list_content"
|
|
|
- >
|
|
|
+ <van-row gutter="14" class="toy_list_content">
|
|
|
<van-col
|
|
|
v-for="(toy, index) in toy_list"
|
|
|
:key="index"
|
|
@@ -92,11 +86,7 @@
|
|
|
: 'toy_item_normal_bg'
|
|
|
"
|
|
|
>
|
|
|
- <img
|
|
|
- :src="toy.img"
|
|
|
- alt=""
|
|
|
- class="toy_img"
|
|
|
- />
|
|
|
+ <img :src="toy.img" alt="" class="toy_img" />
|
|
|
<text class="toy_text padding-top">{{ toy.name }}</text>
|
|
|
</div>
|
|
|
</van-col>
|
|
@@ -104,7 +94,8 @@
|
|
|
</div>
|
|
|
<!-- 结尾 -->
|
|
|
<div class="toy_actions padding text-center">
|
|
|
- <view class="text-gray toy_action_text padding">选择你最感兴趣的项目,点击“选好了”以后将会自动连接
|
|
|
+ <view class="text-gray toy_action_text padding"
|
|
|
+ >选择你最感兴趣的项目,点击“选好了”以后将会自动连接
|
|
|
</view>
|
|
|
<button
|
|
|
class="cu-btn lg cu-btn-primary text-white text-center padding"
|
|
@@ -114,9 +105,8 @@
|
|
|
</button>
|
|
|
</div>
|
|
|
</van-popup>
|
|
|
- <van-toast id="van-toast"/>
|
|
|
- <van-dialog id="van-dialog"/>
|
|
|
-
|
|
|
+ <van-toast id="van-toast" />
|
|
|
+ <van-dialog id="van-dialog" />
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
@@ -133,9 +123,9 @@ import toy_connecting from "@/components/device/toy/connecting";
|
|
|
import gameIng from "@/pages/start/index";
|
|
|
//获取个人信息
|
|
|
import Toast from "../../../static/vant/toast/toast";
|
|
|
-import {game_devices, getDeviceBySn} from "../../requests/game";
|
|
|
+import { game_devices, getDeviceBySn } from "../../requests/game";
|
|
|
import game_store from "@/store/game";
|
|
|
-import {getNowDate} from "../../utils";
|
|
|
+import { getNowDate } from "../../utils";
|
|
|
|
|
|
let $this;
|
|
|
export default {
|
|
@@ -236,12 +226,12 @@ export default {
|
|
|
scan_to_bluetooth() {
|
|
|
wx.scanCode({
|
|
|
onlyFromCamera: true,
|
|
|
- scanType: ['barCode', 'qrCode'],
|
|
|
+ scanType: ["barCode", "qrCode"],
|
|
|
success: (res) => {
|
|
|
let $data = res;
|
|
|
if ($data.result) {
|
|
|
let url = decodeURIComponent($data.result);
|
|
|
- let $code = ""
|
|
|
+ let $code = "";
|
|
|
|
|
|
//二维码
|
|
|
if (res.scanType == "QR_CODE") {
|
|
@@ -255,21 +245,21 @@ export default {
|
|
|
}
|
|
|
|
|
|
// 判断新的标识值
|
|
|
- $this.code = $code
|
|
|
+ $this.code = $code;
|
|
|
//判断是新还是旧
|
|
|
- game_store.setters.setIsNew($code.indexOf('AI') != -1)
|
|
|
+ game_store.setters.setIsNew($code.indexOf("AI") != -1);
|
|
|
|
|
|
console.log("头环码", $code);
|
|
|
- game_store.setters.setDeviceSn($this.code)
|
|
|
+ game_store.setters.setDeviceSn($this.code);
|
|
|
//设备信息
|
|
|
$this.device_data.product_qrcode = url;
|
|
|
- $this.device_data.sn = $this.code
|
|
|
+ $this.device_data.sn = $this.code;
|
|
|
//产品名称、制造工厂
|
|
|
$this.device_data.product_name = "水母智脑环";
|
|
|
- $this.device_data.manufacturing_plan = "深圳水母智脑科技有限公司"
|
|
|
+ $this.device_data.manufacturing_plan = "深圳水母智脑科技有限公司";
|
|
|
// 设备类型
|
|
|
- $this.device_data.type = 1
|
|
|
- $this.device_data.production_date = getNowDate()
|
|
|
+ $this.device_data.type = 1;
|
|
|
+ $this.device_data.production_date = getNowDate();
|
|
|
|
|
|
//打开蓝牙设备
|
|
|
wx.getSystemInfo({
|
|
@@ -292,9 +282,10 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
fail(err) {
|
|
|
- let $msg = $this.$bluetooth.GetopenBluetoothAdapterError(
|
|
|
- err["errCode"]
|
|
|
- );
|
|
|
+ let $msg =
|
|
|
+ $this.$bluetooth.GetopenBluetoothAdapterError(
|
|
|
+ err["errCode"]
|
|
|
+ );
|
|
|
setTimeout(() => {
|
|
|
Toast.fail({
|
|
|
message: $msg,
|
|
@@ -342,8 +333,8 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
fail(res) {
|
|
|
- console.log(res)
|
|
|
- }
|
|
|
+ console.log(res);
|
|
|
+ },
|
|
|
});
|
|
|
},
|
|
|
//关闭窗口的方法
|
|
@@ -358,7 +349,7 @@ export default {
|
|
|
open_choose_toy() {
|
|
|
// $this.choose_toy_window.show = false;
|
|
|
$this.choose_toy_window.show = true;
|
|
|
- $this.toy_connected = false
|
|
|
+ $this.toy_connected = false;
|
|
|
$this.$bluetooth.SendOrder("09");
|
|
|
},
|
|
|
// 选好玩具
|
|
@@ -374,7 +365,10 @@ export default {
|
|
|
}
|
|
|
});
|
|
|
$this.toy_id = $toy.id;
|
|
|
- let $hex = $this.toy_hex = $toy["hex"].substr($toy["hex"].length - 2, 2);
|
|
|
+ let $hex = ($this.toy_hex = $toy["hex"].substr(
|
|
|
+ $toy["hex"].length - 2,
|
|
|
+ 2
|
|
|
+ ));
|
|
|
//连接玩具
|
|
|
$this.current_hex = `03 00 ${$hex} 00 0a`;
|
|
|
|
|
@@ -385,7 +379,7 @@ export default {
|
|
|
if ($this.toy_connected == false) {
|
|
|
$this.change_toy_connect_status(3);
|
|
|
}
|
|
|
- }, 10000)
|
|
|
+ }, 10000);
|
|
|
},
|
|
|
//修改玩具连接状态
|
|
|
change_toy_connect_status($status = 0) {
|
|
@@ -408,7 +402,7 @@ export default {
|
|
|
$this.connect_show = false;
|
|
|
$this.device_bg = false;
|
|
|
|
|
|
- $this.$bluetooth.SendOrder("09")
|
|
|
+ $this.$bluetooth.SendOrder("09");
|
|
|
let deviceId = game_store.getters.getDeviceId();
|
|
|
$this.change_toy_connect_status(0);
|
|
|
//断开蓝牙连接
|
|
@@ -422,13 +416,13 @@ export default {
|
|
|
wx.closeBluetoothAdapter();
|
|
|
},
|
|
|
fail(res) {
|
|
|
- console.log("断开连接error:", res)
|
|
|
+ console.log("断开连接error:", res);
|
|
|
},
|
|
|
complete(res) {
|
|
|
- $this.device = {}
|
|
|
+ $this.device = {};
|
|
|
$this.toy_UUID = "";
|
|
|
$this.$forceUpdate();
|
|
|
- }
|
|
|
+ },
|
|
|
});
|
|
|
} else if ($status == 2) {
|
|
|
$this.connect_show = true;
|
|
@@ -443,7 +437,7 @@ export default {
|
|
|
//2021年10月21日15:07:57 通过sn 返回deviceId
|
|
|
getDeviceBySn($this.code).then((res) => {
|
|
|
let $data = res.data;
|
|
|
- console.log($data.code)
|
|
|
+ console.log($data.code);
|
|
|
$this.change_device_status(1);
|
|
|
$data = $data.data;
|
|
|
wx.getSystemInfo({
|
|
@@ -453,19 +447,18 @@ export default {
|
|
|
$this.onBluetoothDeviceFound();
|
|
|
} else {
|
|
|
if ($data.device_id) {
|
|
|
- console.log("finded")
|
|
|
- $this.device_finded = true
|
|
|
- $this.createBLEConnection($data.device_id)
|
|
|
+ console.log("finded");
|
|
|
+ $this.device_finded = true;
|
|
|
+ $this.createBLEConnection($data.device_id);
|
|
|
} else {
|
|
|
- $this.device_finded = false
|
|
|
- console.log('unfinded')
|
|
|
+ $this.device_finded = false;
|
|
|
+ console.log("unfinded");
|
|
|
$this.onBluetoothDeviceFound();
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
+ },
|
|
|
});
|
|
|
- })
|
|
|
-
|
|
|
+ });
|
|
|
},
|
|
|
fail(err) {
|
|
|
$this.change_device_status(3);
|
|
@@ -498,7 +491,7 @@ export default {
|
|
|
}
|
|
|
if (device["name"].toUpperCase() == $this.code) {
|
|
|
$this.stopBluetoothDevicesDiscovery();
|
|
|
- console.log("搜索设备", device)
|
|
|
+ console.log("搜索设备", device);
|
|
|
$this.createBLEConnection(device.deviceId);
|
|
|
}
|
|
|
});
|
|
@@ -517,30 +510,29 @@ export default {
|
|
|
deviceId: deviceId,
|
|
|
success: (res) => {
|
|
|
console.log("成功连接");
|
|
|
- $this.$bluetooth.current_device_sn = $this.code
|
|
|
+ $this.$bluetooth.current_device_sn = $this.code;
|
|
|
game_store.setters.setDeviceId(deviceId);
|
|
|
|
|
|
//成功连接脑环蓝牙
|
|
|
$this.change_device_status(2);
|
|
|
|
|
|
- $this.$bluetooth.getBLEDeviceServices(deviceId)
|
|
|
+ $this.$bluetooth.getBLEDeviceServices(deviceId);
|
|
|
let $checkServices = setInterval(() => {
|
|
|
let $serviceId = game_store.getters.getServiceId();
|
|
|
if ($serviceId) {
|
|
|
- clearInterval($checkServices)
|
|
|
- $this.$bluetooth.openNotify($this)
|
|
|
- $this.$bluetooth.watchingDevice($this)
|
|
|
+ clearInterval($checkServices);
|
|
|
+ $this.$bluetooth.openNotify($this);
|
|
|
+ $this.$bluetooth.watchingDevice($this);
|
|
|
$this.$bluetooth.watch_bluetooth_status($this);
|
|
|
//录入库
|
|
|
//读取信息逐个写入
|
|
|
if (!$this.device_finded) {
|
|
|
setTimeout(() => {
|
|
|
- $this.$bluetooth.SendOrder("02")
|
|
|
- }, 3000)
|
|
|
+ $this.$bluetooth.SendOrder("02");
|
|
|
+ }, 3000);
|
|
|
}
|
|
|
}
|
|
|
- }, 1500)
|
|
|
-
|
|
|
+ }, 1500);
|
|
|
},
|
|
|
fail(err) {
|
|
|
console.log(err);
|
|
@@ -588,17 +580,18 @@ export default {
|
|
|
// 游戏过程中关闭脑环状态
|
|
|
let $game_close_status = game_store.getters.getGameCloseStatus();
|
|
|
console.log("返回时:" + $game_status, $game_close_status);
|
|
|
+ let $ble_status = wx.getStorageSync("ble_link_status");
|
|
|
+ if ($ble_status == false) {
|
|
|
+ //断开蓝牙连接
|
|
|
+ $this.change_device_status(0);
|
|
|
+ }
|
|
|
if ($game_status == 3) {
|
|
|
//不在游戏状态
|
|
|
$this.connect_toy = 0;
|
|
|
$this.connect_show = true;
|
|
|
$this.$bluetooth.watchingDevice($this);
|
|
|
$this.$bluetooth.watch_bluetooth_status($this);
|
|
|
- // let $ble_status = ble_store.getters.getBluetoothLinkStatus();
|
|
|
- // if ($ble_status == false) {
|
|
|
- // //断开蓝牙连接
|
|
|
- // $this.change_device_status(0);
|
|
|
- // }
|
|
|
+
|
|
|
$this.toy_UUID = "";
|
|
|
$this.$forceUpdate();
|
|
|
// 状态为1的时候重置为1 小乌龟
|
|
@@ -612,7 +605,6 @@ export default {
|
|
|
$this.$forceUpdate();
|
|
|
// 清空链接的设备
|
|
|
game_store.setters.clearDeviceToy();
|
|
|
-
|
|
|
}
|
|
|
}
|
|
|
},
|