ipanel-rnapp-ajb-base 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/app/.local_dev/DemoPage.js +46 -0
- package/app/.local_dev/env.js +1 -0
- package/app/.local_dev/polyfill.js +83 -0
- package/app/App.js +485 -0
- package/app/api/homedApi.js +42 -0
- package/app/api/index.js +2 -0
- package/app/api/ipanelCloudApi.js +796 -0
- package/app/assets/img/add.png +0 -0
- package/app/assets/img/add_img.png +0 -0
- package/app/assets/img/album.png +0 -0
- package/app/assets/img/album2.png +0 -0
- package/app/assets/img/album3.png +0 -0
- package/app/assets/img/album@2x.png +0 -0
- package/app/assets/img/album@3x.png +0 -0
- package/app/assets/img/audioRecordBar.png +0 -0
- package/app/assets/img/bootom_bar_bg.png +0 -0
- package/app/assets/img/close.png +0 -0
- package/app/assets/img/computer.png +0 -0
- package/app/assets/img/confirm.png +0 -0
- package/app/assets/img/delete_pic.png +0 -0
- package/app/assets/img/disabled.png +0 -0
- package/app/assets/img/goBack.png +0 -0
- package/app/assets/img/goBack2.png +0 -0
- package/app/assets/img/ischeck.png +0 -0
- package/app/assets/img/launch_bg.png +0 -0
- package/app/assets/img/launch_bg_panyu.png +0 -0
- package/app/assets/img/launch_logo.png +0 -0
- package/app/assets/img/launch_logo_panyu.png +0 -0
- package/app/assets/img/launch_text.png +0 -0
- package/app/assets/img/launch_text_panyu.png +0 -0
- package/app/assets/img/link.png +0 -0
- package/app/assets/img/login_bg.png +0 -0
- package/app/assets/img/login_bg_new.png +0 -0
- package/app/assets/img/login_left.png +0 -0
- package/app/assets/img/login_right.png +0 -0
- package/app/assets/img/nocheck.png +0 -0
- package/app/assets/img/personal.png +0 -0
- package/app/assets/img/photo.png +0 -0
- package/app/assets/img/photo@2x.png +0 -0
- package/app/assets/img/photo@3x.png +0 -0
- package/app/assets/img/protocol_checked.png +0 -0
- package/app/assets/img/qiehuan.png +0 -0
- package/app/assets/img/scan_border_bottom_left.png +0 -0
- package/app/assets/img/scan_border_bottom_right.png +0 -0
- package/app/assets/img/scan_border_top_left.png +0 -0
- package/app/assets/img/scan_border_top_right.png +0 -0
- package/app/assets/img/scan_move.png +0 -0
- package/app/assets/img/szjt.png +0 -0
- package/app/assets/img/tab.png +0 -0
- package/app/assets/img/tykz.png +0 -0
- package/app/assets/img/update_bg.png +0 -0
- package/app/assets/img/video.png +0 -0
- package/app/assets/img/video@2x.png +0 -0
- package/app/assets/img/video@3x.png +0 -0
- package/app/assets/img/worker.png +0 -0
- package/app/assets/img/wx.png +0 -0
- package/app/assets/img/ykq.png +0 -0
- package/app/assets/img/zfb.png +0 -0
- package/app/base.js +342 -0
- package/app/components/VersionUpdateConfirm.js +117 -0
- package/app/components/common/AccordionCell/index.js +67 -0
- package/app/components/common/ActionPicker/BasicPicker.js +136 -0
- package/app/components/common/ActionPicker/index.js +106 -0
- package/app/components/common/AddressPicker/index.js +211 -0
- package/app/components/common/Card/index.js +19 -0
- package/app/components/common/Cell/index.js +381 -0
- package/app/components/common/CustomDialog/index.js +120 -0
- package/app/components/common/CustomTabBar/index.js +157 -0
- package/app/components/common/CustomTabBar_bak/TabBarInput.js +210 -0
- package/app/components/common/CustomTabBar_bak/index.js +832 -0
- package/app/components/common/DateTimingPicker/index.js +254 -0
- package/app/components/common/Dialog/Notify.js +36 -0
- package/app/components/common/Dialog/baseDialog.js +146 -0
- package/app/components/common/Dialog/index.js +113 -0
- package/app/components/common/Dialog/prompt.js +145 -0
- package/app/components/common/Dialog/quickSelect.js +54 -0
- package/app/components/common/Dialog/select.js +125 -0
- package/app/components/common/Dialog/styles.js +167 -0
- package/app/components/common/Loading/index.js +71 -0
- package/app/components/common/LoginType/index.js +171 -0
- package/app/components/common/LoginType/protocol.js +160 -0
- package/app/components/common/Notify/index.js +68 -0
- package/app/components/common/OnceTouchable/index.js +33 -0
- package/app/components/common/PaymentPicker/index.js +264 -0
- package/app/components/common/ProductOrderPicker/index.js +524 -0
- package/app/components/common/ScreenBackHeader/index.js +144 -0
- package/app/components/common/ScrollPicker/index.js +232 -0
- package/app/components/common/SelectPicker/index.js +171 -0
- package/app/components/common/SmsCodeInput/index.js +93 -0
- package/app/components/common/SmsCodeInput/indexNew.js +101 -0
- package/app/components/common/Steps/index.js +126 -0
- package/app/components/common/Tag/index.js +17 -0
- package/app/components/common/Toast/index.js +103 -0
- package/app/components/common/WeekDaysPicker/index.js +196 -0
- package/app/components/index.js +8 -0
- package/app/components/iot/AddDeviceActionSheet/index.js +934 -0
- package/app/components/iot/AddressActionSheet/index.js +91 -0
- package/app/components/iot/RoomActionSheet/index.js +205 -0
- package/app/components/iot/ViewDeviceActionSheet/index.js +834 -0
- package/app/components/sheets.js +30 -0
- package/app/eventBus/index.js +54 -0
- package/app/hooks/checkLogin.js +30 -0
- package/app/hooks/shopMessageManager.js +308 -0
- package/app/hooks/useAddress.js +179 -0
- package/app/hooks/useAddress2.js +587 -0
- package/app/hooks/useDebounceFn.js +6 -0
- package/app/hooks/useDynamicPackages.js +22 -0
- package/app/hooks/useKeyboard.js +25 -0
- package/app/hooks/useLatest.js +10 -0
- package/app/hooks/useMessageManager.js +368 -0
- package/app/hooks/useNavigationFocus.js +19 -0
- package/app/hooks/useUser.js +56 -0
- package/app/screens/BaseScreen.js +389 -0
- package/app/screens/CommonScreens/BindPhoneScreen/index.js +179 -0
- package/app/screens/CommonScreens/BossScreen/index.js +138 -0
- package/app/screens/CommonScreens/DeviceAnswerDetailScreen/index.js +50 -0
- package/app/screens/CommonScreens/DeviceFeedbackScreen/index.js +365 -0
- package/app/screens/CommonScreens/EditInvoiceTitleScreen/index.js +279 -0
- package/app/screens/CommonScreens/FamilyDetailScreen/index.js +421 -0
- package/app/screens/CommonScreens/InvoiceTitleListScreen/index.js +118 -0
- package/app/screens/CommonScreens/OperatorSelectScreen/index.js +315 -0
- package/app/screens/CommonScreens/PersonalScreen/index.js +348 -0
- package/app/screens/CommonScreens/ScanQRCodeScreen/index.js +407 -0
- package/app/screens/CommonScreens/TvAlbumScreen/index.js +407 -0
- package/app/screens/LoginScreen/OpenLogSheet.js +241 -0
- package/app/screens/LoginScreen/index.js +920 -0
- package/app/screens/LoginScreen/indexNew.js +1354 -0
- package/app/screens/ResePassword/index.js +364 -0
- package/app/screens/SbkScreen.js +19 -0
- package/app/screens/WebviewScreen.js +41 -0
- package/app/storage/index.js +166 -0
- package/app/utils/EventEmitter.js +43 -0
- package/app/utils/RootNavigation.js +32 -0
- package/app/utils/SBK_plugin/convert.js +90 -0
- package/app/utils/SBK_plugin/convertStatus.js +250 -0
- package/app/utils/SBK_plugin/eventProcess.js +339 -0
- package/app/utils/SBK_plugin/index.js +32 -0
- package/app/utils/SBK_plugin/ipanelDeviceToSbkDevice.js +68 -0
- package/app/utils/SBK_plugin/sbk_defs.js +191 -0
- package/app/utils/StyleComposite.js +37 -0
- package/app/utils/applyPermissions.js +251 -0
- package/app/utils/bundleUpdater.js +46 -0
- package/app/utils/common.js +380 -0
- package/app/utils/config.js +47 -0
- package/app/utils/errCodes.js +3 -0
- package/app/utils/homedData.js +57 -0
- package/app/utils/http.js +178 -0
- package/app/utils/notice.js +15 -0
- package/app/utils/priceConversion.js +30 -0
- package/app/utils/registerDialog.js +90 -0
- package/app/utils/scaleSize.js +12 -0
- package/app/utils/soundPlayer.js +85 -0
- package/bin/local-dev.js +7 -0
- package/index.js +8 -0
- package/package.json +18 -0
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import {
|
|
2
|
+
convertToSbkLight,
|
|
3
|
+
convertToSbkCWLight,
|
|
4
|
+
convertToSbkCurtainNoPosition,
|
|
5
|
+
convertToSbkIrCondition,
|
|
6
|
+
} from './ipanelDeviceToSbkDevice';
|
|
7
|
+
import {
|
|
8
|
+
convertLightCmdOrStatus,
|
|
9
|
+
convertCWLightCmdOrStatus,
|
|
10
|
+
convertCurtainNoPositionCmdOrStatus,
|
|
11
|
+
convertIrConditionCmdOrStatus,
|
|
12
|
+
} from './convertStatus';
|
|
13
|
+
|
|
14
|
+
export const convert = ({
|
|
15
|
+
ipanelDevice,
|
|
16
|
+
convertType, // device|cmdOrStatus
|
|
17
|
+
|
|
18
|
+
// convertType="device"
|
|
19
|
+
room,
|
|
20
|
+
status,
|
|
21
|
+
|
|
22
|
+
// convertType="cmdOrStatus"
|
|
23
|
+
order,
|
|
24
|
+
}) => {
|
|
25
|
+
const toDeviceParams = {
|
|
26
|
+
ipanelDevice,
|
|
27
|
+
room,
|
|
28
|
+
familyName: '一楼', //楼层名, 强调说明,这个字段不是id,是楼层名,楼层名(只能是一楼,二楼类似这样的名字)
|
|
29
|
+
};
|
|
30
|
+
const toCmdParams = {
|
|
31
|
+
statusOrOrder: status,
|
|
32
|
+
isStatus: true,
|
|
33
|
+
};
|
|
34
|
+
const toStatusParams = {
|
|
35
|
+
statusOrOrder: order,
|
|
36
|
+
isStatus: false, // isOrder
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
if (
|
|
40
|
+
(ipanelDevice.device_type === 'igot' &&
|
|
41
|
+
ipanelDevice.extend.switch_usage === 'IGOT_LIGHT') ||
|
|
42
|
+
(ipanelDevice.device_type === 'virtual_itee_ds' &&
|
|
43
|
+
ipanelDevice.extend.switch_usage === 'IGOT_LIGHT')
|
|
44
|
+
) {
|
|
45
|
+
// 普通灯(通断器、itee直通开关)
|
|
46
|
+
if (convertType === 'device') {
|
|
47
|
+
return {
|
|
48
|
+
...convertToSbkLight(toDeviceParams),
|
|
49
|
+
jdsmartCtrlCmd: convertLightCmdOrStatus(toCmdParams),
|
|
50
|
+
};
|
|
51
|
+
} else if (convertType === 'cmdOrStatus') {
|
|
52
|
+
return convertLightCmdOrStatus(toStatusParams);
|
|
53
|
+
}
|
|
54
|
+
} else if (
|
|
55
|
+
ipanelDevice.device_type === 'light' &&
|
|
56
|
+
['YHWL', 'oupu', 'sanxiong'].includes(ipanelDevice.extend.brand)
|
|
57
|
+
) {
|
|
58
|
+
// 色温灯
|
|
59
|
+
if (convertType === 'device') {
|
|
60
|
+
return {
|
|
61
|
+
...convertToSbkCWLight(toDeviceParams),
|
|
62
|
+
jdsmartCtrlCmd: convertCWLightCmdOrStatus(toCmdParams),
|
|
63
|
+
};
|
|
64
|
+
} else if (convertType === 'cmdOrStatus') {
|
|
65
|
+
return convertCWLightCmdOrStatus(toStatusParams);
|
|
66
|
+
}
|
|
67
|
+
} else if (['curtain', 'windowpusher'].includes(ipanelDevice.device_type)) {
|
|
68
|
+
// 无位移窗帘
|
|
69
|
+
if (convertType === 'device') {
|
|
70
|
+
return {
|
|
71
|
+
...convertToSbkCurtainNoPosition(toDeviceParams),
|
|
72
|
+
jdsmartCtrlCmd: convertCurtainNoPositionCmdOrStatus(toCmdParams),
|
|
73
|
+
};
|
|
74
|
+
} else if (convertType === 'cmdOrStatus') {
|
|
75
|
+
return convertCurtainNoPositionCmdOrStatus(toStatusParams);
|
|
76
|
+
}
|
|
77
|
+
} else if (['ac'].includes(ipanelDevice.device_type)) {
|
|
78
|
+
// 红外空调
|
|
79
|
+
if (convertType === 'device') {
|
|
80
|
+
return {
|
|
81
|
+
...convertToSbkIrCondition(toDeviceParams),
|
|
82
|
+
jdsmartCtrlCmd: convertIrConditionCmdOrStatus(toCmdParams),
|
|
83
|
+
};
|
|
84
|
+
} else if (convertType === 'cmdOrStatus') {
|
|
85
|
+
return convertIrConditionCmdOrStatus(toStatusParams);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
return false;
|
|
90
|
+
};
|
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
import {JdSmartDeviceType, JdSmartDeviceOrder} from './sbk_defs';
|
|
2
|
+
|
|
3
|
+
export const convertLightCmdOrStatus = ({statusOrOrder, isStatus}) => {
|
|
4
|
+
if (isStatus) {
|
|
5
|
+
const status = statusOrOrder || {
|
|
6
|
+
power: 0,
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
// convertTo cmdStatus
|
|
10
|
+
return {
|
|
11
|
+
order: JdSmartDeviceOrder.OFF,
|
|
12
|
+
value1: status.power === 1 ? '0' : '-1', // 0表示状态是开,-1表示关
|
|
13
|
+
};
|
|
14
|
+
} else {
|
|
15
|
+
// statusOrOrder is order
|
|
16
|
+
const order = statusOrOrder;
|
|
17
|
+
// convertTo status
|
|
18
|
+
if (order.order === JdSmartDeviceOrder.OFF) {
|
|
19
|
+
// 关
|
|
20
|
+
return {
|
|
21
|
+
power: 0,
|
|
22
|
+
};
|
|
23
|
+
} else if (order.order === JdSmartDeviceOrder.ON) {
|
|
24
|
+
// 开
|
|
25
|
+
return {
|
|
26
|
+
power: 1,
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
return {};
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export const convertCWLightCmdOrStatus = ({statusOrOrder, isStatus}) => {
|
|
34
|
+
if (isStatus) {
|
|
35
|
+
const status = statusOrOrder || {
|
|
36
|
+
power: 0,
|
|
37
|
+
color: 70,
|
|
38
|
+
bright: 70,
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
// convertTo cmdStatus
|
|
42
|
+
return {
|
|
43
|
+
order: JdSmartDeviceOrder.OFF,
|
|
44
|
+
value1: status.power === 1 ? '0' : '-1',
|
|
45
|
+
groupData: JSON.stringify({
|
|
46
|
+
[JdSmartDeviceOrder.COLOR_LAMP_MODE]:
|
|
47
|
+
JdSmartDeviceOrder.COLOR_LAMP_MODE_CW,
|
|
48
|
+
// 色温,最大值255
|
|
49
|
+
[JdSmartDeviceOrder.COLOR_LAMP_CW_VALUE]: status.color
|
|
50
|
+
? Math.floor((status.color / 100) * 255) + ''
|
|
51
|
+
: '0',
|
|
52
|
+
// 亮度,最大值255
|
|
53
|
+
[JdSmartDeviceOrder.COLOR_LAMP_CW_BRIGHT]: status.bright
|
|
54
|
+
? Math.floor((status.bright / 100) * 255) + ''
|
|
55
|
+
: '0',
|
|
56
|
+
}),
|
|
57
|
+
};
|
|
58
|
+
} else {
|
|
59
|
+
// statusOrOrder is order
|
|
60
|
+
const order = statusOrOrder;
|
|
61
|
+
// convertTo status
|
|
62
|
+
if (order.order === JdSmartDeviceOrder.OFF) {
|
|
63
|
+
// 关
|
|
64
|
+
return {
|
|
65
|
+
power: 0,
|
|
66
|
+
};
|
|
67
|
+
} else if (order.order === JdSmartDeviceOrder.ON) {
|
|
68
|
+
// 开
|
|
69
|
+
return {
|
|
70
|
+
power: 1,
|
|
71
|
+
};
|
|
72
|
+
} else if (order.order === JdSmartDeviceOrder.SET) {
|
|
73
|
+
if (order.value1 === JdSmartDeviceOrder.COLOR_LAMP_MODE_CW) {
|
|
74
|
+
// 色温,亮度
|
|
75
|
+
return {
|
|
76
|
+
power: 1,
|
|
77
|
+
color: Math.floor((parseInt(order.value2, 10) * 100) / 255),
|
|
78
|
+
bright: Math.floor((parseInt(order.value3, 10) * 100) / 255),
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
return {};
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
export const convertCurtainNoPositionCmdOrStatus = ({
|
|
88
|
+
statusOrOrder,
|
|
89
|
+
isStatus,
|
|
90
|
+
}) => {
|
|
91
|
+
if (isStatus) {
|
|
92
|
+
const status = statusOrOrder || {
|
|
93
|
+
power: 0,
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
// convertTo cmdStatus
|
|
97
|
+
return {
|
|
98
|
+
order: JdSmartDeviceOrder.CLOSE,
|
|
99
|
+
value1: status.power === 1 ? '0' : '-1',
|
|
100
|
+
};
|
|
101
|
+
} else {
|
|
102
|
+
// statusOrOrder is order
|
|
103
|
+
const order = statusOrOrder;
|
|
104
|
+
// convertTo status
|
|
105
|
+
if (order.order === JdSmartDeviceOrder.CLOSE) {
|
|
106
|
+
// 关
|
|
107
|
+
return {
|
|
108
|
+
power: 0,
|
|
109
|
+
};
|
|
110
|
+
} else if (order.order === JdSmartDeviceOrder.OPEN) {
|
|
111
|
+
// 开
|
|
112
|
+
return {
|
|
113
|
+
power: 1,
|
|
114
|
+
};
|
|
115
|
+
} else if (order.order === JdSmartDeviceOrder.STOP) {
|
|
116
|
+
// 停
|
|
117
|
+
return {
|
|
118
|
+
power: 1502,
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
return {};
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
export const convertIrConditionCmdOrStatus = ({statusOrOrder, isStatus}) => {
|
|
126
|
+
let modeMap = {
|
|
127
|
+
0: JdSmartDeviceOrder.AIRCONDITION_MODE_COOL,
|
|
128
|
+
1: JdSmartDeviceOrder.AIRCONDITION_MODE_HEAT,
|
|
129
|
+
2: JdSmartDeviceOrder.AIRCONDITION_MODE_AUTO,
|
|
130
|
+
3: JdSmartDeviceOrder.AIRCONDITION_MODE_WIND,
|
|
131
|
+
4: JdSmartDeviceOrder.AIRCONDITION_MODE_DEHUMIDIFY,
|
|
132
|
+
};
|
|
133
|
+
let dirMap = {
|
|
134
|
+
2: JdSmartDeviceOrder.AIRCONDITION_WIND_DIRECTION__UP_DOWN,
|
|
135
|
+
4: JdSmartDeviceOrder.AIRCONDITION_WIND_DIRECTION_NO_DIRECTION,
|
|
136
|
+
};
|
|
137
|
+
let speedMap = {
|
|
138
|
+
1: JdSmartDeviceOrder.AIRCONDITION_WIND_RATE_LOW,
|
|
139
|
+
2: JdSmartDeviceOrder.AIRCONDITION_WIND_RATE_MIDDLE,
|
|
140
|
+
3: JdSmartDeviceOrder.AIRCONDITION_WIND_RATE_HIGH,
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
if (isStatus) {
|
|
144
|
+
const status = statusOrOrder || {
|
|
145
|
+
power: 0,
|
|
146
|
+
temp: 26,
|
|
147
|
+
mode: 0,
|
|
148
|
+
dir: 4,
|
|
149
|
+
speed: 2,
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
// convertTo cmdStatus
|
|
153
|
+
return {
|
|
154
|
+
order: JdSmartDeviceOrder.CLOSE,
|
|
155
|
+
value1: status.power === 1 ? '0' : '-1',
|
|
156
|
+
groupData: JSON.stringify({
|
|
157
|
+
// 温度
|
|
158
|
+
[JdSmartDeviceOrder.TEMPERATURE]: status.temp + '',
|
|
159
|
+
// 模式
|
|
160
|
+
[JdSmartDeviceOrder.AIRCONDITION_MODE_TYPE]: modeMap[status.mode],
|
|
161
|
+
// 风速
|
|
162
|
+
[JdSmartDeviceOrder.AIRCONDITION_WIND_RATE_TYPE]:
|
|
163
|
+
speedMap[status.speed],
|
|
164
|
+
// 风向
|
|
165
|
+
[JdSmartDeviceOrder.AIRCONDITION_WIND_DIRECTION_TYPE]:
|
|
166
|
+
dirMap[status.dir],
|
|
167
|
+
}),
|
|
168
|
+
};
|
|
169
|
+
} else {
|
|
170
|
+
// statusOrOrder is order
|
|
171
|
+
const order = statusOrOrder;
|
|
172
|
+
// convertTo status
|
|
173
|
+
if (order.order === JdSmartDeviceOrder.CLOSE) {
|
|
174
|
+
// 关
|
|
175
|
+
return {
|
|
176
|
+
power: 0,
|
|
177
|
+
};
|
|
178
|
+
} else if (order.order === JdSmartDeviceOrder.OPEN) {
|
|
179
|
+
// 开
|
|
180
|
+
return {
|
|
181
|
+
power: 1,
|
|
182
|
+
};
|
|
183
|
+
} else if (order.order === JdSmartDeviceOrder.MoveToLevel) {
|
|
184
|
+
// 温度
|
|
185
|
+
return {
|
|
186
|
+
power: 1,
|
|
187
|
+
temp: parseInt(order.value1, 10),
|
|
188
|
+
};
|
|
189
|
+
} else if (order.order === JdSmartDeviceOrder.SET) {
|
|
190
|
+
// 模式
|
|
191
|
+
if (order.value1 === order.AIRCONDITION_MODE_TYPE) {
|
|
192
|
+
let mode = findKeyByValue(modeMap, order.value2);
|
|
193
|
+
if (isDef(mode)) {
|
|
194
|
+
mode = parseInt(mode, 10);
|
|
195
|
+
} else {
|
|
196
|
+
mode = 0;
|
|
197
|
+
}
|
|
198
|
+
return {
|
|
199
|
+
power: 1,
|
|
200
|
+
mode,
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
// 风向
|
|
205
|
+
if (order.value1 === order.AIRCONDITION_WIND_DIRECTION_TYPE) {
|
|
206
|
+
let dir = findKeyByValue(dirMap, order.value2);
|
|
207
|
+
if (isDef(dir)) {
|
|
208
|
+
dir = parseInt(dir, 10);
|
|
209
|
+
} else {
|
|
210
|
+
dir = 4;
|
|
211
|
+
}
|
|
212
|
+
return {
|
|
213
|
+
power: 1,
|
|
214
|
+
dir,
|
|
215
|
+
};
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
// 风速
|
|
219
|
+
if (order.value1 === order.AIRCONDITION_WIND_RATE_TYPE) {
|
|
220
|
+
let speed = findKeyByValue(speedMap, order.value2);
|
|
221
|
+
if (isDef(speed)) {
|
|
222
|
+
speed = parseInt(speed, 10);
|
|
223
|
+
} else {
|
|
224
|
+
speed = 2;
|
|
225
|
+
}
|
|
226
|
+
return {
|
|
227
|
+
power: 1,
|
|
228
|
+
speed,
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
return {};
|
|
234
|
+
}
|
|
235
|
+
};
|
|
236
|
+
|
|
237
|
+
function findKeyByValue(obj, value) {
|
|
238
|
+
let key;
|
|
239
|
+
Object.entries(obj).forEach(([k, v]) => {
|
|
240
|
+
if (v === value) {
|
|
241
|
+
key = k;
|
|
242
|
+
}
|
|
243
|
+
});
|
|
244
|
+
|
|
245
|
+
return key;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
function isDef(v) {
|
|
249
|
+
return typeof v !== 'undefined';
|
|
250
|
+
}
|
|
@@ -0,0 +1,339 @@
|
|
|
1
|
+
import {NativeModules} from 'react-native';
|
|
2
|
+
import {throttle} from 'lodash';
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
getAddrInfo,
|
|
6
|
+
getSceneModes,
|
|
7
|
+
taskNotify,
|
|
8
|
+
sceneNotify,
|
|
9
|
+
getDeviceStatusReportHistory,
|
|
10
|
+
} from '../../api';
|
|
11
|
+
import storage from '../../storage';
|
|
12
|
+
|
|
13
|
+
import {convert} from './convert';
|
|
14
|
+
|
|
15
|
+
let ipanelDevices = [];
|
|
16
|
+
let sbkDevices = [];
|
|
17
|
+
|
|
18
|
+
let ipanelScenes = [];
|
|
19
|
+
|
|
20
|
+
// device_id -> status
|
|
21
|
+
let ipanelStatusMap = {};
|
|
22
|
+
|
|
23
|
+
// 获取全部设备
|
|
24
|
+
export const processGetAllDevices = throttle(
|
|
25
|
+
async function (obj) {
|
|
26
|
+
console.log('SBK getAllDevices');
|
|
27
|
+
|
|
28
|
+
const accessToken = await storage.get('accessToken');
|
|
29
|
+
if (!accessToken) {
|
|
30
|
+
console.log('SBK getAllDevices Error: ajb-app no login');
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
const activeAddr = await storage.get('activeAddr');
|
|
34
|
+
if (!activeAddr || !activeAddr.address_id) {
|
|
35
|
+
console.log('SBK getAllDevices Error: ajb-app no active addr');
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// 加载当前家庭数据
|
|
40
|
+
const res = await getAddrInfo({
|
|
41
|
+
address_id: activeAddr.address_id,
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
ipanelDevices = [];
|
|
45
|
+
sbkDevices = [];
|
|
46
|
+
ipanelStatusMap = {};
|
|
47
|
+
|
|
48
|
+
const promises = [];
|
|
49
|
+
|
|
50
|
+
(res.result.address_list || []).forEach(address => {
|
|
51
|
+
(address.room_list || []).forEach(room => {
|
|
52
|
+
const deviceList = room.device_list || [];
|
|
53
|
+
|
|
54
|
+
if (!deviceList.find(device => device.device_type === 'itee')) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
promises.push(
|
|
59
|
+
(async function () {
|
|
60
|
+
const result = await getDeviceStatusReportHistory({
|
|
61
|
+
room_id: room.room_id,
|
|
62
|
+
limit: 1,
|
|
63
|
+
}).catch(err => {
|
|
64
|
+
console.log('getDeviceStatusReportHistory', err);
|
|
65
|
+
});
|
|
66
|
+
let lastReport;
|
|
67
|
+
if (result && result.code === 0 && result.result.history[0]) {
|
|
68
|
+
lastReport = result.result.history[0];
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
deviceList.forEach(device => {
|
|
72
|
+
let status;
|
|
73
|
+
if (
|
|
74
|
+
lastReport &&
|
|
75
|
+
lastReport.abstract_data.map[device.device_id]
|
|
76
|
+
) {
|
|
77
|
+
status = lastReport.abstract_data.map[device.device_id];
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
try {
|
|
81
|
+
const sbkDevice = convert({
|
|
82
|
+
ipanelDevice: device,
|
|
83
|
+
convertType: 'device',
|
|
84
|
+
room,
|
|
85
|
+
status,
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
if (sbkDevice) {
|
|
89
|
+
ipanelDevices.push(device);
|
|
90
|
+
sbkDevices.push(sbkDevice);
|
|
91
|
+
ipanelStatusMap[device.device_id] = status;
|
|
92
|
+
}
|
|
93
|
+
} catch (e) {
|
|
94
|
+
console.log(device.device_name, e);
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
})(),
|
|
98
|
+
);
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
await Promise.all(promises);
|
|
103
|
+
|
|
104
|
+
const data = {
|
|
105
|
+
vendor: 'ipanel',
|
|
106
|
+
devices: sbkDevices,
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
console.log('SBK sbkDevices:', sbkDevices);
|
|
110
|
+
|
|
111
|
+
NativeModules?.SBKModule?.setAllDevices(JSON.stringify(data));
|
|
112
|
+
},
|
|
113
|
+
10000,
|
|
114
|
+
{
|
|
115
|
+
trailing: false,
|
|
116
|
+
},
|
|
117
|
+
);
|
|
118
|
+
|
|
119
|
+
// 控制设备
|
|
120
|
+
export const processControlDevice = async (obj, callback) => {
|
|
121
|
+
console.log('SBK controlDevice=', obj.data);
|
|
122
|
+
|
|
123
|
+
const order = JSON.parse(obj.data);
|
|
124
|
+
|
|
125
|
+
const targetDevice = sbkDevices.find(
|
|
126
|
+
device => device.deviceId === order.deviceId,
|
|
127
|
+
);
|
|
128
|
+
|
|
129
|
+
if (!targetDevice) {
|
|
130
|
+
console.log(
|
|
131
|
+
"SBK controlDevice Error, can't find device, deviceId=",
|
|
132
|
+
order.deviceId,
|
|
133
|
+
);
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
console.log(targetDevice);
|
|
138
|
+
|
|
139
|
+
const targetIpanelDevice = ipanelDevices.find(
|
|
140
|
+
device => device.device_id === targetDevice.deviceId,
|
|
141
|
+
);
|
|
142
|
+
if (!targetIpanelDevice) {
|
|
143
|
+
console.log(
|
|
144
|
+
"SBK controlDevice Error, can't find ipanel_device, deviceId=",
|
|
145
|
+
order.deviceId,
|
|
146
|
+
);
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
let changedStatus = convert({
|
|
151
|
+
ipanelDevice: targetIpanelDevice,
|
|
152
|
+
convertType: 'cmdOrStatus',
|
|
153
|
+
order,
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
if (!changedStatus) {
|
|
157
|
+
console.log(
|
|
158
|
+
'SBK controlDevice Error, convert status failed. deviceId=',
|
|
159
|
+
order.deviceId,
|
|
160
|
+
);
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
const status = {
|
|
165
|
+
...ipanelStatusMap[targetIpanelDevice.device_id],
|
|
166
|
+
...changedStatus,
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
const params = {
|
|
170
|
+
room_id: targetDevice._room_id,
|
|
171
|
+
data: {
|
|
172
|
+
[targetIpanelDevice.extend.id]: status,
|
|
173
|
+
},
|
|
174
|
+
trigger: {
|
|
175
|
+
immediate: 1,
|
|
176
|
+
},
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
const res = await taskNotify(params).catch(err => {
|
|
180
|
+
console.log('err', err);
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
console.log('taskNotify res:', res);
|
|
184
|
+
|
|
185
|
+
if (res && res.code === 0) {
|
|
186
|
+
const sbkDevice = convert({
|
|
187
|
+
ipanelDevice: targetIpanelDevice,
|
|
188
|
+
convertType: 'device',
|
|
189
|
+
room: {
|
|
190
|
+
room_id: targetDevice._room_id,
|
|
191
|
+
room_name: targetDevice._room_name,
|
|
192
|
+
},
|
|
193
|
+
status,
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
NativeModules?.SBKModule?.controlDeviceResult(true, 'success');
|
|
197
|
+
NativeModules?.SBKModule?.changeDeviceStatus(JSON.stringify(sbkDevice));
|
|
198
|
+
} else {
|
|
199
|
+
// 还原
|
|
200
|
+
NativeModules?.SBKModule?.controlDeviceResult(false, 'fail');
|
|
201
|
+
NativeModules?.SBKModule?.changeDeviceStatus(JSON.stringify(targetDevice));
|
|
202
|
+
}
|
|
203
|
+
};
|
|
204
|
+
|
|
205
|
+
// 获取全部场景
|
|
206
|
+
export const processGetScenes = throttle(
|
|
207
|
+
async obj => {
|
|
208
|
+
console.log('SBK getScenes');
|
|
209
|
+
const accessToken = await storage.get('accessToken');
|
|
210
|
+
if (!accessToken) {
|
|
211
|
+
console.log('SBK getScenes Error: ajb-app no login');
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
const activeAddr = await storage.get('activeAddr');
|
|
216
|
+
if (!activeAddr || !activeAddr.address_id) {
|
|
217
|
+
console.log('SBK getAllDevices Error: ajb-app no active addr');
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
// 加载当前家庭数据
|
|
222
|
+
const res = await getAddrInfo({
|
|
223
|
+
address_id: activeAddr.address_id,
|
|
224
|
+
});
|
|
225
|
+
|
|
226
|
+
const promises = [];
|
|
227
|
+
const promiseRooms = [];
|
|
228
|
+
(res.result.address_list || []).forEach(address => {
|
|
229
|
+
const roomList = (address.room_list || []).filter(room => {
|
|
230
|
+
return !!(room.device_list || []).find(
|
|
231
|
+
device => device.device_type === 'itee',
|
|
232
|
+
);
|
|
233
|
+
});
|
|
234
|
+
|
|
235
|
+
roomList.forEach(room => {
|
|
236
|
+
promises.push(
|
|
237
|
+
getSceneModes({
|
|
238
|
+
room_id: room.room_id,
|
|
239
|
+
userbins_id: 1,
|
|
240
|
+
}).catch(err => {
|
|
241
|
+
console.log('SBK getSceneModes ERROR, room_id=', room.room_id, err);
|
|
242
|
+
}),
|
|
243
|
+
);
|
|
244
|
+
|
|
245
|
+
promiseRooms.push(room);
|
|
246
|
+
});
|
|
247
|
+
});
|
|
248
|
+
|
|
249
|
+
ipanelScenes = [];
|
|
250
|
+
|
|
251
|
+
const results = await Promise.all(promises);
|
|
252
|
+
|
|
253
|
+
console.log(
|
|
254
|
+
'roomNames:',
|
|
255
|
+
promiseRooms.map(room => room.room_name),
|
|
256
|
+
);
|
|
257
|
+
|
|
258
|
+
results.forEach((result, index) => {
|
|
259
|
+
if (result && result.code === 0) {
|
|
260
|
+
const scenelist = result.result.map(scene => {
|
|
261
|
+
return {
|
|
262
|
+
...scene,
|
|
263
|
+
room_name: promiseRooms[index].room_name,
|
|
264
|
+
room_id: promiseRooms[index].room_id,
|
|
265
|
+
};
|
|
266
|
+
});
|
|
267
|
+
ipanelScenes.push(...scenelist);
|
|
268
|
+
}
|
|
269
|
+
});
|
|
270
|
+
|
|
271
|
+
console.log(
|
|
272
|
+
'SBK ipanelScenes:',
|
|
273
|
+
ipanelScenes.map(scene => scene.room_name + '-' + scene.name),
|
|
274
|
+
);
|
|
275
|
+
|
|
276
|
+
NativeModules?.SBKModule?.setAllScenes(
|
|
277
|
+
JSON.stringify({
|
|
278
|
+
vendor: 'ipanel',
|
|
279
|
+
scenes: ipanelScenes.map((scene, index) => {
|
|
280
|
+
return {
|
|
281
|
+
sceneId: scene.room_id + '_' + scene.id,
|
|
282
|
+
sceneName: scene.name + '|' + scene.room_name,
|
|
283
|
+
sceneNo: index + '',
|
|
284
|
+
groupId: '',
|
|
285
|
+
roomId: scene.room_name,
|
|
286
|
+
pic: '',
|
|
287
|
+
vendor: 'ipanel',
|
|
288
|
+
extension: '',
|
|
289
|
+
internalExtension: '',
|
|
290
|
+
bindKey: index,
|
|
291
|
+
nicknameList: [scene.name],
|
|
292
|
+
voiceTTS: scene.name,
|
|
293
|
+
localMusicPath: '',
|
|
294
|
+
isNormal: false,
|
|
295
|
+
voiceEnable: true,
|
|
296
|
+
};
|
|
297
|
+
}),
|
|
298
|
+
}),
|
|
299
|
+
);
|
|
300
|
+
},
|
|
301
|
+
10000,
|
|
302
|
+
{
|
|
303
|
+
trailing: false,
|
|
304
|
+
},
|
|
305
|
+
);
|
|
306
|
+
|
|
307
|
+
// 控制场景
|
|
308
|
+
export const processControlScene = async obj => {
|
|
309
|
+
console.log('SBK controlScene=', obj.data);
|
|
310
|
+
|
|
311
|
+
const data = JSON.parse(obj.data);
|
|
312
|
+
|
|
313
|
+
const targetScene = ipanelScenes.find(
|
|
314
|
+
scene => scene.room_id + '_' + scene.id === data.sceneId,
|
|
315
|
+
);
|
|
316
|
+
|
|
317
|
+
if (!targetScene) {
|
|
318
|
+
console.log(
|
|
319
|
+
"SBK controlScene Error, can't find scene, sceneId=",
|
|
320
|
+
data.sceneId,
|
|
321
|
+
);
|
|
322
|
+
return;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
const res = await sceneNotify({
|
|
326
|
+
room_id: targetScene.room_id,
|
|
327
|
+
scene_id: targetScene.id,
|
|
328
|
+
}).catch(err => {
|
|
329
|
+
console.log(err);
|
|
330
|
+
});
|
|
331
|
+
|
|
332
|
+
console.log('sceneNotify res:', res);
|
|
333
|
+
|
|
334
|
+
if (res && res.code === 0) {
|
|
335
|
+
NativeModules?.SBKModule?.controlSceneResult(true, 'success');
|
|
336
|
+
} else {
|
|
337
|
+
NativeModules?.SBKModule?.controlSceneResult(false, 'fail');
|
|
338
|
+
}
|
|
339
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Platform,
|
|
3
|
+
DeviceEventEmitter,
|
|
4
|
+
NativeEventEmitter,
|
|
5
|
+
NativeModules,
|
|
6
|
+
} from 'react-native';
|
|
7
|
+
|
|
8
|
+
import {
|
|
9
|
+
processGetAllDevices,
|
|
10
|
+
processGetScenes,
|
|
11
|
+
processControlDevice,
|
|
12
|
+
processControlScene,
|
|
13
|
+
} from './eventProcess';
|
|
14
|
+
|
|
15
|
+
// 事件监听器
|
|
16
|
+
let eventEmitter;
|
|
17
|
+
if (Platform.OS === 'android') {
|
|
18
|
+
// ----yusm:安卓使用DeviceEventEmitter
|
|
19
|
+
eventEmitter = DeviceEventEmitter;
|
|
20
|
+
|
|
21
|
+
// 声必可中控屏接入指南 - 可对接设备类型及功能
|
|
22
|
+
// http://developer.aispeaker.com/docs/DevFile/devByGateWaySDK/devices.html
|
|
23
|
+
|
|
24
|
+
/* 监听app原生层发送上来的消息 */
|
|
25
|
+
eventEmitter.addListener('getAllDevices', processGetAllDevices);
|
|
26
|
+
|
|
27
|
+
eventEmitter.addListener('getScenes', processGetScenes);
|
|
28
|
+
|
|
29
|
+
eventEmitter.addListener('controlDevice', processControlDevice);
|
|
30
|
+
|
|
31
|
+
eventEmitter.addListener('controlScene', processControlScene);
|
|
32
|
+
}
|