master
blak-kong 2 years ago
commit 70e7ec5186

@ -36,8 +36,8 @@
"author": "",
"dependencies": {
"@antmjs/vantui": "^3.2.2",
"@flossom-npm/iot-translater": "^1.0.14",
"@flossom-npm/iot-translater-we100": "^1.0.74",
"@flossom-npm/iot-translater": "^1.0.8",
"@flossom-npm/iot-translater-we100": "^1.0.66",
"@reduxjs/toolkit": "^2.0.1",
"@taroify/core": "^0.1.1-alpha.8",
"@tarojs/components": "3.6.19",
@ -65,6 +65,7 @@
},
"devDependencies": {
"@babel/core": "^7.8.0",
"@babel/runtime": "^7.7.7",
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.5",
"@tarojs/cli": "3.6.19",
"@tarojs/taro-loader": "3.6.19",
@ -86,11 +87,10 @@
"react-refresh": "^0.11.0",
"stylelint": "9.3.0",
"taro-plugin-compiler-optimization": "^1.0.4",
"terser-webpack-plugin": "^5.3.9",
"thread-loader": "^4.0.2",
"ts-node": "^10.9.1",
"typescript": "^4.1.0",
"webpack": "^5.78.0",
"terser-webpack-plugin": "^5.3.9",
"@babel/runtime": "^7.7.7"
"webpack": "^5.78.0"
}
}

