Home.js 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278
  1. import React, {Component} from 'react';
  2. import {
  3. StyleSheet,
  4. View,
  5. Text,
  6. StatusBar,
  7. Dimensions,
  8. Image,
  9. TouchableOpacity,
  10. ScrollView,
  11. RefreshControl,
  12. DeviceEventEmitter,
  13. Platform,
  14. } from 'react-native';
  15. import {Provider} from '@ant-design/react-native';
  16. import {connect} from 'react-redux';
  17. import CheckPrem from '../../components/CheckPrem';
  18. import IconBadge from 'react-native-icon-badge';
  19. import {createAction} from '../../utils';
  20. import {ComponentsStyles} from '../../components/ComponentsStyles';
  21. import {Tooltip} from 'react-native-elements';
  22. import SyncStorage from 'sync-storage';
  23. const {width} = Dimensions.get('window');
  24. const qkgl = [
  25. {
  26. name: '客户报备',
  27. img: require('../../../assets/images/jdws2.png'),
  28. navetion: 'ReceptionList',
  29. param: {},
  30. premission: 'customer.view_report_customer',
  31. },
  32. {
  33. name: '报备审核',
  34. img: require('../../../assets/images/qksh2.png'),
  35. navetion: 'VisitorList',
  36. param: {},
  37. badge: 'report_customer_count',
  38. premission: 'customer.check_report_customer',
  39. },
  40. {
  41. name: '客户跟踪',
  42. img: require('../../../assets/images/jrxg2.png'),
  43. navetion: 'CallList',
  44. param: {},
  45. premission: 'customer.view_new_customer',
  46. },
  47. {
  48. name: '跟踪审核',
  49. img: require('../../../assets/images/jryg2.png'),
  50. navetion: 'NetworkList',
  51. param: {},
  52. premission: 'customer.check_review',
  53. badge: 'review_count',
  54. },
  55. {
  56. name: '进度跟踪',
  57. img: require('../../../assets/images/jdgl2.png'),
  58. navetion: 'ReviewTodayList',
  59. param: {track_status: 'today', title: '今日需跟', status: ''},
  60. premission: 'order.view_order',
  61. },
  62. {
  63. name: '进度审核',
  64. img: require('../../../assets/images/jcgl2.png'),
  65. navetion: 'ReviewTodayList',
  66. param: {track_status: 'today_ok', title: '今日已跟', status: ''},
  67. badge: 'order_count',
  68. premission: 'order.order_process_dispatch',
  69. },
  70. ];
  71. @connect(auth => ({...auth}))
  72. class SalesHome extends Component {
  73. constructor(props) {
  74. super(props);
  75. this.state = {
  76. page: 1,
  77. };
  78. }
  79. static navigationOptions = {
  80. headerShown: false, //隐藏顶部导航栏
  81. };
  82. componentDidMount() {
  83. this._entry = DeviceEventEmitter.addListener('ShowWhiteStatusBar', (param) => {
  84. this._setStatusBar();
  85. });
  86. this._fetchData();
  87. }
  88. _fetchData = () => {
  89. this.props.dispatch(createAction('auth/fetchHomeCount')());
  90. this.props.dispatch(createAction('auth/fetchTipsCount')());
  91. };
  92. componentWillUnmount() {
  93. this._entry.remove();
  94. }
  95. _setStatusBar = () => {
  96. StatusBar.setBarStyle('dark-content');
  97. if (Platform.OS === 'android') {
  98. StatusBar.setTranslucent(false);
  99. StatusBar.setBackgroundColor('#f2f2f2');
  100. }
  101. };
  102. onItemPrss = (navetion, param, premission) => {
  103. const prem = CheckPrem(navetion, premission);
  104. if (prem) {
  105. this.props.navigation.navigate(navetion, param);
  106. }
  107. };
  108. render() {
  109. const {homeCount, tipsCount, loading} = this.props.auth;
  110. const qinake = [
  111. {name: '今日新增', count: homeCount.today_report, tips: '管理范围内,新增报备且已审核的客户数量。'},
  112. {name: '本月新增', count: homeCount.mouth_report, tips: '管理范围内,新增报备且已审核的客户数量。'},
  113. {name: '总报备', count: homeCount.general_report, tips: '管理范围内,总的报备且已审核的客户数量。'},
  114. ];
  115. return (
  116. <View style={styles.container}>
  117. <StatusBar backgroundColor={'#f2f2f2'} barStyle='dark-content'/>
  118. <Provider>
  119. <ScrollView
  120. refreshControl={
  121. <RefreshControl
  122. refreshing={loading}
  123. onRefresh={() => {
  124. this._fetchData();
  125. }}
  126. />}
  127. >
  128. <View style={styles.monthView}>
  129. <View style={{flexDirection: 'row'}}>
  130. {qinake.map((item, index) => (
  131. <Tooltip
  132. key={index}
  133. withOverlay={false}
  134. skipAndroidStatusBar={true}
  135. height={50}
  136. popover={<Text style={ComponentsStyles.toolTipText}>{item.tips}</Text>}>
  137. <View style={{
  138. padding: 10,
  139. width: (width - 20) / 3,
  140. alignItems: 'center',
  141. }}>
  142. <Text style={{color: '#fffe37'}}>{item.name}</Text>
  143. <Text style={styles.countText}>{item.count}</Text>
  144. </View>
  145. </Tooltip>
  146. ))}
  147. </View>
  148. </View>
  149. <View style={styles.itemView}>
  150. <View style={[styles.titleView, {flexDirection: 'row'}]}>
  151. <Text style={styles.titleText}>客户服务管理</Text>
  152. </View>
  153. <View style={styles.fixBody}>
  154. {qkgl.map((item, index) => (
  155. <TouchableOpacity
  156. key={index}
  157. style={styles.fixBodyItem}
  158. onPress={() => this.onItemPrss(item.navetion, item.param, item.premission)}
  159. >
  160. <IconBadge
  161. MainElement={
  162. <Image
  163. source={item.img}
  164. style={styles.img}/>
  165. }
  166. BadgeElement={
  167. <Text style={{
  168. color: '#FFFFFF',
  169. fontSize: 10,
  170. }}>{tipsCount[item.badge]}</Text>
  171. }
  172. IconBadgeStyle={
  173. {
  174. minWidth: 8 + 6 * (tipsCount[item.badge] ? tipsCount[item.badge] : '').toString().length,
  175. height: 15,
  176. left: 30,
  177. top: -2,
  178. borderRadius: 10,
  179. backgroundColor: '#ff3d27',
  180. }
  181. }
  182. Hidden={!tipsCount[item.badge]}
  183. />
  184. <Text style={styles.nameText}>{item.name}</Text>
  185. </TouchableOpacity>
  186. ))}
  187. </View>
  188. </View>
  189. </ScrollView>
  190. </Provider>
  191. </View>
  192. );
  193. }
  194. }
  195. const styles = StyleSheet.create({
  196. monthText: {
  197. color: '#fff',
  198. fontSize: 18,
  199. padding: 10,
  200. paddingBottom: 0,
  201. },
  202. container: {
  203. flex: 1,
  204. paddingHorizontal: 10,
  205. marginTop: ComponentsStyles.top_margin,
  206. },
  207. fixBody: {
  208. flexDirection: 'row',
  209. flexWrap: 'wrap',
  210. },
  211. fixBodyItem: {
  212. alignItems: 'center',
  213. margin: 2,
  214. // borderWidth: 1,
  215. padding: 3,
  216. width: (width - 40) / 4,
  217. },
  218. img: {
  219. height: 30,
  220. width: 30,
  221. },
  222. nameText: {
  223. paddingVertical: 3,
  224. },
  225. itemView: {
  226. marginVertical: 5,
  227. borderRadius: 5,
  228. backgroundColor: '#fff',
  229. },
  230. titleView: {
  231. paddingVertical: 5,
  232. paddingLeft: 10,
  233. },
  234. titleText: {
  235. color: '#333',
  236. fontSize: 18,
  237. },
  238. monthView: {
  239. marginVertical: 10,
  240. backgroundColor: '#0f89f7',
  241. borderRadius: 5,
  242. },
  243. countText: {
  244. color: '#fff',
  245. fontSize: 18,
  246. paddingTop: 5,
  247. },
  248. searchBarIcon: {
  249. fontFamily: 'iconfont',
  250. fontSize: 14,
  251. paddingHorizontal: 5,
  252. color: '#ababab',
  253. },
  254. searchBarInput: {
  255. justifyContent: 'center',
  256. backgroundColor: '#fff',
  257. borderRadius: 15,
  258. flexDirection: 'row',
  259. flex: 1,
  260. margin: Platform.OS === 'ios' ? 0 : 5,
  261. padding: Platform.OS === 'ios' ? 0 : 5,
  262. },
  263. });
  264. export default SalesHome;