处理636的兼容
This commit is contained in:
@@ -23,7 +23,49 @@ App({
|
|||||||
secret: "eQ50JYimMp0X7uhNLj6D3lTEk4TUUvEG7dvaqKM9t1U="
|
secret: "eQ50JYimMp0X7uhNLj6D3lTEk4TUUvEG7dvaqKM9t1U="
|
||||||
},
|
},
|
||||||
device: {
|
device: {
|
||||||
setting: [], // 即将要搜索周边秤的配置
|
setting: [{
|
||||||
|
"advLength": 999,
|
||||||
|
"calorieStatus": 0,
|
||||||
|
"createBy": null,
|
||||||
|
"deviceAccuracyType": 2,
|
||||||
|
"deviceCalcuteType": 3,
|
||||||
|
"deviceConnectType": 2,
|
||||||
|
"deviceFuncType": 223,
|
||||||
|
"deviceName": "CF568_G",
|
||||||
|
"devicePowerType": 3,
|
||||||
|
"deviceProtocolType": 3,
|
||||||
|
"deviceType": 1,
|
||||||
|
"deviceUnitType": "0,1,11",
|
||||||
|
"id": 65,
|
||||||
|
"imgUrl": null,
|
||||||
|
"macAddressStart": 6,
|
||||||
|
"remark": null,
|
||||||
|
"sign": "FF",
|
||||||
|
"status": 0,
|
||||||
|
"uhStatus": 1,
|
||||||
|
"updateBy": null
|
||||||
|
}, {
|
||||||
|
"advLength": 999,
|
||||||
|
"calorieStatus": 0,
|
||||||
|
"createBy": null,
|
||||||
|
"deviceAccuracyType": 2,
|
||||||
|
"deviceCalcuteType": 4,
|
||||||
|
"deviceConnectType": 2,
|
||||||
|
"deviceFuncType": 65759,
|
||||||
|
"deviceName": "CF636_G",
|
||||||
|
"devicePowerType": 3,
|
||||||
|
"deviceProtocolType": 3,
|
||||||
|
"deviceType": 1,
|
||||||
|
"deviceUnitType": "0,1,2",
|
||||||
|
"id": 216,
|
||||||
|
"imgUrl": null,
|
||||||
|
"macAddressStart": 6,
|
||||||
|
"remark": null,
|
||||||
|
"sign": "FF",
|
||||||
|
"status": 0,
|
||||||
|
"uhStatus": 1,
|
||||||
|
"updateBy": null
|
||||||
|
}], // 即将要搜索周边秤的配置
|
||||||
list: [], // 根据配置搜索到秤的列表
|
list: [], // 根据配置搜索到秤的列表
|
||||||
mac: null, // 选中的设备mac地址/SN码
|
mac: null, // 选中的设备mac地址/SN码
|
||||||
name: "", // 设备名称
|
name: "", // 设备名称
|
||||||
|
|||||||
@@ -38,8 +38,8 @@
|
|||||||
"style": "v2",
|
"style": "v2",
|
||||||
"plugins": {
|
"plugins": {
|
||||||
"ppScale-plugin": {
|
"ppScale-plugin": {
|
||||||
"version": "1.2.14",
|
"version": "0.0.11",
|
||||||
"provider": "wx0ffb48417ce6345c"
|
"provider": "wx0826af4e4908f524"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"sitemapLocation": "sitemap.json",
|
"sitemapLocation": "sitemap.json",
|
||||||
|
|||||||
@@ -5,12 +5,11 @@ Page({
|
|||||||
data: {
|
data: {
|
||||||
deviceConnect: false,
|
deviceConnect: false,
|
||||||
|
|
||||||
deviceInfo: null
|
deviceInfo: null,
|
||||||
},
|
},
|
||||||
|
|
||||||
onLoad(options) {
|
onLoad(options) {
|
||||||
this.getDevice();
|
this.getDevice();
|
||||||
this.initBluetooth();
|
|
||||||
|
|
||||||
app.globalData.ppScale.plugin.bus.subscribe("deviceConnect", (res) => {
|
app.globalData.ppScale.plugin.bus.subscribe("deviceConnect", (res) => {
|
||||||
console.log('deviceInfo ===》deviceConnect', res);
|
console.log('deviceInfo ===》deviceConnect', res);
|
||||||
@@ -21,17 +20,8 @@ Page({
|
|||||||
app.globalData.ppScale.activeProtocol.codeUpdateMTU((res) => {
|
app.globalData.ppScale.activeProtocol.codeUpdateMTU((res) => {
|
||||||
console.log("deviceInfo ===》codeUpdateMTU", res);
|
console.log("deviceInfo ===》codeUpdateMTU", res);
|
||||||
|
|
||||||
$.ajax("weighingScale/list/device", {}, "GET", false).then((res) => {
|
this.setData({
|
||||||
if(res.result && res.result.length) {
|
deviceConnect: true
|
||||||
let deviceConnect = res.result.some(item => item.macAddress === app.globalData.ppScale.device.mac);
|
|
||||||
if(deviceConnect) {
|
|
||||||
this.setData({
|
|
||||||
deviceConnect: true
|
|
||||||
})
|
|
||||||
} else {
|
|
||||||
app.globalData.ppScale.plugin.Blue.disconnect();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -54,56 +44,27 @@ Page({
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
async refreshToken(fn, flag) {
|
getDeviceSettingList() {
|
||||||
let bodyToken = wx.getStorageSync('bodyToken');
|
let seviceList = [];
|
||||||
let bodyTokenTime = wx.getStorageSync('bodyTokenTime');
|
app.globalData.ppScale.device.setting.map(item => {
|
||||||
if (!bodyToken || bodyTokenTime * 1000 < +new Date() || flag) {
|
if(this.data.deviceInfo.type === item.deviceName) {
|
||||||
let res = await app.globalData.ppScale.plugin.refreshToken({
|
seviceList.push(item);
|
||||||
url: "https://uniquehealth.lefuenergy.com",
|
}
|
||||||
data: {
|
})
|
||||||
"appKey": app.globalData.ppScale.options.key,
|
if(seviceList && seviceList.length) {
|
||||||
"appSecret": app.globalData.ppScale.options.secret
|
app.globalData.ppScale.plugin.Blue.setDeviceSetting(seviceList);
|
||||||
|
app.globalData.ppScale.plugin.Blue.start(seviceList[0].deviceName, false);
|
||||||
|
app.globalData.ppScale.plugin.bus.subscribe("devicesList", (res) => {
|
||||||
|
console.log("deviceInfo ===> devicesList", res);
|
||||||
|
let fIndex = res.findIndex(item => item.deviceId === this.data.deviceInfo.deviceId);
|
||||||
|
if (fIndex >= 0) {
|
||||||
|
app.globalData.ppScale.plugin.Blue.stopBluetoothDevicesDiscovery();
|
||||||
|
app.globalData.ppScale.plugin.Blue.createBLEConnection(res[fIndex]);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (res.data.code == 200) {
|
|
||||||
wx.setStorageSync('bodyToken', res.data.data.token);
|
|
||||||
wx.setStorageSync('bodyTokenTime', res.data.data.expireTime);
|
|
||||||
fn();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
fn();
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
getDeviceSettingList() {
|
|
||||||
let bodyToken = wx.getStorageSync("bodyToken");
|
|
||||||
app.globalData.ppScale.plugin.getDeviceSettingList({
|
|
||||||
url: "https://uniquehealth.lefuenergy.com",
|
|
||||||
data: {
|
|
||||||
appKey: app.globalData.ppScale.options.key
|
|
||||||
},
|
|
||||||
header: {
|
|
||||||
"token": bodyToken,
|
|
||||||
"Accept-Language": wx.getStorageSync("lang") || 'zh'
|
|
||||||
}
|
|
||||||
}).then((res) => {
|
|
||||||
if (res.data.code == 200) {
|
|
||||||
app.globalData.ppScale.plugin.Blue.setDeviceSetting(res.data.data);
|
|
||||||
app.globalData.ppScale.device.setting = res.data.data;
|
|
||||||
let deviceNames = res.data.data.map(item => item.deviceName);
|
|
||||||
app.globalData.ppScale.plugin.Blue.start(deviceNames, false);
|
|
||||||
app.globalData.ppScale.plugin.bus.subscribe("devicesList", (res_) => {
|
|
||||||
app.globalData.ppScale.plugin.Blue.stopBluetoothDevicesDiscovery();
|
|
||||||
app.globalData.ppScale.plugin.Blue.createBLEConnection(res_[0]);
|
|
||||||
});
|
|
||||||
} else if (res.data.code == 401 || res.data.code == 4008) {
|
|
||||||
// 401 token过期 / 4008 token为空
|
|
||||||
// 重新请求token解析数据
|
|
||||||
this.refreshToken(() => {
|
|
||||||
this.getDeviceSettingList();
|
|
||||||
}, true);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
// 获取已经绑定的设备列表
|
// 获取已经绑定的设备列表
|
||||||
getDevice() {
|
getDevice() {
|
||||||
@@ -112,6 +73,7 @@ Page({
|
|||||||
this.setData({
|
this.setData({
|
||||||
deviceInfo: res.result[0]
|
deviceInfo: res.result[0]
|
||||||
})
|
})
|
||||||
|
this.initBluetooth();
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -120,7 +82,7 @@ Page({
|
|||||||
app.globalData.ppScale.activeProtocol.codeClearDeviceData("00", (res) => {
|
app.globalData.ppScale.activeProtocol.codeClearDeviceData("00", (res) => {
|
||||||
console.log("deviceInfo === codeClearDeviceData", res);
|
console.log("deviceInfo === codeClearDeviceData", res);
|
||||||
|
|
||||||
let scaleDeviceId = app.globalData.ppScale.device.mac.replace(/:/g, '');
|
let scaleDeviceId = this.data.deviceInfo.macAddress.replace(/:/g, '');
|
||||||
let params = {
|
let params = {
|
||||||
equipmentCode: scaleDeviceId,
|
equipmentCode: scaleDeviceId,
|
||||||
};
|
};
|
||||||
@@ -141,7 +103,8 @@ Page({
|
|||||||
icon: "none",
|
icon: "none",
|
||||||
title: "删除失败,请靠近设备并点亮后再试"
|
title: "删除失败,请靠近设备并点亮后再试"
|
||||||
})
|
})
|
||||||
this.initBluetooth();
|
app.globalData.ppScale.plugin.Blue.stop();
|
||||||
|
this.getDeviceSettingList();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@@ -31,4 +31,4 @@
|
|||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view class="btn" bind:tap="delDevice">删除设备</view>
|
<view class="btn" bind:tap="delDevice">删除设备</view>
|
||||||
|
|||||||
+39
-3
@@ -25,13 +25,49 @@ Page({
|
|||||||
url: "/pages/userInfo/userInfo?initBluetooth=1&customerType=1"
|
url: "/pages/userInfo/userInfo?initBluetooth=1&customerType=1"
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
wx.showToast({
|
wx.login({
|
||||||
icon: "none",
|
success: (res) => {
|
||||||
title: "请先登录"
|
if (res.code) {
|
||||||
|
this.checkOpenIdLogin(res.code);
|
||||||
|
} else {
|
||||||
|
wx.showToast({
|
||||||
|
icon: "none",
|
||||||
|
title: "登录失败,请稍后再试!",
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// 微信一键登录
|
||||||
|
checkOpenIdLogin(code) {
|
||||||
|
let params = {
|
||||||
|
code: code
|
||||||
|
};
|
||||||
|
$.ajax("weighingScale/checkOpenIdLogin", params, "POST", true, "登录中...").then((res) => {
|
||||||
|
wx.setStorageSync("userInfo", res.result.user);
|
||||||
|
wx.setStorageSync("token", res.result.token);
|
||||||
|
if(res.result.token && res.result.user) {
|
||||||
|
this.setData({
|
||||||
|
token: res.result.token,
|
||||||
|
userInfo: res.result.user
|
||||||
|
})
|
||||||
|
this.getDevice();
|
||||||
|
} else {
|
||||||
|
wx.showToast({
|
||||||
|
icon: "none",
|
||||||
|
title: "请先补全个人信息"
|
||||||
|
})
|
||||||
|
setTimeout(() => {
|
||||||
|
wx.navigateTo({
|
||||||
|
url: "/pages/userInfo/userInfo?initBluetooth=0&customerType=1"
|
||||||
|
})
|
||||||
|
}, 1500)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
// 打开设备详情
|
// 打开设备详情
|
||||||
openDeviceInfo() {
|
openDeviceInfo() {
|
||||||
if(this.data.userInfo) {
|
if(this.data.userInfo) {
|
||||||
|
|||||||
@@ -114,51 +114,8 @@ Page({
|
|||||||
this.setData({
|
this.setData({
|
||||||
initText: "设备搜索中..."
|
initText: "设备搜索中..."
|
||||||
});
|
});
|
||||||
let seviceList = [{
|
let seviceList = app.globalData.ppScale.device.setting;
|
||||||
"advLength": 999,
|
|
||||||
"calorieStatus": 0,
|
|
||||||
"createBy": null,
|
|
||||||
"deviceAccuracyType": 2,
|
|
||||||
"deviceCalcuteType": 3,
|
|
||||||
"deviceConnectType": 2,
|
|
||||||
"deviceFuncType": 223,
|
|
||||||
"deviceName": "CF568_G",
|
|
||||||
"devicePowerType": 3,
|
|
||||||
"deviceProtocolType": 3,
|
|
||||||
"deviceType": 1,
|
|
||||||
"deviceUnitType": "0,1,11",
|
|
||||||
"id": 65,
|
|
||||||
"imgUrl": null,
|
|
||||||
"macAddressStart": 6,
|
|
||||||
"remark": null,
|
|
||||||
"sign": "FF",
|
|
||||||
"status": 0,
|
|
||||||
"uhStatus": 1,
|
|
||||||
"updateBy": null
|
|
||||||
}, {
|
|
||||||
"advLength": 999,
|
|
||||||
"calorieStatus": 0,
|
|
||||||
"createBy": null,
|
|
||||||
"deviceAccuracyType": 2,
|
|
||||||
"deviceCalcuteType": 4,
|
|
||||||
"deviceConnectType": 2,
|
|
||||||
"deviceFuncType": 65759,
|
|
||||||
"deviceName": "CF636_G",
|
|
||||||
"devicePowerType": 3,
|
|
||||||
"deviceProtocolType": 3,
|
|
||||||
"deviceType": 1,
|
|
||||||
"deviceUnitType": "0,1,2",
|
|
||||||
"id": 216,
|
|
||||||
"imgUrl": null,
|
|
||||||
"macAddressStart": 6,
|
|
||||||
"remark": null,
|
|
||||||
"sign": "FF",
|
|
||||||
"status": 0,
|
|
||||||
"uhStatus": 1,
|
|
||||||
"updateBy": null
|
|
||||||
}];
|
|
||||||
app.globalData.ppScale.plugin.Blue.setDeviceSetting(seviceList);
|
app.globalData.ppScale.plugin.Blue.setDeviceSetting(seviceList);
|
||||||
app.globalData.ppScale.device.setting = seviceList;
|
|
||||||
let deviceNames = seviceList.map(item => item.deviceName);
|
let deviceNames = seviceList.map(item => item.deviceName);
|
||||||
app.globalData.ppScale.plugin.Blue.start(deviceNames, false);
|
app.globalData.ppScale.plugin.Blue.start(deviceNames, false);
|
||||||
app.globalData.ppScale.plugin.bus.subscribe("devicesList", (res) => {
|
app.globalData.ppScale.plugin.bus.subscribe("devicesList", (res) => {
|
||||||
|
|||||||
@@ -14,11 +14,13 @@ Page({
|
|||||||
app.globalData.ppScale.wifi.password = password;
|
app.globalData.ppScale.wifi.password = password;
|
||||||
|
|
||||||
let mac = app.globalData.ppScale.device.mac;
|
let mac = app.globalData.ppScale.device.mac;
|
||||||
if(mac) {
|
let deviceId = app.globalData.ppScale.device.connection.deviceId;
|
||||||
|
if(mac && deviceId) {
|
||||||
let scaleDeviceId = mac.replace(/:/g, '');
|
let scaleDeviceId = mac.replace(/:/g, '');
|
||||||
let params = {
|
let params = {
|
||||||
equipmentName: app.globalData.ppScale.device.name,
|
equipmentName: app.globalData.ppScale.device.name,
|
||||||
scaleDeviceId: scaleDeviceId,
|
scaleDeviceId: scaleDeviceId,
|
||||||
|
deviceId: deviceId
|
||||||
};
|
};
|
||||||
$.ajax("weighingScale/binding/device", params, "POST").then(res => {
|
$.ajax("weighingScale/binding/device", params, "POST").then(res => {
|
||||||
app.globalData.ppScale.activeProtocol.codeSetBindingState((res) => {
|
app.globalData.ppScale.activeProtocol.codeSetBindingState((res) => {
|
||||||
@@ -42,7 +44,7 @@ Page({
|
|||||||
} else {
|
} else {
|
||||||
wx.showToast({
|
wx.showToast({
|
||||||
icon: "none",
|
icon: "none",
|
||||||
title: "Mac 地址获取失败,请重新绑定"
|
title: "Mac 地址与 deviceId 获取失败,请重新绑定"
|
||||||
})
|
})
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
wx.switchTab({
|
wx.switchTab({
|
||||||
|
|||||||
+56
-63
@@ -7,6 +7,7 @@ Page({
|
|||||||
|
|
||||||
initBluetooth: "0",
|
initBluetooth: "0",
|
||||||
customerType: "1",
|
customerType: "1",
|
||||||
|
deviceInfo: null,
|
||||||
|
|
||||||
id: "",
|
id: "",
|
||||||
realname: "",
|
realname: "",
|
||||||
@@ -69,35 +70,55 @@ Page({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(options.initBluetooth === "1") {
|
if(options.initBluetooth === "1") {
|
||||||
this.initBluetooth();
|
this.getDevice();
|
||||||
|
|
||||||
app.globalData.ppScale.plugin.bus.subscribe("deviceConnect", (res) => {
|
app.globalData.ppScale.plugin.bus.subscribe("deviceConnect", (res) => {
|
||||||
console.log('deviceInfo ===》deviceConnect', res);
|
console.log('userInfo ===》deviceConnect', res);
|
||||||
|
|
||||||
|
|
||||||
app.globalData.ppScale.plugin.ScaleAction.startDataProgress();
|
app.globalData.ppScale.plugin.ScaleAction.startDataProgress();
|
||||||
app.globalData.ppScale.activeProtocol = app.globalData.ppScale.plugin.ScaleAction.getActiveProtocol();
|
app.globalData.ppScale.activeProtocol = app.globalData.ppScale.plugin.ScaleAction.getActiveProtocol();
|
||||||
|
|
||||||
app.globalData.ppScale.activeProtocol.codeUpdateMTU((res) => {
|
app.globalData.ppScale.activeProtocol.codeUpdateMTU((res) => {
|
||||||
console.log("deviceInfo ===》codeUpdateMTU", res);
|
console.log("userInfo ===》codeUpdateMTU", res);
|
||||||
|
|
||||||
$.ajax("weighingScale/list/device", {}, "GET", false).then((res) => {
|
this.setData({
|
||||||
if(res.result && res.result.length) {
|
deviceConnect: true
|
||||||
let deviceConnect = res.result.some(item => item.macAddress === app.globalData.ppScale.device.mac);
|
|
||||||
if(deviceConnect) {
|
|
||||||
this.setData({
|
|
||||||
deviceConnect: true
|
|
||||||
})
|
|
||||||
} else {
|
|
||||||
app.globalData.ppScale.plugin.Blue.disconnect();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// 获取已经绑定的设备列表
|
||||||
|
getDevice() {
|
||||||
|
let params = {};
|
||||||
|
$.ajax("weighingScale/list/device", params, "GET", false).then((res) => {
|
||||||
|
if(res.result && res.result.length) {
|
||||||
|
this.setData({
|
||||||
|
deviceInfo: res.result[0]
|
||||||
|
})
|
||||||
|
this.initBluetooth();
|
||||||
|
} else {
|
||||||
|
wx.showModal({
|
||||||
|
title: "提示",
|
||||||
|
content: "当前暂未绑定设备,需要绑定吗?",
|
||||||
|
confirmText: "去绑定",
|
||||||
|
success: (res) => {
|
||||||
|
if (res.confirm) {
|
||||||
|
wx.navigateTo({
|
||||||
|
url: "/pages/searchDevice/searchDevice"
|
||||||
|
})
|
||||||
|
} else if (res.cancel) {
|
||||||
|
wx.navigateBack({
|
||||||
|
delta: 1
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
// 初始化蓝牙
|
// 初始化蓝牙
|
||||||
initBluetooth() {
|
initBluetooth() {
|
||||||
wx.openBluetoothAdapter({
|
wx.openBluetoothAdapter({
|
||||||
@@ -115,56 +136,27 @@ Page({
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
async refreshToken(fn, flag) {
|
getDeviceSettingList() {
|
||||||
let bodyToken = wx.getStorageSync('bodyToken');
|
let seviceList = [];
|
||||||
let bodyTokenTime = wx.getStorageSync('bodyTokenTime');
|
app.globalData.ppScale.device.setting.map(item => {
|
||||||
if (!bodyToken || bodyTokenTime * 1000 < +new Date() || flag) {
|
if(this.data.deviceInfo.type === item.deviceName) {
|
||||||
let res = await app.globalData.ppScale.plugin.refreshToken({
|
seviceList.push(item);
|
||||||
url: "https://uniquehealth.lefuenergy.com",
|
}
|
||||||
data: {
|
})
|
||||||
"appKey": app.globalData.ppScale.options.key,
|
if(seviceList && seviceList.length) {
|
||||||
"appSecret": app.globalData.ppScale.options.secret
|
app.globalData.ppScale.plugin.Blue.setDeviceSetting(seviceList);
|
||||||
|
app.globalData.ppScale.plugin.Blue.start(seviceList[0].deviceName, false);
|
||||||
|
app.globalData.ppScale.plugin.bus.subscribe("devicesList", (res) => {
|
||||||
|
console.log("deviceInfo ===> devicesList", res);
|
||||||
|
let fIndex = res.findIndex(item => item.deviceId === this.data.deviceInfo.deviceId);
|
||||||
|
if (fIndex >= 0) {
|
||||||
|
app.globalData.ppScale.plugin.Blue.stopBluetoothDevicesDiscovery();
|
||||||
|
app.globalData.ppScale.plugin.Blue.createBLEConnection(res[fIndex]);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (res.data.code == 200) {
|
|
||||||
wx.setStorageSync('bodyToken', res.data.data.token);
|
|
||||||
wx.setStorageSync('bodyTokenTime', res.data.data.expireTime);
|
|
||||||
fn();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
fn();
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
getDeviceSettingList() {
|
|
||||||
let bodyToken = wx.getStorageSync("bodyToken");
|
|
||||||
app.globalData.ppScale.plugin.getDeviceSettingList({
|
|
||||||
url: "https://uniquehealth.lefuenergy.com",
|
|
||||||
data: {
|
|
||||||
appKey: app.globalData.ppScale.options.key
|
|
||||||
},
|
|
||||||
header: {
|
|
||||||
"token": bodyToken,
|
|
||||||
"Accept-Language": wx.getStorageSync("lang") || 'zh'
|
|
||||||
}
|
|
||||||
}).then((res) => {
|
|
||||||
if (res.data.code == 200) {
|
|
||||||
app.globalData.ppScale.plugin.Blue.setDeviceSetting(res.data.data);
|
|
||||||
app.globalData.ppScale.device.setting = res.data.data;
|
|
||||||
let deviceNames = res.data.data.map(item => item.deviceName);
|
|
||||||
app.globalData.ppScale.plugin.Blue.start(deviceNames, false);
|
|
||||||
app.globalData.ppScale.plugin.bus.subscribe("devicesList", (res_) => {
|
|
||||||
app.globalData.ppScale.plugin.Blue.stopBluetoothDevicesDiscovery();
|
|
||||||
app.globalData.ppScale.plugin.Blue.createBLEConnection(res_[0]);
|
|
||||||
});
|
|
||||||
} else if (res.data.code == 401 || res.data.code == 4008) {
|
|
||||||
// 401 token过期 / 4008 token为空
|
|
||||||
// 重新请求token解析数据
|
|
||||||
this.refreshToken(() => {
|
|
||||||
this.getDeviceSettingList();
|
|
||||||
}, true);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
// 姓名输入
|
// 姓名输入
|
||||||
realnameInput(e) {
|
realnameInput(e) {
|
||||||
@@ -247,7 +239,7 @@ Page({
|
|||||||
icon: "none",
|
icon: "none",
|
||||||
title: "请靠近设备并点亮后再试"
|
title: "请靠近设备并点亮后再试"
|
||||||
})
|
})
|
||||||
this.initBluetooth();
|
this.getDeviceSettingList();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if(!realname) {
|
if(!realname) {
|
||||||
@@ -426,7 +418,8 @@ Page({
|
|||||||
icon: "none",
|
icon: "none",
|
||||||
title: "删除失败,请靠近设备并点亮后再试"
|
title: "删除失败,请靠近设备并点亮后再试"
|
||||||
})
|
})
|
||||||
this.initBluetooth();
|
app.globalData.ppScale.plugin.Blue.stop();
|
||||||
|
this.getDeviceSettingList();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user