ipanel-rnapp-ajb-base 1.0.21 → 1.0.24

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.
@@ -1,4 +1,4 @@
1
- import React, {useEffect, useMemo, useState, useLayoutEffect} from 'react';
1
+ import React, { useEffect, useMemo, useState, useLayoutEffect } from "react";
2
2
  import {
3
3
  View,
4
4
  StyleSheet,
@@ -10,18 +10,20 @@ import {
10
10
  KeyboardAvoidingView,
11
11
  Keyboard,
12
12
  NativeModules,
13
- } from 'react-native';
14
- import {Divider, Icon, Input, Slider, Text} from '@rneui/themed';
15
- import {launchImageLibrary} from 'react-native-image-picker';
16
- import useKeyboard from '../../../hooks/useKeyboard';
13
+ } from "react-native";
14
+ import { Divider, Icon, Input, Slider, Text } from "@rneui/themed";
15
+ import { launchImageLibrary } from "react-native-image-picker";
16
+ import useKeyboard from "../../../hooks/useKeyboard";
17
17
 
18
- const {ScreenBackHeader} = global.base.commonComponents;
18
+ const { ScreenBackHeader } = global.base.commonComponents;
19
19
 
20
20
  const px = global.base.scaleSize;
21
21
 
22
- const appName = NativeModules?.RNToNativeEmitter?.appName || global.base?.config?.LOCALTEST_APP_NAME;
22
+ const appName =
23
+ NativeModules?.RNToNativeEmitter?.appName ||
24
+ global.base?.config?.LOCALTEST_APP_NAME;
23
25
 
24
- import {getProductAnswers} from '../../../api';
26
+ import { getProductAnswers } from "../../../api";
25
27
 
26
28
  // 设备类型对应题库
