Procházet zdrojové kódy

Merge remote-tracking branch 'origin/master'

Csy817 před 6 roky
rodič
revize
0d04befba8
2 změnil soubory, kde provedl 16 přidání a 27 odebrání
  1. 16 24
      src/App.js
  2. 0 3
      src/pages/home/index.js

+ 16 - 24
src/App.js

@@ -13,6 +13,12 @@ class App extends Component {
         }
     }
 
+    changeTabBar = (tab) => {
+        this.setState({
+            selectedTab: tab
+        })
+    }
+
     render() {
         let {selectedTab} = this.state;
         return (
@@ -34,26 +40,22 @@ class App extends Component {
                         selectedIcon={<HomeSelectedIcon/>}
                         selected={selectedTab === 'home'}
                         onPress={() => {
-                            this.setState({
-                                selectedTab: 'home',
-                            })
+                            this.changeTabBar('home')
                         }}
                     >
-                        <Home/>
+                        <Home changeTabBar={this.changeTabBar}/>
                     </TabBar.Item>
                     <TabBar.Item
-                        icon={<Icon type="shopping" style={{fontSize:22}}/>}
-                        selectedIcon={<Icon type="shopping" theme="twoTone" style={{fontSize:22}}/>}
+                        icon={<CartUnselectedIcon/>}
+                        selectedIcon={<CartSelectedIcon/>}
                         title="购物袋"
                         key="cart"
                         selected={selectedTab === 'cart'}
                         onPress={() => {
-                            this.setState({
-                                selectedTab: 'cart',
-                            })
+                            this.changeTabBar('cart')
                         }}
                     >
-                        <Cart/>
+                        <Cart changeTabBar={this.changeTabBar}/>
                     </TabBar.Item>
                     <TabBar.Item
                         icon={<MyUnselectedIcon/>}
@@ -62,12 +64,10 @@ class App extends Component {
                         key="my"
                         selected={selectedTab === 'my'}
                         onPress={() => {
-                            this.setState({
-                                selectedTab: 'my',
-                            })
+                            this.changeTabBar('my')
                         }}
                     >
-                        <My/>
+                        <My changeTabBar={this.changeTabBar}/>
                     </TabBar.Item>
                 </TabBar>
             </div>
@@ -94,19 +94,11 @@ const HomeSelectedIcon = () => (
 )
 
 const CartUnselectedIcon = () => (
-    <div style={{
-        width: '22px',
-        height: '22px',
-        background: 'url(https://gw.alipayobjects.com/zos/rmsportal/BTSsmHkPsQSPTktcXyTV.svg) center center /  21px 21px no-repeat'
-    }}/>
+    <Icon type="shopping" style={{fontSize:22}}/>
 )
 
 const CartSelectedIcon = () => (
-    <div style={{
-        width: '22px',
-        height: '22px',
-        background: 'url(https://gw.alipayobjects.com/zos/rmsportal/ekLecvKBnRazVLXbWOnE.svg) center center /  21px 21px no-repeat'
-    }}/>
+    <Icon type="shopping" theme="twoTone" style={{fontSize:22}}/>
 )
 
 const MyUnselectedIcon = () => (

+ 0 - 3
src/pages/home/index.js

@@ -113,9 +113,6 @@ class Like extends Component {
 
     render() {
         let {data} = this.props
-        if (data % 2 !== 0) {
-            data.splice(0, 1)
-        }
         return (
             <div className='guess-wrapper'>
                 <div className='guess-title'>- 猜你喜欢 -</div>