yu_ber пре 4 година
родитељ
комит
2d2d9129c4

+ 56 - 28
src/layouts/index.js

@@ -1,30 +1,58 @@
-// import React, { Component } from 'react'
-// import BaseLayout from './baseLayout';
 
-// const ULR_NO_LAYOUT = ['/', '/home', '/class', '/my'];
 
-// class Index extends Component {
-//   componentDidMount() {
-//   }
-//   renderBody = () => {
-//     const {location: {pathname}, children } = this.props;
-//     if (ULR_NO_LAYOUT.includes(pathname)) {
-//       return  (<BaseLayout {...this.props} />);
-//     }
-//     return (
-//       <React.Fragment>
-//         {children}
-//       </React.Fragment>
-//     );
-//   }
-
-//   render() {
-//     return (
-//       <React.Fragment>
-//         {this.renderBody()}
-//       </React.Fragment>
-//     )
-//   }
-// }
-
-// export default Index;
+import React, { Component } from 'react'
+import qs from 'qs';
+import { config, request , util } from 'utils';
+class Index extends Component {
+    constructor(props) {
+        super(props)
+        this.state = {
+            token: null
+        }
+    }
+  componentDidMount() {
+      this.getUpdateToken()
+  }
+   getUpdateToken = (value) => {
+        let user = util.auth.getUser();
+        if (!user) {
+            util.auth.removeToken();
+        }
+        let data = {};
+        data['client_id'] = ClientIdCms;
+        data['client_secret'] = ClientSecretCms;
+        data['applicationKey'] = 'wechatcp';
+        data['grant_type'] = "client_credentials";
+        data['autoRefresh'] = true;
+        let strData = qs.stringify(data);
+        request({
+            url: config.api.getOperationToken,
+            method: 'post',
+            data: strData,
+            dataHeader: { headers: { 'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8' } }
+        }).then((data) => {
+            if (data.success) {
+                var user = util.auth.getUser();
+                if (user) {
+                    util.auth.setUser(user);
+                }
+                util.auth.setToken(data.result.access_token);
+                this.setState({ token: data.result.access_token })
+            } else {
+                util.auth.removeToken();
+            }
+        });
+  }
+  renderBody = () => {
+    const { children } = this.props;
+    return (
+      <React.Fragment>
+        {children}
+      </React.Fragment>
+    );
+  }
+  render() {
+   return  this.state.token ?  <React.Fragment>{this.renderBody()}</React.Fragment> : <div /> ;
+  }
+}
+export default Index;

+ 1 - 0
src/pages/class/index.js

@@ -27,6 +27,7 @@ class ClassPage extends Component {
     }
   }
   componentDidMount() {
+    console.log("入口页");
     this.setState({
       columnId:this.props.location.query.columnId,
       searchText:this.props.location.query.searchText,

+ 1 - 1
src/pages/viewHome/categoryEntry/index.js

@@ -62,7 +62,7 @@ class categoryEntry extends Component {
                                 </li>
                             })
                         }
-                        <li className={styles.nav_item} onClick={() => this.onClick({departmentId:""})}>
+                        <li className={styles.nav_item} onClick={() => this.onClick({departmentId:""})} style={{display:this.state.departmentList.length >0 ? "block":"none"}}>
                             <a href="javascript:void(0);" className={styles.nav_item_link}>
                             <div className={styles.itemStyle}></div>
                                 <span className={styles.title}>更多</span>

+ 6 - 3
src/pages/viewHome/contentDetails/index.js

@@ -18,11 +18,14 @@ class contentDetails extends Component {
         }
     }
     componentDidMount() {
-        this.requsetData();
+        const articleId = this.props.location.query.articleId
+        if(articleId){
+            this.requsetData(articleId);
+        }
     }