@ -17,6 +17,7 @@ export default defineAppConfig({
"pages/instrument_manage/index",
"pages/instrument_detail/index",
"pages/instrumentClickinUpload/index",
"pages/iotCarePlan/iotCarePlan",
'pages/privacyPolicy/privacyPolicy',
'pages/userPolicy/userPolicy',
'pages/about/about',

@ -24,6 +24,7 @@ class App extends Component<PropsWithChildren> {
return;
}
// go("/pages/iotCarePlan/iotCarePlan");
// go("/pages/instrument_clickin_upload/index");
// go("/pages/instrument/intro");
// Taro.switchTab({

@ -1,10 +1,16 @@
const InstrumentTypeEnum = {
//仪器类型
FR200: 1,
MATRIX: 2,
WL200: 3,
FR380: 4,
FR390: 5,
M01: 6,
// FR200: 1,
// MATRIX: 2,
// WL200: 3,
// FR380: 4,
// FR390: 5,
// M01: 6,
FR200: "FR200",
MATRIX: "MATRIX",
WL200: "WL200",
FR380: "FR380",
FR390: "FR390",
M01: "M01",
};
export default InstrumentTypeEnum;

@ -8,7 +8,10 @@ import DeviceConnectPopup from "../device-connection-popup/device-connection-pop
/*** redux ***/
import { connect } from "react-redux";
import { setBluetoothInfo } from "../../../store/features/deviceInfo";
import {
setBluetoothInfo,
setDeviceId,
} from "../../../store/features/deviceInfo";
/*** redux end ***/
import {
@ -47,7 +50,7 @@ import { DeviceToolKit as DeviceToolKitFR200 } from "@flossom-npm/iot-translater
import { showModal, msg } from "@/utils/traoAPI";
// const { InstrumentTypeEnum, OtaDeviceTypeEnum } = app.globalData;
import InstrumentTypeEnum from "../instrumentTypeEnum";
import InstrumentTypeEnum from "../InstrumentTypeEnum";
import OtaDeviceTypeEnum from "../OtaDeviceTypeEnum";
let isGetVersionTimer: any = null;
@ -67,7 +70,7 @@ let searchBluetootTimersNum = 0; // 搜索蓝牙秒数
let connectionTimer: any = null; // 连接蓝牙定时器
let connectionTimerNum = 0;
let sendPairingTimer: any = null;
let sendPairingTimer: any = null; // 发送配对
import "./index.less";
@ -143,7 +146,7 @@ class ConnectionBluetoot extends Component<any, any> {
/** 开始连接 */
connection() {
this.setState({
isConnection: true,
isConnection: false,
});
//初始化 蓝牙连接
this.bluetoothInit();
@ -210,7 +213,7 @@ class ConnectionBluetoot extends Component<any, any> {
openBluetoothAdapter() {
openBluetoothAdapter()
.then((res) => {
console.info("openBluetoothAdapter res value =>", res);
console.log("openBluetoothAdapter res value =>", res);
let { errno, errMsg } = res;
if (errno == 0) {
this.startBluetoothDevicesDiscovery();
@ -233,7 +236,7 @@ class ConnectionBluetoot extends Component<any, any> {
this.close();
});
} else {
console.info("openBluetoothAdapter err value => ", err);
console.log("openBluetoothAdapter err value => ", err);
this.failErrorCode(errno, errMsg);
}
});
@ -295,7 +298,9 @@ class ConnectionBluetoot extends Component<any, any> {
// };
// let type = this.props.yiqiInfo.model || "FR200";
let type = "WE200";
// console.info('搜索到到蓝牙设备 value => ', item.devices[0]?.name)
// this.props.yiqiInfo.model = type;
console.log("this.props.yiqiInfo.model", this.props.yiqiInfo.model);
console.info("搜索到到蓝牙设备 value => ", item.devices[0]?.name);
for (let i = 0; i < item.devices.length; i++) {
if (
item.devices[i].connectable &&
@ -304,12 +309,18 @@ class ConnectionBluetoot extends Component<any, any> {
: item.devices[i].name
).indexOf(`${type}`) !== -1
) {
console.info("连接的设备信息", item.devices[i], type);
console.log("连接的设备信息", item.devices[i], type);
let params = {
deviceId: item.devices[i].deviceId,
};
this.props.setDeviceId(params);
clearInterval(searchBluetootTimers);
Taro.stopBluetoothDevicesDiscovery(); //停止搜索蓝牙
// app.globalData.deviceInfo.deviceId = item.devices[i].deviceId;
this.createBLEConnection();
setTimeout(() => {
clearInterval(searchBluetootTimers);
Taro.stopBluetoothDevicesDiscovery(); //停止搜索蓝牙
// app.globalData.deviceInfo.deviceId = item.devices[i].deviceId;
this.createBLEConnection();
}, 10);
break;
}
}
@ -319,21 +330,23 @@ class ConnectionBluetoot extends Component<any, any> {
/** 5.新建蓝牙连接 */
async createBLEConnection() {
console.log("========新建蓝牙连接========");
this.setState({ isConnection: true }); // 开始蓝牙连接
try {
await closeBLEConnection(this.props.bluetoothInfo.deviceId);
} catch (e) {}
clearTimeout(connectionTimer);
const { yiqiInfo: deviceInfo } = this.props;
console.log(
"this.props.bluetoothInfo.deviceId",
this.props.bluetoothInfo.deviceId
);
/*********开始主动连接*******/
createBLEConnection(this.props.bluetoothInfo.deviceId)
.then((res) => {
console.log("createBLEConnection", res);
let { errno, errMsg } = res;
if (errno == 0) {
if (
deviceInfo.type == InstrumentTypeEnum.FR200 ||
deviceInfo.type == InstrumentTypeEnum.FR380 ||
deviceInfo.type == InstrumentTypeEnum.FR390
) {
if (deviceInfo.model === "WL200") {
this.setState({
connectionStatus: true,
});
@ -358,24 +371,35 @@ class ConnectionBluetoot extends Component<any, any> {
/** 6.获取蓝牙特征值 */
getBLEDeviceServices() {
console.log("========6.获取蓝牙特征值========");
getBLEDeviceServices(this.props.bluetoothInfo.deviceId)
.then((res) => {
let bluetoothInfo = this.props.bluetoothInfo;
bluetoothInfo.servicesuuid = res.servicesuuid;
bluetoothInfo.characteristicsuuid1 = res.characteristicsuuid1;
bluetoothInfo.characteristicsuuid0 = res.characteristicsuuid0;
this.props.setBluetoothInfo(bluetoothInfo);
this.notifyBLECharacteristicValueChange();
console.log("特征值", res);
let params = {
deviceId: this.props.bluetoothInfo.deviceId,
servicesuuid: res.servicesuuid,
characteristicsuuid1: res.characteristicsuuid1,
characteristicsuuid0: res.characteristicsuuid0,
};
console.log("getBLEDeviceServices", params);
// 获取并修改蓝牙特征值
this.props.setBluetoothInfo(params);
setTimeout(() => {
this.notifyBLECharacteristicValueChange();
}, 10);
})
.catch((err) => {
let { errno, errMsg } = err;
console.info("getBLEDeviceServices error =>", err);
console.log("getBLEDeviceServices error =>", err);
this.failErrorCode(errno, errMsg);
});
}
/** 7.通知BLE特征值更改 */
notifyBLECharacteristicValueChange() {
console.log("7.通知BLE特征值更改");
const { yiqiInfo: deviceInfo } = this.props;
const bluetoothInfo = this.props.bluetoothInfo;
notifyBLECharacteristicValueChange({
@ -387,240 +411,145 @@ class ConnectionBluetoot extends Component<any, any> {
.then((ress) => {
let { errno, errMsg } = ress;
if (errno == 0) {
// 订阅特征码变化
Taro.onBLECharacteristicValueChange((value) => {
console.info("onBLECharacteristicValueChange value => ", value);
// 配对成功进入?
console.log("onBLECharacteristicValueChange value => ", value);
let str = ab2hex(value.value); //转为16进制字符串
console.log("转为16进制字符串 str", str);
let connectionStatus = [
InstrumentTypeEnum.FR200,
InstrumentTypeEnum.WL200,
InstrumentTypeEnum.FR380,
InstrumentTypeEnum.FR390,
InstrumentTypeEnum.M01,
].includes(Number(deviceInfo.type));
const isFRDevice = [
InstrumentTypeEnum.FR200,
InstrumentTypeEnum.FR380,
InstrumentTypeEnum.FR390,
].includes(Number(deviceInfo.type));
if (isFRDevice) {
this.setState({
connectionStatus,
});
log.info(
commandMap.reciviedBLECommand,
`仪器类型: ${deviceInfo.type}`,
value
);
filterBleData(str).forEach((item) => {
console.log("设备响应数据===》", item);
if (item.indexOf(`dbf0a8010155`) !== -1) {
//配对成功
log.info("蓝牙配对成功");
clearInterval(sendPairingTimer);
this.setState({ islian: true });
console.log("获取设备版本号");
this.sendGetVersion();
sendgetversionTimer = setInterval(() => {
this.sendGetVersion();
}, 1000);
}
"FR200",
"WL200",
"FR380",
"FR390",
"M01",
].includes(deviceInfo.model);
if (item.indexOf("dbf0a0030b") !== -1) {
// 版本号获取成功
clearInterval(sendgetversionTimer);
let v1 = String(hex2int(str.substring(10, 12))).padStart(
2,
"0"
);
let v2 = String(hex2int(str.substring(12, 14))).padStart(
2,
"0"
);
let v3 = String(hex2int(str.substring(14, 16))).padStart(
2,
"0"
);
let versionInfo = {
v1,
v2,
v3,
version: `${v1}${v2}${v3}`,
};
this.setState({ versionInfo });
console.log("版本号:" + versionInfo.version);
log.info(
commandMap.versionInfoCG,
`connection_guide, ${deviceInfo.type}:${versionInfo.version}`
);
if (
deviceInfo.type == InstrumentTypeEnum.FR380 ||
deviceInfo.type == InstrumentTypeEnum.FR390
) {
console.log("跳转护理页");
// this.triggerEvent("offlineChange", this.state);
this.offlineChange(this.state);
} else {
if (this.state.isgetoffline) {
// 获取离线记录
console.log("获取离线记录(总)");
this.sendofflistSummary();
} else {
console.log("跳转护理页");
// that.triggerEvent("offlineChange", this.state);
this.offlineChange(this.state);
}
}
}
if (item.indexOf("dbf0a0020b") !== -1) {
//离线护理记录(总)获取成功
// 先获取记录总条数,再获取详细
console.log("获取离线记录总条数====>", item);
log.info(
commandMap.finishOfflineData,
`接收到总的离线记录=》${item}`
);
// this.state.offlineDataindex =
// 7 || Number(item.substring(24, 2));
let offlineDataindex = 7 || Number(item.substring(24, 2));
this.setState({ offlineDataindex });
if (this.state.offlineDataindex > 0) {
this.sendofflist();
} else {
// this.triggerEvent("offlineChange", that.data);
this.offlineChange(this.state);
}
}
if (item.indexOf("dbf0a00211") !== -1) {
//设备响应离线护理记录(细)
log.info(
commandMap.finishOfflineData,
"接收到详细离线记录, 准备进入sendofflist"
);
this.sendOfflistPost(str);
this.sendofflist();
}
if (item.indexOf("dbf0a001006dde") !== -1) {
// 同步时间
// that.sendAsyncTime()
}
});
} else {
let jsonStatus: any = null;
let querySubDeviceArrayBuffer;
if (deviceInfo.type == InstrumentTypeEnum.WL200) {
// querySubDeviceArrayBuffer = deviceToolKitInstanceWL200.toBleCommand(bleCommandSamples.querySubDevice);
// jsonStatus = deviceToolKitInstanceWL200.toJsonStatus(value.value);
jsonStatus = deviceToolKitInstanceM01.toJsonStatus(value.value);
querySubDeviceArrayBuffer =
deviceToolKitInstanceM01.toBleCommand(
bleCommandSamples.querySubDevice as any
); // todo
} else if (deviceInfo.type == InstrumentTypeEnum.M01) {
jsonStatus = deviceToolKitInstanceM01.toJsonStatus(value.value);
querySubDeviceArrayBuffer =
deviceToolKitInstanceM01.toBleCommand(
bleCommandSamples.querySubDevice as any
);
}
log.info(
commandMap.reciviedBLECommand,
`仪器类型: ${deviceInfo.type}`,
jsonStatus
let jsonStatus: any = null;
let querySubDeviceArrayBuffer;
if (deviceInfo.model == "WL200") {
// querySubDeviceArrayBuffer =
// deviceToolKitInstanceWL200.toBleCommand(
// bleCommandSamples.querySubDevice as any
// );
// jsonStatus = deviceToolKitInstanceWL200.toJsonStatus(
// value.value
// );
jsonStatus = deviceToolKitInstanceM01.toJsonStatus(value.value);
querySubDeviceArrayBuffer = deviceToolKitInstanceM01.toBleCommand(
bleCommandSamples.querySubDevice as any
); // todo
} else if (deviceInfo.model == "M01") {
jsonStatus = deviceToolKitInstanceM01.toJsonStatus(value.value);
querySubDeviceArrayBuffer = deviceToolKitInstanceM01.toBleCommand(
bleCommandSamples.querySubDevice as any
);
if (jsonStatus?.commandType === "BleMatch") {
switch (jsonStatus?.bleCommandType) {
case "SendMatchCode":
if (jsonStatus.matchedSuccess) {
console.log("蓝牙配对成功");
clearInterval(sendPairingTimer);
if (overTimer) clearTimeout(overTimer);
if (this.state.connectionSuccess) return;
this.setState({
connectionSuccess: true,
connectionStatus,
});
// 暂时不需要查询是否连接子设备, 直接进入查询版本信息
this.detectVersionUpdate();
/*if(deviceInfo.type == instrumentTypeEnum.M01) {
}
// log.info(
// commandMap.reciviedBLECommand,
// `仪器模式: ${deviceInfo.model}`,
// jsonStatus
// );
console.log(
commandMap.reciviedBLECommand,
`仪器模式: ${deviceInfo.model}`,
jsonStatus
);
console.log("jsonStatus", jsonStatus);
if (jsonStatus?.commandType === "BleMatch") {
switch (jsonStatus?.bleCommandType) {
case "SendMatchCode":
if (jsonStatus.matchedSuccess) {
console.log("BleMatch蓝牙配对成功");
clearInterval(sendPairingTimer);
if (overTimer) clearTimeout(overTimer);
this.setState({
connectionSuccess: true,
connectionStatus,
islian: true, // 不需要离线记录但暂未完全删除这部分逻辑所以直接设为true
});
// this.detectVersionUpdate(); // 获取升级信息
// todo 连接成功需删除离线记录,暂时未缓存离线记录
if (this.state.connectionSuccess) return;
// 暂时不需要查询是否连接子设备, 直接进入查询版本信息
// this.detectVersionUpdate();
/*if(deviceInfo.type == instrumentTypeEnum.M01) {
this.detectVersionUpdate()
} else {
this.sendQuerySubDevice(querySubDeviceArrayBuffer)
}*/
}
break;
case "BleStatusSync":
if (jsonStatus.connectMessage?.connectType == "CONNECTED") {
switch (jsonStatus.connectMessage?.deviceName) {
case OtaDeviceTypeEnum.WE100:
case OtaDeviceTypeEnum.FACIALMASK:
console.log("面膜连上了 value => ", jsonStatus);
this.detectVersionUpdate();
break;
case OtaDeviceTypeEnum.WL200:
console.log("面罩连上了 value => ", jsonStatus);
this.detectVersionUpdate();
break;
default:
break;
}
break;
case "BleStatusSync":
if (jsonStatus.connectMessage?.connectType == "CONNECTED") {
switch (jsonStatus.connectMessage?.deviceName) {
case OtaDeviceTypeEnum.WE100:
case OtaDeviceTypeEnum.FACIALMASK:
console.log("面膜连上了 value => ", jsonStatus);
this.detectVersionUpdate();
break;
case OtaDeviceTypeEnum.WL200:
console.log("面罩连上了 value => ", jsonStatus);
this.detectVersionUpdate();
break;
default:
break;
}
}
console.info("BleStatusSync value => ", jsonStatus);
break;
case "QueryMatchStatus":
console.info("QueryMatchStatus value => ", jsonStatus);
break;
default:
break;
}
} else if (jsonStatus?.commandType === "InfoQuery") {
switch (jsonStatus.infoQueryType) {
case "versionInfo":
if (this.state.hasVersionInfo) return;
clearTimeout(isGetVersionTimer);
this.setState({
hasVersionInfo: true, // 已返回版本信息
connectionStatus: true,
subDeviceConnectedStatus: true,
synchronousStatus: true,
});
const deviceVersionNo = jsonStatus.versionNo;
const latestVersionNo = deviceInfo.iot_versions;
// const isNeedToUpdateBl = isNeedToUpdate(deviceVersionNo, latestVersionNo)
// 判断是否需要升级
// M01和WL200 不需要在这里进行蓝牙更新
// if (isNeedToUpdateBl) {
// const pages = getCurrentPages();
// const matchPageList = [{
// route: 'pages/MatrixWL200/pages/index/index'
// },{
// route: 'pages/MatrixM01/pages/index/index'
// }];
// const hadOpen = checkSameKey(pages, matchPageList, 'route');
// if (!hadOpen) {
// this.triggerEvent("pairingChange", { deviceVersionNo });
this.pairingChange({ deviceVersionNo });
// }
// } else {
// this.sendSyncRecording()
// }
break;
case "offlineClockSummary":
clearTimeout(isGetSyncRecordingTimer);
if (this.state.hasSyncRecord) return;
this.setState({
hasSyncRecord: true,
synchronousStatus: true,
});
console.info("offlineClockSummary value =>", jsonStatus);
// this.triggerEvent("pairingChange", this.state);
this.pairingChange(this.state);
// TODO 查询离线记录结果
default:
break;
}
}
console.log("BleStatusSync value => ", jsonStatus);
break;
case "QueryMatchStatus":
console.log("QueryMatchStatus value => ", jsonStatus);
break;
default:
break;
}
} else if (jsonStatus?.commandType === "InfoQuery") {
console.log("查询版本信息", jsonStatus);
switch (jsonStatus.infoQueryType) {
case "versionInfo":
if (this.state.hasVersionInfo) return;
clearTimeout(isGetVersionTimer);
this.setState({
hasVersionInfo: true, // 已返回版本信息
connectionStatus: true,
subDeviceConnectedStatus: true,
synchronousStatus: true,
});
const deviceVersionNo = jsonStatus.versionNo;
const latestVersionNo = deviceInfo.iot_versions;
// const isNeedToUpdateBl = isNeedToUpdate(deviceVersionNo, latestVersionNo)
// 判断是否需要升级
// M01和WL200 不需要在这里进行蓝牙更新
// if (isNeedToUpdateBl) {
// const pages = getCurrentPages();
// const matchPageList = [{
// route: 'pages/MatrixWL200/pages/index/index'
// },{
// route: 'pages/MatrixM01/pages/index/index'
// }];
// const hadOpen = checkSameKey(pages, matchPageList, 'route');
// if (!hadOpen) {
// this.triggerEvent("pairingChange", { deviceVersionNo });
this.pairingChange({ deviceVersionNo });
// }
// } else {
// this.sendSyncRecording()
// }
break;
case "offlineClockSummary":
clearTimeout(isGetSyncRecordingTimer);
if (this.state.hasSyncRecord) return;
this.setState({
hasSyncRecord: true,
synchronousStatus: true,
});
console.log("offlineClockSummary value =>", jsonStatus);
// this.triggerEvent("pairingChange", this.state);
this.pairingChange(this.state);
// TODO 查询离线记录结果
default:
break;
}
}
});
@ -632,23 +561,21 @@ class ConnectionBluetoot extends Component<any, any> {
* type3 we100
* type4 FR380
*/
console.log("发送配对码");
if (deviceInfo.type == InstrumentTypeEnum.FR200) {
console.log("发送配对码", deviceInfo.model);
if (deviceInfo.model == "FR200") {
if (sendPairingTimer) clearInterval(sendPairingTimer);
sendPairingTimer = setInterval(() => {
this.sendPairingSignal();
}, 1000);
} else if (
deviceInfo.type == InstrumentTypeEnum.WL200 ||
deviceInfo.type == InstrumentTypeEnum.M01
) {
} else if (deviceInfo.model == "WL200" || deviceInfo.model == "M01") {
if (sendPairingTimer) clearInterval(sendPairingTimer);
sendPairingTimer = setInterval(() => {
console.log("test WL200");
this.sendPairingSignal();
}, 1000);
} else if (
deviceInfo.type == InstrumentTypeEnum.FR380 ||
deviceInfo.type == InstrumentTypeEnum.FR390
deviceInfo.model == "FR380" ||
deviceInfo.model == "FR390"
) {
if (sendPairingTimer) clearInterval(sendPairingTimer);
sendPairingTimer = setInterval(() => {
@ -659,7 +586,7 @@ class ConnectionBluetoot extends Component<any, any> {
overTimer = setTimeout(() => {
if (this.state.islian) {
console.log("超时跳转护理页");
log.info("超时跳转护理页");
// log.info("超时跳转护理页");
// 已配对成功,其它操作导致超时未跳转则直接跳转
// this.triggerEvent("offlineChange", this.state);
this.offlineChange(this.state);
@ -682,12 +609,9 @@ class ConnectionBluetoot extends Component<any, any> {
// 8.发送指令:获取仪器版本号
sendGetVersion() {
const { yiqiInfo: deviceInfo } = this.props;
const isFRDevice = [
InstrumentTypeEnum.FR200,
InstrumentTypeEnum.FR380,
InstrumentTypeEnum.FR390,
].includes(Number(deviceInfo.type));
log.info(commandMap.sendVersionCommand, `仪器:${deviceInfo.type}`);
const isFRDevice = ["FR200", "FR380", "FR390"].includes(deviceInfo.model);
// log.info(commandMap.sendVersionCommand, `仪器:${deviceInfo.model}`);
console.log(commandMap.sendVersionCommand, `仪器:${deviceInfo.model}`);
if (isFRDevice) {
writeBLECharacteristicValue({
//发送获取仪器版本号
@ -701,7 +625,7 @@ class ConnectionBluetoot extends Component<any, any> {
// const otaDeviceType = deviceInfo.type == instrumentTypeEnum.WL200 ? OtaDeviceTypeEnum.WL200 : OtaDeviceTypeEnum.WE100;
// 通过发箍连 都用we100
const otaDeviceType =
deviceInfo.type == InstrumentTypeEnum.WL200
deviceInfo.model == InstrumentTypeEnum.WL200
? OtaDeviceTypeEnum.WE100
: OtaDeviceTypeEnum.WE100;
const versionCommand = {
@ -710,7 +634,7 @@ class ConnectionBluetoot extends Component<any, any> {
otaDeviceType,
};
const value =
deviceInfo.type == InstrumentTypeEnum.WL200
deviceInfo.model == InstrumentTypeEnum.WL200
? deviceToolKitInstanceM01.toBleCommand(versionCommand as any)
: deviceToolKitInstanceM01.toBleCommand(versionCommand as any);
// const value = deviceInfo.type == instrumentTypeEnum.WL200 ? deviceToolKitInstanceWL200.toBleCommand(versionCommand) : deviceToolKitInstanceM01.toBleCommand(versionCommand);
@ -723,7 +647,7 @@ class ConnectionBluetoot extends Component<any, any> {
// log.info()
if (this.state.offlineDataindex == this.state.offlineDataList.length) {
console.log("离线记录获取完成");
log.info(commandMap.finishOfflineData, this.state.offlineDataList);
// log.info(commandMap.finishOfflineData, this.state.offlineDataList);
/****
*
* ****/
@ -738,7 +662,7 @@ class ConnectionBluetoot extends Component<any, any> {
return false;
}
console.log("发送获取离线记录(细)指令");
log.info(commandMap.finishOfflineData, "发送获取离线记录(细)指令");
// log.info(commandMap.finishOfflineData, "发送获取离线记录(细)指令");
writeBLECharacteristicValue({
//发送获取离线记录
deviceId: this.props.bluetoothInfo.deviceId,
@ -753,7 +677,7 @@ class ConnectionBluetoot extends Component<any, any> {
let str = "DBF0A00200";
console.log("发送离线记录汇总指令 ==》", str);
this.setState({ offlineDataList: [] }); // 置空重查离线记录
log.info(commandMap.finishOfflineData, `发送获取离线记录(总)指令`);
// log.info(commandMap.finishOfflineData, `发送获取离线记录(总)指令`);
writeBLECharacteristicValue({
//发送获取离线记录
deviceId: this.props.bluetoothInfo.deviceId,
@ -764,18 +688,26 @@ class ConnectionBluetoot extends Component<any, any> {
});
}
/** 9.发送配对码 */
sendPairingSignal() {
console.log("9.发送配对码 sendPairingSignal");
const { yiqiInfo: deviceInfo } = this.props;
log.info(commandMap.sendMatchCode, `仪器:${deviceInfo.type}发送匹配码`);
// log.info(commandMap.sendMatchCode, `仪器:${deviceInfo.model}发送匹配码`);
console.log(commandMap.sendMatchCode, `仪器:${deviceInfo.model}发送匹配码`);
let matchArrayBuffer: any = null;
switch (deviceInfo.type) {
switch (deviceInfo.model) {
case InstrumentTypeEnum.FR200:
matchArrayBuffer = deviceToolKitInstanceFR200.toBleCommand(
bleCommandSamples.match as any
);
break;
case InstrumentTypeEnum.WL200:
matchArrayBuffer = deviceToolKitInstanceWL200.toBleCommand(
// console.log("WL200无法配对只能用M01");
console.log("正在发送WL200", bleCommandSamples.match);
// matchArrayBuffer = deviceToolKitInstanceWL200.toBleCommand(
// bleCommandSamples.match as any
// );
matchArrayBuffer = deviceToolKitInstanceM01.toBleCommand(
bleCommandSamples.match as any
);
break;
@ -805,15 +737,17 @@ class ConnectionBluetoot extends Component<any, any> {
default:
break;
}
if (matchArrayBuffer)
sendCommand({ value: matchArrayBuffer })
.then(() => {})
.catch((e) => {
// 下发配对指令失败,走重连操作
clearInterval(sendPairingTimer);
// wx.closeBLEConnection();
this.createBLEConnection();
});
if (matchArrayBuffer) console.log("matchArrayBuffer", matchArrayBuffer);
sendCommand({ value: matchArrayBuffer })
.then((res) => {
console.log("matchArrayBuffer res", res);
})
.catch((e) => {
// 下发配对指令失败,走重连操作
clearInterval(sendPairingTimer);
// wx.closeBLEConnection();
this.createBLEConnection();
});
}
/** 发送记录 */
@ -891,7 +825,7 @@ class ConnectionBluetoot extends Component<any, any> {
errorCode(errno, errMsg) {
clearInterval(searchBluetootTimers);
clearInterval(sendgetversionTimer);
console.info("errorCode err => ", errno, errMsg);
// console.info("errorCode err => ", errno, errMsg);
if (errno == 10001 || errno == 10009) {
let t2 =
errno == 10001
@ -965,10 +899,11 @@ class ConnectionBluetoot extends Component<any, any> {
}
failErrorCode(errno, errMsg) {
console.info("failErrorCode err => ", errno, errMsg);
console.log("failErrorCode err => ", errno, errMsg);
clearInterval(searchBluetootTimers);
clearInterval(sendgetversionTimer);
log.info("连接仪器失败", errno, errMsg);
// log.info("连接仪器失败", errno, errMsg);
console.log("连接仪器失败", errno, errMsg);
let errorText = "";
switch (errno) {
case 1500101:
@ -1071,6 +1006,8 @@ class ConnectionBluetoot extends Component<any, any> {
// this.sendSyncRecording()
// }, 5000);
}
/** 发送同步记录 */
sendSyncRecording() {
const { yiqiInfo: deviceInfo } = this.props;
const versionCommand = {
@ -1078,7 +1015,7 @@ class ConnectionBluetoot extends Component<any, any> {
infoQueryType: "offlineClockSummary",
};
const value =
deviceInfo.type == InstrumentTypeEnum.WL200
deviceInfo.model == InstrumentTypeEnum.WL200
? deviceToolKitInstanceWL200.toBleCommand(versionCommand as any)
: deviceToolKitInstanceM01.toBleCommand(versionCommand as any);
sendCommand({ value }).then();
@ -1100,6 +1037,11 @@ class ConnectionBluetoot extends Component<any, any> {
this.props.confirm("confirm");
};
onReconnect = () => {
console.log("onReconnect");
// this.props.confirm("confirm");
};
pairingChange = (data) => {
this.props.pairingChange(data);
};
@ -1109,17 +1051,21 @@ class ConnectionBluetoot extends Component<any, any> {
};
render() {
let { name, isConnection, connectionStatus } = this.state;
let { name, isConnection, connectionStatus, connectionSuccess, error } =
this.state;
let { yiqiInfo } = this.props;
return (
<Block>
<DeviceConnectPopup
close={this.onClose}
confirm={this.onConfirm}
reconnect={this.onReconnect}
data={yiqiInfo}
isShow={true}
connectionStatus={connectionStatus}
// connectionStatus={connectionStatus}
connectionSuccess={connectionSuccess}
isConnection={isConnection}
error={error}
title="面罩模式启动中"
/>
<View>{name}</View>
@ -1135,5 +1081,8 @@ const mapDispatchToProps = (dispatch) => ({
setBluetoothInfo(data) {
dispatch(setBluetoothInfo(data));
},
setDeviceId(data) {
dispatch(setDeviceId(data));
},
});
export default connect(mapStateToProps, mapDispatchToProps)(ConnectionBluetoot);

@ -1,66 +1,66 @@
/**蓝牙命令合集*/
export const bleCommandSamples = {
/**发送配对码*/
match: {
commandType: "BleMatch",
bleCommandType: "SendMatchCode",
},
/**查询附属设备的配对状态*/
querySubDevice: {
commandType: "BleMatch",
bleCommandType: "QueryMatchStatus",
},
/**查询设备状态指令*/
queryDeviceStatus: {
commandType: "DeviceStatusSync",
deviceSyncCommandType: 'queryDeviceStatus'
},
/**查询版本指令*/
queryDeviceVersionStatus: {
commandType: "InfoQuery",
infoQueryType: 'versionInfo',
otaDeviceType: ''
},
/**查询当前记录*/
queryCurrentMaskReportInfo: {
commandType: "InfoQuery",
infoQueryType: 'currentMaskReportInfo'
}
/**发送配对码*/
match: {
commandType: "BleMatch",
bleCommandType: "SendMatchCode",
},
/**查询附属设备的配对状态*/
querySubDevice: {
commandType: "BleMatch",
bleCommandType: "QueryMatchStatus",
},
/**查询设备状态指令*/
queryDeviceStatus: {
commandType: "DeviceStatusSync",
deviceSyncCommandType: "queryDeviceStatus",
},
/**查询版本指令*/
queryDeviceVersionStatus: {
commandType: "InfoQuery",
infoQueryType: "versionInfo",
otaDeviceType: "",
},
/**查询当前记录*/
queryCurrentMaskReportInfo: {
commandType: "InfoQuery",
infoQueryType: "currentMaskReportInfo",
},
};
/**控制设备命令合集*/
export const deviceCommandSamples = {
/**控制设备暂停 pause暂停 working启动 end关闭*/
pause:{
commandType: "DeviceControl",
workStatus: "pause",
},
standby:{
commandType: "DeviceControl",
workStatus: "standby",
},
end:{
commandType: "DeviceControl",
workStatus: "end",
},
/*
* powerfulSoothing 强效舒缓 01
* Stability 维稳维护 02
* Brighten 均色提亮 03
* FirmSkin 紧致淡纹 04
* Custom 自定义模式 05
* WaterLightEssence 水光精华模式 11
* ShapeBeautyEssence 塑颜精华模式 12
* DiyFacial DIY面膜模式 13
* FacialMaskCustom 面膜定制模式 1A
*/
work:{
commandType: "DeviceControl",
workStatus: "working",
workMode: "",
},
gear:{
commandType: "DeviceControl",
partitionStatus: [{gear: 1},{gear: 1},{gear: 1},{gear: 1},]
}
/**控制设备暂停 pause暂停 working启动 end关闭*/
pause: {
commandType: "DeviceControl",
workStatus: "pause",
},
standby: {
commandType: "DeviceControl",
workStatus: "standby",
},
end: {
commandType: "DeviceControl",
workStatus: "end",
},
/*
* powerfulSoothing 强效舒缓 01
* Stability 维稳维护 02
* Brighten 均色提亮 03
* FirmSkin 紧致淡纹 04
* Custom 自定义模式 05
* WaterLightEssence 水光精华模式 11
* ShapeBeautyEssence 塑颜精华模式 12
* DiyFacial DIY面膜模式 13
* FacialMaskCustom 面膜定制模式 1A
*/
work: {
commandType: "DeviceControl",
workStatus: "working",
workMode: "",
},
gear: {
commandType: "DeviceControl",
partitionStatus: [{ gear: 1 }, { gear: 1 }, { gear: 1 }, { gear: 1 }],
},
};

@ -1,4 +1,11 @@
.site-popup-content-box {
.common-box {
width: 670rpx;
box-sizing: border-box;
}
.device-connection-box {
height: 1150rpx;
}
.device-popup-content-box {
margin: 0;
}
// .van-popup {
@ -33,17 +40,6 @@
box-sizing: border-box;
}
.upload-tips-common-box {
padding: 50rpx 20rpx 44rpx 20rpx;
.tips-message {
margin-top: 30rpx;
text-align: center;
font-size: 28rpx;
line-height: 45rpx;
color: #666;
}
}
.popup-btn-one {
display: flex;
margin-top: 60rpx;
@ -62,3 +58,65 @@
font-family: PingFang SC;
}
}
.block,
.block2 {
display: flex;
align-items: center;
position: relative;
width: 100%;
box-sizing: border-box;
display: flex;
// column-gap: 30rpx;
// padding-top: 10px;
margin: 0 auto 10px;
text-align: center;
.icon {
/* margin-top: 5rpx; */
width: 36rpx;
min-width: 36rpx;
height: 36rpx;
image {
width: 100%;
height: 100%;
vertical-align: middle;
}
}
}
.block {
margin-top: 80rpx;
}
.block2 {
margin-top: 40rpx;
}
.images,
.videos {
display: block;
width: 600rpx;
height: 600rpx;
border-radius: 30rpx;
// width: 100%;
// height: 100%;
overflow: hidden;
}
.error-block {
display: block;
text-align: center;
color: #030000;
.tip1 {
margin-top: 80rpx;
font-size: 28rpx;
font-weight: 400;
}
.tip2 {
margin-top: 40rpx;
font-size: 28rpx;
font-weight: 400;
}
}
.device-popup-btns {
margin-top: 60rpx;
}

@ -30,7 +30,6 @@ export default class DeviceConnectPopup extends Component<any, any> {
super(props);
this.state = {
name: "蓝牙提示弹窗",
current: 0,
toRight: false,
isClick: false,
};
@ -60,14 +59,32 @@ export default class DeviceConnectPopup extends Component<any, any> {
this.props.confirm();
};
onReconnect = () => {
this.props.reconnect();
};
onClickStop = (e) => {
e.stopPropagation();
};
isImage = (url) => {
if (url) {
if (url.includes(".mp4")) {
return false;
}
}
return true;
};
render() {
let { isShow, data, isLarge, title, connectionStatus, isConnection } =
this.props;
let { current } = this.state;
let {
isShow,
data,
// connectionStatus,
isConnection,
connectionSuccess,
error,
} = this.props;
return (
<Block>
@ -84,72 +101,123 @@ export default class DeviceConnectPopup extends Component<any, any> {
className="at-icon at-icon-close site-close"
onClick={this.onClose}
></View>
<View className={classnames("common-box upload-tips-common-box")}>
<View className={classnames("common-popup-title", "margin-samll")}>
{data.bluetoothConnectingTitle}
</View>
<View className="site-popup-content-box">
<Video src={data.bluetoothConnecting} />
<View className="block">
<View className="icon">
{connectionStatus ? (
<Image
className="images"
src={require("../../../img/selected_success.png")}
mode="aspectFill"
/>
{!error && (
<View className={classnames("common-box device-connection-box")}>
<View
className={classnames("common-popup-title", "margin-samll")}
>
{data.bluetoothConnectingTitle}
</View>
<View className="device-popup-content-box">
{this.isImage(data.bluetoothConnecting) ? (
<Video className="videos" src={data.bluetoothConnecting} />
) : (
<Image
className="images"
src={data.bluetoothConnecting}
mode="aspectFill"
/>
)}
<View className="block">
{isConnection ? (
<Block>
<View className="icon">
<Image
className="images"
src={require("../../../img/selected_success.png")}
mode="aspectFill"
/>
</View>
<View className="tip">
{data.bluetoothConnectingContent}
</View>
</Block>
) : (
<Image
className="images"
src={require("../../../img/select_success.png")}
mode="aspectFill"
/>
<Block>
<View className="icon">
<Image
className="images"
src={require("../../../img/select_success.png")}
mode="aspectFill"
/>
</View>
<View className="tip success">
{data.bluetoothConnectingContent}
</View>
</Block>
)}
</View>
<View className="block2">
{connectionSuccess ? (
<Block>
<View className="icon">
<Image
className="images"
src={require("../../../img/selected_success.png")}
mode="aspectFill"
/>
</View>
<View className="tip"></View>
</Block>
) : (
<Block>
<View className="icon">
<Image
className="images"
src={require("../../../img/select_success.png")}
mode="aspectFill"
/>
</View>
<View className="tip success">
</View>
</Block>
)}
</View>
{isConnection && <View></View>}
<View className="tip1">skinpilot</View>
</View>
<View className="common-popup-btns">
<Button className="common-popup-btn2" onClick={this.onClose}>
</Button>
<Button className="common-popup-btn2" onClick={this.onConfirm}>
</Button>
</View>
</View>
<View className="common-popup-btns">
<Button className="common-popup-btn2" onClick={this.onClose}>
</Button>
<Button className="common-popup-btn2" onClick={this.onConfirm}>
</Button>
</View>
{/* <View>
{data.length === 1 && (
<View className="popup-btn-one">
<Button className="popup-btn" onClick={this.onClose}>
</Button>
</View>
)}
{data.length > 1 && current === 0 && (
<View className="popup-btn-one">
<Button className="popup-btn" onClick={this.onPrev}>
</Button>
</View>
)}
{data.length > 1 && (
<View className="common-popup-btns">
<Button className="common-popup-btn2" onClick={this.onPrev}>
{current > 0 && current < data.length - 1 && "上一步"}
</Button>
<Button className="common-popup-btn2" onClick={this.onNext}>
{current > 0 && current < data.length - 1 && "下一步"}
{current > 0 && current === data.length - 1 && "知道了"}
</Button>
)}
{error && (
<View className={classnames("common-box", "device-connection-box")}>
<View
className={classnames("common-popup-title", "margin-samll")}
>
{data.bluetoothConnectFailTitle}
</View>
<View className="device-popup-content-box">
<Video className="videos" src={data.bluetoothConnectFail} />
<View className="error-block">
<View className="tip1"></View>
<View className="tip2">
{data.bluetoothConnectFailContent}
</View>
</View>
)}
</View> */}
</View>
</View>
<View className="common-popup-btns device-popup-btns">
<Button className="common-popup-btn2" onClick={this.onClose}>
</Button>
<Button
className="common-popup-btn2"
onClick={this.onReconnect}
>
</Button>
</View>
</View>
)}
</Popup>
</Block>
);

@ -573,22 +573,13 @@ class Index extends Component<any, any> {
goNursing = (item) => {
console.log("goNursing", item);
setStorageSync("instrument_detail", JSON.stringify(item));
// setStorageSync("connectInstrument", JSON.stringify(item));
// this.setState({ instrument_detail: item });
// this.setState({ connectInstrument: item });
// setTimeout(() => this.bindBlockLeft());
// isConnectShow
setTimeout(() => {
go("/pages/instrumentClickinUpload/index?id=" + item.id);
}, 10);
// go("/pages/instrument/intro?id=" + item.id);
this.setState({ connectInstrument: item });
setTimeout(() => this.bindBlockLeft());
};
/* 扫码进入逻辑 */
/** 蓝牙逻辑 */
bindBlockLeft() {
console.log("this.state.userinfo", this.state.userinfo);
if (!this.state.userinfo.mobile) {
//未注册授权
this.alertRegister();
@ -596,7 +587,12 @@ class Index extends Component<any, any> {
}
if (this.state.connectInstrument.type === 1) {
//非IOT
setTimeout(() => {
go("/pages/instrumentClickinUpload/index");
}, 10);
} else {
go("/pages/iotCarePlan/iotCarePlan"); // 画页面直接跳转
return;
Taro.getSystemInfo({
success: (res) => {
console.log("getSystemInfo", res);
@ -716,6 +712,7 @@ class Index extends Component<any, any> {
//连接完成时数据的回调
offlineChange = async (e) => {
console.log("offlineChange", e);
const that = this;
log.info(
commandMap.versionInfoHome,
@ -1131,6 +1128,8 @@ class Index extends Component<any, any> {
yiqiInfo={connectInstrument}
close={this.connectionClose}
confirm={this.connectionConfirm}
offlineChange={this.offlineChange}
pairingChange={this.pairingChange}
/>
)}
{/* <ConnectionBluetoot /> */}

@ -0,0 +1,99 @@
.mode-list-box {
width: 100%;
height: 160rpx;
margin-bottom: 20rpx;
&:last-child {
margin-bottom: 0;
}
.mode-list {
display: flex;
align-items: center;
.mode-item-title {
display: flex;
align-items: center;
justify-content: center;
width: 110rpx;
min-width: 110rpx;
font-size: 26rpx;
font-family: PingFang SC;
font-weight: bold;
color: #000000;
margin: 0 20rpx;
}
.mode-item {
display: flex;
min-width: 140rpx;
height: 160rpx;
align-items: center;
margin-bottom: 20rpx;
background-color: #fff;
border-radius: 20rpx;
/*padding: 17rpx 18rpx;*/
box-sizing: border-box;
transition: all 0.3s;
flex-shrink: 0;
overflow: hidden;
.mode-info {
min-width: 140rpx;
padding-left: 10rpx;
padding-right: 10rpx;
.mode-info-title {
margin-bottom: 4rpx;
font-size: 26rpx;
text-align: center;
}
.mode-info-time {
margin-bottom: 4rpx;
text-align: center;
color: #666666;
font-size: 24rpx;
}
.mode-info-select {
display: flex;
align-items: center;
justify-content: center;
width: 30rpx;
height: 30rpx;
margin: 10rpx auto 0;
border: 3rpx solid #f1f1f1;
border-radius: 50%;
box-sizing: border-box;
&.is-select {
background-color: #fff;
border: none;
}
}
.mode-info-select-point {
width: 14rpx;
height: 14rpx;
background-color: #000000;
border-radius: 50%;
}
}
}
.mode-item + .mode-item {
margin-left: 20rpx;
}
.mode-item-active {
min-width: 300rpx;
padding-right: 11rpx;
background: linear-gradient(90deg, #efdcc2 0%, #fff2df 100%);
}
.mode-pic {
width: 140rpx;
height: 140rpx;
/*margin-left: 20rpx;*/
background-color: #f1f1f1;
border-radius: 20rpx;
overflow: hidden;
}
.mode-pic image {
width: 100%;
height: 100%;
vertical-align: middle;
}
}
}

@ -0,0 +1,104 @@
import Taro from "@tarojs/taro";
import { Block, View, ScrollView, Image } from "@tarojs/components";
import "./index.less";
interface Props {
// link: string;
// children?: any;
ModeList: any;
}
let scrollIntoView = "0";
function Index({ ModeList }: any) {
let VisorList = ModeList.filter((item) => item.modeType === 1); // 面罩模式
let CabinList = ModeList.filter((item) => item.modeType === 2); // 舱体模式
let YimeishList = ModeList.filter((item) => item.modeType === 3); // 医美术后
return (
<Block>
<ScrollView
className="mode-list-box"
scroll-x="true"
scrollIntoView={scrollIntoView}
>
{VisorList.length > 0 && (
<View className="mode-list">
<View className="mode-item-title"></View>
{VisorList.map((item: any, index: any) => {
return (
<View key={index} className="mode-item mode-item-active">
<View className="mode-info">
<View className="mode-info-title">{item.modeName}</View>
<View className="mode-info-time">{item.modeDesc}</View>
<View className="mode-info-select is-select">
<View className="mode-info-select-point"></View>
</View>
</View>
<View className="mode-pic">
<Image src={item.banner} mode="aspectFill" />
</View>
</View>
);
})}
</View>
)}
</ScrollView>
<ScrollView
className="mode-list-box"
scrollX={true}
scrollIntoView={scrollIntoView}
>
{CabinList.length > 0 && (
<View className="mode-list">
<View className="mode-item-title"></View>
{CabinList.map((item: any, index: any) => {
return (
<View key={index} className="mode-item mode-item-active">
<View className="mode-info">
<View className="mode-info-title">{item.title}</View>
<View className="mode-info-time">{item.time}</View>
<View className="mode-info-select is-select">
<View className="mode-info-select-point"></View>
</View>
</View>
<View className="mode-pic">
<Image src={item.banner} mode="aspectFill" />
</View>
</View>
);
})}
</View>
)}
</ScrollView>
<ScrollView
className="mode-list-box"
scrollX={true}
scrollIntoView={scrollIntoView}
>
{YimeishList.length > 0 && (
<View className="mode-list">
<View className="mode-item-title"></View>
{YimeishList.map((item: any, index: any) => {
return (
<View key={index} className="mode-item mode-item-active">
<View className="mode-info">
<View className="mode-info-title">{item.title}</View>
<View className="mode-info-time">{item.time}</View>
<View className="mode-info-select is-select">
<View className="mode-info-select-point"></View>
</View>
</View>
<View className="mode-pic">
<Image src={item.banner} mode="aspectFill" />
</View>
</View>
);
})}
</View>
)}
</ScrollView>
</Block>
);
}
export default Index;

@ -0,0 +1,52 @@
.iot-main {
padding: 20rpx 30rpx;
background: #f8f8f8;
box-sizing: border-box;
.banner-box {
position: relative;
display: block;
width: 690rpx;
height: 790rpx;
background-color: #fff;
border-radius: 30rpx;
.music-btn {
position: absolute;
top: 17rpx;
right: 17rpx;
width: 54rpx;
height: 54rpx;
background: #f8f8f8;
border-radius: 50%;
z-index: 10;
display: flex;
justify-content: center;
align-items: center;
.music-btn_icon {
width: 54rpx;
height: 54rpx;
}
}
.video-or-image {
display: block;
width: 690rpx;
height: 690rpx;
border-radius: 30rpx;
}
.iot-device {
width: 690rpx;
height: 100rpx;
display: flex;
align-items: center;
.item {
flex: 1;
display: flex;
align-items: center;
justify-content: center;
height: 50rpx;
}
.border-right {
border-right: 1px solid #ddd;
}
}
}
}

@ -0,0 +1,168 @@
import Taro from "@tarojs/taro";
import classnames from "classnames";
import { Component, PropsWithChildren, useEffect, useState } from "react";
import {
Block,
View,
Text,
Image,
Video,
Input,
Button,
} from "@tarojs/components";
/*** redux ***/
import { connect } from "react-redux";
/*** redux end ***/
// import log from "@/utils/log";
// log.info("123456info", 123456, { sdfasdf: 123 });
/* 公共组件 */
import Navbar from "@/components/navbar/navbar";
/* 公共组件 END */
/* 本页组件 */
import ModeListView from "./components/ModeList/index";
/* 本页组件 END */
import { getStorageSync, setStorageSync } from "@/utils/traoAPI";
import { InstrumentInfo } from "@/utils/Interface";
import "./iotCarePlan.less";
class IotCarePlan extends Component<any, any> {
constructor(props) {
super(props);
this.state = {
name: "iotCarePlan",
musicStatus: false, // 声音播放状态
// visorList: [
// {
// title: "visorList",
// time: "2024-02-04",
// banner: "",
// },
// {
// title: "visorList",
// time: "2024-02-04",
// banner: "",
// },
// {
// title: "visorList",
// time: "2024-02-04",
// banner: "",
// },
// {
// title: "visorList",
// time: "2024-02-04",
// banner: "",
// },
// ],
// cabinList: [
// {
// title: "cabinList",
// time: "2024-02-04",
// banner: "",
// },
// {
// title: "cabinList",
// time: "2024-02-04",
// banner: "",
// },
// {
// title: "cabinList",
// time: "2024-02-04",
// banner: "",
// },
// {
// title: "cabinList",
// time: "2024-02-04",
// banner: "",
// },
// ],
ModeList: [],
};
}
async onLoad() {}
componentDidMount() {}
componentWillUnmount() {}
componentDidShow() {
this.initData();
}
componentDidHide() {}
async initData() {
let objStr = getStorageSync("instrument_detail");
if (objStr) {
let info = JSON.parse(objStr);
this.GetModeList(info.id);
}
}
GetModeList = async (id) => {
let params = {
instrumentId: id,
};
let res = await InstrumentInfo.modeInfoList(params);
console.log("GetModeList", res);
if (res.data.code === 200) {
this.setState({ ModeList: res.data.data });
}
};
render() {
let { name, musicStatus, ModeList } = this.state;
return (
<Block>
<Navbar titleSlot="美容仪名字" isBack={true} />
<View>
<View className="iot-main">
<View className="banner-box">
<View className="music-btn">
{musicStatus ? (
<Image
className="music-btn_icon"
src={require("../../img/volume_icon.png")}
mode="aspectFill"
/>
) : (
<Image
className="music-btn_icon"
src={require("../../img/mute_icon.png")}
mode="aspectFill"
/>
)}
</View>
<Video className="video-or-image" src="" />
<View className="iot-device">
<View className="item border-right">
<Text>10:00</Text>
</View>
<View className="item">
<Text>WE200</Text>
</View>
</View>
</View>
<ModeListView ModeList={ModeList} />
</View>
</View>
</Block>
);
}
}
const mapStateToProps = (state) => ({
// background: state.navigation.background,
});
const mapDispatchToProps = (dispatch) => ({
// userRefresh(data) {
// dispatch(userRefresh(data));
// },
});
export default connect(mapStateToProps, mapDispatchToProps)(IotCarePlan);

@ -6,7 +6,7 @@ const deviceInfoReducer = createSlice({
name: "deviceinfo", // store的名字
initialState: {
bluetoothInfo: {
deviceId: "5FF5FD4F-9EF9-3CB6-AD89-F915B55E5DE9", // 先测试一下
deviceId: "", // 先测试一下
servicesuuid: "",
characteristicsuuid0: "",
characteristicsuuid1: "",
@ -18,10 +18,28 @@ const deviceInfoReducer = createSlice({
state = JSON.parse(JSON.stringify(payload));
},
setBluetoothInfo(state, { payload }) {
state.bluetoothInfo = JSON.parse(JSON.stringify(payload));
console.log("setBluetoothInfo payload", payload);
state.bluetoothInfo.deviceId = payload.deviceId;
if (payload.servicesuuid) {
state.bluetoothInfo.servicesuuid = payload.servicesuuid;
}
if (payload.characteristicsuuid0) {
state.bluetoothInfo.characteristicsuuid0 = payload.characteristicsuuid0;
}
if (payload.characteristicsuuid1) {
state.bluetoothInfo.characteristicsuuid1 = payload.characteristicsuuid1;
}
if (payload.characteristicId) {
state.bluetoothInfo.characteristicId = payload.characteristicId;
}
},
setDeviceId(state, { payload }) {
console.log("setDeviceId payload", payload);
state.bluetoothInfo.deviceId = payload.deviceId;
console.log("state.bluetoothInfo.deviceId", state.bluetoothInfo.deviceId);
},
},
});
export const { setBluetoothInfo } = deviceInfoReducer.actions;
export const { setBluetoothInfo, setDeviceId } = deviceInfoReducer.actions;
export default deviceInfoReducer.reducer;

@ -1,6 +1,5 @@
import Taro from "@tarojs/taro";
import store from "../store";
const deviceInfo = store.getState().deviceInfo;
import { msg, back, showModal, go, loading } from "./traoAPI";
// const app = getApp();
@ -155,6 +154,7 @@ export const writeBLECharacteristicValue = (info, completeCallback) => {
};
export const sendCommand = (info) => {
const deviceInfo = store.getState().deviceInfo;
return new Promise((reslove, reject) => {
Taro.writeBLECharacteristicValue({
deviceId: deviceInfo.bluetoothInfo.deviceId,
@ -162,7 +162,6 @@ export const sendCommand = (info) => {
characteristicId: deviceInfo.bluetoothInfo.characteristicsuuid0,
value: info.value,
success(res) {
console.log(info.value);
reslove(res);
},
fail(err) {

@ -1,30 +1,37 @@
var log = wx.getRealtimeLogManager ? wx.getRealtimeLogManager() : null
import Taro from "@tarojs/taro";
module.exports = {
// var logger = Taro.getRealtimeLogManager ? Taro.getRealtimeLogManager() : null;
var logger = Taro.getRealtimeLogManager();
const log = {
debug() {
if (!log) return
log.debug.apply(log, arguments)
if (!logger) return;
logger.debug.apply(logger, arguments);
},
info() {
if (!log) return
log.info.apply(log, arguments)
if (!logger) return;
logger.info.apply(logger, arguments);
},
warn() {
if (!log) return
log.warn.apply(log, arguments)
if (!logger) return;
logger.warn.apply(logger, arguments);
},
error() {
if (!log) return
log.error.apply(log, arguments)
if (!logger) return;
logger.error.apply(logger, arguments);
},
setFilterMsg(msg) {
// 从基础库2.7.3开始支持
if (!logger || !logger.setFilterMsg) return;
if (typeof msg !== "string") return;
logger.setFilterMsg(msg);
},
setFilterMsg(msg) { // 从基础库2.7.3开始支持
if (!log || !log.setFilterMsg) return
if (typeof msg !== 'string') return
log.setFilterMsg(msg)
addFilterMsg(msg) {
// 从基础库2.8.1开始支持
if (!logger || !logger.addFilterMsg) return;
if (typeof msg !== "string") return;
logger.addFilterMsg(msg);
},
addFilterMsg(msg) { // 从基础库2.8.1开始支持
if (!log || !log.addFilterMsg) return
if (typeof msg !== 'string') return
log.addFilterMsg(msg)
}
}
};
export default log;

@ -13,13 +13,13 @@ import formdata from "./wxFormdata/formData";
import store from "../store";
import { tokenRefresh } from "../store/features/userInfo";
const global = store.getState().globalStore;
const global_requestUrlList = []; // 全局正在请求的url地址防止多次点击
// api调用失败重试次数
let api_retry_count = 0;
export const Ajax = (params) => {
const global = store.getState().globalStore;
const app = Taro.getApp();
const domain = global.domain;
// Taro.showLoading({
@ -51,7 +51,7 @@ export const Ajax = (params) => {
},
data: params.data,
success(res) {
console.log("res", res);
// console.log("res", res);
if (res.data.code == 401 || res.data.code == 403) {
// 自动重新登录
Taro.removeStorageSync("token");
@ -87,9 +87,6 @@ export const Ajax = (params) => {
return false;
}
if (requestUrlList.length > 0) {
requestUrlList.splice(requestUrlList.indexOf(params.url), 1);
}
reslove(res);
},
fail(err) {
@ -102,6 +99,9 @@ export const Ajax = (params) => {
// });
},
complete() {
if (requestUrlList.length > 0) {
requestUrlList.splice(requestUrlList.indexOf(params.url), 1);
}
if (requestUrlList.length === 0) {
Taro.hideLoading();
}

Loading…
Cancel
Save