ReportBusinessScreen.jsx 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. import * as WebBrowser from 'expo-web-browser';
  2. import * as React from 'react';
  3. import {
  4. Div,
  5. Button,
  6. Image,
  7. Text,
  8. Avatar,
  9. Radio,
  10. RadioGroup,
  11. } from 'react-native-magnus';
  12. import { TextareaItem } from '@ant-design/react-native';
  13. import { ScrollView } from 'react-native-gesture-handler';
  14. import { useCreation } from '@umijs/hooks';
  15. import useModel from 'flooks';
  16. import User from '../../flooks/User'; // detail模块通用方法
  17. import DetailModel from './model'; // detail模块通用方法
  18. import Order from '../Order/model';
  19. import Header from '../../components/Header';
  20. import ImagePicker from '../../components/ImagePicker';
  21. const reasomsMap = new Map([
  22. [
  23. '商家资质问题(缺少相关从业资质)',
  24. { name: '商家资质问题(缺少相关从业资质)' },
  25. ],
  26. [
  27. '商家价格问题(价格虚高恶意设置高满减)',
  28. { name: '商家价格问题(价格虚高恶意设置高满减)' },
  29. ],
  30. ['商家品类问题(品类设置不符)', { name: '商家品类问题(品类设置不符)' }],
  31. ['商家logo问题(涉及侵权)', { name: '商家logo问题(涉及侵权)' }],
  32. [
  33. '商家配送问题(起送价、餐盒费设置过高)',
  34. { name: '商家配送问题(起送价、餐盒费设置过高)' },
  35. ],
  36. ['其它问题', { name: '其它问题' }],
  37. ]);
  38. export default function ReportBusinessScreen({ navigation }) {
  39. const { merchantInfo, complaintSave } = useModel(DetailModel, [
  40. 'merchantInfo',
  41. ]);
  42. const { id } = useModel(User, ['id']);
  43. const { logo, showName, mid } = merchantInfo;
  44. const [type, settype] = React.useState('商家资质问题(缺少相关从业资质)');
  45. const [imgList, setimgList] = React.useState(['']);
  46. const [content, setcontent] = React.useState('');
  47. function changeImg(img, index) {
  48. const list = [...imgList];
  49. if (!img) {
  50. list.splice(index, 1);
  51. } else {
  52. list.splice(index, 1, img);
  53. }
  54. if (index === list.length - 1 && list.length < 4) {
  55. list.push('');
  56. }
  57. setimgList(list);
  58. }
  59. function deleteImg(index) {
  60. const list = [...imgList];
  61. if (!list[index]) {
  62. return null;
  63. } else {
  64. return () => changeImg('', index);
  65. }
  66. }
  67. const canSubmit = useCreation(() => {
  68. if (type && content) {
  69. return true;
  70. } else {
  71. return false;
  72. }
  73. }, [type, content, imgList]);
  74. function submit() {
  75. const img = [...imgList].filter((item) => {
  76. return item;
  77. });
  78. complaintSave(id, mid, type, content, img.join(',')).then(() => {
  79. navigation.goBack();
  80. });
  81. }
  82. return (
  83. <>
  84. <Header title="举报商家" />
  85. <ScrollView
  86. contentContainerStyle={{
  87. flexGrow: 1,
  88. backgroundColor: '#fff',
  89. }}
  90. >
  91. <Div bg="white" px={15} py={5}>
  92. <Div
  93. row
  94. alignItems="center"
  95. py={15}
  96. borderBottomWidth={1}
  97. borderColor="gray200"
  98. >
  99. <Image w={33} h={33} rounded="sm" source={{ uri: logo }} />
  100. <Text fontSize="xl" fontWeight="bold" ml={10}>
  101. {showName}
  102. </Text>
  103. </Div>
  104. <Div py={5} borderBottomWidth={1} borderColor="gray200">
  105. <Text py={5} fontSize="xs">
  106. 举报商家存在如下问题:
  107. </Text>
  108. <RadioGroup value={type} onChange={(value: any) => settype(value)}>
  109. {[...reasomsMap.keys()].map((item, index) => {
  110. return (
  111. <Radio
  112. key={index}
  113. value={item}
  114. activeColor="brand500"
  115. inactiveColor="gray300"
  116. py={5}
  117. >
  118. <Text
  119. color={item === type ? 'brand500' : 'gray300'}
  120. fontSize="xs"
  121. ml={10}
  122. >
  123. {reasomsMap.get(item).name}
  124. </Text>
  125. </Radio>
  126. );
  127. })}
  128. </RadioGroup>
  129. </Div>
  130. <Div row py={10}>
  131. {imgList.map((item, index) => {
  132. return (
  133. <ImagePicker
  134. key={index}
  135. img={item}
  136. setImg={(img) => changeImg(img, index)}
  137. cancelEvent={deleteImg(index)}
  138. />
  139. );
  140. })}
  141. </Div>
  142. <Div mb={10}>
  143. <TextareaItem
  144. rows={4}
  145. placeholder="可补充具体投诉内容,您的投诉真实性对我们的处理至关重要"
  146. count={50}
  147. style={{
  148. backgroundColor: '#eeeeee',
  149. paddingVertical: 10,
  150. fontSize: 10,
  151. borderBottomWidth: 0,
  152. }}
  153. onChange={setcontent}
  154. />
  155. </Div>
  156. <Button
  157. block
  158. bg="brand500"
  159. color="white"
  160. my={10}
  161. mx={20}
  162. onPress={submit}
  163. disabled={!canSubmit}
  164. >
  165. 提交
  166. </Button>
  167. </Div>
  168. </ScrollView>
  169. </>
  170. );
  171. }