master
blak-kong 2 years ago
commit 70e7ec5186

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

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

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

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

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

@ -1,66 +1,66 @@
/**蓝牙命令合集*/ /**蓝牙命令合集*/
export const bleCommandSamples = { export const bleCommandSamples = {
/**发送配对码*/ /**发送配对码*/
match: { match: {
commandType: "BleMatch", commandType: "BleMatch",
bleCommandType: "SendMatchCode", bleCommandType: "SendMatchCode",
}, },
/**查询附属设备的配对状态*/ /**查询附属设备的配对状态*/
querySubDevice: { querySubDevice: {
commandType: "BleMatch", commandType: "BleMatch",
bleCommandType: "QueryMatchStatus", bleCommandType: "QueryMatchStatus",
}, },
/**查询设备状态指令*/ /**查询设备状态指令*/
queryDeviceStatus: { queryDeviceStatus: {
commandType: "DeviceStatusSync", commandType: "DeviceStatusSync",
deviceSyncCommandType: 'queryDeviceStatus' deviceSyncCommandType: "queryDeviceStatus",
}, },
/**查询版本指令*/ /**查询版本指令*/
queryDeviceVersionStatus: { queryDeviceVersionStatus: {
commandType: "InfoQuery", commandType: "InfoQuery",
infoQueryType: 'versionInfo', infoQueryType: "versionInfo",
otaDeviceType: '' otaDeviceType: "",
}, },
/**查询当前记录*/ /**查询当前记录*/
queryCurrentMaskReportInfo: { queryCurrentMaskReportInfo: {
commandType: "InfoQuery", commandType: "InfoQuery",
infoQueryType: 'currentMaskReportInfo' infoQueryType: "currentMaskReportInfo",
} },
}; };
/**控制设备命令合集*/ /**控制设备命令合集*/
export const deviceCommandSamples = { export const deviceCommandSamples = {
/**控制设备暂停 pause暂停 working启动 end关闭*/ /**控制设备暂停 pause暂停 working启动 end关闭*/
pause:{ pause: {
commandType: "DeviceControl", commandType: "DeviceControl",
workStatus: "pause", workStatus: "pause",
}, },
standby:{ standby: {
commandType: "DeviceControl", commandType: "DeviceControl",
workStatus: "standby", workStatus: "standby",
}, },
end:{ end: {
commandType: "DeviceControl", commandType: "DeviceControl",
workStatus: "end", workStatus: "end",
}, },
/* /*
* powerfulSoothing 强效舒缓 01 * powerfulSoothing 强效舒缓 01
* Stability 维稳维护 02 * Stability 维稳维护 02
* Brighten 均色提亮 03 * Brighten 均色提亮 03
* FirmSkin 紧致淡纹 04 * FirmSkin 紧致淡纹 04
* Custom 自定义模式 05 * Custom 自定义模式 05
* WaterLightEssence 水光精华模式 11 * WaterLightEssence 水光精华模式 11
* ShapeBeautyEssence 塑颜精华模式 12 * ShapeBeautyEssence 塑颜精华模式 12
* DiyFacial DIY面膜模式 13 * DiyFacial DIY面膜模式 13
* FacialMaskCustom 面膜定制模式 1A * FacialMaskCustom 面膜定制模式 1A
*/ */
work:{ work: {
commandType: "DeviceControl", commandType: "DeviceControl",
workStatus: "working", workStatus: "working",
workMode: "", workMode: "",
}, },
gear:{ gear: {
commandType: "DeviceControl", commandType: "DeviceControl",
partitionStatus: [{gear: 1},{gear: 1},{gear: 1},{gear: 1},] 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; margin: 0;
} }
// .van-popup { // .van-popup {
@ -33,17 +40,6 @@
box-sizing: border-box; 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 { .popup-btn-one {
display: flex; display: flex;
margin-top: 60rpx; margin-top: 60rpx;
@ -62,3 +58,65 @@
font-family: PingFang SC; 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); super(props);
this.state = { this.state = {
name: "蓝牙提示弹窗", name: "蓝牙提示弹窗",
current: 0,
toRight: false, toRight: false,
isClick: false, isClick: false,
}; };
@ -60,14 +59,32 @@ export default class DeviceConnectPopup extends Component<any, any> {
this.props.confirm(); this.props.confirm();
}; };
onReconnect = () => {
this.props.reconnect();
};
onClickStop = (e) => { onClickStop = (e) => {
e.stopPropagation(); e.stopPropagation();
}; };
isImage = (url) => {
if (url) {
if (url.includes(".mp4")) {
return false;
}
}
return true;
};
render() { render() {
let { isShow, data, isLarge, title, connectionStatus, isConnection } = let {
this.props; isShow,
let { current } = this.state; data,
// connectionStatus,
isConnection,
connectionSuccess,
error,
} = this.props;
return ( return (
<Block> <Block>
@ -84,72 +101,123 @@ export default class DeviceConnectPopup extends Component<any, any> {
className="at-icon at-icon-close site-close" className="at-icon at-icon-close site-close"
onClick={this.onClose} onClick={this.onClose}
></View> ></View>
<View className={classnames("common-box upload-tips-common-box")}>
<View className={classnames("common-popup-title", "margin-samll")}> {!error && (
{data.bluetoothConnectingTitle} <View className={classnames("common-box device-connection-box")}>
</View> <View
<View className="site-popup-content-box"> className={classnames("common-popup-title", "margin-samll")}
<Video src={data.bluetoothConnecting} /> >
{data.bluetoothConnectingTitle}
<View className="block"> </View>
<View className="icon"> <View className="device-popup-content-box">
{connectionStatus ? ( {this.isImage(data.bluetoothConnecting) ? (
<Image <Video className="videos" src={data.bluetoothConnecting} />
className="images" ) : (
src={require("../../../img/selected_success.png")} <Image
mode="aspectFill" 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 <Block>
className="images" <View className="icon">
src={require("../../../img/select_success.png")} <Image
mode="aspectFill" 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> </View>
{isConnection && <View></View>} </View>
<View className="common-popup-btns">
<View className="tip1">skinpilot</View> <Button className="common-popup-btn2" onClick={this.onClose}>
</Button>
<Button className="common-popup-btn2" onClick={this.onConfirm}>
</Button>
</View> </View>
</View> </View>
)}
<View className="common-popup-btns">
<Button className="common-popup-btn2" onClick={this.onClose}> {error && (
<View className={classnames("common-box", "device-connection-box")}>
</Button> <View
<Button className="common-popup-btn2" onClick={this.onConfirm}> className={classnames("common-popup-title", "margin-samll")}
>
</Button> {data.bluetoothConnectFailTitle}
</View> </View>
<View className="device-popup-content-box">
{/* <View> <Video className="videos" src={data.bluetoothConnectFail} />
{data.length === 1 && (
<View className="popup-btn-one"> <View className="error-block">
<Button className="popup-btn" onClick={this.onClose}> <View className="tip1"></View>
<View className="tip2">
</Button> {data.bluetoothConnectFailContent}
</View> </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>
</View> </View>
)} </View>
</View> */} <View className="common-popup-btns device-popup-btns">
</View> <Button className="common-popup-btn2" onClick={this.onClose}>
</Button>
<Button
className="common-popup-btn2"
onClick={this.onReconnect}
>
</Button>
</View>
</View>
)}
</Popup> </Popup>
</Block> </Block>
); );

@ -573,22 +573,13 @@ class Index extends Component<any, any> {
goNursing = (item) => { goNursing = (item) => {
console.log("goNursing", item); console.log("goNursing", item);
setStorageSync("instrument_detail", JSON.stringify(item)); setStorageSync("instrument_detail", JSON.stringify(item));
// setStorageSync("connectInstrument", JSON.stringify(item)); this.setState({ connectInstrument: item });
setTimeout(() => this.bindBlockLeft());
// 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);
}; };
/* 扫码进入逻辑 */ /* 扫码进入逻辑 */
/** 蓝牙逻辑 */ /** 蓝牙逻辑 */
bindBlockLeft() { bindBlockLeft() {
console.log("this.state.userinfo", this.state.userinfo);
if (!this.state.userinfo.mobile) { if (!this.state.userinfo.mobile) {
//未注册授权 //未注册授权
this.alertRegister(); this.alertRegister();
@ -596,7 +587,12 @@ class Index extends Component<any, any> {
} }
if (this.state.connectInstrument.type === 1) { if (this.state.connectInstrument.type === 1) {
//非IOT //非IOT
setTimeout(() => {
go("/pages/instrumentClickinUpload/index");
}, 10);
} else { } else {
go("/pages/iotCarePlan/iotCarePlan"); // 画页面直接跳转
return;
Taro.getSystemInfo({ Taro.getSystemInfo({
success: (res) => { success: (res) => {
console.log("getSystemInfo", res); console.log("getSystemInfo", res);
@ -716,6 +712,7 @@ class Index extends Component<any, any> {
//连接完成时数据的回调 //连接完成时数据的回调
offlineChange = async (e) => { offlineChange = async (e) => {
console.log("offlineChange", e);
const that = this; const that = this;
log.info( log.info(
commandMap.versionInfoHome, commandMap.versionInfoHome,
@ -1131,6 +1128,8 @@ class Index extends Component<any, any> {
yiqiInfo={connectInstrument} yiqiInfo={connectInstrument}
close={this.connectionClose} close={this.connectionClose}
confirm={this.connectionConfirm} confirm={this.connectionConfirm}
offlineChange={this.offlineChange}
pairingChange={this.pairingChange}
/> />
)} )}
{/* <ConnectionBluetoot /> */} {/* <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的名字 name: "deviceinfo", // store的名字
initialState: { initialState: {
bluetoothInfo: { bluetoothInfo: {
deviceId: "5FF5FD4F-9EF9-3CB6-AD89-F915B55E5DE9", // 先测试一下 deviceId: "", // 先测试一下
servicesuuid: "", servicesuuid: "",
characteristicsuuid0: "", characteristicsuuid0: "",
characteristicsuuid1: "", characteristicsuuid1: "",
@ -18,10 +18,28 @@ const deviceInfoReducer = createSlice({
state = JSON.parse(JSON.stringify(payload)); state = JSON.parse(JSON.stringify(payload));
}, },
setBluetoothInfo(state, { 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; export default deviceInfoReducer.reducer;

@ -1,6 +1,5 @@
import Taro from "@tarojs/taro"; import Taro from "@tarojs/taro";
import store from "../store"; import store from "../store";
const deviceInfo = store.getState().deviceInfo;
import { msg, back, showModal, go, loading } from "./traoAPI"; import { msg, back, showModal, go, loading } from "./traoAPI";
// const app = getApp(); // const app = getApp();
@ -155,6 +154,7 @@ export const writeBLECharacteristicValue = (info, completeCallback) => {
}; };
export const sendCommand = (info) => { export const sendCommand = (info) => {
const deviceInfo = store.getState().deviceInfo;
return new Promise((reslove, reject) => { return new Promise((reslove, reject) => {
Taro.writeBLECharacteristicValue({ Taro.writeBLECharacteristicValue({
deviceId: deviceInfo.bluetoothInfo.deviceId, deviceId: deviceInfo.bluetoothInfo.deviceId,
@ -162,7 +162,6 @@ export const sendCommand = (info) => {
characteristicId: deviceInfo.bluetoothInfo.characteristicsuuid0, characteristicId: deviceInfo.bluetoothInfo.characteristicsuuid0,
value: info.value, value: info.value,
success(res) { success(res) {
console.log(info.value);
reslove(res); reslove(res);
}, },
fail(err) { 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() { debug() {
if (!log) return if (!logger) return;
log.debug.apply(log, arguments) logger.debug.apply(logger, arguments);
}, },
info() { info() {
if (!log) return if (!logger) return;
log.info.apply(log, arguments) logger.info.apply(logger, arguments);
}, },
warn() { warn() {
if (!log) return if (!logger) return;
log.warn.apply(log, arguments) logger.warn.apply(logger, arguments);
}, },
error() { error() {
if (!log) return if (!logger) return;
log.error.apply(log, arguments) 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开始支持 addFilterMsg(msg) {
if (!log || !log.setFilterMsg) return // 从基础库2.8.1开始支持
if (typeof msg !== 'string') return if (!logger || !logger.addFilterMsg) return;
log.setFilterMsg(msg) if (typeof msg !== "string") return;
logger.addFilterMsg(msg);
}, },
addFilterMsg(msg) { // 从基础库2.8.1开始支持 };
if (!log || !log.addFilterMsg) return
if (typeof msg !== 'string') return export default log;
log.addFilterMsg(msg)
}
}

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

Loading…
Cancel
Save