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,834 @@
|
|
|
1
|
+
import React, { useState, useEffect } from "react";
|
|
2
|
+
import { View, Text, StyleSheet, Alert, ScrollView } from "react-native";
|
|
3
|
+
import ActionSheet, { SheetManager } from "react-native-actions-sheet";
|
|
4
|
+
import { Icon, Button } from "@rneui/themed";
|
|
5
|
+
import { Cell, Picker } from "../../index";
|
|
6
|
+
import {
|
|
7
|
+
adjustDevice,
|
|
8
|
+
moveDevice,
|
|
9
|
+
getRoomDeviceStatuses,
|
|
10
|
+
taskNotify,
|
|
11
|
+
} from "../../../api";
|
|
12
|
+
|
|
13
|
+
const { storage, navigate } = global.base;
|
|
14
|
+
|
|
15
|
+
const switchUsages = [
|
|
16
|
+
{
|
|
17
|
+
name: "控制灯",
|
|
18
|
+
value: "IGOT_LIGHT",
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
name: "控制排气风扇",
|
|
22
|
+
value: "IGOT_FAN",
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
name: "默认",
|
|
26
|
+
value: "",
|
|
27
|
+
},
|
|
28
|
+
];
|
|
29
|
+
|
|
30
|
+
const lightUsages = [
|
|
31
|
+
{
|
|
32
|
+
name: "吊灯",
|
|
33
|
+
value: "PENDENT_LAMP",
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
name: "吸顶灯",
|
|
37
|
+
value: "CEILING_LIGHT",
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
name: "筒灯",
|
|
41
|
+
value: "DOWN_LIGHT",
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
name: "灯带",
|
|
45
|
+
value: "LIGHT_BELT",
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
name: "床头灯",
|
|
49
|
+
value: "BEDSIDE_LAMP",
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
name: "镜前灯",
|
|
53
|
+
value: "MIRROR_LIGHT",
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
name: "过道灯",
|
|
57
|
+
value: "CORRIDOR_LAMP",
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
name: "玄关灯",
|
|
61
|
+
value: "PORCH_LIGHT",
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
name: "台灯",
|
|
65
|
+
value: "DESK_LAMP",
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
name: "壁灯",
|
|
69
|
+
value: "WALL_LAMP",
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
name: "餐厅灯",
|
|
73
|
+
value: "RESTAURANT_LIGHT",
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
name: "浴室灯",
|
|
77
|
+
value: "BATHROOM_LIGHT",
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
name: "厨房灯",
|
|
81
|
+
value: "KITCHEN_LIGHT",
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
name: "默认",
|
|
85
|
+
value: "",
|
|
86
|
+
},
|
|
87
|
+
];
|
|
88
|
+
|
|
89
|
+
// 公共设备类型,只能添加到“储物间”(room_type === "STORAGEROOM")
|
|
90
|
+
const publicDeviceTypes = ["scale", "hematometer"];
|
|
91
|
+
|
|
92
|
+
// 跳转到设备功能页前需要初始化该参数对象,并传递过去
|
|
93
|
+
let currentPageOptions = {};
|
|
94
|
+
|
|
95
|
+
function isStorageRoom(room) {
|
|
96
|
+
return room.room_type === "STORAGEROOM";
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
function iteeConfigureNetwork(barcode) {
|
|
100
|
+
const screen = "Itee";
|
|
101
|
+
|
|
102
|
+
navigate(screen, currentPageOptions);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
function iteeStudyMode() {
|
|
106
|
+
const screen = "IteeStudy"; // todo 填写实际的screen name
|
|
107
|
+
|
|
108
|
+
currentPageOptions.itee_id = currentPageOptions.device_id;
|
|
109
|
+
navigate(screen, currentPageOptions);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function wxdLightReset() {
|
|
113
|
+
const screen = "WuXianDao";
|
|
114
|
+
|
|
115
|
+
currentPageOptions.reset = 1;
|
|
116
|
+
navigate(screen, currentPageOptions);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
function wxdLightRepair() {
|
|
120
|
+
const screen = "WuXianDao";
|
|
121
|
+
|
|
122
|
+
navigate(screen, currentPageOptions);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
function supportSub1gGroup(device_type, brand, model, emit) {
|
|
126
|
+
if (emit !== "sub1g") {
|
|
127
|
+
return false;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
if (device_type === "igot" && brand === "kingserry" && model === "IGRL0012") {
|
|
131
|
+
return true;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
return false;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
function supportBleGroup(device_type, brand, model, emit) {
|
|
138
|
+
if (emit !== "blebc") {
|
|
139
|
+
return false;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
if (device_type === "light" && brand === "YHWL") {
|
|
143
|
+
return true;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
return false;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
function supportCodeGroup(device_type, brand, model, emit) {
|
|
150
|
+
return (
|
|
151
|
+
supportSub1gGroup(device_type, brand, model, emit) ||
|
|
152
|
+
supportBleGroup(device_type, brand, model, emit)
|
|
153
|
+
);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
function isDef(val) {
|
|
157
|
+
return typeof val !== "undefined";
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
function getDeviceStatusStructure(deviceStatusStructures, device) {
|
|
161
|
+
for (let i = 0; i < deviceStatusStructures.length; i++) {
|
|
162
|
+
const item = deviceStatusStructures[i];
|
|
163
|
+
|
|
164
|
+
for (let j = 0; j < item.match.length; j++) {
|
|
165
|
+
const matchItem = item.match[j];
|
|
166
|
+
|
|
167
|
+
let isMatch = true;
|
|
168
|
+
const device_type_CompareFlag = isDef(matchItem.device_type);
|
|
169
|
+
const extend_brand_CompareFlag =
|
|
170
|
+
matchItem.extend && isDef(matchItem.extend.brand);
|
|
171
|
+
const extend_model_CompareFlag =
|
|
172
|
+
matchItem.extend && isDef(matchItem.extend.model);
|
|
173
|
+
const extend_device_type_CompareFlag =
|
|
174
|
+
matchItem.extend && isDef(matchItem.extend.device_type);
|
|
175
|
+
|
|
176
|
+
if (
|
|
177
|
+
(device_type_CompareFlag &&
|
|
178
|
+
matchItem.device_type !== device.device_type) ||
|
|
179
|
+
(extend_brand_CompareFlag &&
|
|
180
|
+
matchItem.extend.brand !== device.extend.brand) ||
|
|
181
|
+
(extend_model_CompareFlag &&
|
|
182
|
+
matchItem.extend.model !== device.extend.model) ||
|
|
183
|
+
(extend_device_type_CompareFlag &&
|
|
184
|
+
matchItem.extend.device_type !== device.extend.device_type)
|
|
185
|
+
) {
|
|
186
|
+
isMatch = false;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
if (isMatch) {
|
|
190
|
+
return item.structure;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
const DeviceActionSheet = ({ sheetId, payload }) => {
|
|
197
|
+
let title = "设备信息";
|
|
198
|
+
const submitBtnText = "保存";
|
|
199
|
+
|
|
200
|
+
const curDevice = payload.device;
|
|
201
|
+
// console.log(curDevice);
|
|
202
|
+
|
|
203
|
+
// 设备类型
|
|
204
|
+
const targetDeviceType = payload.deviceTypeList.find(
|
|
205
|
+
(item) => item.class === curDevice.device_type
|
|
206
|
+
);
|
|
207
|
+
const curDeviceType = targetDeviceType.class;
|
|
208
|
+
const deviceTypeName = targetDeviceType.title;
|
|
209
|
+
|
|
210
|
+
const statusStructure = getDeviceStatusStructure(
|
|
211
|
+
payload.deviceStatusStructures,
|
|
212
|
+
curDevice
|
|
213
|
+
);
|
|
214
|
+
const [deviceStatus, setDeviceStatus] = useState({});
|
|
215
|
+
|
|
216
|
+
const updateDeviceStatus = async (data) => {
|
|
217
|
+
console.log(data);
|
|
218
|
+
setDeviceStatus(data);
|
|
219
|
+
|
|
220
|
+
const activeAddr = await storage.get("activeAddr");
|
|
221
|
+
|
|
222
|
+
const result = await taskNotify({
|
|
223
|
+
room_id: payload.room.room_id,
|
|
224
|
+
user_id: activeAddr.user_id,
|
|
225
|
+
data: {
|
|
226
|
+
[curDevice.extend.id]: data,
|
|
227
|
+
},
|
|
228
|
+
trigger: {
|
|
229
|
+
immediate: 1, // 立即执行
|
|
230
|
+
},
|
|
231
|
+
});
|
|
232
|
+
if (result && result.code === 0) {
|
|
233
|
+
global.toast.showToast("指令已发送,看看设备状态吧");
|
|
234
|
+
} else {
|
|
235
|
+
global.toast.showToast(result ? result.message : "网络异常");
|
|
236
|
+
}
|
|
237
|
+
};
|
|
238
|
+
|
|
239
|
+
useEffect(() => {
|
|
240
|
+
getRoomDeviceStatuses({
|
|
241
|
+
room_id: payload.room.room_id,
|
|
242
|
+
}).then((res) => {
|
|
243
|
+
if (res.code === 0) {
|
|
244
|
+
const status = res.result[curDevice.extend.id] || {};
|
|
245
|
+
setDeviceStatus(status);
|
|
246
|
+
}
|
|
247
|
+
});
|
|
248
|
+
}, []);
|
|
249
|
+
|
|
250
|
+
// 品牌型号
|
|
251
|
+
let brandModelText = "未知";
|
|
252
|
+
let selectedBrand = {};
|
|
253
|
+
let selectedModel = {};
|
|
254
|
+
if (curDevice.extend.brand && curDevice.extend.model) {
|
|
255
|
+
const brand = targetDeviceType.brands.find(
|
|
256
|
+
(brand) => brand.code === curDevice.extend.brand
|
|
257
|
+
);
|
|
258
|
+
if (brand) {
|
|
259
|
+
selectedBrand = brand;
|
|
260
|
+
const model = selectedBrand.models.find(
|
|
261
|
+
(model) => model.code === curDevice.extend.model
|
|
262
|
+
);
|
|
263
|
+
if (model) {
|
|
264
|
+
selectedModel = model;
|
|
265
|
+
brandModelText = `${selectedBrand.name} ${selectedModel.name}`;
|
|
266
|
+
} else {
|
|
267
|
+
brandModelText = `${selectedBrand.name} ${curDevice.extend.model}`;
|
|
268
|
+
}
|
|
269
|
+
} else {
|
|
270
|
+
brandModelText = curDevice.extend.brand;
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
let tvid = "";
|
|
275
|
+
if (curDeviceType === "tv") {
|
|
276
|
+
tvid = curDevice.device_mac;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
let barcode = "";
|
|
280
|
+
if (curDevice.extend.barcode) {
|
|
281
|
+
barcode = curDevice.extend.barcode;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
// 设备名称
|
|
285
|
+
const [deviceName, setDeviceName] = useState(curDevice.device_name);
|
|
286
|
+
|
|
287
|
+
// 开关用途
|
|
288
|
+
let defaultSwitchUsageIndex = switchUsages.findIndex(
|
|
289
|
+
(item) => item.value === (curDevice.extend.switch_usage || "")
|
|
290
|
+
);
|
|
291
|
+
let defaultSwitchUsageName = switchUsages[defaultSwitchUsageIndex]
|
|
292
|
+
? switchUsages[defaultSwitchUsageIndex].name
|
|
293
|
+
: "";
|
|
294
|
+
const [switchUsageIndex, setSwitchUsageIndex] = useState(
|
|
295
|
+
defaultSwitchUsageIndex
|
|
296
|
+
);
|
|
297
|
+
const [switchUsage, setSwitchUsage] = useState(defaultSwitchUsageName);
|
|
298
|
+
const handleShowSwitchUsagePicker = async () => {
|
|
299
|
+
const result = await SheetManager.show("action-picker", {
|
|
300
|
+
context: "global",
|
|
301
|
+
payload: {
|
|
302
|
+
title: "选择开关用途",
|
|
303
|
+
defaultIndex: switchUsageIndex,
|
|
304
|
+
columns: switchUsages,
|
|
305
|
+
nameProp: "name",
|
|
306
|
+
},
|
|
307
|
+
});
|
|
308
|
+
if (result) {
|
|
309
|
+
setSwitchUsageIndex(result.index);
|
|
310
|
+
setSwitchUsage(result.data.name);
|
|
311
|
+
}
|
|
312
|
+
};
|
|
313
|
+
|
|
314
|
+
// 灯光用途
|
|
315
|
+
let defaultLightUsageIndex = lightUsages.findIndex(
|
|
316
|
+
(item) => item.value === (curDevice.extend.light_usage || "")
|
|
317
|
+
);
|
|
318
|
+
let defaultLightUsageName = lightUsages[defaultLightUsageIndex]
|
|
319
|
+
? lightUsages[defaultLightUsageIndex].name
|
|
320
|
+
: "";
|
|
321
|
+
const [lightUsageIndex, setLightUsageIndex] = useState(
|
|
322
|
+
defaultLightUsageIndex
|
|
323
|
+
);
|
|
324
|
+
const [lightUsage, setLightUsage] = useState(defaultLightUsageName);
|
|
325
|
+
const handleShowLightUsagePicker = async () => {
|
|
326
|
+
const result = await SheetManager.show("action-picker", {
|
|
327
|
+
context: "global",
|
|
328
|
+
payload: {
|
|
329
|
+
title: "选择灯光用途",
|
|
330
|
+
defaultIndex: lightUsageIndex,
|
|
331
|
+
columns: lightUsages,
|
|
332
|
+
nameProp: "name",
|
|
333
|
+
},
|
|
334
|
+
});
|
|
335
|
+
if (result) {
|
|
336
|
+
setLightUsageIndex(result.index);
|
|
337
|
+
setLightUsage(result.data.name);
|
|
338
|
+
|
|
339
|
+
if (!deviceName) {
|
|
340
|
+
setDeviceName(result.data.name);
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
};
|
|
344
|
+
|
|
345
|
+
// 选择房间
|
|
346
|
+
let defaultRoomIndex = payload.roomList.findIndex(
|
|
347
|
+
(room) => room.room_id === payload.room.room_id
|
|
348
|
+
);
|
|
349
|
+
let defaultRoomName = payload.roomList[defaultRoomIndex]
|
|
350
|
+
? payload.roomList[defaultRoomIndex].room_name
|
|
351
|
+
: "";
|
|
352
|
+
const [roomIndex, setRoomIndex] = useState(defaultRoomIndex);
|
|
353
|
+
const [roomName, setRoomName] = useState(defaultRoomName);
|
|
354
|
+
const handleShowRoomPicker = async () => {
|
|
355
|
+
const result = await SheetManager.show("action-picker", {
|
|
356
|
+
context: "global",
|
|
357
|
+
payload: {
|
|
358
|
+
title: "选择房间",
|
|
359
|
+
defaultIndex: roomIndex,
|
|
360
|
+
columns: payload.roomList,
|
|
361
|
+
nameProp: "room_name",
|
|
362
|
+
},
|
|
363
|
+
});
|
|
364
|
+
|
|
365
|
+
if (result) {
|
|
366
|
+
if (curDeviceType) {
|
|
367
|
+
const isPickingStorageRoom = isStorageRoom(result.data);
|
|
368
|
+
if (
|
|
369
|
+
publicDeviceTypes.includes(curDeviceType) &&
|
|
370
|
+
!isPickingStorageRoom
|
|
371
|
+
) {
|
|
372
|
+
Alert.alert("公共设备不能加入储物间以外的房间");
|
|
373
|
+
return;
|
|
374
|
+
}
|
|
375
|
+
if (
|
|
376
|
+
!publicDeviceTypes.includes(curDeviceType) &&
|
|
377
|
+
isPickingStorageRoom
|
|
378
|
+
) {
|
|
379
|
+
Alert.alert("非公共设备不能加入储物间");
|
|
380
|
+
return;
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
setRoomIndex(result.index);
|
|
385
|
+
setRoomName(result.data.room_name);
|
|
386
|
+
}
|
|
387
|
+
};
|
|
388
|
+
|
|
389
|
+
const curBrand = selectedBrand.code;
|
|
390
|
+
const curModel = selectedModel.code;
|
|
391
|
+
|
|
392
|
+
// 支持根据条码生成码值的通断器
|
|
393
|
+
const hasBarcodeSwitch = (() => {
|
|
394
|
+
if (curDeviceType === "igot") {
|
|
395
|
+
if (
|
|
396
|
+
(curBrand === "kingserry" && curModel === "IGRL0012") ||
|
|
397
|
+
(curBrand === "yibailong" && curModel === "IGRL0021") ||
|
|
398
|
+
(curBrand === "shengbiao" && curModel === "IGRLN041")
|
|
399
|
+
) {
|
|
400
|
+
return true;
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
return false;
|
|
404
|
+
})();
|
|
405
|
+
// 易百珑随意贴
|
|
406
|
+
const isYblSyt = (() => {
|
|
407
|
+
if (curDeviceType === "ifree") {
|
|
408
|
+
if (curBrand === "yibailong" && curModel === "ITFKE101W") {
|
|
409
|
+
return true;
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
return false;
|
|
413
|
+
})();
|
|
414
|
+
// 当前要添加的设备是否为需要学习码值的433随意贴
|
|
415
|
+
const isSub1gLearningSuiyitieSelected = (() => {
|
|
416
|
+
if (curDeviceType === "ifree") {
|
|
417
|
+
if (
|
|
418
|
+
(curBrand === "kingserry" && curModel === "ITFBT101W") ||
|
|
419
|
+
(curBrand === "lingpu" && curModel === "ITFKR101W")
|
|
420
|
+
) {
|
|
421
|
+
return true;
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
return false;
|
|
425
|
+
})();
|
|
426
|
+
|
|
427
|
+
const hasChanged = (() => {
|
|
428
|
+
const oldSwitchUsage = curDevice.extend.switch_usage || "";
|
|
429
|
+
const oldLightUsage = curDevice.extend.light_usage || "";
|
|
430
|
+
if (
|
|
431
|
+
deviceName !== curDevice.device_name ||
|
|
432
|
+
switchUsages[switchUsageIndex].value !== oldSwitchUsage ||
|
|
433
|
+
lightUsages[lightUsageIndex].value !== oldLightUsage ||
|
|
434
|
+
payload.roomList[roomIndex].room_id !== payload.room.room_id
|
|
435
|
+
) {
|
|
436
|
+
return true;
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
return false;
|
|
440
|
+
})();
|
|
441
|
+
|
|
442
|
+
currentPageOptions = {
|
|
443
|
+
device_type: curDeviceType,
|
|
444
|
+
brand: curBrand,
|
|
445
|
+
model: curModel,
|
|
446
|
+
room_id: payload.room.room_id,
|
|
447
|
+
device_id: curDevice.device_id,
|
|
448
|
+
};
|
|
449
|
+
|
|
450
|
+
const handleThermostatControl = () => {
|
|
451
|
+
navigate("ThermostatControlScreen", {
|
|
452
|
+
room_id: currentPageOptions.room_id,
|
|
453
|
+
extend_key: curDevice.extend.id,
|
|
454
|
+
device_status: deviceStatus,
|
|
455
|
+
});
|
|
456
|
+
SheetManager.hide(sheetId);
|
|
457
|
+
};
|
|
458
|
+
|
|
459
|
+
const [isSaveBtnDisabled, setIsSaveBtnDisabled] = useState(false);
|
|
460
|
+
const handleSaveDevice = async () => {
|
|
461
|
+
if (deviceName === "") {
|
|
462
|
+
Alert.alert("请输入设备名称");
|
|
463
|
+
return;
|
|
464
|
+
}
|
|
465
|
+
if (roomName === "") {
|
|
466
|
+
Alert.alert("请选择设备位置");
|
|
467
|
+
return;
|
|
468
|
+
}
|
|
469
|
+
setIsSaveBtnDisabled(true);
|
|
470
|
+
|
|
471
|
+
let res1, res2;
|
|
472
|
+
|
|
473
|
+
const adjustParams = {};
|
|
474
|
+
|
|
475
|
+
if (deviceName !== curDevice.device_name) {
|
|
476
|
+
adjustParams.device_name = deviceName;
|
|
477
|
+
}
|
|
478
|
+
const oldSwitchUsage = curDevice.extend.switch_usage || "";
|
|
479
|
+
if (switchUsages[switchUsageIndex].value !== oldSwitchUsage) {
|
|
480
|
+
adjustParams.extend = {
|
|
481
|
+
switch_usage: switchUsages[switchUsageIndex].value,
|
|
482
|
+
};
|
|
483
|
+
}
|
|
484
|
+
const oldLightUsage = curDevice.extend.light_usage || "";
|
|
485
|
+
if (lightUsages[lightUsageIndex].value !== oldLightUsage) {
|
|
486
|
+
adjustParams.extend = {
|
|
487
|
+
light_usage: lightUsages[lightUsageIndex].value,
|
|
488
|
+
...(adjustParams.extend || {}),
|
|
489
|
+
};
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
if (Object.keys(adjustParams).length > 0) {
|
|
493
|
+
res1 = await adjustDevice({
|
|
494
|
+
room_id: payload.room.room_id,
|
|
495
|
+
device_id: curDevice.device_id,
|
|
496
|
+
...adjustParams,
|
|
497
|
+
});
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
if (payload.roomList[roomIndex].room_id !== payload.room.room_id) {
|
|
501
|
+
res2 = await moveDevice({
|
|
502
|
+
room_id: payload.room.room_id,
|
|
503
|
+
device_id: curDevice.device_id,
|
|
504
|
+
new_room_id: payload.roomList[roomIndex].room_id,
|
|
505
|
+
});
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
if ((res1 && res1.code === 0) || (res2 && res2.code === 0)) {
|
|
509
|
+
SheetManager.hide(sheetId, {
|
|
510
|
+
payload: {
|
|
511
|
+
room_id: payload.room.room_id,
|
|
512
|
+
},
|
|
513
|
+
});
|
|
514
|
+
}
|
|
515
|
+
setIsSaveBtnDisabled(false);
|
|
516
|
+
};
|
|
517
|
+
|
|
518
|
+
return (
|
|
519
|
+
<>
|
|
520
|
+
<ActionSheet id={sheetId} isModal={false} useBottomSafeAreaPadding>
|
|
521
|
+
<View style={styles.title}>
|
|
522
|
+
<Text style={styles.titleText}>{title}</Text>
|
|
523
|
+
<View style={styles.closeBtn}>
|
|
524
|
+
<Icon
|
|
525
|
+
name="close"
|
|
526
|
+
type="ionicon"
|
|
527
|
+
size={28}
|
|
528
|
+
color="#999"
|
|
529
|
+
onPress={() => {
|
|
530
|
+
SheetManager.hide(sheetId);
|
|
531
|
+
}}
|
|
532
|
+
/>
|
|
533
|
+
</View>
|
|
534
|
+
</View>
|
|
535
|
+
|
|
536
|
+
<ScrollView keyboardShouldPersistTaps="handled">
|
|
537
|
+
<View style={styles.contentBlock}>
|
|
538
|
+
<View style={styles.contentBlockHeader}>
|
|
539
|
+
<Text style={styles.contentBlockTitle}>基础信息</Text>
|
|
540
|
+
</View>
|
|
541
|
+
|
|
542
|
+
{/* 不可修改属性 */}
|
|
543
|
+
<Cell
|
|
544
|
+
style={styles.disabledCell}
|
|
545
|
+
type="text"
|
|
546
|
+
label="智能设备"
|
|
547
|
+
value={deviceTypeName}
|
|
548
|
+
/>
|
|
549
|
+
{targetDeviceType &&
|
|
550
|
+
targetDeviceType.brands &&
|
|
551
|
+
targetDeviceType.brands.length > 0 &&
|
|
552
|
+
curDeviceType !== "itee" && (
|
|
553
|
+
<Cell
|
|
554
|
+
style={styles.disabledCell}
|
|
555
|
+
type="text"
|
|
556
|
+
label="品牌型号"
|
|
557
|
+
value={brandModelText}
|
|
558
|
+
/>
|
|
559
|
+
)}
|
|
560
|
+
|
|
561
|
+
{curDeviceType === "tv" && (
|
|
562
|
+
<Cell
|
|
563
|
+
type="text"
|
|
564
|
+
label="电视ID"
|
|
565
|
+
value={tvid}
|
|
566
|
+
style={styles.disabledCell}
|
|
567
|
+
/>
|
|
568
|
+
)}
|
|
569
|
+
{(curDeviceType === "itee" || hasBarcodeSwitch || isYblSyt) && (
|
|
570
|
+
<Cell
|
|
571
|
+
type="text"
|
|
572
|
+
label="机身条码"
|
|
573
|
+
value={barcode}
|
|
574
|
+
style={styles.disabledCell}
|
|
575
|
+
/>
|
|
576
|
+
)}
|
|
577
|
+
|
|
578
|
+
{/* 可修改属性 */}
|
|
579
|
+
<Cell
|
|
580
|
+
type="input"
|
|
581
|
+
label="设备名称"
|
|
582
|
+
value={deviceName}
|
|
583
|
+
placeholder="请输入设备名称"
|
|
584
|
+
onChangeText={(text) => setDeviceName(text)}
|
|
585
|
+
/>
|
|
586
|
+
{curDeviceType === "igot" && (
|
|
587
|
+
<Cell
|
|
588
|
+
type="link"
|
|
589
|
+
label="开关用途"
|
|
590
|
+
value={switchUsage}
|
|
591
|
+
onRightPress={handleShowSwitchUsagePicker}
|
|
592
|
+
/>
|
|
593
|
+
)}
|
|
594
|
+
{((curDeviceType === "igot" &&
|
|
595
|
+
switchUsages[switchUsageIndex].value === "IGOT_LIGHT") ||
|
|
596
|
+
curDeviceType === "light") && (
|
|
597
|
+
<Cell
|
|
598
|
+
type="link"
|
|
599
|
+
label="灯光用途"
|
|
600
|
+
value={lightUsage}
|
|
601
|
+
onRightPress={handleShowLightUsagePicker}
|
|
602
|
+
/>
|
|
603
|
+
)}
|
|
604
|
+
<Cell
|
|
605
|
+
type="link"
|
|
606
|
+
label="设备位置"
|
|
607
|
+
value={roomName}
|
|
608
|
+
onRightPress={handleShowRoomPicker}
|
|
609
|
+
/>
|
|
610
|
+
|
|
611
|
+
{hasChanged && (
|
|
612
|
+
<View>
|
|
613
|
+
<Button
|
|
614
|
+
title={submitBtnText}
|
|
615
|
+
disabled={isSaveBtnDisabled}
|
|
616
|
+
size="lg"
|
|
617
|
+
onPress={handleSaveDevice}
|
|
618
|
+
/>
|
|
619
|
+
</View>
|
|
620
|
+
)}
|
|
621
|
+
</View>
|
|
622
|
+
|
|
623
|
+
{statusStructure && (
|
|
624
|
+
<View style={styles.contentBlock}>
|
|
625
|
+
<View style={styles.contentBlockHeader}>
|
|
626
|
+
<Text style={styles.contentBlockTitle}>远程控制</Text>
|
|
627
|
+
{curDeviceType === "thermostat" &&
|
|
628
|
+
Object.keys(deviceStatus).length > 0 && (
|
|
629
|
+
<Button
|
|
630
|
+
title="高级控制"
|
|
631
|
+
size="sm"
|
|
632
|
+
onPress={handleThermostatControl}
|
|
633
|
+
/>
|
|
634
|
+
)}
|
|
635
|
+
</View>
|
|
636
|
+
|
|
637
|
+
{Object.keys(deviceStatus).length === 0 && (
|
|
638
|
+
<Text style={{ textAlign: "center" }}>
|
|
639
|
+
设备状态未知,请控制一次进行状态记录
|
|
640
|
+
</Text>
|
|
641
|
+
)}
|
|
642
|
+
|
|
643
|
+
{Object.entries(statusStructure).map(
|
|
644
|
+
([statusKey, descriptor]) => {
|
|
645
|
+
switch (descriptor.type) {
|
|
646
|
+
case "switch":
|
|
647
|
+
return (
|
|
648
|
+
<Cell
|
|
649
|
+
type="switch"
|
|
650
|
+
label={descriptor.name}
|
|
651
|
+
key={statusKey}
|
|
652
|
+
value={!!deviceStatus[statusKey]}
|
|
653
|
+
onValueChange={(val) => {
|
|
654
|
+
updateDeviceStatus({
|
|
655
|
+
...deviceStatus,
|
|
656
|
+
[statusKey]: val ? 1 : 0,
|
|
657
|
+
});
|
|
658
|
+
}}
|
|
659
|
+
/>
|
|
660
|
+
);
|
|
661
|
+
case "range":
|
|
662
|
+
return deviceStatus.power ? (
|
|
663
|
+
<Cell
|
|
664
|
+
type="slider"
|
|
665
|
+
label={descriptor.name}
|
|
666
|
+
key={statusKey}
|
|
667
|
+
value={deviceStatus[statusKey]}
|
|
668
|
+
sliderOptions={{
|
|
669
|
+
min: descriptor.min,
|
|
670
|
+
max: descriptor.max,
|
|
671
|
+
onSlidingComplete: (val) => {
|
|
672
|
+
updateDeviceStatus({
|
|
673
|
+
...deviceStatus,
|
|
674
|
+
[statusKey]: val,
|
|
675
|
+
});
|
|
676
|
+
},
|
|
677
|
+
}}
|
|
678
|
+
/>
|
|
679
|
+
) : null;
|
|
680
|
+
case "enum":
|
|
681
|
+
const selectedIndex = descriptor.list.findIndex(
|
|
682
|
+
(item) => item.value === deviceStatus[statusKey]
|
|
683
|
+
);
|
|
684
|
+
return deviceStatus.power ? (
|
|
685
|
+
<Cell
|
|
686
|
+
type="enum"
|
|
687
|
+
label={descriptor.name}
|
|
688
|
+
key={statusKey}
|
|
689
|
+
value={selectedIndex}
|
|
690
|
+
enumButtons={descriptor.list.map((item) => item.name)}
|
|
691
|
+
onValueChange={(index) => {
|
|
692
|
+
updateDeviceStatus({
|
|
693
|
+
...deviceStatus,
|
|
694
|
+
[statusKey]: descriptor.list[index].value,
|
|
695
|
+
});
|
|
696
|
+
}}
|
|
697
|
+
/>
|
|
698
|
+
) : null;
|
|
699
|
+
}
|
|
700
|
+
}
|
|
701
|
+
)}
|
|
702
|
+
</View>
|
|
703
|
+
)}
|
|
704
|
+
|
|
705
|
+
{supportCodeGroup(
|
|
706
|
+
curDeviceType,
|
|
707
|
+
curBrand,
|
|
708
|
+
curModel,
|
|
709
|
+
curDevice.extend.emit
|
|
710
|
+
) && (
|
|
711
|
+
<View style={styles.contentBlock}>
|
|
712
|
+
<View style={styles.contentBlockHeader}>
|
|
713
|
+
<Text style={styles.contentBlockTitle}>控制分组</Text>
|
|
714
|
+
</View>
|
|
715
|
+
</View>
|
|
716
|
+
)}
|
|
717
|
+
|
|
718
|
+
{(curDeviceType === "itee" ||
|
|
719
|
+
(curDeviceType === "light" && curBrand === "WXD")) && (
|
|
720
|
+
<View style={styles.contentBlock}>
|
|
721
|
+
<View style={styles.contentBlockHeader}>
|
|
722
|
+
<Text style={styles.contentBlockTitle}>更多功能</Text>
|
|
723
|
+
</View>
|
|
724
|
+
|
|
725
|
+
{curDeviceType === "itee" && (
|
|
726
|
+
<>
|
|
727
|
+
<View style={styles.featureBtnGroup}>
|
|
728
|
+
<Button
|
|
729
|
+
containerStyle={styles.featureBtn}
|
|
730
|
+
title="配网"
|
|
731
|
+
size="md"
|
|
732
|
+
onPress={() => {
|
|
733
|
+
iteeConfigureNetwork();
|
|
734
|
+
SheetManager.hide(sheetId);
|
|
735
|
+
}}
|
|
736
|
+
/>
|
|
737
|
+
<Button
|
|
738
|
+
containerStyle={styles.featureBtn}
|
|
739
|
+
title="学习模式(开发测试用)"
|
|
740
|
+
size="md"
|
|
741
|
+
onPress={() => {
|
|
742
|
+
iteeStudyMode();
|
|
743
|
+
SheetManager.hide(sheetId);
|
|
744
|
+
}}
|
|
745
|
+
/>
|
|
746
|
+
</View>
|
|
747
|
+
</>
|
|
748
|
+
)}
|
|
749
|
+
|
|
750
|
+
{curDeviceType === "light" && curBrand === "WXD" && (
|
|
751
|
+
<>
|
|
752
|
+
<View style={styles.featureBtnGroup}>
|
|
753
|
+
<Button
|
|
754
|
+
containerStyle={styles.featureBtn}
|
|
755
|
+
title="恢复出厂设置"
|
|
756
|
+
size="md"
|
|
757
|
+
onPress={() => {
|
|
758
|
+
wxdLightReset();
|
|
759
|
+
SheetManager.hide(sheetId);
|
|
760
|
+
}}
|
|
761
|
+
/>
|
|
762
|
+
<Button
|
|
763
|
+
containerStyle={styles.featureBtn}
|
|
764
|
+
title="重新配对"
|
|
765
|
+
size="md"
|
|
766
|
+
onPress={() => {
|
|
767
|
+
wxdLightRepair();
|
|
768
|
+
SheetManager.hide(sheetId);
|
|
769
|
+
}}
|
|
770
|
+
/>
|
|
771
|
+
</View>
|
|
772
|
+
</>
|
|
773
|
+
)}
|
|
774
|
+
</View>
|
|
775
|
+
)}
|
|
776
|
+
</ScrollView>
|
|
777
|
+
</ActionSheet>
|
|
778
|
+
</>
|
|
779
|
+
);
|
|
780
|
+
};
|
|
781
|
+
|
|
782
|
+
const styles = StyleSheet.create({
|
|
783
|
+
title: {
|
|
784
|
+
position: "relative",
|
|
785
|
+
height: 50,
|
|
786
|
+
paddingHorizontal: 60,
|
|
787
|
+
alignItems: "center",
|
|
788
|
+
justifyContent: "center",
|
|
789
|
+
},
|
|
790
|
+
titleText: {
|
|
791
|
+
fontSize: 18,
|
|
792
|
+
color: "#333",
|
|
793
|
+
},
|
|
794
|
+
closeBtn: {
|
|
795
|
+
position: "absolute",
|
|
796
|
+
height: "100%",
|
|
797
|
+
top: 0,
|
|
798
|
+
right: 0,
|
|
799
|
+
width: 60,
|
|
800
|
+
alignItems: "center",
|
|
801
|
+
justifyContent: "center",
|
|
802
|
+
},
|
|
803
|
+
|
|
804
|
+
contentBlock: {
|
|
805
|
+
marginBottom: 20,
|
|
806
|
+
},
|
|
807
|
+
contentBlockHeader: {
|
|
808
|
+
height: 40,
|
|
809
|
+
paddingHorizontal: 10,
|
|
810
|
+
flexDirection: "row",
|
|
811
|
+
alignItems: "center",
|
|
812
|
+
justifyContent: "space-between",
|
|
813
|
+
borderBottomWidth: 1,
|
|
814
|
+
borderBottomColor: "#eee",
|
|
815
|
+
marginBottom: 3,
|
|
816
|
+
},
|
|
817
|
+
contentBlockTitle: {
|
|
818
|
+
fontSize: 18,
|
|
819
|
+
fontWeight: "bold",
|
|
820
|
+
color: "#999",
|
|
821
|
+
},
|
|
822
|
+
disabledCell: {
|
|
823
|
+
backgroundColor: "#eee",
|
|
824
|
+
},
|
|
825
|
+
featureBtnGroup: {
|
|
826
|
+
flexDirection: "row",
|
|
827
|
+
marginTop: 10,
|
|
828
|
+
},
|
|
829
|
+
featureBtn: {
|
|
830
|
+
marginHorizontal: 10,
|
|
831
|
+
},
|
|
832
|
+
});
|
|
833
|
+
|
|
834
|
+
export default DeviceActionSheet;
|