27
29
  const DEVICE_TO_QUESTION = {
@@ -42,17 +44,17 @@ const DEVICE_TO_QUESTION = {
42
44
  oximeter: 16,
43
45
  };
44
46
 
45
- export default ({route, navigation}) => {
46
- const {device_type} = route.params;
47
+ export default ({ route, navigation }) => {
48
+ const { device_type } = route.params;
47
49
  const [questionList, setQuestionList] = useState([]);
48
- const [feedbackText, setFeedbackText] = useState('');
50
+ const [feedbackText, setFeedbackText] = useState("");
49
51
  // 用于反馈的图片列表
50
52
  const [imgList, setImgList] = useState([]);
51
53
  const buttonDisabled = useMemo(() => {
52
54
  return !feedbackText;
53
55
  }, [feedbackText]);
54
56
  const [showQuestion, setShowQuestion] = useState(true);
55
- const {keyboardShow} = useKeyboard();
57
+ const { keyboardShow } = useKeyboard();
56
58
 
57
59
  useLayoutEffect(() => {
58
60
  init();
@@ -73,14 +75,14 @@ export default ({route, navigation}) => {
73
75
  // 选择相册图片
74
76
  const handleSelectPicture = async () => {
75
77
  const result = await launchImageLibrary({
76
- mediaType: 'mixed',
78
+ mediaType: "mixed",
77
79
  selectionLimit: 5,
78
80
  // includeBase64: true,
79
81
  });
80
82
  if (result.didCancel) {
81
- console.log('cancel');
83
+ console.log("cancel");
82
84
  } else if (result.errorCode) {
83
- console.log('error', result);
85
+ console.log("error", result);
84
86
  } else {
85
87
  const files = result.assets;
86
88
  setImgList([...imgList, ...files]);
@@ -91,55 +93,62 @@ export default ({route, navigation}) => {
91
93
  const submitFeedback = () => {
92
94
  const formData = new FormData();
93
95
  formData.append(
94
- 'productId',
95
- route.params.questionId || DEVICE_TO_QUESTION[device_type] + '',
96
+ "productId",
97
+ route.params.questionId || DEVICE_TO_QUESTION[device_type] + ""
96
98
  );
97
- formData.append('questionDescription', feedbackText);
98
- imgList.forEach(img => {
99
- formData.append('file', {
100
- uri: Platform.OS === 'ios' ? img.uri.replace('file://', '') : img.uri,
101
- type: 'multipart/form-data',
99
+ formData.append("questionDescription", feedbackText);
100
+ imgList.forEach((img) => {
101
+ formData.append("file", {
102
+ uri: Platform.OS === "ios" ? img.uri.replace("file://", "") : img.uri,
103
+ type: "multipart/form-data",
102
104
  name: img.fileName,
103
105
  // name: img.type,
104
106
  });
105
107
  });
106
- global.loading.showLoading('提交中...');
107
- console.log(formData, 'formData');
108
- fetch(`https://${appName === '禺乐慧家' ? 'szjtyfw.panyu.gd.cn:50443' : 'api.cloud.ipanel.cn'}/vgatehelp/ajb/problemFeedback`, {
109
- method: 'POST',
110
- headers: {
111
- 'Content-Type': 'multipart/form-data',
112
- },
113
- body: formData,
114
- })
115
- .then(res => {
108
+ global.loading.showLoading("提交中...");
109
+ console.log(formData, "formData");
110
+ fetch(
111
+ `https://${
112
+ ["禺乐慧家", "悦慧家"].includes(appName)
113
+ ? "szjtyfw.panyu.gd.cn:50443"
114
+ : "api.cloud.ipanel.cn"
115
+ }/vgatehelp/ajb/problemFeedback`,
116
+ {
117
+ method: "POST",
118
+ headers: {
119
+ "Content-Type": "multipart/form-data",
120
+ },
121
+ body: formData,
122
+ }
123
+ )
124
+ .then((res) => {
116
125
  global.loading.hideLoading();
117
126
  return res.json();
118
127
  })
119
- .then(data => {
128
+ .then((data) => {
120
129
  console.log(data);
121
130
  if (data.error_code === 0) {
122
- global.toast.showToast('提交成功');
131
+ global.toast.showToast("提交成功");
123
132
  } else {
124
- global.toast.showToast('提交失败');
133
+ global.toast.showToast("提交失败");
125
134
  }
126
135
  })
127
- .catch(err => {
136
+ .catch((err) => {
128
137
  console.log(err);
129
138
  global.loading.hideLoading();
130
- global.toast.showToast('提交失败');
139
+ global.toast.showToast("提交失败");
131
140
  });
132
141
  };
133
142
 
134
143
  // 删除图片
135
- const deleteImg = index => {
144
+ const deleteImg = (index) => {
136
145
  return setImgList([...imgList.filter((item, i) => i !== index)]);
137
146
  };
138
147
 
139
148
  return (
140
149
  <View style={styles.container}>
141
150
  <ScreenBackHeader title="帮助与反馈" backgroundColor="#fff" />
142
- <View style={{flex: 1}}>
151
+ <View style={{ flex: 1 }}>
143
152
  <ScrollView showsVerticalScrollIndicator={false}>
144
153
  <View style={styles.titleBox}>
145
154
  <Text style={styles.title}>常见问题</Text>
@@ -147,18 +156,20 @@ export default ({route, navigation}) => {
147
156
 
148
157
  <View
149
158
  style={{
150
- backgroundColor: '#fff',
151
- }}>
152
- {questionList.map(item => (
159
+ backgroundColor: "#fff",
160
+ }}
161
+ >
162
+ {questionList.map((item) => (
153
163
  <React.Fragment key={item.id}>
154
164
  <TouchableOpacity
155
165
  style={styles.cellBox}
156
166
  onPress={() =>
157
- navigation.navigate('DeviceAnswerDetailScreen', {
167
+ navigation.navigate("DeviceAnswerDetailScreen", {
158
168
  question: item.product_question_name,
159
169
  answer: item.product_question_answer,
160
170
  })
161
- }>
171
+ }
172
+ >
162
173
  <Text style={styles.cellLabel}>
163
174
  {item.product_question_name}
164
175
  </Text>
@@ -169,7 +180,7 @@ export default ({route, navigation}) => {
169
180
  {/* color="#aaa"*/}
170
181
  {/*/>*/}
171
182
  <Image
172
- source={require('../../../assets/img/link.png')}
183
+ source={require("../../../assets/img/link.png")}
173
184
  style={{
174
185
  width: px(30),
175
186
  height: px(30),
@@ -198,8 +209,8 @@ export default ({route, navigation}) => {
198
209
  borderWidth: 0,
199
210
  }}
200
211
  inputContainerStyle={{
201
- height: '100%',
202
- width: '100%',
212
+ height: "100%",
213
+ width: "100%",
203
214
  padding: 0,
204
215
  margin: 0,
205
216
  borderBottomWidth: 0,
@@ -208,9 +219,9 @@ export default ({route, navigation}) => {
208
219
  fontSize: px(44),
209
220
  paddingLeft: px(82),
210
221
  // height: px(350),
211
- justifyContent: 'flex-start',
212
- alignItems: 'flex-start',
213
- color: '#333',
222
+ justifyContent: "flex-start",
223
+ alignItems: "flex-start",
224
+ color: "#333",
214
225
  }}
215
226
  placeholder="请详细描述问题~"
216
227
  placeholderTextColor="#999"
@@ -218,37 +229,41 @@ export default ({route, navigation}) => {
218
229
  <View
219
230
  style={{
220
231
  paddingLeft: px(82),
221
- flexDirection: 'row',
222
- alignItems: 'center',
223
- position: 'absolute',
232
+ flexDirection: "row",
233
+ alignItems: "center",
234
+ position: "absolute",
224
235
  bottom: px(38),
225
236
  left: 0,
226
237
  right: 0,
227
- }}>
238
+ }}
239
+ >
228
240
  <TouchableOpacity
229
241
  style={styles.addImgBox}
230
- onPress={handleSelectPicture}>
242
+ onPress={handleSelectPicture}
243
+ >
231
244
  <Image
232
- source={require('../../../assets/img/add_img.png')}
245
+ source={require("../../../assets/img/add_img.png")}
233
246
  style={styles.addImg}
234
247
  />
235
248
  </TouchableOpacity>
236
249
  <View style={styles.imgList}>
237
250
  <ScrollView
238
251
  showsHorizontalScrollIndicator={true}
239
- horizontal={true}>
252
+ horizontal={true}
253
+ >
240
254
  {imgList.map((img, index) => (
241
255
  <View style={styles.imgBox} key={img.fileName}>
242
256
  <Image
243
- source={{uri: img.uri}}
257
+ source={{ uri: img.uri }}
244
258
  style={styles.imgItem}
245
259
  resizeMode="contain"
246
260
  />
247
261
  <TouchableOpacity
248
262
  style={styles.deleteImgButton}
249
- onPress={() => deleteImg(index)}>
263
+ onPress={() => deleteImg(index)}
264
+ >
250
265
  <Image
251
- source={require('../../../assets/img/delete_pic.png')}
266
+ source={require("../../../assets/img/delete_pic.png")}
252
267
  resizeMode="contain"
253
268
  style={styles.deleteImg}
254
269
  />
@@ -264,10 +279,11 @@ export default ({route, navigation}) => {
264
279
  style={{
265
280
  ...styles.button,
266
281
  backgroundColor: buttonDisabled
267
- ? 'rgba(234, 96, 0, 0.3)'
268
- : 'rgba(234, 96, 0, 1)',
282
+ ? "rgba(234, 96, 0, 0.3)"
283
+ : "rgba(234, 96, 0, 1)",
269
284
  }}
270
- disabled={buttonDisabled}>
285
+ disabled={buttonDisabled}
286
+ >
271
287
  <Text style={styles.buttonText}>提交反馈</Text>
272
288
  </TouchableOpacity>
273
289
  </ScrollView>
@@ -279,7 +295,7 @@ export default ({route, navigation}) => {
279
295
  const styles = StyleSheet.create({
280
296
  container: {
281
297
  flex: 1,
282
- backgroundColor: '#eee',
298
+ backgroundColor: "#eee",
283
299
  },
284
300
  titleBox: {
285
301
  paddingTop: px(25),
@@ -288,32 +304,32 @@ const styles = StyleSheet.create({
288
304
  },
289
305
  title: {
290
306
  fontSize: px(38),
291
- color: '#333',
292
- fontWeight: '400',
307
+ color: "#333",
308
+ fontWeight: "400",
293
309
  },
294
310
 
295
311
  cellBox: {
296
312
  paddingVertical: px(30),
297
313
  minHeight: px(150),
298
- flexDirection: 'row',
299
- justifyContent: 'space-between',
300
- alignItems: 'center',
314
+ flexDirection: "row",
315
+ justifyContent: "space-between",
316
+ alignItems: "center",
301
317
  paddingLeft: px(38),
302
318
  paddingRight: px(44),
303
319
  },
304
320
 
305
321
  cellLabel: {
306
322
  fontSize: px(49),
307
- color: '#333',
308
- fontWeight: '400',
323
+ color: "#333",
324
+ fontWeight: "400",
309
325
  marginRight: px(50),
310
326
  flex: 1,
311
327
  },
312
328
 
313
329
  feedbackBox: {
314
- backgroundColor: '#fff',
330
+ backgroundColor: "#fff",
315
331
  height: px(555),
316
- position: 'relative',
332
+ position: "relative",
317
333
  },
318
334
 
319
335
  addImgBox: {
@@ -326,16 +342,16 @@ const styles = StyleSheet.create({
326
342
 
327
343
  // 反馈图片列表
328
344
  imgList: {
329
- flexDirection: 'row',
330
- alignItems: 'center',
345
+ flexDirection: "row",
346
+ alignItems: "center",
331
347
  },
332
348
  imgBox: {
333
349
  marginLeft: px(38),
334
350
  width: px(148 + 11),
335
351
  height: px(148 + 11),
336
- justifyContent: 'center',
337
- alignItems: 'center',
338
- position: 'relative',
352
+ justifyContent: "center",
353
+ alignItems: "center",
354
+ position: "relative",
339
355
  },
340
356
  imgItem: {
341
357
  width: px(148),
@@ -343,7 +359,7 @@ const styles = StyleSheet.create({
343
359
  borderRadius: px(16),
344
360
  },
345
361
  deleteImgButton: {
346
- position: 'absolute',
362
+ position: "absolute",
347
363
  right: px(0),
348
364
  top: px(0),
349
365
  },
@@ -355,14 +371,14 @@ const styles = StyleSheet.create({
355
371
  button: {
356
372
  marginHorizontal: px(82),
357
373
  marginVertical: px(115),
358
- backgroundColor: '#EA6000',
374
+ backgroundColor: "#EA6000",
359
375
  paddingVertical: px(33),
360
376
  borderRadius: px(69),
361
377
  },
362
378
  buttonText: {
363
379
  fontSize: px(49),
364
- color: '#fff',
365
- textAlign: 'center',
366
- fontWeight: '500',
380
+ color: "#fff",
381
+ textAlign: "center",
382
+ fontWeight: "500",
367
383
  },
368
384
  });