|
@@ -196,8 +196,8 @@ const store = new Vuex.Store({
|
|
|
//是否安装了微信
|
|
//是否安装了微信
|
|
|
bInstallWechat: false,
|
|
bInstallWechat: false,
|
|
|
bHideWeixin: false,
|
|
bHideWeixin: false,
|
|
|
-
|
|
|
|
|
- clientName:'',//但是客户端名字
|
|
|
|
|
|
|
+
|
|
|
|
|
+ clientName: '', //但是客户端名字
|
|
|
system: '', // 系统版本
|
|
system: '', // 系统版本
|
|
|
platform: '', // 平台
|
|
platform: '', // 平台
|
|
|
appName: '',
|
|
appName: '',
|
|
@@ -205,6 +205,13 @@ const store = new Vuex.Store({
|
|
|
versionCode: '',
|
|
versionCode: '',
|
|
|
showEndTime: config.endTime, //游戏显示时间字段,后台返回对应此时间之前的数据
|
|
showEndTime: config.endTime, //游戏显示时间字段,后台返回对应此时间之前的数据
|
|
|
|
|
|
|
|
|
|
+ //现在游戏显示在对应的平台
|
|
|
|
|
+ gamePlatform: {
|
|
|
|
|
+ 0: 'android',
|
|
|
|
|
+ 1: 'ios',
|
|
|
|
|
+ 2: 'all'
|
|
|
|
|
+ },
|
|
|
|
|
+
|
|
|
globalAcc: null,
|
|
globalAcc: null,
|
|
|
globalOri: null,
|
|
globalOri: null,
|
|
|
|
|
|
|
@@ -267,6 +274,12 @@ const store = new Vuex.Store({
|
|
|
bListenerUpdate: false,
|
|
bListenerUpdate: false,
|
|
|
bListenerJson: false,
|
|
bListenerJson: false,
|
|
|
bListenerMac: false,
|
|
bListenerMac: false,
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ BluetoothAdapter: null,
|
|
|
|
|
+
|
|
|
|
|
+ //版本状态,用于区分部分特定的环境
|
|
|
|
|
+ versionCodeState: null
|
|
|
},
|
|
},
|
|
|
mutations: {
|
|
mutations: {
|
|
|
|
|
|
|
@@ -290,14 +303,17 @@ const store = new Vuex.Store({
|
|
|
* @param {Object} device
|
|
* @param {Object} device
|
|
|
*/
|
|
*/
|
|
|
setFinallUseDevice(state, device) {
|
|
setFinallUseDevice(state, device) {
|
|
|
- uni.setStorage({
|
|
|
|
|
- key: 'finallyUseDevice',
|
|
|
|
|
- data: device,
|
|
|
|
|
- success: (res) => {
|
|
|
|
|
- state.finallyUseDevice = device;
|
|
|
|
|
- console.log("保存finallyUseDevice:", res);
|
|
|
|
|
- }
|
|
|
|
|
- })
|
|
|
|
|
|
|
+ uni.setStorageSync('finallyUseDevice', device);
|
|
|
|
|
+ state.finallyUseDevice = device;
|
|
|
|
|
+ console.log("保存finallyUseDevice:", state.finallyUseDevice);
|
|
|
|
|
+ // uni.setStorage({
|
|
|
|
|
+ // key: 'finallyUseDevice',
|
|
|
|
|
+ // data: device,
|
|
|
|
|
+ // success: (res) => {
|
|
|
|
|
+ // state.finallyUseDevice = device;
|
|
|
|
|
+ // console.log("保存finallyUseDevice:", res);
|
|
|
|
|
+ // }
|
|
|
|
|
+ // })
|
|
|
},
|
|
},
|
|
|
/**
|
|
/**
|
|
|
* 移除记录的use device
|
|
* 移除记录的use device
|
|
@@ -742,7 +758,7 @@ const store = new Vuex.Store({
|
|
|
for (let i = 0; i < state.BLEInfoList.length; i++) {
|
|
for (let i = 0; i < state.BLEInfoList.length; i++) {
|
|
|
let eq = state.BLEInfoList[i];
|
|
let eq = state.BLEInfoList[i];
|
|
|
if (item.id == eq.id) {
|
|
if (item.id == eq.id) {
|
|
|
- console.log("存储的======================:",item,eq);
|
|
|
|
|
|
|
+ // console.log("存储的======================:", item, eq);
|
|
|
state.BLEDeviceShowList.push(Object.assign({}, item, eq));
|
|
state.BLEDeviceShowList.push(Object.assign({}, item, eq));
|
|
|
break;
|
|
break;
|
|
|
}
|
|
}
|
|
@@ -859,7 +875,7 @@ const store = new Vuex.Store({
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
reqUtil.requestData(
|
|
reqUtil.requestData(
|
|
|
- config.URL.GAMELIST_BY_RANKING_SHOW, {
|
|
|
|
|
|
|
+ config.URL.GAMELIST_BY_RANKING_SHOW_AND_PLATFORM, {
|
|
|
rankingShow: 1,
|
|
rankingShow: 1,
|
|
|
page: 1,
|
|
page: 1,
|
|
|
size: 100
|
|
size: 100
|
|
@@ -1043,6 +1059,9 @@ const store = new Vuex.Store({
|
|
|
// }
|
|
// }
|
|
|
// });
|
|
// });
|
|
|
|
|
|
|
|
|
|
+ //获取版本信息
|
|
|
|
|
+ this.commit('getVersionCode');
|
|
|
|
|
+
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
// 退出登录
|
|
// 退出登录
|
|
@@ -1720,7 +1739,13 @@ const store = new Vuex.Store({
|
|
|
az
|
|
az
|
|
|
} = data.acc;
|
|
} = data.acc;
|
|
|
|
|
|
|
|
- state.filter.Update(new o0.Vector3(ax, ay, az), msGap, callback); //我自己的更新acc的函数
|
|
|
|
|
|
|
+ let {
|
|
|
|
|
+ gx,
|
|
|
|
|
+ gy,
|
|
|
|
|
+ gz
|
|
|
|
|
+ } = data.gyro;
|
|
|
|
|
+
|
|
|
|
|
+ state.filter.Update(new o0.Vector3(ax, ay, az), msGap, new o0.Vector3(gx, gy, gz) , callback); //我自己的更新acc的函数
|
|
|
},
|
|
},
|
|
|
/**
|
|
/**
|
|
|
* 限制开始游戏
|
|
* 限制开始游戏
|
|
@@ -1950,7 +1975,7 @@ const store = new Vuex.Store({
|
|
|
uni.getBLEDeviceServices({
|
|
uni.getBLEDeviceServices({
|
|
|
deviceId: item.deviceId,
|
|
deviceId: item.deviceId,
|
|
|
success: res => {
|
|
success: res => {
|
|
|
- console.log("getBLEDeviceServices==", JSON.stringify(res), item);
|
|
|
|
|
|
|
+ // console.log("getBLEDeviceServices==", JSON.stringify(res), item);
|
|
|
serviceList = res.services;
|
|
serviceList = res.services;
|
|
|
if (getServiceList) {
|
|
if (getServiceList) {
|
|
|
getServiceList(serviceList);
|
|
getServiceList(serviceList);
|
|
@@ -1990,8 +2015,8 @@ const store = new Vuex.Store({
|
|
|
fail: failRes => {
|
|
fail: failRes => {
|
|
|
console.log('device services:', failRes.services)
|
|
console.log('device services:', failRes.services)
|
|
|
uni.showModal({
|
|
uni.showModal({
|
|
|
- title: '连接失败',
|
|
|
|
|
- content: '未获取到相应服务,请继续尝试连接设备。'
|
|
|
|
|
|
|
+ title: '连接错误',
|
|
|
|
|
+ content: '请尝试重新连接设备。'
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
@@ -2267,22 +2292,13 @@ const store = new Vuex.Store({
|
|
|
//获取手机中蓝牙已匹配的设备
|
|
//获取手机中蓝牙已匹配的设备
|
|
|
B_GetBondedDevices(state, context) {
|
|
B_GetBondedDevices(state, context) {
|
|
|
// console.log("getBondedDevices ====>");
|
|
// console.log("getBondedDevices ====>");
|
|
|
- // uni.getBluetoothDevices({
|
|
|
|
|
- // success(res) {
|
|
|
|
|
- // console.log("getBluetoothDevices:", res)
|
|
|
|
|
- // }
|
|
|
|
|
- // })
|
|
|
|
|
-
|
|
|
|
|
- // uni.getConnectedBluetoothDevices({
|
|
|
|
|
- // success(res) {
|
|
|
|
|
- // console.log("getConnectedBluetoothDevices:", res)
|
|
|
|
|
- // }
|
|
|
|
|
- // })
|
|
|
|
|
let {
|
|
let {
|
|
|
- success = null
|
|
|
|
|
|
|
+ success = null,
|
|
|
|
|
+ deviceId = null
|
|
|
} = context;
|
|
} = context;
|
|
|
//Android
|
|
//Android
|
|
|
- function android_bluetooth_list(deviceName) {
|
|
|
|
|
|
|
+ function android_bluetooth_list(deviceName, deviceId, count, callback) {
|
|
|
|
|
+ console.log("===》调用android_bluetooth_list count:", count);
|
|
|
var main = plus.android.runtimeMainActivity();
|
|
var main = plus.android.runtimeMainActivity();
|
|
|
var BluetoothAdapter = plus.android.importClass("android.bluetooth.BluetoothAdapter");
|
|
var BluetoothAdapter = plus.android.importClass("android.bluetooth.BluetoothAdapter");
|
|
|
var BAdapter = BluetoothAdapter.getDefaultAdapter();
|
|
var BAdapter = BluetoothAdapter.getDefaultAdapter();
|
|
@@ -2290,19 +2306,85 @@ const store = new Vuex.Store({
|
|
|
var lists = BAdapter.getBondedDevices();
|
|
var lists = BAdapter.getBondedDevices();
|
|
|
plus.android.importClass(lists);
|
|
plus.android.importClass(lists);
|
|
|
var len = lists.size();
|
|
var len = lists.size();
|
|
|
- // console.log("getBondedDevices.len=" + len);
|
|
|
|
|
|
|
+ // var BluetoothManager = plus.android.importClass("android.bluetooth.BluetoothManager");
|
|
|
|
|
+ // var BluetoothDevice = plus.android.importClass("android.bluetooth.BluetoothDevice");
|
|
|
|
|
+ // var ProfileType = plus.android.importClass("android.bluetooth.ProfileType");
|
|
|
|
|
+ // plus.android.importClass(BluetoothManager);
|
|
|
|
|
+ // plus.android.importClass(BluetoothDevice);
|
|
|
|
|
+ // plus.android.importClass(ProfileType);
|
|
|
|
|
+ // var UUID = plus.android.importClass("java.util.UUID");
|
|
|
|
|
+ // var uuid = UUID.fromString("0000FFF0-0000-1000-8000-00805F9B34FB");
|
|
|
|
|
+
|
|
|
|
|
+ // var gDevice = BAdapter.getRemoteDevice("C5:5C:19:04:00:30");
|
|
|
|
|
+ // plus.android.importClass(gDevice);
|
|
|
|
|
+ // var bluetoothSocket = gDevice.createInsecureRfcommSocketToServiceRecord(uuid);
|
|
|
|
|
+ // plus.android.importClass(bluetoothSocket);
|
|
|
|
|
+ // console.log("是否连接:",bluetoothSocket.isConnected());
|
|
|
|
|
+ // var deviceLists = BluetoothManager.getConnectedDevices();
|
|
|
|
|
+ // plus.android.importClass(deviceLists);
|
|
|
|
|
+ // console.log("deviceLists.len=" + deviceLists.size());
|
|
|
|
|
+
|
|
|
|
|
+ console.log("getBondedDevices.len=", len, "deviceId:", deviceId);
|
|
|
|
|
+
|
|
|
|
|
+ //测试start===》 如果没有配对的设备,重新获取
|
|
|
|
|
+ // count--;
|
|
|
|
|
+ // if(count >0){
|
|
|
|
|
+ // setTimeout(()=>{
|
|
|
|
|
+ // android_bluetooth_list("BGBox", deviceId, count, callback);
|
|
|
|
|
+ // },1000)
|
|
|
|
|
+ // return;
|
|
|
|
|
+ // }
|
|
|
|
|
+ //测试end
|
|
|
|
|
+
|
|
|
if (len == 0) {
|
|
if (len == 0) {
|
|
|
- //如果没有配对的设备
|
|
|
|
|
- return null;
|
|
|
|
|
|
|
+ //如果没有配对的设备,重新获取
|
|
|
|
|
+ count--;
|
|
|
|
|
+ if (count > 0) {
|
|
|
|
|
+ setTimeout(() => {
|
|
|
|
|
+ android_bluetooth_list("BGBox", deviceId, count, callback);
|
|
|
|
|
+ }, 2000)
|
|
|
|
|
+ } else {
|
|
|
|
|
+ if (callback)
|
|
|
|
|
+ callback(null);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
} else {
|
|
} else {
|
|
|
var iterator = lists.iterator();
|
|
var iterator = lists.iterator();
|
|
|
|
|
+ let temp = null;
|
|
|
plus.android.importClass(iterator);
|
|
plus.android.importClass(iterator);
|
|
|
while (iterator.hasNext()) {
|
|
while (iterator.hasNext()) {
|
|
|
var d = iterator.next();
|
|
var d = iterator.next();
|
|
|
plus.android.importClass(d);
|
|
plus.android.importClass(d);
|
|
|
- let temp = null;
|
|
|
|
|
- console.log("匹配列表的:",d.getName(),d.getBondState());
|
|
|
|
|
- if (d.getName().indexOf(deviceName) > -1) {
|
|
|
|
|
|
|
+ // if (d.getName().indexOf(deviceName) > -1)
|
|
|
|
|
+ console.log(d.getAddress(), deviceId);
|
|
|
|
|
+ if (deviceId == null && d.getName().indexOf(deviceName) > -1) {
|
|
|
|
|
+ let typeEnum = {
|
|
|
|
|
+ 0: 'Unknown',
|
|
|
|
|
+ 1: 'Classic',
|
|
|
|
|
+ 2: 'Le',
|
|
|
|
|
+ 3: 'Dual'
|
|
|
|
|
+ };
|
|
|
|
|
+ let bondStateEnum = {
|
|
|
|
|
+ 10: 'None',
|
|
|
|
|
+ 11: 'Bonding',
|
|
|
|
|
+ 12: 'Bonded'
|
|
|
|
|
+ };
|
|
|
|
|
+ temp = {
|
|
|
|
|
+ name: d.getName(),
|
|
|
|
|
+ address: d.getAddress(),
|
|
|
|
|
+ type: {
|
|
|
|
|
+ 'value': d.getType(),
|
|
|
|
|
+ 'name': typeEnum[d.getType()]
|
|
|
|
|
+ },
|
|
|
|
|
+ bondState: {
|
|
|
|
|
+ 'value': d.getBondState(),
|
|
|
|
|
+ 'name': bondStateEnum[d.getBondState()]
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ console.log("获取到设备,并且跳出:", temp);
|
|
|
|
|
+ break;
|
|
|
|
|
+ } else if (d.getAddress() == deviceId) {
|
|
|
// console.log(d.getName());
|
|
// console.log(d.getName());
|
|
|
// console.log(d.getAddress());
|
|
// console.log(d.getAddress());
|
|
|
// Classic 1
|
|
// Classic 1
|
|
@@ -2337,161 +2419,125 @@ const store = new Vuex.Store({
|
|
|
'name': bondStateEnum[d.getBondState()]
|
|
'name': bondStateEnum[d.getBondState()]
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+ console.log("获取到设备,并且跳出:", temp);
|
|
|
|
|
+ break;
|
|
|
}
|
|
}
|
|
|
- return temp;
|
|
|
|
|
|
|
+ }
|
|
|
|
|
+ // return temp;
|
|
|
|
|
+ if (temp == null && count > 0) {
|
|
|
|
|
+ count--;
|
|
|
|
|
+ setTimeout(() => {
|
|
|
|
|
+ android_bluetooth_list("BGBox", deviceId, count, callback);
|
|
|
|
|
+ }, 2000)
|
|
|
|
|
+ } else {
|
|
|
|
|
+ if (callback)
|
|
|
|
|
+ callback(temp);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ function ios_bluetooth_list(deviceName, callback) {
|
|
|
|
|
+ //原生操作 首先需要通过 uni.requireNativePlugin("ModuleName") 获取 module
|
|
|
|
|
+ var SLABluetoothModule = uni.requireNativePlugin("SLABluetoothUniPlugin-SLAModule")
|
|
|
|
|
+ if (SLABluetoothModule) {
|
|
|
|
|
+ SLABluetoothModule.getConnectionDevicesAsync({
|
|
|
|
|
+ serviceUUIDs: "FFF0"
|
|
|
|
|
+ }, (res) => {
|
|
|
|
|
+ console.log("***************getConnectionDevicesAsync:", JSON.stringify(res));
|
|
|
|
|
+ if (res.data) {
|
|
|
|
|
+ console.log("获取到对应的匹配设备!");
|
|
|
|
|
|
|
|
- function searchIOS() {
|
|
|
|
|
- var CBCentralManager = plus.ios.import("CBCentralManager");
|
|
|
|
|
- var manager = new CBCentralManager();
|
|
|
|
|
- var delegate = plus.ios.implements("CBCentralManagerDelegate", {
|
|
|
|
|
- "centralManagerDidUpdateState:": centralManagerDidUpdateState,
|
|
|
|
|
- "centralManager:didDiscoverPeripheral:advertisementData:RSSI:": didDiscoverPeripheral
|
|
|
|
|
- });
|
|
|
|
|
- if (plus.device.model == "iPad" || plus.device.model == "iPod") {
|
|
|
|
|
- manager.initWithDelegatequeue(delegate, null);
|
|
|
|
|
- } else {
|
|
|
|
|
- manager.initWithDelegatequeue(delegate, null, null);
|
|
|
|
|
- let arr = manager.retrieveConnectedPeripheralsWithServices();
|
|
|
|
|
- console.error(arr.length);
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- function centralManagerDidUpdateState(central) {
|
|
|
|
|
- console.log(central);
|
|
|
|
|
- var state = central.plusGetAttribute('state');
|
|
|
|
|
- console.log(state);
|
|
|
|
|
- if (state == 4) {
|
|
|
|
|
- writelog('请开启蓝牙');
|
|
|
|
|
- }
|
|
|
|
|
- if (state == 5) {
|
|
|
|
|
- console.log("中央外设管理器状态 state= " + state);
|
|
|
|
|
- central.scanForPeripheralsWithServicesoptions(null, null);
|
|
|
|
|
- }
|
|
|
|
|
- //writelog("中央外设管理器状态 state= " + state);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- function didDiscoverPeripheral(central, peripheral, advertisementData, RSSI) {
|
|
|
|
|
- var name = peripheral.plusGetAttribute("name");
|
|
|
|
|
- var uuid = peripheral.plusGetAttribute("identifier").plusGetAttribute("UUIDString");
|
|
|
|
|
- var rssi = RSSI.plusGetAttribute("intValue");
|
|
|
|
|
- var dist = calcDistByRSSI(rssi, 74, 2);
|
|
|
|
|
- writelog("蓝牙设备:" + name + " " + uuid + " " + rssi + " " + dist + "米");
|
|
|
|
|
-
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- function writelog(msg) {
|
|
|
|
|
- console.log(msg);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- function calcDistByRSSI(rssi, a, n) {
|
|
|
|
|
- var rs = Math.abs(rssi);
|
|
|
|
|
- var power = (rs - a) / (10 * n);
|
|
|
|
|
- return Math.pow(10, parseFloat(power)).toFixed(2);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ let typeEnum = {
|
|
|
|
|
+ 0: 'Unknown',
|
|
|
|
|
+ 1: 'Classic',
|
|
|
|
|
+ 2: 'Le',
|
|
|
|
|
+ 3: 'Dual'
|
|
|
|
|
+ };
|
|
|
|
|
+ let bondStateEnum = {
|
|
|
|
|
+ 10: 'None',
|
|
|
|
|
+ 11: 'Bonding',
|
|
|
|
|
+ 12: 'Bonded'
|
|
|
|
|
+ };
|
|
|
|
|
+ let temp = {
|
|
|
|
|
+ name: res.data[0].name,
|
|
|
|
|
+ address: res.data[0].identifier,
|
|
|
|
|
+ type: {
|
|
|
|
|
+ 'value': 2,
|
|
|
|
|
+ 'name': typeEnum[2]
|
|
|
|
|
+ },
|
|
|
|
|
+ bondState: {
|
|
|
|
|
+ 'value': 12,
|
|
|
|
|
+ 'name': bondStateEnum[12]
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ if (callback) {
|
|
|
|
|
+ callback({
|
|
|
|
|
+ "device": temp
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- function ios_bluetooth_list(deviceName,callback) {
|
|
|
|
|
- // let CBCentralManager= plus.ios.importClass("CBCentralManager");
|
|
|
|
|
- // let _centralManager = new CBCentralManager();
|
|
|
|
|
- // _centralManager.initWithDelegatequeue(plus.ios.currentWebview(),null);
|
|
|
|
|
- // let arr = _centralManager.retrieveConnectedPeripheralsWithServices();
|
|
|
|
|
- // console.error(arr.length);
|
|
|
|
|
- // searchIOS();
|
|
|
|
|
- //原生操作
|
|
|
|
|
- // 首先需要通过 uni.requireNativePlugin("ModuleName") 获取 module
|
|
|
|
|
- var SLABluetoothModule = uni.requireNativePlugin("SLABluetoothUniPlugin-SLAModule")
|
|
|
|
|
- if(SLABluetoothModule){
|
|
|
|
|
- SLABluetoothModule.getConnectionDevicesAsync({serviceUUIDs:"FFF0"},(res)=>{
|
|
|
|
|
- console.log("***************getConnectionDevicesAsync:",JSON.stringify(res));
|
|
|
|
|
- if(res.data){
|
|
|
|
|
- console.log("获取到对应的匹配设备!");
|
|
|
|
|
-
|
|
|
|
|
- let typeEnum = {
|
|
|
|
|
- 0: 'Unknown',
|
|
|
|
|
- 1: 'Classic',
|
|
|
|
|
- 2: 'Le',
|
|
|
|
|
- 3: 'Dual'
|
|
|
|
|
- };
|
|
|
|
|
- let bondStateEnum = {
|
|
|
|
|
- 10: 'None',
|
|
|
|
|
- 11: 'Bonding',
|
|
|
|
|
- 12: 'Bonded'
|
|
|
|
|
- };
|
|
|
|
|
- let temp = {
|
|
|
|
|
- name: res.data[0].name,
|
|
|
|
|
- address: res.data[0].identifier,
|
|
|
|
|
- type: {
|
|
|
|
|
- 'value': 2,
|
|
|
|
|
- 'name': typeEnum[2]
|
|
|
|
|
- },
|
|
|
|
|
- bondState: {
|
|
|
|
|
- 'value': 12,
|
|
|
|
|
- 'name': bondStateEnum[12]
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- if(callback){
|
|
|
|
|
- callback({"device":temp});
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- }else{
|
|
|
|
|
- console.log("匹配设备数据不存在!");
|
|
|
|
|
- if(callback){
|
|
|
|
|
- callback({"device":null});
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- })
|
|
|
|
|
- }else{
|
|
|
|
|
- console.error("不存在SLABluetoothModule ios 插件!");
|
|
|
|
|
- if(callback){
|
|
|
|
|
- callback({"device":null});
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ } else {
|
|
|
|
|
+ console.log("匹配设备数据不存在!");
|
|
|
|
|
+ if (callback) {
|
|
|
|
|
+ callback({
|
|
|
|
|
+ "device": null
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+ } else {
|
|
|
|
|
+ console.error("不存在SLABluetoothModule ios 插件!");
|
|
|
|
|
+ if (callback) {
|
|
|
|
|
+ callback({
|
|
|
|
|
+ "device": null
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let device = null;
|
|
let device = null;
|
|
|
|
|
+ let _count = 3;
|
|
|
|
|
|
|
|
switch (plus.os.name) {
|
|
switch (plus.os.name) {
|
|
|
case "Android":
|
|
case "Android":
|
|
|
// Android平台: plus.android.*
|
|
// Android平台: plus.android.*
|
|
|
- device = android_bluetooth_list("BGBox");
|
|
|
|
|
- console.log("android getBondedDevices 匹配的对象======>", device)
|
|
|
|
|
- if (device != null) {
|
|
|
|
|
- state.bPhoneMatched = true;
|
|
|
|
|
- } else {
|
|
|
|
|
- state.bPhoneMatched = false;
|
|
|
|
|
- }
|
|
|
|
|
- if (success) {
|
|
|
|
|
- success(device);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ android_bluetooth_list("BGBox", deviceId, _count, (data) => {
|
|
|
|
|
+ device = data;
|
|
|
|
|
+ console.log("android getBondedDevices 匹配的对象======>", device)
|
|
|
|
|
+ if (device != null) {
|
|
|
|
|
+ state.bPhoneMatched = true;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ state.bPhoneMatched = false;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (success) {
|
|
|
|
|
+ success(device);
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
break;
|
|
break;
|
|
|
case "iOS":
|
|
case "iOS":
|
|
|
// iOS平台: plus.ios.*
|
|
// iOS平台: plus.ios.*
|
|
|
- ios_bluetooth_list("BGBox",(res)=>{
|
|
|
|
|
- device = res.device
|
|
|
|
|
- if (success) {
|
|
|
|
|
- success(device);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- console.log("ios getBondedDevices 匹配的对象======>", device)
|
|
|
|
|
- if (device != null) {
|
|
|
|
|
- state.bPhoneMatched = true;
|
|
|
|
|
- } else {
|
|
|
|
|
- state.bPhoneMatched = false;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ ios_bluetooth_list("BGBox", (res) => {
|
|
|
|
|
+ device = res.device
|
|
|
|
|
+ if (success) {
|
|
|
|
|
+ success(device);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ console.log("ios getBondedDevices 匹配的对象======>", device)
|
|
|
|
|
+ if (device != null) {
|
|
|
|
|
+ state.bPhoneMatched = true;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ state.bPhoneMatched = false;
|
|
|
|
|
+ }
|
|
|
});
|
|
});
|
|
|
break;
|
|
break;
|
|
|
default:
|
|
default:
|
|
|
- // 其它平台
|
|
|
|
|
- if (success) {
|
|
|
|
|
- success(device);
|
|
|
|
|
|
|
+ // 其它平台
|
|
|
|
|
+ if (success) {
|
|
|
|
|
+ success(device);
|
|
|
}
|
|
}
|
|
|
break;
|
|
break;
|
|
|
}
|
|
}
|
|
@@ -2509,7 +2555,7 @@ const store = new Vuex.Store({
|
|
|
main.startActivity(intent);
|
|
main.startActivity(intent);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- function ios_bluetooth_setting() {
|
|
|
|
|
|
|
+ function ios_bluetooth_setting() {
|
|
|
// var UIApplication = plus.ios.import("UIApplication");
|
|
// var UIApplication = plus.ios.import("UIApplication");
|
|
|
// var application2 = UIApplication.sharedApplication();
|
|
// var application2 = UIApplication.sharedApplication();
|
|
|
// var NSURL2 = plus.ios.import("NSURL");
|
|
// var NSURL2 = plus.ios.import("NSURL");
|
|
@@ -2523,10 +2569,12 @@ const store = new Vuex.Store({
|
|
|
// action: 'App-Prefs:root=Bluetooth'
|
|
// action: 'App-Prefs:root=Bluetooth'
|
|
|
// }, function(e) {
|
|
// }, function(e) {
|
|
|
// console.log(JSON.stringify(e));
|
|
// console.log(JSON.stringify(e));
|
|
|
- // });
|
|
|
|
|
-
|
|
|
|
|
- plus.runtime.launchApplication({action:'App-Prefs:root=Bluetooth'}, function(e){
|
|
|
|
|
- console.log(JSON.stringify(e));
|
|
|
|
|
|
|
+ // });
|
|
|
|
|
+
|
|
|
|
|
+ plus.runtime.launchApplication({
|
|
|
|
|
+ action: 'App-Prefs:root=Bluetooth'
|
|
|
|
|
+ }, function(e) {
|
|
|
|
|
+ console.log(JSON.stringify(e));
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -2546,7 +2594,23 @@ const store = new Vuex.Store({
|
|
|
break;
|
|
break;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ },
|
|
|
|
|
+
|
|
|
|
|
+ //获取versionCode状态,用于处理特定的信息显示
|
|
|
|
|
+ getVersionCode(state) {
|
|
|
|
|
+ let self = this;
|
|
|
|
|
+ reqUtil.requestData(config.URL.GETVERSIONCODE, {
|
|
|
|
|
+ code: state.versionCode
|
|
|
|
|
+ }).then(res => {
|
|
|
|
|
+ console.log('获取GETVERSIONCODE =====', res);
|
|
|
|
|
+ if (res.code == 0) {
|
|
|
|
|
+ state.versionCodeState = res.data;
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ e => {
|
|
|
|
|
+ console.log(e)
|
|
|
|
|
+ });
|
|
|
|
|
+ },
|
|
|
}
|
|
}
|
|
|
})
|
|
})
|
|
|
|
|
|