TabBarBottom.jsx 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. import React from 'react';
  2. import { TabBar } from 'antd-mobile';
  3. //import {PageContext} from '../context'
  4. class TabBarBottom extends React.Component {
  5. constructor(props) {
  6. super(props);
  7. this.state = {
  8. selectedTab: 'bill',
  9. hidden: false,
  10. fullScreen: true,
  11. };
  12. this.handleChange=this.handleChange.bind(this)
  13. }
  14. //要保留,勿动
  15. renderContent(page){}
  16. handleChange(page){
  17. this.props.changePage(page)
  18. }
  19. render() {
  20. //这里渲染一次
  21. return (
  22. <div style={this.state.fullScreen ? { position: 'absolute', height: '100%', width: '100%', bottom: 0 } : { height: 400 }}>
  23. <TabBar
  24. unselectedTintColor="#949494"
  25. tintColor="#33A3F4"
  26. barTintColor="white"
  27. hidden={this.state.hidden}
  28. >
  29. <TabBar.Item
  30. title="账单"
  31. key="bill"
  32. icon={<div style={{
  33. width: '22px',
  34. height: '22px',
  35. background: 'url(https://wly-1254337200.cos.ap-guangzhou.myqcloud.com/bill.svg) center center / 21px 21px no-repeat' }}
  36. />
  37. }
  38. selectedIcon={<div style={{
  39. width: '22px',
  40. height: '22px',
  41. background: 'url(https://wly-1254337200.cos.ap-guangzhou.myqcloud.com/bill_s.svg) center center / 21px 21px no-repeat' }}
  42. />
  43. }
  44. selected={this.state.selectedTab === 'bill'}
  45. onPress={() => {
  46. this.setState({
  47. selectedTab: 'bill',
  48. });
  49. this.handleChange('bill')
  50. }}
  51. data-seed="logId"
  52. >
  53. {this.renderContent('bill')}
  54. </TabBar.Item>
  55. <TabBar.Item
  56. icon={
  57. <div style={{
  58. width: '22px',
  59. height: '22px',
  60. background: 'url(https://wly-1254337200.cos.ap-guangzhou.myqcloud.com/assets.svg) center center / 21px 21px no-repeat' }}
  61. />
  62. }
  63. selectedIcon={
  64. <div style={{
  65. width: '22px',
  66. height: '22px',
  67. background: 'url(https://wly-1254337200.cos.ap-guangzhou.myqcloud.com/assets_s.svg) center center / 21px 21px no-repeat' }}
  68. />
  69. }
  70. title="总资产"
  71. key="assets"
  72. selected={this.state.selectedTab === 'assets'}
  73. onPress={() => {
  74. this.setState({
  75. selectedTab: 'assets',
  76. });
  77. this.handleChange('assets')
  78. }}
  79. data-seed="logId1"
  80. >
  81. {this.renderContent('assets')}
  82. </TabBar.Item>
  83. <TabBar.Item
  84. icon={
  85. <div style={{
  86. width: '22px',
  87. height: '22px',
  88. background: 'url(https://wly-1254337200.cos.ap-guangzhou.myqcloud.com/user.svg) center center / 21px 21px no-repeat' }}
  89. />
  90. }
  91. selectedIcon={
  92. <div style={{
  93. width: '22px',
  94. height: '22px',
  95. background: 'url(https://wly-1254337200.cos.ap-guangzhou.myqcloud.com/user_s.svg) center center / 21px 21px no-repeat' }}
  96. />
  97. }
  98. title="我的"
  99. key="my"
  100. selected={this.state.selectedTab === 'my'}
  101. onPress={() => {
  102. this.setState({
  103. selectedTab: 'my',
  104. });
  105. this.handleChange('my')
  106. }}
  107. >
  108. {this.renderContent('my')}
  109. </TabBar.Item>
  110. </TabBar>
  111. </div>
  112. );
  113. }
  114. }
  115. export default TabBarBottom
  116. // export default props => (
  117. // <PageContext.Consumer>
  118. // {(obj)=> <TabBarBottom {...props} {...obj}/>}
  119. // </PageContext.Consumer>
  120. // );