Home.js 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  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: 'ReportCustomerList',
  29. param: {report_status: ''},
  30. premission: 'customer.view_report_customer',
  31. },
  32. {
  33. name: '报备审核',
  34. img: require('../../../assets/images/qksh2.png'),
  35. navetion: 'ReportCustomerList',
  36. param: {report_status: 0},
  37. badge: 'report_customer_count',
  38. premission: 'customer.check_report_customer',
  39. },
  40. {
  41. name: '客户跟踪',
  42. img: require('../../../assets/images/jrxg2.png'),
  43. navetion: 'ReviewTodayList',
  44. param: {status: 1},
  45. premission: 'customer.view_new_customer',
  46. },
  47. {
  48. name: '跟踪审核',
  49. img: require('../../../assets/images/jryg2.png'),
  50. navetion: '',
  51. param: {},
  52. premission: 'customer.check_review',
  53. badge: 'review_count',
  54. },
  55. {
  56. name: '进度跟踪',
  57. img: require('../../../assets/images/jdgl2.png'),
  58. navetion: '',
  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: '',
  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/fetchTipsCount')());
  90. };
  91. componentWillUnmount() {
  92. this._entry.remove();
  93. }
  94. _setStatusBar = () => {
  95. StatusBar.setBarStyle('dark-content');
  96. if (Platform.OS === 'android') {
  97. StatusBar.setTranslucent(false);
  98. StatusBar.setBackgroundColor('#f2f2f2');
  99. }
  100. };
  101. onItemPrss = (navetion, param, premission) => {
  102. const prem = CheckPrem(navetion, premission);
  103. if (prem) {
  104. this.props.navigation.navigate(navetion, param);
  105. }
  106. };
  107. render() {
  108. const {tipsCount, loading} = this.props.auth;
  109. const qinake = [
  110. {name: '今日新增', count: tipsCount.today_report, tips: '管理范围内,新增报备且已审核的客户数量。'},
  111. {name: '本月新增', count: tipsCount.mouth_report, tips: '管理范围内,新增报备且已审核的客户数量。'},
  112. {name: '总报备', count: tipsCount.general_report, tips: '管理范围内,总的报备且已审核的客户数量。'},
  113. ];
  114. return (
  115. <View style={styles.container}>
  116. <StatusBar backgroundColor={'#f2f2f2'} barStyle='dark-content'/>
  117. <Provider>
  118. <ScrollView
  119. refreshControl={
  120. <RefreshControl
  121. refreshing={loading}
  122. onRefresh={() => {
  123. this._fetchData();
  124. }}
  125. />}
  126. >
  127. <View style={styles.monthView}>
  128. <View style={{flexDirection: 'row'}}>
  129. {qinake.map((item, index) => (
  130. <Tooltip
  131. key={index}
  132. withOverlay={false}
  133. skipAndroidStatusBar={true}
  134. height={50}
  135. popover={<Text style={ComponentsStyles.toolTipText}>{item.tips}</Text>}>
  136. <View style={{
  137. padding: 10,
  138. width: (width - 20) / 3,
  139. alignItems: 'center',
  140. }}>
  141. <Text style={{color: '#fffe37'}}>{item.name}</Text>
  142. <Text style={styles.countText}>{item.count}</Text>
  143. </View>
  144. </Tooltip>
  145. ))}
  146. </View>
  147. </View>
  148. <View style={styles.itemView}>
  149. <View style={[styles.titleView, {flexDirection: 'row'}]}>
  150. <Text style={styles.titleText}>客户服务管理</Text>
  151. </View>
  152. <View style={styles.fixBody}>
  153. {qkgl.map((item, index) => (
  154. <TouchableOpacity
  155. key={index}
  156. style={styles.fixBodyItem}
  157. onPress={() => this.onItemPrss(item.navetion, item.param, item.premission)}
  158. >
  159. <IconBadge
  160. MainElement={
  161. <Image
  162. source={item.img}
  163. style={styles.img}/>
  164. }
  165. BadgeElement={
  166. <Text style={{
  167. color: '#FFFFFF',
  168. fontSize: 10,
  169. }}>{tipsCount[item.badge]}</Text>
  170. }
  171. IconBadgeStyle={
  172. {
  173. minWidth: 8 + 6 * (tipsCount[item.badge] ? tipsCount[item.badge] : '').toString().length,
  174. height: 15,
  175. left: 30,
  176. top: -2,
  177. borderRadius: 10,
  178. backgroundColor: '#ff3d27',
  179. }
  180. }
  181. Hidden={!tipsCount[item.badge]}
  182. />
  183. <Text style={styles.nameText}>{item.name}</Text>
  184. </TouchableOpacity>
  185. ))}
  186. </View>
  187. </View>
  188. </ScrollView>
  189. </Provider>
  190. </View>
  191. );
  192. }
  193. }
  194. const styles = StyleSheet.create({
  195. monthText: {
  196. color: '#fff',
  197. fontSize: 18,
  198. padding: 10,
  199. paddingBottom: 0,
  200. },
  201. container: {
  202. flex: 1,
  203. paddingHorizontal: 10,
  204. marginTop: ComponentsStyles.top_margin,
  205. },
  206. fixBody: {
  207. flexDirection: 'row',
  208. flexWrap: 'wrap',
  209. },
  210. fixBodyItem: {
  211. alignItems: 'center',
  212. margin: 2,
  213. // borderWidth: 1,
  214. padding: 3,
  215. width: (width - 40) / 4,
  216. },
  217. img: {
  218. height: 30,
  219. width: 30,
  220. },
  221. nameText: {
  222. paddingVertical: 3,
  223. },
  224. itemView: {
  225. marginVertical: 5,
  226. borderRadius: 5,
  227. backgroundColor: '#fff',
  228. },
  229. titleView: {
  230. paddingVertical: 5,
  231. paddingLeft: 10,
  232. },
  233. titleText: {
  234. color: '#333',
  235. fontSize: 18,
  236. },
  237. monthView: {
  238. marginVertical: 10,
  239. backgroundColor: '#0f89f7',
  240. borderRadius: 5,
  241. },
  242. countText: {
  243. color: '#fff',
  244. fontSize: 18,
  245. paddingTop: 5,
  246. },
  247. searchBarIcon: {
  248. fontFamily: 'iconfont',
  249. fontSize: 14,
  250. paddingHorizontal: 5,
  251. color: '#ababab',
  252. },
  253. searchBarInput: {
  254. justifyContent: 'center',
  255. backgroundColor: '#fff',
  256. borderRadius: 15,
  257. flexDirection: 'row',
  258. flex: 1,
  259. margin: Platform.OS === 'ios' ? 0 : 5,
  260. padding: Platform.OS === 'ios' ? 0 : 5,
  261. },
  262. });
  263. export default SalesHome;