|
@@ -120,8 +120,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"/>
|
|
|
|
|
|
<!-- <van-popup-->
|
|
|
<!-- :show="start_show"-->
|
|
@@ -210,42 +210,52 @@ export default {
|
|
|
},
|
|
|
//扫描连接蓝牙
|
|
|
scan_to_bluetooth() {
|
|
|
- wx.scanCode({
|
|
|
- onlyFromCamera: true,
|
|
|
- success: (res) => {
|
|
|
- wx.vibrateShort({
|
|
|
- type: "heavy",
|
|
|
- });
|
|
|
-
|
|
|
- let $data = res;
|
|
|
- if ($data.result) {
|
|
|
- let url = decodeURIComponent($data.result);
|
|
|
- let $code = url.match(/\?ring=(.*)/)
|
|
|
- ? url.match(/\?ring=(.*)/)
|
|
|
- : url.match(/\?code=(.*)/);
|
|
|
- // 判断新的标识值
|
|
|
- $this.code = $code[1].toUpperCase();
|
|
|
- console.log("头环码", $code);
|
|
|
- //打开蓝牙设备
|
|
|
- wx.openBluetoothAdapter({
|
|
|
- success(res) {
|
|
|
- //判断已经打开连接了
|
|
|
- if (res["errMsg"] == "openBluetoothAdapter:ok") {
|
|
|
- $this.startBluetoothDevicesDiscovery();
|
|
|
- }
|
|
|
- },
|
|
|
- fail(err) {
|
|
|
- if (err["errCode"] == 10001) {
|
|
|
- Toast.fail({
|
|
|
- message: "请打开蓝牙和位置信息!",
|
|
|
- });
|
|
|
- } else {
|
|
|
- Toast.fail({
|
|
|
- message: "蓝牙连接失败",
|
|
|
+ wx.getSystemInfoAsync({
|
|
|
+ success(res) {
|
|
|
+ console.log(res)
|
|
|
+ if (res.bluetoothEnabled == false || res.locationEnabled == false) {
|
|
|
+ Toast.fail('请打开蓝牙和位置信息')
|
|
|
+ } else {
|
|
|
+ wx.scanCode({
|
|
|
+ onlyFromCamera: true,
|
|
|
+ success: (res) => {
|
|
|
+ wx.vibrateShort({
|
|
|
+ type: "heavy"
|
|
|
+ })
|
|
|
+
|
|
|
+ let $data = res;
|
|
|
+ if ($data.result) {
|
|
|
+ let url = decodeURIComponent($data.result);
|
|
|
+ let $code = url.match(/\?ring=(.*)/)
|
|
|
+ ? url.match(/\?ring=(.*)/)
|
|
|
+ : url.match(/\?code=(.*)/);
|
|
|
+ // 判断新的标识值
|
|
|
+ $this.code = $code[1].toUpperCase();
|
|
|
+ console.log("头环码", $code);
|
|
|
+ //打开蓝牙设备
|
|
|
+ wx.openBluetoothAdapter({
|
|
|
+ success(res) {
|
|
|
+ //判断已经打开连接了
|
|
|
+ if (res["errMsg"] == "openBluetoothAdapter:ok") {
|
|
|
+ $this.startBluetoothDevicesDiscovery();
|
|
|
+ }
|
|
|
+ },
|
|
|
+ fail(err) {
|
|
|
+ if (err["errCode"] == 10001) {
|
|
|
+ Toast.fail({
|
|
|
+ message: "请打开蓝牙和位置信息!",
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ Toast.fail({
|
|
|
+ message: "蓝牙连接失败",
|
|
|
+ });
|
|
|
+ }
|
|
|
+ },
|
|
|
});
|
|
|
}
|
|
|
},
|
|
|
});
|
|
|
+
|
|
|
}
|
|
|
},
|
|
|
});
|
|
@@ -430,12 +440,6 @@ export default {
|
|
|
},
|
|
|
mounted() {
|
|
|
$this.get_toy_list();
|
|
|
- wx.getSystemInfo({
|
|
|
- success(res) {
|
|
|
- console.log(res);
|
|
|
- console.log(res.brand);
|
|
|
- },
|
|
|
- });
|
|
|
},
|
|
|
created() {
|
|
|
$this = this;
|