MineHome.js 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503
  1. import React, { Component } from 'react'
  2. import {
  3. StyleSheet,
  4. View,
  5. Image,
  6. Text,
  7. StatusBar,
  8. Alert,
  9. ImageBackground,
  10. PixelRatio,
  11. TouchableOpacity,
  12. ScrollView,
  13. } from 'react-native'
  14. import { connect } from 'react-redux'
  15. import { createAction, NavigationActions } from '../../utils'
  16. import Icon from '../../components/Iconfont/Iconfont'
  17. import CodePush from 'react-native-code-push'
  18. import Background from '../../static/images/mine-background.png'
  19. import TX from '../../static/images/mine-TX.png'
  20. import { ScaleUtil } from '../../utils/utils'
  21. import MineHome_0 from '../../static/images/MineHome-0.png'
  22. import MineHome_1 from '../../static/images/MineHome-1.png'
  23. import MineHome_2 from '../../static/images/MineHome-2.png'
  24. import MineHome_3 from '../../static/images/MineHome-3.png'
  25. import MineHome_4 from '../../static/images/MineHome-4.png'
  26. import MineHome_5 from '../../static/images/MineHome-5.png'
  27. import { ppHOC, POC, extHOC } from './highComponent'
  28. import { isIphoneX } from '../common/theme/config'
  29. // @CodePush({
  30. // checkFrequency: CodePush.CheckFrequency.ON_APP_RESUME,
  31. // installMode: CodePush.InstallMode.ON_NEXT_RESUME
  32. // })
  33. @connect(({ theme, mine_header }) => ({ ...theme, ...mine_header }))
  34. class MineHome extends Component {
  35. constructor(props) {
  36. super(props)
  37. this.state = {
  38. huanfu: '',
  39. }
  40. }
  41. static navigationOptions = {
  42. tabBarLabel: ({ tintColor }) => (
  43. <Text
  44. style={{
  45. alignSelf: 'center',
  46. marginBottom: 2,
  47. fontSize: 10,
  48. lineHeight: 14,
  49. letterSpacing: 0.12,
  50. color: tintColor,
  51. }}
  52. >
  53. 我的
  54. </Text>
  55. ),
  56. tabBarIcon: ({ focused, tintColor }) =>
  57. tintColor == '#333' ? (
  58. <View style={{ paddingTop: 7 }}>
  59. <Icon name="icon-icon-wode" size={28} color={tintColor} />
  60. </View>
  61. ) : (
  62. <View style={{ paddingTop: 7 }}>
  63. <Icon name="icon-icon-wodexuanzhong" size={28} color={tintColor} />
  64. </View>
  65. ),
  66. }
  67. hotDog() {
  68. // //访问慢,不稳定
  69. CodePush.checkForUpdate().then(update => {
  70. if (!update) {
  71. Alert.alert('提示', '已是最新版本--', [
  72. {
  73. text: 'Ok',
  74. onPress: () => {
  75. console.log('点了OK')
  76. },
  77. },
  78. ])
  79. } else {
  80. CodePush.sync({
  81. // deploymentKey:
  82. // "ODZaOd9nY_uCJ1PiwkHL-CUb23lr8504fd21-5b83-418e-89df-e737a5111208",
  83. // updateDialog: {
  84. // optionalIgnoreButtonLabel: "稍后",
  85. // optionalInstallButtonLabel: "立即更新",
  86. // optionalUpdateMessage: "有新版本了,是否更新?",
  87. // title: "更新提示"
  88. // },
  89. updateDialog: true,
  90. installMode: CodePush.InstallMode.IMMEDIATE,
  91. })
  92. }
  93. })
  94. }
  95. codePushStatusDidChange(status) {
  96. switch (status) {
  97. case codePush.SyncStatus.CHECKING_FOR_UPDATE:
  98. console.log('Checking for updates.')
  99. break
  100. case codePush.SyncStatus.DOWNLOADING_PACKAGE:
  101. console.log('Downloading package.')
  102. break
  103. case codePush.SyncStatus.INSTALLING_UPDATE:
  104. console.log('Installing update.')
  105. break
  106. case codePush.SyncStatus.UP_TO_DATE:
  107. console.log('Up-to-date.')
  108. break
  109. case codePush.SyncStatus.UPDATE_INSTALLED:
  110. console.log('Update installed.')
  111. break
  112. }
  113. }
  114. codePushDownloadDidProgress(progress) {
  115. console.log(
  116. progress.receivedBytes + ' of ' + progress.totalBytes + ' received.'
  117. )
  118. }
  119. componentDidMount = () => {
  120. const date = new Date().getTime()
  121. // 信用当前可用余额
  122. // this.RequestOthers('mine_header/CreditSaga', {
  123. // customer: CUSTOMERINFO.id,
  124. // })
  125. // 费用当前可用余额
  126. // this.RequestOthers('mine_header/CastBalSaga', {
  127. // search_customer: CUSTOMERINFO.id,
  128. // search_billDate_date: date,
  129. // })
  130. // 可用财务组织、销售组织
  131. this.RequestOthers('mine/getCusSup', {
  132. customerId: CUSTOMERINFO.id,
  133. customerRankCode: CUSTOMERINFO.customerRankCode,
  134. comeFrom: 'castBalance',
  135. })
  136. // 账户余额
  137. this.RequestOthers('mine_header/MaxBalanceSaga', {
  138. customerId: CUSTOMERINFO.id,
  139. })
  140. }
  141. // 跳转
  142. NavigateToOthers(routeName, params) {
  143. this.props.dispatch(
  144. NavigationActions.navigate({ routeName: routeName, params: params })
  145. )
  146. }
  147. // 请求
  148. RequestOthers(actionName, actionSearch) {
  149. this.props.dispatch(createAction(actionName)(actionSearch))
  150. }
  151. skinChange = () => {
  152. if (this.state.huanfu == 0) {
  153. this.RequestOthers('theme/getTheme', { getColor: 'black' })
  154. this.state.huanfu = 1
  155. } else {
  156. this.RequestOthers('theme/getTheme', { getColor: 'white' })
  157. this.state.huanfu = 0
  158. }
  159. }
  160. logout = () => {
  161. this.RequestOthers('app/logout')
  162. }
  163. TouchList(item) {
  164. let returnVal = [],
  165. ImageView = []
  166. for (let i = 0; i < item.length; i++) {
  167. if (item[i].text == '应付对账') {
  168. ImageView = (
  169. <Image source={MineHome_0} style={{ width: 28, height: 28 }} />
  170. )
  171. } else if (item[i].text == '费用对账') {
  172. ImageView = (
  173. <Image source={MineHome_1} style={{ width: 28, height: 28 }} />
  174. )
  175. } else if (item[i].text == '基本信息') {
  176. ImageView = (
  177. <Image source={MineHome_2} style={{ width: 28, height: 28 }} />
  178. )
  179. } else if (item[i].text == '客户收货地址') {
  180. ImageView = (
  181. <Image source={MineHome_3} style={{ width: 28, height: 28 }} />
  182. )
  183. } else if (item[i].text == '客户联系人') {
  184. ImageView = (
  185. <Image source={MineHome_4} style={{ width: 28, height: 28 }} />
  186. )
  187. } else if (item[i].text == '我的供应商') {
  188. ImageView = (
  189. <Image source={MineHome_5} style={{ width: 28, height: 28 }} />
  190. )
  191. }
  192. returnVal.push(
  193. <TouchableOpacity
  194. key={i}
  195. onPress={() => item[i].onTouch()}
  196. style={{
  197. paddingVertical: 10,
  198. flexDirection: 'row',
  199. justifyContent: 'space-between',
  200. borderTopWidth: 1 / PixelRatio.get(),
  201. borderTopColor: '#EEE',
  202. }}
  203. >
  204. <View
  205. style={{
  206. flexDirection: 'row',
  207. }}
  208. >
  209. {/* <View
  210. style={{
  211. width: 19,
  212. height: 19,
  213. backgroundColor: "#FD325A",
  214. marginRight: 10
  215. }}
  216. /> */}
  217. {ImageView}
  218. <Text
  219. style={{
  220. fontSize: 14,
  221. lineHeight: 20,
  222. color: '#333',
  223. marginLeft: 5,
  224. alignSelf: 'center',
  225. }}
  226. >
  227. {item[i].text}
  228. </Text>
  229. </View>
  230. <Icon name="icon-icon-jianjinzhishiqi" size={24} color={'#CCC'} />
  231. </TouchableOpacity>
  232. )
  233. }
  234. return (
  235. <View
  236. style={{
  237. marginTop: 10,
  238. paddingHorizontal: 10,
  239. backgroundColor: '#FFF',
  240. }}
  241. >
  242. {returnVal}
  243. </View>
  244. )
  245. }
  246. render() {
  247. const { appTheme, creditBalance, CastDdlData, maxBalData } = this.props
  248. // 对账
  249. const duizhang = [
  250. {
  251. text: '应付对账',
  252. onTouch: () => this.NavigateToOthers('PayReconciliation'),
  253. },
  254. {
  255. text: '费用对账',
  256. onTouch: () => {
  257. this.RequestOthers('mine/getOrgans', { searchMore: true })
  258. this.RequestOthers('mine/getCusSup', {
  259. customerId: CUSTOMERINFO.id,
  260. customerRankCode: CUSTOMERINFO.customerRankCode,
  261. forUse: 'CostReconciliation',
  262. })
  263. },
  264. },
  265. ]
  266. const basicInfo = [
  267. {
  268. text: '基本信息',
  269. onTouch: () =>
  270. this.RequestOthers('mine/getBasic', { customerId: CUSTOMERINFO.id }),
  271. },
  272. {
  273. text: '客户收货地址',
  274. onTouch: () =>
  275. this.RequestOthers('mine/getCusAdd', { customerId: CUSTOMERINFO.id }),
  276. },
  277. {
  278. text: '客户联系人',
  279. onTouch: () =>
  280. this.RequestOthers('mine/getContacts', {
  281. customerId: CUSTOMERINFO.id,
  282. }),
  283. },
  284. // {
  285. // text: '付款单登记',
  286. // onTouch: () => this.NavigateToOthers('PaymentRegister'),
  287. // },
  288. // {
  289. // text: '支付单',
  290. // onTouch: () => this.NavigateToOthers('RechargeHome'),
  291. // },
  292. ]
  293. const mySupplier = [
  294. {
  295. text: '我的供应商',
  296. onTouch: () =>
  297. this.RequestOthers('mine/getCusSup', {
  298. customerId: CUSTOMERINFO.id,
  299. customerRankCode: CUSTOMERINFO.customerRankCode,
  300. comeFrom: 'supplier',
  301. toOthers: true,
  302. }),
  303. },
  304. ]
  305. return (
  306. <View
  307. style={[
  308. styles.container,
  309. { backgroundColor: appTheme.backgroundColor },
  310. ]}
  311. >
  312. <StatusBar
  313. animated={true}
  314. barStyle={appTheme.barStyle}
  315. // barStyle={"dark-content"}
  316. backgroundColor={'transparent'}
  317. translucent={true}
  318. />
  319. <View style={{ paddingBottom: 10, backgroundColor: '#FFF' }}>
  320. <ImageBackground
  321. source={Background}
  322. style={{ height: isIphoneX() ? 159 : 135 }}
  323. >
  324. <View
  325. style={{
  326. marginTop: isIphoneX() ? 35 : 30,
  327. paddingHorizontal: 10,
  328. flexDirection: 'row',
  329. justifyContent: 'space-between',
  330. backgroundColor: 'transparent',
  331. }}
  332. >
  333. <Icon
  334. name="icon-shezhi"
  335. size={26}
  336. color={'#FFF'}
  337. onPress={() => this.NavigateToOthers('Setting')}
  338. />
  339. {/* <Icon name="icon-xitong" size={20} color={"#FFF"} /> */}
  340. </View>
  341. <View
  342. style={{
  343. position: 'absolute',
  344. top: '30%',
  345. alignSelf: 'center',
  346. backgroundColor: 'transparent',
  347. }}
  348. >
  349. <Image
  350. source={TX}
  351. style={{
  352. width: 60,
  353. height: 60,
  354. marginLeft: 5,
  355. alignSelf: 'center',
  356. }}
  357. />
  358. <Text
  359. style={{
  360. fontSize: 14,
  361. lineHeight: 15,
  362. color: '#FFF',
  363. }}
  364. >
  365. {/* {USERINFO.userName} */}
  366. {CUSTOMERINFO.name}
  367. </Text>
  368. </View>
  369. </ImageBackground>
  370. {CUSTOMERINFO.customerRankCode == 1 ? (
  371. <View
  372. style={{
  373. marginTop: 20,
  374. flexDirection: 'row',
  375. }}
  376. >
  377. {/* <TouchableOpacity
  378. onPress={() => this.NavigateToOthers('Account')}
  379. style={{
  380. flex: 1,
  381. paddingVertical: 8,
  382. alignItems: 'center',
  383. }}
  384. >
  385. <Text
  386. style={{ fontSize: 14, lineHeight: 20, color: '#E14C46' }}
  387. >
  388. {CURRENCY.currencySign}
  389. {ScaleUtil(maxBalData || 0, CURRENCY.currencyAmountScale)}
  390. </Text>
  391. <Text
  392. style={{
  393. marginTop: 7,
  394. fontSize: 14,
  395. lineHeight: 20,
  396. color: '#333',
  397. }}
  398. >
  399. 账户
  400. </Text>
  401. </TouchableOpacity> */}
  402. <View style={{ height: 52, backgroundColor: '#EEE', width: 1 }} />
  403. {/* <TouchableOpacity
  404. onPress={() => {
  405. this.RequestOthers('mine/getOrgans', { forUse: 'tiaozhuan' })
  406. }}
  407. style={{
  408. flex: 1,
  409. paddingVertical: 10,
  410. alignItems: 'center',
  411. }}
  412. >
  413. <Text
  414. style={{ fontSize: 14, lineHeight: 20, color: '#E14C46' }}
  415. >
  416. {CURRENCY.currencySign}
  417. {ScaleUtil(CastDdlData, CURRENCY.currencyAmountScale)}
  418. </Text>
  419. <Text
  420. style={{
  421. marginTop: 7,
  422. fontSize: 14,
  423. lineHeight: 20,
  424. color: '#333',
  425. }}
  426. >
  427. 费用
  428. </Text>
  429. </TouchableOpacity> */}
  430. <View style={{ height: 52, backgroundColor: '#EEE', width: 1 }} />
  431. {/* <TouchableOpacity
  432. onPress={() => {
  433. this.NavigateToOthers('Credit')
  434. }}
  435. style={{
  436. flex: 1,
  437. paddingVertical: 10,
  438. alignItems: 'center',
  439. }}
  440. >
  441. <Text
  442. style={{ fontSize: 14, lineHeight: 20, color: '#E14C46' }}
  443. >
  444. {CURRENCY.currencySign}
  445. {ScaleUtil(creditBalance, CURRENCY.currencyAmountScale)}
  446. </Text>
  447. <Text
  448. style={{
  449. marginTop: 7,
  450. fontSize: 14,
  451. lineHeight: 20,
  452. color: '#333',
  453. }}
  454. >
  455. 信用
  456. </Text>
  457. </TouchableOpacity> */}
  458. </View>
  459. ) : null}
  460. </View>
  461. <ScrollView style={{ flex: 1 }}>
  462. {/* {CUSTOMERINFO.customerRankCode == 1 ? this.TouchList(duizhang) : null} */}
  463. {this.TouchList(basicInfo)}
  464. {this.TouchList(mySupplier)}
  465. {/* {this.TouchList([
  466. { text: "换肤", onTouch: () => this.skinChange() },
  467. {
  468. text: "更新",
  469. onTouch: () => this.hotDog()
  470. }
  471. ])} */}
  472. </ScrollView>
  473. </View>
  474. )
  475. }
  476. }
  477. const styles = StyleSheet.create({
  478. container: {
  479. flex: 1,
  480. },
  481. })
  482. // MineHome = CodePush(MineHome);
  483. export default MineHome