-    requsetData = () => {
+    requsetData = ( articleId ) => {
         request({
-            url: WXMpAPI + '/wx/content/article/queryArticleByArticleId/' + this.props.location.query.articleId,
+            url: WXMpAPI + '/wx/content/article/queryArticleByArticleId/' + articleId,
             method: "get",
         }).then((data) => {
             this.setState({

+ 1 - 62
src/pages/viewHome/index.js

@@ -1,70 +1,9 @@
-import Home from '../viewHome'
 import React, { Component } from 'react'
 import HomeContent from './HomeContent'
-import qs from 'qs';
-import { config, request, permission, util } from 'utils';
-import { BrowserRouter  as Router } from 'react-router-dom'
-import { Provider } from 'react-redux'
-// import store from './store'
- 
-import ReactDOM from 'react-dom'; 
-
-
-
-const { ClientIdCms,ClientSecretCms } = config
 
 class Index extends Component {
-    constructor(props) {
-        super(props)
-        this.state = {
-            token: null
-        }
-    }
-    getUpdateToken = (value) => {
-        let user = util.auth.getUser();
-        if (!user) {
-            util.auth.removeToken();
-        }
-        let data = {};
-        data['client_id'] = ClientIdCms;
-        data['client_secret'] = ClientSecretCms;
-        data['applicationKey'] = 'wechatcp';
-        data['grant_type'] = "client_credentials";
-        let strData = qs.stringify(data);
-
-        request({
-            url: config.api.getOperationToken,
-            method: 'post',
-            data: strData,
-            dataHeader: { headers: { 'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8' } }
-        }).then((data) => {
-            if (data.success) {
-                var user = util.auth.getUser();
-                if (user) {
-                    util.auth.setUser(user);
-                }
-                util.auth.setToken(data.result.access_token);
-                this.setState({ token: data.result.access_token })
-            } else {
-                util.auth.removeToken();
-            }
-        });
-    }
-    componentWillMount() {
-        this.getUpdateToken();
-    }
     render() {
-        return  this.state.token ?  <HomeContent /> : <div /> ;
-        // return <div></div>
+        return <HomeContent />
     }
 }
-
 export default Index;
-
-
-
-// ReactDOM.render(  
-// <Router basename="/app/"> 
-// <Index />  
-// </Router> , document.getElementById('root'));
- 

+ 8 - 2
src/pages/viewHome/productDetails/index.js

@@ -26,10 +26,16 @@ class TabsList extends Component {
             deep: [],
             classList: [],
             deepList: [],
-            showModal:false
+            showModal:false,
+            columnId:""
         }
     }
     componentDidMount() {
+        const columnId = this.props.location.query.columnId
+        console.log(columnId,'我是详情页');
+        this.setState({
+            columnId:columnId
+        })
         this.props.history.listen(route => {
             if (route.pathname == "/viewHome/productDetails" && !route.query.code) {
                 this.setState({
@@ -277,7 +283,7 @@ class TabsList extends Component {
                 </div>
 
                 <div className={styles.hotClass} style={{ display: this.state.pameDate.length <= 0 ? "block" : "none" }}>热词搜索</div>
-                <ProductListSeach  pathname={this.state.pathname} queryAllSearchTerms={this.state.queryAllSearchTerms} pameDate={this.state.pameDate}></ProductListSeach>
+                <ProductListSeach  pathname={this.state.pathname} queryAllSearchTerms={this.state.queryAllSearchTerms} pameDate={this.state.pameDate} columnId={this.state.columnId}></ProductListSeach>
             </div>
         )
     }

+ 1 - 1
src/pages/viewHome/productList/productListSeach.js

@@ -73,7 +73,7 @@ class productListSeach extends Component {
         })
     }
     onClickRouter = (path) => {
-        router.push({ pathname: '/viewHome/contentDetails', query: { articleId: path.articleId } })
+        router.push({ pathname: '/viewHome/contentDetails', query: { articleId: path.articleId,columnId:this.props.columnId } })
     }
     render() {
         const { TabPane } = Tabs;