diff --git a/build-site/src/actions/goods.js b/build-site/src/actions/goods.js
index 484bab5..d668f76 100644
--- a/build-site/src/actions/goods.js
+++ b/build-site/src/actions/goods.js
@@ -3,6 +3,7 @@ import goodService from '../service/goodService'
// Action Type
const FETCH_GOOD = 'FETCH_GOOD'
+const RECEIVE_GOOD = 'RECEIVE_GOOD'
const ADD_GOOD = 'ADD_GOOD'
const DEL_GOOD = 'DEL_GOOD'
@@ -10,15 +11,25 @@ const DEL_GOOD = 'DEL_GOOD'
if(!sessionStorage) sessionStorage=window;
+const receiveGood=(type,goods) =>({
+ type:RECEIVE_GOOD,
+ payload: { goods, qryType: type ,isFetching:false}
+
+})
+
const fetchGood = (type, dispatch) => {
+ dispatch({
+ type: FETCH_GOOD,
+ payload: { goods:[], qryType: type ,isFetching:true}
+ })
goodService.query(type, (goods) => {
sessionStorage[type] = JSON.stringify(goods);
- dispatch({
- type: FETCH_GOOD,
- payload: { goods, qryType: type }
- })
+ dispatch(receiveGood(type,goods))
+
})
}
+
+
// 设计一次查询所有商品时,前端sessionStorage保存,查询其他类别不走请求
const queryList = type => dispatch => {
if (!sessionStorage[type]) {
@@ -26,10 +37,7 @@ const queryList = type => dispatch => {
} else {
let goods=sessionStorage[type] && JSON.parse(sessionStorage[type]);
if (goods && goods.length) {
- dispatch({
- type: FETCH_GOOD,
- payload: { goods, qryType: type }
- })
+ dispatch(receiveGood(type,goods))
}
}
}
@@ -46,5 +54,6 @@ export default {
// 故在此直接给出处理逻辑
// ================================
export const ACTION_HANDLERS = {
- [FETCH_GOOD]: (goods, {payload}) => payload
+ [FETCH_GOOD]: (goods, {payload}) => payload,
+ [RECEIVE_GOOD]: (goods, {payload}) => payload
}
\ No newline at end of file
diff --git a/build-site/src/components/common/CircleLoading.js b/build-site/src/components/common/CircleLoading.js
new file mode 100644
index 0000000..7f9705e
--- /dev/null
+++ b/build-site/src/components/common/CircleLoading.js
@@ -0,0 +1,21 @@
+/**
+ * Created by giscafer on 2017/3/5.
+ */
+
+import React from 'react';
+import getSize from '../../utils/getSize'
+
+// const {windowH,windowW} = getSize()
+const style = {
+ display:'block',
+ color:'red',
+ width:'100%',
+ textAlign:'center',
+ margin:'30px auto'
+
+}
+const CircleLoading = () => (
+
加载中……
+);
+
+export default CircleLoading;
\ No newline at end of file
diff --git a/build-site/src/components/common/header/Header.css b/build-site/src/components/common/header/Header.css
index cfdfabe..a42e9c8 100644
--- a/build-site/src/components/common/header/Header.css
+++ b/build-site/src/components/common/header/Header.css
@@ -53,6 +53,7 @@ a {
}
.navbar-nav {
+ position: relative;
display: inline-block;
margin: 0;
padding: 0;
@@ -80,8 +81,9 @@ a {
.navbar-nav li span {
cursor: pointer;
}
+
.navbar-nav li.selected {
- height:50px;
+ height: 50px;
background-color: #5e5e5e;
padding: 0 10px;
border-bottom: 2px solid #fff;
@@ -90,9 +92,11 @@ a {
.navbar-nav li span:hover {
color: #fff;
}
-#bs-navbar span.btn{
+
+#bs-navbar span.btn {
display: none;
}
+
/**
* 响应式
*/
@@ -101,31 +105,37 @@ a {
font-size: 1.2em;
color: #1d976c
}
- #bs-navbar .navbar-nav{
- position: relative;
- z-index: 1000;
- display: none;
+
+ #bs-navbar .navbar-nav {
+ display: none;
+ position: relative;
+ z-index: 1000;
+ width: 100%;
}
+
/*#bs-navbar span:hover ~ ul{*/
- /*display: block;*/
+ /*display: block;*/
/*}*/
#bs-navbar .navbar-nav li {
clear: both;
border-top: 1px solid #ddd;
background-color: #2d3e4d;
- width:100%;
- margin:0;
+ width: 100%;
+ margin: 0;
}
- #bs-navbar span.btn{
- display:inline;
+
+ #bs-navbar span.btn {
+ display: inline;
line-height: 50px;
}
- .menu-btn:hover ~ #bs-navbar .navbar-nav{
+
+ .menu-btn:hover ~ #bs-navbar .navbar-nav {
display: block;
}
+
#bs-navbar .navbar-nav li.selected {
padding: 0;
- border:none;
+ border: none;
}
}
diff --git a/build-site/src/components/common/header/Header.jsx b/build-site/src/components/common/header/Header.jsx
index 57339e7..ef756cb 100644
--- a/build-site/src/components/common/header/Header.jsx
+++ b/build-site/src/components/common/header/Header.jsx
@@ -1,8 +1,9 @@
import React from 'react'
-import './Header.css'
-export default class Header extends React.Component{
+import getSize from '../../../utils/getSize';
+import './Header.css';
+export default class Header extends React.Component {
- constructor(){
+ constructor() {
super()
this.displayValue = 'none';
}
@@ -10,16 +11,25 @@ export default class Header extends React.Component{
/**
* 菜单绑定事件
*/
- menuClickHandler() {
- if(this.displayValue==='block'){
- this.displayValue='none';
- }else{
- this.displayValue='block';
+ menuClickHandler(e) {
+ let block='inline-block';
+ const {windowW} = getSize();
+ if(windowW<800){
+ block='block';
}
- this.refs.myMenu.style.display=this.displayValue;
+
+ if (e && e.target && e.target.nodeName === 'SPAN' && block!=='block') {
+ return;
+ }
+ if (this.displayValue === block) {
+ this.displayValue = 'none';
+ } else {
+ this.displayValue = block;
+ }
+ this.refs.myMenu.style.display = this.displayValue;
}
- render(){
+ render() {
let {onFilterClick, filterType}=this.props;
return (
@@ -29,21 +39,39 @@ export default class Header extends React.Component{
百度前端技术学院demo
- this.menuClickHandler()}>
-
菜单
-
+
+
this.menuClickHandler()}>菜单
+
- onFilterClick('XIAOWEI')}>小薇学院
+ onClick={(e) => {
+ this.menuClickHandler(e);
+ onFilterClick('XIAOWEI')
+ }}>小薇学院
- onFilterClick('BINBIN')}>斌斌学院
+ onClick={(e) => {
+ this.menuClickHandler(e);
+ onFilterClick('BINBIN')
+ }}>斌斌学院
- onFilterClick('YAOYAO')}>耀耀学院
+ onClick={() => {
+ this.menuClickHandler();
+ onFilterClick('YAOYAO')
+ }}>耀耀学院
- onFilterClick('BUSINESS')}>商业平台学院
+ onClick={() => {
+ this.menuClickHandler();
+ onFilterClick('BUSINESS')
+ }}>商业平台学院
- onFilterClick('ECHARTSVR')}>Echarts & WebVR
+ onClick={() => {
+ this.menuClickHandler();
+ onFilterClick('ECHARTSVR')
+ }}>Echarts & WebVR
- onFilterClick('NUOMI')}>百度糯米学院
+ onClick={() => {
+ this.menuClickHandler();
+ onFilterClick('NUOMI')
+ }}>百度糯米学院
diff --git a/build-site/src/components/goods/GoodList.css b/build-site/src/components/goods/GoodList.css
index 01300fe..cf97c25 100644
--- a/build-site/src/components/goods/GoodList.css
+++ b/build-site/src/components/goods/GoodList.css
@@ -4,6 +4,23 @@
margin-bottom: 80px;
margin-top:250px;
}
+@media screen and (min-width: 1400px) {
+ .main-container {
+ min-width: 1170px;
+ }
+}
+
+@media screen and (min-width: 1200px) {
+ .main-container {
+ min-width: 1170px;
+ }
+}
+
+@media screen and (min-width: 992px) {
+ .main-container {
+ min-width: 970px;
+ }
+}
.good-column{
display: -webkit-flex; /* Safari */
display: flex;
diff --git a/build-site/src/components/goods/GoodList.jsx b/build-site/src/components/goods/GoodList.jsx
index dbec162..95fdae7 100644
--- a/build-site/src/components/goods/GoodList.jsx
+++ b/build-site/src/components/goods/GoodList.jsx
@@ -1,15 +1,18 @@
import React from 'react'
import Good from './Good';
+import CircleLoading from '../common/CircleLoading';
import './GoodList.css';
-export default ({goods=[]})=>{
+export default ({goods = []}) => {
return (
- {
- goods.map((good,index)=>{
- return
+ {goods.length === 0 && }
+ {goods.length !== 0 &&
+ goods.map((good, index) => {
+ return
})
}
+
)
}
\ No newline at end of file
diff --git a/build-site/src/stores/initState.js b/build-site/src/stores/initState.js
index c97c0c4..b080b8e 100644
--- a/build-site/src/stores/initState.js
+++ b/build-site/src/stores/initState.js
@@ -5,6 +5,7 @@
export default {
good:{
goods:[],
- goodType:''
+ goodType:'',
+ isFetching:false
}
}
\ No newline at end of file
diff --git a/build-site/src/utils/getSize.js b/build-site/src/utils/getSize.js
new file mode 100644
index 0000000..a3d2ec4
--- /dev/null
+++ b/build-site/src/utils/getSize.js
@@ -0,0 +1,14 @@
+/**
+ * Created by giscafer on 2017/3/5.
+ */
+const getSize = () => {
+ let windowW,windowH,contentH,contentW,scrollT;
+ windowH = window.innerHeight;
+ windowW = window.innerWidth;
+ scrollT = document.documentElement.scrollTop || document.body.scrollTop;
+ contentH = (document.documentElement.scrollHeight > document.body.scrollHeight) ? document.documentElement.scrollHeight : document.body.scrollHeight;
+ contentW = (document.documentElement.scrollWidth > document.body.scrollWidth) ? document.documentElement.scrollWidth : document.body.scrollWidth;
+ return {windowW,windowH,contentH,contentW,scrollT}
+}
+
+export default getSize;
\ No newline at end of file
diff --git "a/\346\226\214\346\226\214\345\255\246\351\231\242/\344\273\273\345\212\241\344\272\224\357\274\232\345\237\272\347\241\200JavaScript\347\273\203\344\271\240\357\274\210\344\272\214\357\274\211/index.html" "b/\346\226\214\346\226\214\345\255\246\351\231\242/\344\273\273\345\212\241\344\272\224\357\274\232\345\237\272\347\241\200JavaScript\347\273\203\344\271\240\357\274\210\344\272\214\357\274\211/index.html"
index e5f6a94..f02943e 100644
--- "a/\346\226\214\346\226\214\345\255\246\351\231\242/\344\273\273\345\212\241\344\272\224\357\274\232\345\237\272\347\241\200JavaScript\347\273\203\344\271\240\357\274\210\344\272\214\357\274\211/index.html"
+++ "b/\346\226\214\346\226\214\345\255\246\351\231\242/\344\273\273\345\212\241\344\272\224\357\274\232\345\237\272\347\241\200JavaScript\347\273\203\344\271\240\357\274\210\344\272\214\357\274\211/index.html"
@@ -2,7 +2,7 @@
- IFE JavaScript Task 02
+ 任务五:基础JavaScript练习(二)
diff --git "a/\346\226\214\346\226\214\345\255\246\351\231\242/\344\273\273\345\212\241\345\233\233\357\274\232\345\237\272\347\241\200JavaScript\347\273\203\344\271\240\357\274\210\344\270\200\357\274\211/index.html" "b/\346\226\214\346\226\214\345\255\246\351\231\242/\344\273\273\345\212\241\345\233\233\357\274\232\345\237\272\347\241\200JavaScript\347\273\203\344\271\240\357\274\210\344\270\200\357\274\211/index.html"
index df6b46b..a36ed0e 100644
--- "a/\346\226\214\346\226\214\345\255\246\351\231\242/\344\273\273\345\212\241\345\233\233\357\274\232\345\237\272\347\241\200JavaScript\347\273\203\344\271\240\357\274\210\344\270\200\357\274\211/index.html"
+++ "b/\346\226\214\346\226\214\345\255\246\351\231\242/\344\273\273\345\212\241\345\233\233\357\274\232\345\237\272\347\241\200JavaScript\347\273\203\344\271\240\357\274\210\344\270\200\357\274\211/index.html"
@@ -2,7 +2,7 @@
-
IFE JavaScript Task 02
+ 任务四:基础JavaScript练习(一)