From 297db293f4e09df3f642547cc86bf2dee9aa17f2 Mon Sep 17 00:00:00 2001 From: Guan Guan Date: Wed, 17 Aug 2016 20:26:46 +0800 Subject: [PATCH] =?UTF-8?q?=E9=87=8D=E5=91=BD=E5=90=8Dsku=E4=B8=BAtoy?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .jshintrc | 7 + src/index.html | 11 +- src/less/draft.less | 223 -------- src/less/main.less | 495 ------------------ src/oldHtml.html | 75 --- .../actions/{skuAction.js => toyAction.js} | 60 +-- src/scripts/app.js | 8 +- src/scripts/components/App/App.jsx | 2 +- src/scripts/components/PostList/PostList.jsx | 26 +- .../components/PostPanel/PostPanel.jsx | 20 +- src/scripts/components/SkuList/index.js | 18 +- .../SkuList.jsx => ToyList/ToyList.jsx} | 58 +- src/scripts/components/ToyList/index.js | 23 + .../components/{editsku.jsx => edittoy.jsx} | 10 +- src/scripts/reducers/skuReducer.js | 46 -- src/scripts/reducers/toyReducer.js | 46 ++ src/scripts/routes.js | 12 +- src/scripts/store.js | 6 +- 18 files changed, 190 insertions(+), 956 deletions(-) create mode 100644 .jshintrc delete mode 100644 src/less/draft.less delete mode 100644 src/less/main.less delete mode 100644 src/oldHtml.html rename src/scripts/actions/{skuAction.js => toyAction.js} (70%) rename src/scripts/components/{SkuList/SkuList.jsx => ToyList/ToyList.jsx} (73%) create mode 100644 src/scripts/components/ToyList/index.js rename src/scripts/components/{editsku.jsx => edittoy.jsx} (97%) delete mode 100644 src/scripts/reducers/skuReducer.js create mode 100644 src/scripts/reducers/toyReducer.js diff --git a/.jshintrc b/.jshintrc new file mode 100644 index 0000000..59cd9fc --- /dev/null +++ b/.jshintrc @@ -0,0 +1,7 @@ +{ + "node": true, + "browser": true, + "esnext": true, + "newcap": false, + "asi": true +} diff --git a/src/index.html b/src/index.html index 2de80cf..36d0e13 100644 --- a/src/index.html +++ b/src/index.html @@ -10,13 +10,10 @@ Play玩具控 - Dashboard - - - - + + + +
diff --git a/src/less/draft.less b/src/less/draft.less deleted file mode 100644 index 593824c..0000000 --- a/src/less/draft.less +++ /dev/null @@ -1,223 +0,0 @@ -.edit-section { - padding-top: 10px; - padding-bottom: 10px; -} - -.edit-section .insert-window { - position: relative;; - left: 20%; - bottom: 200px; - background-color: #fff; - border: 1px solid #ddd; - width: 60%; - min-height: 200px; - z-index: 1000; - - -webkit-box-shadow: 0 10px 16px 0 rgba(0,0,0,0.2),0 6px 20px 0 rgba(0,0,0,0.19); - -moz-box-shadow: 0 10px 16px 0 rgba(0,0,0,0.2),0 6px 20px 0 rgba(0,0,0,0.19); - box-shadow: 0 10px 16px 0 rgba(0,0,0,0.2),0 6px 20px 0 rgba(0,0,0,0.19); - - .close { - cursor:pointer; - } - - .video-code { - width: 100%; - height: auto; - } - - .modal-body { - max-height: 400px; - overflow: auto; - float: left; - } -} - -.edit-section { - .gallery-image { - float: left; - margin-right: 10px; - margin-bottom: 10px; - img { - width: 100px; - height: 100px; - object-fit: cover; - border: 2px solid #fff; - } - img:hover { - border: 2px solid #40E837; - } - } - .dropzone { - border-width: 2px; - border-color: black; - border-style: dashed; - border-radius: 4px; - font-size: 12px; - font-weight: bold; - padding: 15px; - width: 100px; - height: 100px; - font-size: - transition: all 0.5s; - } - .cover-img { - width: auto; - height: 100px; - object-fit: cover; - border: 2px solid #fff; - } -} - - -.RichEditor-root { - background: #fff; - border: 1px solid #ddd; - font-family: 'Georgia', serif; - font-size: 14px; - padding: 15px; -} - -.RichEditor-editor { - cursor: text; - font-size: 16px; -} - -.DraftEditor-root { - border-bottom: 1px solid #ddd; - padding-bottom: 15px; - margin-bottom: 10px; -} - -.RichEditor-editor .public-DraftEditorPlaceholder-root, -.RichEditor-editor .public-DraftEditor-content { - margin: 0 -15px -15px; - padding: 15px; -} - -.RichEditor-editor .public-DraftEditor-content { - min-height: 100px; -} - -.RichEditor-hidePlaceholder .public-DraftEditorPlaceholder-root { - display: none; -} - -.RichEditor-editor .RichEditor-blockquote { - border-left: 5px solid #eee; - color: #666; - font-family: 'Hoefler Text', 'Georgia', serif; - font-style: italic; - margin: 16px 0; - padding: 10px 20px; -} - -.RichEditor-editor .public-DraftStyleDefault-pre { - background-color: rgba(0, 0, 0, 0.05); - font-family: 'Inconsolata', 'Menlo', 'Consolas', monospace; - font-size: 16px; - padding: 20px; -} - -.RichEditor-controls { - font-family: 'Helvetica', sans-serif; - font-size: 14px; - margin-bottom: 5px; - user-select: none; - display: inline-block; -} - -.RichEditor-controls-btn { - font-size: 14px; - margin-bottom: 5px; - user-select: none; - display: inline-block; - margin-left: 5px; - margin-right: 5px; - cursor: pointer; -} - -.RichEditor-styleButton { - color: #999; - cursor: pointer; - margin-right: 4px; - display: inline-block; - border: 1px solid #fff; - border-radius: 3px; - width: 30px; - height: 30px; - text-align: center; - line-height: 30px; -} - -.RichEditor-styleButton::before { - line-height: 30px; -} - -.RichEditor-activeButton { - color: #5890ff; - border: 1px solid #5890ff; -} - -// -.DraftEditor-editorContainer,.DraftEditor-root,.public-DraftEditor-content{height:inherit;text-align:initial}.DraftEditor-root{position:relative}.DraftEditor-editorContainer{background-color:rgba(255,255,255,0);border-left:.1px solid transparent;position:relative;z-index:1}.public-DraftEditor-block{position:relative}.DraftEditor-alignLeft .public-DraftStyleDefault-block{text-align:left}.DraftEditor-alignLeft .public-DraftEditorPlaceholder-root{left:0;text-align:left}.DraftEditor-alignCenter .public-DraftStyleDefault-block{text-align:center}.DraftEditor-alignCenter .public-DraftEditorPlaceholder-root{margin:0 auto;text-align:center;width:100%}.DraftEditor-alignRight .public-DraftStyleDefault-block{text-align:right}.DraftEditor-alignRight .public-DraftEditorPlaceholder-root{right:0;text-align:right}.public-DraftEditorPlaceholder-root{color:#9197a3;position:absolute;z-index:0}.public-DraftEditorPlaceholder-hasFocus{color:#bdc1c9}.DraftEditorPlaceholder-hidden{display:none}.public-DraftStyleDefault-block{position:relative;white-space:pre-wrap}.public-DraftStyleDefault-ltr{direction:ltr;text-align:left}.public-DraftStyleDefault-rtl{direction:rtl;text-align:right}.public-DraftStyleDefault-listLTR{direction:ltr}.public-DraftStyleDefault-listRTL{direction:rtl}.public-DraftStyleDefault-ol,.public-DraftStyleDefault-ul{margin:16px 0;padding:0}.public-DraftStyleDefault-depth0.public-DraftStyleDefault-listLTR{margin-left:1.5em}.public-DraftStyleDefault-depth0.public-DraftStyleDefault-listRTL{margin-right:1.5em}.public-DraftStyleDefault-depth1.public-DraftStyleDefault-listLTR{margin-left:3em}.public-DraftStyleDefault-depth1.public-DraftStyleDefault-listRTL{margin-right:3em}.public-DraftStyleDefault-depth2.public-DraftStyleDefault-listLTR{margin-left:4.5em}.public-DraftStyleDefault-depth2.public-DraftStyleDefault-listRTL{margin-right:4.5em}.public-DraftStyleDefault-depth3.public-DraftStyleDefault-listLTR{margin-left:6em}.public-DraftStyleDefault-depth3.public-DraftStyleDefault-listRTL{margin-right:6em}.public-DraftStyleDefault-depth4.public-DraftStyleDefault-listLTR{margin-left:7.5em}.public-DraftStyleDefault-depth4.public-DraftStyleDefault-listRTL{margin-right:7.5em}.public-DraftStyleDefault-unorderedListItem{list-style-type:square;position:relative}.public-DraftStyleDefault-unorderedListItem.public-DraftStyleDefault-depth0{list-style-type:disc}.public-DraftStyleDefault-unorderedListItem.public-DraftStyleDefault-depth1{list-style-type:circle}.public-DraftStyleDefault-orderedListItem{list-style-type:none;position:relative}.public-DraftStyleDefault-orderedListItem.public-DraftStyleDefault-listLTR:before{left:-36px;position:absolute;text-align:right;width:30px}.public-DraftStyleDefault-orderedListItem.public-DraftStyleDefault-listRTL:before{position:absolute;right:-36px;text-align:left;width:30px}.public-DraftStyleDefault-orderedListItem:before{content:counter(ol0) ". ";counter-increment:ol0}.public-DraftStyleDefault-orderedListItem.public-DraftStyleDefault-depth1:before{content:counter(ol1) ". ";counter-increment:ol1}.public-DraftStyleDefault-orderedListItem.public-DraftStyleDefault-depth2:before{content:counter(ol2) ". ";counter-increment:ol2}.public-DraftStyleDefault-orderedListItem.public-DraftStyleDefault-depth3:before{content:counter(ol3) ". ";counter-increment:ol3}.public-DraftStyleDefault-orderedListItem.public-DraftStyleDefault-depth4:before{content:counter(ol4) ". ";counter-increment:ol4}.public-DraftStyleDefault-depth0.public-DraftStyleDefault-reset{counter-reset:ol0}.public-DraftStyleDefault-depth1.public-DraftStyleDefault-reset{counter-reset:ol1}.public-DraftStyleDefault-depth2.public-DraftStyleDefault-reset{counter-reset:ol2}.public-DraftStyleDefault-depth3.public-DraftStyleDefault-reset{counter-reset:ol3}.public-DraftStyleDefault-depth4.public-DraftStyleDefault-reset{counter-reset:ol4} - - -// -.title-input { - background-color: #fff; - border: 1px solid #ccc; - overflow: hidden; - padding-left: 5px; - padding-top: 5px; - width: 100%; - line-height: 30px; - font-size: 20px; - font-weight: 300; -} - -// tags-input -.react-tagsinput { - background-color: #fff; - border: 1px solid #ccc; - overflow: hidden; - padding-left: 5px; - padding-top: 5px; -} - -.react-tagsinput-tag { - background-color: #cde69c; - border-radius: 2px; - border: 1px solid #a5d24a; - color: #638421; - display: inline-block; - font-family: sans-serif; - font-size: 13px; - font-weight: 400; - margin-bottom: 5px; - margin-right: 5px; - padding: 5px; -} - -.react-tagsinput-remove { - cursor: pointer; - font-weight: bold; -} - -.react-tagsinput-tag a::before { - content: " x"; -} - -.react-tagsinput-input { - background: transparent; - border: 0; - color: #777; - font-family: sans-serif; - font-size: 13px; - font-weight: 400; - margin-bottom: 6px; - margin-top: 1px; - outline: none; - padding: 5px; - width: 80px; -} diff --git a/src/less/main.less b/src/less/main.less deleted file mode 100644 index 143bf00..0000000 --- a/src/less/main.less +++ /dev/null @@ -1,495 +0,0 @@ -body { - background: #fafafa; - font-family: system, -apple-system, ".SFNSDisplay-Regular", "Helvetica Neue", Helvetica, Arial, sans-serif; - color: #333; -} - -html, body { - height: 100%; -} - -.content-wrapper { - background-color: #fafafa; -} - -.fluid-container { - .row { - margin-left: 0; - margin-right: 0; - } -} - -.main { - padding-top: 80px; -} - -.footer { - bottom: 0; - margin-top: 20px; - width: 100%; - height: 60px; - background-color: #f5f5f5; -} - -.wrap { - min-height: 100%; - height: auto; - margin: 0 auto -60px; -} - -.wrap > .container { - padding: 70px 15px 20px; -} - -.col { - padding-right:5px; - padding-left:5px; -} - -.footer { - height: 60px; - background-color: #f5f5f5; - border-top: 1px solid #ddd; - padding-top: 20px; -} - -.jumbotron { - text-align: center; - background-color: transparent; -} - -.jumbotron .btn { - font-size: 21px; - padding: 14px 24px; -} - -.not-set { - color: #c55; - font-style: italic; -} - -// New version -////////////// - -// panel ... -.no-padding { - padding: 0; -} - -.no-top-padding { - padding-top: 0; - padding-bottom: 0; -} - -.panel-video { - position:absolute; - height:100%; - width:100%; - overflow: hidden; -} - -video { - width: 100% !important; - height: auto !important; -} - -.panel-photos-wrapper { - width: 100%; - height: 0; - padding-bottom: 100%; - overflow: hidden; -} -.panel-photos-big { - object-fit: cover; - max-height: 300px; - width: 100%; -} -.panel-photos-small { - object-fit: cover; - max-height: 100px; - padding: 2px 2px 2px 0; -} -.panel-photos div { - width: 12.5%; - height: 0; - padding-bottom: 12.5%; - overflow: hidden; - display: inline; -} -.panel-photos img { - object-fit: cover; - width: 100% !important; - height: auto !important; - display: inline; -} -// panel end... - -.toy-item .products-list .product-img img { - width: 100px; - height: 100px; - object-fit: cover; - object-position: 0px 0px; -} - -.toy-item .products-list .product-info { - margin-left: 110px; -} - -.products-list .product-title { - white-space: nowrap; - text-overflow: ellipsis; - overflow: hidden; -} - -.toy-item .products-list .product-title { - white-space: nowrap; - text-overflow: ellipsis; - word-break: break-all; - overflow: hidden; - line-height: 1.1em; - height: 2.2em; -} - -.label { - font-size: 100% !important; - a { - color: #fff; - cursor: pointer; - } - a:visited { - color: #fff; - } - i { - cursor: pointer; - } -} - -.tag-info { - color: #999; - font-size: 12px; -} - -.box-footer a { - color: #333; -} - -.label-margin { - margin: 3px; - display: inline-block; -} - -.pl-form { - margin: 10px 50px; -} - -.ql-toolbar-container { - border-bottom: 1px solid #ccc; - padding: 5px 12px; -} - -.alloyeditor-container { - padding: 10px; - margin: 10px; -} - -////////////// - - -/* add sorting icons to gridview sort links */ -a.asc:after, a.desc:after { - position: relative; - top: 1px; - display: inline-block; - font-family: 'Glyphicons Halflings'; - font-style: normal; - font-weight: normal; - line-height: 1; - padding-left: 5px; -} - -a.asc:after { - content: /*"\e113"*/ "\e151"; -} - -a.desc:after { - content: /*"\e114"*/ "\e152"; -} - -.sort-numerical a.asc:after { - content: "\e153"; -} - -.sort-numerical a.desc:after { - content: "\e154"; -} - -.sort-ordinal a.asc:after { - content: "\e155"; -} - -.sort-ordinal a.desc:after { - content: "\e156"; -} - -.grid-view th { - white-space: nowrap; -} - -.hint-block { - display: block; - margin-top: 5px; - color: #999; -} - -.error-summary { - color: #a94442; - background: #fdf7f7; - border-left: 3px solid #eed3d7; - padding: 10px 20px; - margin: 0 0 15px 0; -} - -.table > tbody > tr > td { - vertical-align: middle; -} - -.post-panel { - - .post-heading { - padding:0; - background-color: #fdfdfd; - } - - .post-heading>a { - display: block; - padding: 0 10px; - clear: both; - font-weight: 400; - line-height: 1.42857143; - color: #333; - white-space: nowrap - } - - .post-heading>a:focus,.post-heading>a:hover { - color: #262626; - text-decoration: none; - background-color: #f5f5f5; - } - -} - -.post-caption { - padding: 5px; - .post-caption-btn { - // margin-right: 2px; - } -} - -.post-image { - position: relative; - /*padding: 2px;*/ - img { - width: 100% !important; - display: block !important; - } -} - -.image-modal { - max-width: 100%; -} - -.media, .media-body { - overflow: hidden; - zoom: 1; -} - -.media .media-object { - margin: 5px 0 5px 0; -} - -.media .post-user-info { - padding: 10px 5px 10px 0; - width: 60%; - .block { - display: block; - white-space: nowrap; - overflow: hidden; - text-overflow: ellipsis; - margin: 0; - } - .text-muted { - } -} - -.thumb { - display: inline-block; -} - -.post-summary { - padding: 0 0 15px 15px; -} - -.user-profile { - display: inline-block; - color: #979898; - vertical-align: middle; - padding: 0 0 0 10px; -} - -.user-profile h2 { - margin-top: 5px; - margin-bottom: 0px; -} - -img.img-corona { - -webkit-box-shadow: 0 0 0 4px rgba(221,221,221,.3); - -moz-box-shadow: 0 0 0 4px rgba(221,221,221,.3); - box-shadow: 0 0 0 4px rgba(221,221,221,.3); -} - -.user-info { - -} - -.publish-btn { - padding-top: 28px; -} - -.empty { - padding:15px; -} - -.post-pagination { - padding-right:15px; -} - -.post-image .thumb-pane { - position: absolute; - bottom: 40px; - width: 100%; - opacity: 0.6; - background-color: #000; - - .post-mark-li { - cursor: pointer; - } - .liked { - background-color: #ff442c; - border-radius: 2px; - } -} - -.post-panel:hover .thumb-pane { - opacity: 0.8; -} - -.thumb-pane ul { - list-style: none; - padding: 0; -} - -.thumb-pane ul li { - float: left; - padding: 3px; - margin: 5px; - color: #fff; - font-size: 14px; - font-weight: normal; -} - -.thumbnail-text p { - margin: 0; -} - -.post-info { - display: inline-block; - color: #979898; - vertical-align: middle; - padding: 0 0 0 10px; -} - -.post-info .glyphicon { - font-size: 18px; -} - -.load-more-btn { - text-align: center; - margin: auto; - width: 350px; - border: 1px solid #dddddd; - padding: 20px 40px; - cursor: pointer; -} - -.tag-panel { - .panel-heading { - padding: 5px; - } - .panel-body { - padding: 0; - } -} - -.tag-add-btn { - padding: 5px; - margin-left: 5px; -} - -.tag-btn { - margin: 5px; - padding: 5px 10px; - font-size: 12px; - line-height: 1.5; - border-radius: 5px; -} - -.browsehappy { - margin: 0.2em 0; - background: #ccc; - color: #000; - padding: 0.2em 0; -} - -.nav-tabs-custom .nav-tabs { - margin: 0; - border-bottom-color: #f4f4f4; - border-top-right-radius: 3px; - border-top-left-radius: 3px; -} -.nav-tabs-custom .nav-tabs>li:first-of-type { - margin-left: 0; -} -.nav-tabs-custom .nav-tabs>li.active { - border-top-color: #3c8dbc; -} -.nav-tabs-custom .nav-tabs>li { - border-top: 3px solid transparent; - margin-bottom: -2px; - margin-right: 5px; -} -.nav-tabs-custom .nav-tabs>li:first-of-type.active>a { - border-left-color: transparent; -} -.nav-tabs-custom .nav-tabs>li.active>a { - border-top-color: transparent; - border-left-color: #f4f4f4; - border-right-color: #f4f4f4; -} -.nav-tabs-custom .nav-tabs>li.active>a, .nav-tabs-custom .nav-tabs>li.active:hover>a { - background-color: #fff; - color: #444; -} -.nav-tabs-custom .nav-tabs>li>a, .nav-tabs-custom .nav-tabs>li>a:hover { - background: transparent; - margin: 0; -} -.nav-tabs-custom .nav-tabs>li>a { - color: #444; - border-radius: 0; -} -.nav-tabs-custom .nav-tabs>li:not(.active)>a { - border: none; -} - - -@import "draft.less"; diff --git a/src/oldHtml.html b/src/oldHtml.html deleted file mode 100644 index b242fa7..0000000 --- a/src/oldHtml.html +++ /dev/null @@ -1,75 +0,0 @@ - - - - - - - - - - Play玩具控 - Dashboard - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - diff --git a/src/scripts/actions/skuAction.js b/src/scripts/actions/toyAction.js similarity index 70% rename from src/scripts/actions/skuAction.js rename to src/scripts/actions/toyAction.js index bbbca08..fba20f7 100644 --- a/src/scripts/actions/skuAction.js +++ b/src/scripts/actions/toyAction.js @@ -1,22 +1,22 @@ import Request from 'superagent' -export const SKL_RECEIVE_SKU = 'SKL_RECEIVE_SKU' -export const SKL_RECEIVE_SKU_NEW = 'SKL_RECEIVE_SKU_NEW' +export const SKL_RECEIVE_TOY = 'SKL_RECEIVE_TOY' +export const SKL_RECEIVE_TOY_NEW = 'SKL_RECEIVE_TOY_NEW' export const SKL_TOGGLE_R18 = 'SKL_TOGGLE_R18' export const SKL_TOGGLE_RECOMMEND = 'SKL_TOGGLE_RECOMMEND' -export const SKL_DELETE_SKU = 'SKL_DELETE_SKU' -export const SKL_ADD_SKU = 'SKL_ADD_SKU' +export const SKL_DELETE_TOY = 'SKL_DELETE_TOY' +export const SKL_ADD_TOY = 'SKL_ADD_TOY' -function receiveSku(res) { +function receiveToy(res) { return { - type: SKL_RECEIVE_SKU, + type: SKL_RECEIVE_TOY, res } } -function receiveSkuNew(res) { +function receiveToyNew(res) { return { - type: SKL_RECEIVE_SKU_NEW, + type: SKL_RECEIVE_TOY_NEW, res } } @@ -32,27 +32,27 @@ function _toggleRecommend(id) { id } } -function _deleteSku(id) { +function _deleteToy(id) { return { - type: SKL_DELETE_SKU, + type: SKL_DELETE_TOY, id } } -function _addSku(res) { +function _addToy(res) { return { - type: SKL_ADD_SKU, + type: SKL_ADD_TOY, res } } export function toggleR18(id) { return (dispatch,getState) => { let value = null - let index = getState().skuReducer.get('skus').findIndex((item) => { + let index = getState().toyReducer.get('toys').findIndex((item) => { value = item.get('id') === id ? item.get('isR18') : null return item.get('id') === id }) Request - .post(`/api/sku/${id}/r18`) + .post(`/api/toy/${id}/r18`) .send({ r18: !value }) @@ -64,12 +64,12 @@ export function toggleR18(id) { export function toggleRecommend(id) { return (dispatch,getState) => { let value = null - let index = getState().skuReducer.get('skus').findIndex((item) => { + let index = getState().toyReducer.get('toys').findIndex((item) => { value = item.get('id') === id ? item.get('isRec') : null return item.get('id') === id }) Request - .post(`/api/sku/${id}/recommend`) + .post(`/api/toy/${id}/recommend`) .send({ recommend: !value }) @@ -78,12 +78,12 @@ export function toggleRecommend(id) { }) } } -export function deleteSku(id) { +export function deleteToy(id) { return (dispatch) => { Request - .del(`/api/sku/${id}`) + .del(`/api/toy/${id}`) .end((err,res) => { - dispatch(_deleteSku(id)) + dispatch(_deleteToy(id)) }) } } @@ -96,23 +96,23 @@ export function recommend(id) { }) } } -export function addSku() { +export function addToy() { $.ajax({ - url: '/api/sku', + url: '/api/toy', dataType: 'json', type: 'POST', context: this, success: function(data) { console.log(data); - this.skus.unshift(data); - this.trigger(this.skus); + this.toys.unshift(data); + this.trigger(this.toys); } }); return (dispatch) => { Request - .post(`/api/sku`) + .post(`/api/toy`) .end((err,res) => { - dispatch(_addSku(res.body)) + dispatch(_addToy(res.body)) }) } } @@ -123,7 +123,7 @@ const status = { page: 0, overload: false, } -export function fetchSku(filter, query, sort) { +export function fetchToys(filter, query, sort) { if (status.query !== query || status.filter !== filter || status.sort !== sort) { status.filter = filter status.query = query @@ -132,7 +132,7 @@ export function fetchSku(filter, query, sort) { status.overload = true } else { status.overload = false - } + } let params = {} if (status.page !== 0) { params.page = status.page @@ -148,11 +148,11 @@ export function fetchSku(filter, query, sort) { } return (dispatch) => { return Request - .get(`/api/skus`) + .get(`/api/toys`) .query(params) .end((err,res) => { status.page = res.body.nextPage - status.overload ? dispatch(receiveSkuNew(res.body.skus)) : dispatch(receiveSku(res.body.skus)) + status.overload ? dispatch(receiveToyNew(res.body.toys)) : dispatch(receiveToy(res.body.toys)) }) } -} \ No newline at end of file +} diff --git a/src/scripts/app.js b/src/scripts/app.js index ff9eec4..58e4fad 100644 --- a/src/scripts/app.js +++ b/src/scripts/app.js @@ -8,7 +8,7 @@ import RecommendHome from './components/recommendhome'; import ExplorePage from './components/explorepage'; import PostList from './components/postlist'; import UserList from './components/userlist'; -import SkuList from './components/skulist'; +import ToyList from './components/toylist'; import UserDetail from './components/userdetail'; import TagList from './components/taglist'; import StickerList from './components/stickerlist'; @@ -19,7 +19,7 @@ import EditShortVideo from './components/editshortvideo'; import EditSticker from './components/editsticker'; import EditStickerSet from './components/editstickerset'; import EditRecommend from './components/editrecommend'; -import EditSku from './components/editsku'; +import EditToy from './components/edittoy'; import EditArticle from './components/editarticle'; import Test from './components/test'; @@ -36,14 +36,14 @@ ReactDOM.render(( - + - + diff --git a/src/scripts/components/App/App.jsx b/src/scripts/components/App/App.jsx index f8d26a6..41df35b 100644 --- a/src/scripts/components/App/App.jsx +++ b/src/scripts/components/App/App.jsx @@ -58,7 +58,7 @@ export default class App extends Component{
  • 图片
  • 文章
  • 用户
  • -
  • 玩具
  • +
  • 玩具
  • 标签
  • 贴纸
  • diff --git a/src/scripts/components/PostList/PostList.jsx b/src/scripts/components/PostList/PostList.jsx index e000b35..53949eb 100644 --- a/src/scripts/components/PostList/PostList.jsx +++ b/src/scripts/components/PostList/PostList.jsx @@ -11,11 +11,11 @@ export default class Post extends Component{ constructor(props) { super(props) this.state = { - filter: '', - query: '', - showModal: false, - showImage: '', - selectedPost: null + filter: '', + query: '', + showModal: false, + showImage: '', + selectedPost: null } this.onChangeQuery = (e) => this.setState({ query: e.target.value }) this.onChangeFilter = (e) => this.setState({ filter: e.target.value }) @@ -63,7 +63,7 @@ export default class Post extends Component{ { this.state.selectedPost.cls.map(function(c){ return ( - this.removePostClassification( this.state.selectedPost.id, c) } className="label label-warning label-margin" >{_.isEmpty(this.props.classifications) ? c : this.props.classifications[c].name}); }, this) @@ -74,9 +74,9 @@ export default class Post extends Component{ { cls.map((c,key) => { return ( - this.setPostClassification(this.state.selectedPost.id, c.id) }>{c.name} ) }) @@ -121,16 +121,16 @@ export default class Post extends Component{ { - this.props.posts ? + this.props.posts ? this.props.posts.map(function (post) { return ( ); }, this):null - + } - +
    Load More
    @@ -146,4 +146,4 @@ export default class Post extends Component{ ) } -} \ No newline at end of file +} diff --git a/src/scripts/components/PostPanel/PostPanel.jsx b/src/scripts/components/PostPanel/PostPanel.jsx index 64423fc..d72407d 100644 --- a/src/scripts/components/PostPanel/PostPanel.jsx +++ b/src/scripts/components/PostPanel/PostPanel.jsx @@ -1,7 +1,7 @@ import React,{ Component } from 'react' import { Link } from 'react-router' import { - Col, ButtonToolbar, + Col, ButtonToolbar, } from 'react-bootstrap' import Moment from 'moment' const _ = require('lodash') @@ -9,7 +9,7 @@ const _ = require('lodash') export default class PostPanel extends Component{ constructor(props) { super(props); - + this.state = {} this.toggleRecommend = this._toggleRecommend.bind(this) this.toggleBlock = this._toggleBlock.bind(this) @@ -59,10 +59,10 @@ export default class PostPanel extends Component{ let skuDiv = '' - if (this.props.post.toys !== undefined && this.props.post.toys !== null) { + if (this.props.post.toy !== undefined && this.props.post.toy !== null) { skuDiv = ( - - {this.props.post.toys.name.substring(0, 25)+'...'} + + {this.props.post.toy.name.substring(0, 25)+'...'} ) } @@ -80,15 +80,15 @@ export default class PostPanel extends Component{ contentDiv = (
    - Photo + Photo
    { this.props.post.photos.slice(1, this.props.post.photos.length).map(function (photo, i) { return (
    - Photo
    ) }, this) @@ -115,7 +115,7 @@ export default class PostPanel extends Component{
    {this.props.post.tags.map(function (t) { - return ({t.text}{" "} this.removeTag(t.id)}>); + return ({t.text}{" "} this.removeTag(t.id)}>); },this)} {skuDiv}
    @@ -139,4 +139,4 @@ export default class PostPanel extends Component{ ) } -} \ No newline at end of file +} diff --git a/src/scripts/components/SkuList/index.js b/src/scripts/components/SkuList/index.js index 98ba200..0fe3d98 100644 --- a/src/scripts/components/SkuList/index.js +++ b/src/scripts/components/SkuList/index.js @@ -1,23 +1,23 @@ import { connect } from 'react-redux' -import SkuList from './SkuList' -import { fetchSku, recommend, toggleR18, toggleRecommend, deleteSku, addSku } from '../../actions/skuAction' +import ToyList from './ToyList' +import { fetchToy, recommend, toggleR18, toggleRecommend, deleteToy, addToy } from '../../actions/toyAction' const mapActionCreators = { - fetchSku, + fetchToy, recommend, toggleR18, toggleRecommend, - deleteSku, - addSku, + deleteToy, + addToy, } const mapStateToProps = (state) => { - const { skus } = state.skuReducer.toJS() - const loaded = state.skuReducer.get('loaded') + const { toys } = state.toyReducer.toJS() + const loaded = state.toyReducer.get('loaded') return { - skus, + toys, loaded } } -export default connect(mapStateToProps, mapActionCreators)(SkuList) \ No newline at end of file +export default connect(mapStateToProps, mapActionCreators)(ToyList) diff --git a/src/scripts/components/SkuList/SkuList.jsx b/src/scripts/components/ToyList/ToyList.jsx similarity index 73% rename from src/scripts/components/SkuList/SkuList.jsx rename to src/scripts/components/ToyList/ToyList.jsx index 3277ef4..c145247 100644 --- a/src/scripts/components/SkuList/SkuList.jsx +++ b/src/scripts/components/ToyList/ToyList.jsx @@ -5,35 +5,35 @@ import { } from 'react-bootstrap' import { Link } from 'react-router' -export default class SkuList extends Component{ +export default class toyList extends Component{ constructor(props) { super(props) - + this.state = { - filter: '', - query: '', + filter: '', + query: '', sort: 'created' } this.onChangeSort = (e) => this.setState({sort:e.target.value}) this.onChangeFilter = (e) => this.setState({filter:e.target.value}) this.onChangeQuery = (e) => this.setState({query:e.target.value}) - this.search = () => this.props.fetchSku(this.state.filter,this.state.query.trim(),this.state.sort) + this.search = () => this.props.fetchToys(this.state.filter,this.state.query.trim(),this.state.sort) this.recommend = this._recommend.bind(this) this.toggleR18 = (id) => this.props.toggleR18(id) this.toggleRecommend = (id) => this.props.toggleRecommend(id) - this.deleteSku = this._deleteSku.bind(this) - this.addSku = this._addSku.bind(this) + this.deletetoy = this._deletetoy.bind(this) + this.addtoy = this._addtoy.bind(this) } componentWillMount() { if(!this.props.loaded){ - this.props.fetchSku(this.state.filter,this.state.query.trim(),this.state.sort) + this.props.fetchToys(this.state.filter,this.state.query.trim(),this.state.sort) } } - _deleteSku(id) { - if (confirm('Delete this SKU?')) { - this.props.deleteSku(id) + _deletetoy(id) { + if (confirm('Delete this toy?')) { + this.props.deletetoy(id) } } _recommend(id) { @@ -41,9 +41,9 @@ export default class SkuList extends Component{ this.props.recommend(id) } } - _addSku() { + _addtoy() { if (confirm('创建一个新的玩具?')) { - this.props.addSku() + this.props.addtoy() } } render() { @@ -53,7 +53,7 @@ export default class SkuList extends Component{
    - + @@ -83,31 +83,31 @@ export default class SkuList extends Component{
    - {this.props.skus.map((sku) => { + {this.props.toys.map((toy) => { let recommendClass = 'btn btn-sm'; - if (sku.isRec === true) { + if (toy.isRec === true) { recommendClass = 'btn bg-orange btn-sm'; } let r18Class = 'btn btn-sm'; - if (sku.isR18 === true) { + if (toy.isR18 === true) { r18Class = 'btn bg-orange btn-sm'; } return ( - +
    • - +
      - {sku.name} + {toy.name}
      -

      {sku.name}

      +

      {toy.name}

      - {sku.company}
      - {sku.release}
      - {sku.money} + {toy.company}
      + {toy.release}
      + {toy.money}
      @@ -116,10 +116,10 @@ export default class SkuList extends Component{
    - this.recommend(sku.id) } className="btn btn-sm"> - this.toggleR18(sku.id) } className={r18Class}> - this.toggleRecommend(sku.id) } className={recommendClass}> - this.deleteSku(sku.id) } className="btn btn-sm"> + this.recommend(toy.id) } className="btn btn-sm"> + this.toggleR18(toy.id) } className={r18Class}> + this.toggleRecommend(toy.id) } className={recommendClass}> + this.deletetoy(toy.id) } className="btn btn-sm">
    @@ -134,4 +134,4 @@ export default class SkuList extends Component{ ) } -} \ No newline at end of file +} diff --git a/src/scripts/components/ToyList/index.js b/src/scripts/components/ToyList/index.js new file mode 100644 index 0000000..b71dbf8 --- /dev/null +++ b/src/scripts/components/ToyList/index.js @@ -0,0 +1,23 @@ +import { connect } from 'react-redux' +import ToyList from './ToyList' +import { fetchToys, recommend, toggleR18, toggleRecommend, deleteToy, addToy } from '../../actions/toyAction' + +const mapActionCreators = { + fetchToys, + recommend, + toggleR18, + toggleRecommend, + deleteToy, + addToy, +} + +const mapStateToProps = (state) => { + const { toys } = state.toyReducer.toJS() + const loaded = state.toyReducer.get('loaded') + return { + toys, + loaded + } +} + +export default connect(mapStateToProps, mapActionCreators)(ToyList) diff --git a/src/scripts/components/editsku.jsx b/src/scripts/components/edittoy.jsx similarity index 97% rename from src/scripts/components/editsku.jsx rename to src/scripts/components/edittoy.jsx index d44bcdd..15eda21 100644 --- a/src/scripts/components/editsku.jsx +++ b/src/scripts/components/edittoy.jsx @@ -27,7 +27,7 @@ var EditSku = React.createClass({ }; }, componentDidMount: function() { - $.get('/api/sku/'+this.props.params.id, function(data) { + $.get('/api/toy/'+this.props.params.id, function(data) { console.log(data); if (this.isMounted()) { this.refs.form.resetModel(data); @@ -49,7 +49,7 @@ var EditSku = React.createClass({ var formData = new FormData(); formData.append('file', images[0]); $.ajax({ - url : '/api/upload?key=sku/cover/'+this.props.params.id + '.jpg', + url : '/api/upload?key=toy/cover/'+this.props.params.id + '.jpg', type : 'POST', data : formData, processData: false, // tell jQuery not to process the data @@ -66,7 +66,7 @@ var EditSku = React.createClass({ var formData = new FormData(); formData.append('file', images[0]); $.ajax({ - url : '/api/upload?key=sku/img/'+this.props.params.id + '_' + (Date.now() / 1000) + '.jpg', + url : '/api/upload?key=toy/img/'+this.props.params.id + '_' + (Date.now() / 1000) + '.jpg', type : 'POST', data : formData, processData: false, // tell jQuery not to process the data @@ -116,7 +116,7 @@ var EditSku = React.createClass({ console.log(filteredModel); $.ajax({ - url: '/api/sku/'+this.props.params.id, //Server script to process data + url: '/api/toy/'+this.props.params.id, //Server script to process data type: 'POST', data: JSON.stringify(filteredModel), contentType: 'application/json; charset=utf-8', @@ -128,7 +128,7 @@ var EditSku = React.createClass({ }); }, onConfirm: function() { - this.context.router.push('/sku'); + this.context.router.push('/toy'); }, onClose: function() { this.setState({alert: false}); diff --git a/src/scripts/reducers/skuReducer.js b/src/scripts/reducers/skuReducer.js deleted file mode 100644 index 08d82eb..0000000 --- a/src/scripts/reducers/skuReducer.js +++ /dev/null @@ -1,46 +0,0 @@ -import Immutable from 'immutable' -import { - SKL_RECEIVE_SKU, SKL_RECEIVE_SKU_NEW, - SKL_TOGGLE_R18, SKL_TOGGLE_RECOMMEND, SKL_DELETE_SKU, SKL_ADD_SKU -} from '../actions/skuAction' - -export default (state = Immutable.fromJS({ skus: [], loaded:false }),action)=>{ - switch (action.type) { - case SKL_RECEIVE_SKU: - return state.updateIn(['skus'], (skus) => skus.concat(Immutable.fromJS(action.res))).set('loaded',true) - case SKL_RECEIVE_SKU_NEW: - return state.updateIn(['skus'], (skus) => skus.clear().concat(Immutable.fromJS(action.res))) - case SKL_TOGGLE_R18: - return state.updateIn(['skus'], (skus) => { - return skus.update( - skus.findIndex((item) => { - return item.get('id') === action.id - }),(item) => { - return item.set('isR18', !item.get('isR18')) - } - ) - }) - case SKL_TOGGLE_RECOMMEND: - return state.updateIn(['skus'], (skus) => { - return skus.update( - skus.findIndex((item) => { - return item.get('id') === action.id - }), (item) => { - return item.set('isRec', !item.get('isRec')); - } - ) - }) - case SKL_DELETE_SKU: - return state.updateIn(['skus'], (skus) => { - return skus.delete(skus.findKey((skus) => { - return skus.get('id') === action.id - })) - }) - case SKL_ADD_SKU: - return state.updateIn(['skus'], (skus) => { - return skus.unshift(Immutable.fromJS(action.res)) - }) - default: - return state - } -} \ No newline at end of file diff --git a/src/scripts/reducers/toyReducer.js b/src/scripts/reducers/toyReducer.js new file mode 100644 index 0000000..b4f80b7 --- /dev/null +++ b/src/scripts/reducers/toyReducer.js @@ -0,0 +1,46 @@ +import Immutable from 'immutable' +import { + SKL_RECEIVE_TOY, SKL_RECEIVE_TOY_NEW, + SKL_TOGGLE_R18, SKL_TOGGLE_RECOMMEND, SKL_DELETE_TOY, SKL_ADD_TOY +} from '../actions/toyAction' + +export default (state = Immutable.fromJS({ toys: [], loaded:false }),action)=>{ + switch (action.type) { + case SKL_RECEIVE_TOY: + return state.updateIn(['toys'], (toys) => toys.concat(Immutable.fromJS(action.res))).set('loaded',true) + case SKL_RECEIVE_TOY_NEW: + return state.updateIn(['toys'], (toys) => toys.clear().concat(Immutable.fromJS(action.res))) + case SKL_TOGGLE_R18: + return state.updateIn(['toys'], (toys) => { + return toys.update( + toys.findIndex((item) => { + return item.get('id') === action.id + }),(item) => { + return item.set('isR18', !item.get('isR18')) + } + ) + }) + case SKL_TOGGLE_RECOMMEND: + return state.updateIn(['toys'], (toys) => { + return toys.update( + toys.findIndex((item) => { + return item.get('id') === action.id + }), (item) => { + return item.set('isRec', !item.get('isRec')); + } + ) + }) + case SKL_DELETE_TOY: + return state.updateIn(['toys'], (toys) => { + return toys.delete(toys.findKey((toys) => { + return toys.get('id') === action.id + })) + }) + case SKL_ADD_TOY: + return state.updateIn(['toys'], (toys) => { + return toys.unshift(Immutable.fromJS(action.res)) + }) + default: + return state + } +} diff --git a/src/scripts/routes.js b/src/scripts/routes.js index 3157ee4..1025eea 100644 --- a/src/scripts/routes.js +++ b/src/scripts/routes.js @@ -9,7 +9,7 @@ import ArticleList from './components/ArticleList/index' import UserList from './components/UserList/index' import TagList from './components/TagList/index' import UserDetail from './components/UserDetail/index' -import SkuList from './components/SkuList/index' +import ToyList from './components/ToyList/index' import StickerList from './components/StickerList/index' import EditArticle from './components/EditArticle/EditArticle' @@ -20,7 +20,7 @@ import EditArticle from './components/EditArticle/EditArticle' // import ExplorePage from './components/explorepage'; // import TagList from './components/taglist'; // import UserList from './components/userlist'; -// import SkuList from './components/skulist'; +// import ToyList from './components/toylist'; // import StickerList from './components/stickerlist'; // import ArticleList from './components/articlelist'; @@ -29,7 +29,7 @@ import EditShortVideo from './components/editshortvideo'; import EditSticker from './components/editsticker'; import EditStickerSet from './components/editstickerset'; import EditRecommend from './components/editrecommend'; -import EditSku from './components/editsku'; +import EditToy from './components/edittoy'; // import EditArticle from './components/editarticle'; import Test from './components/test'; @@ -46,15 +46,15 @@ export default { { path:'/article', component:ArticleList }, { path:'/user', component:UserList }, { path:'/tag', component:TagList }, - { path:'/sku', component:SkuList }, + { path:'/toy', component:ToyList }, { path:'/sticker', component:StickerList }, - + { path:'/user/:id', component:UserDetail }, { path:'/tag/:id', component:EditTag }, { path:'/sticker/set/:id/edit', component:EditStickerSet }, { path:'/sticker/set/:id/add', component:EditSticker }, { path:'/recommend/:id/edit', component:EditRecommend }, - { path:'/sku/:id/edit', component:EditSku }, + { path:'/toy/:id/edit', component:EditToy }, { path:'/video/edit', component:EditShortVideo }, { path:'/article/edit', component:EditArticle }, { path:'/test', component:Test }, diff --git a/src/scripts/store.js b/src/scripts/store.js index c78ef41..1e9ff85 100644 --- a/src/scripts/store.js +++ b/src/scripts/store.js @@ -11,7 +11,7 @@ import tagReducer from './reducers/tagReducer' import exploreReducer from './reducers/exploreReducer' import userReducer from './reducers/userReducer' import articleReducer from './reducers/articleReducer' -import skuReducer from './reducers/skuReducer' +import toyReducer from './reducers/toyReducer' import stickerReducer from './reducers/stickerReducer' export const makeRootReducer = (asyncReducers) => { return combineReducers({ @@ -25,7 +25,7 @@ export const makeRootReducer = (asyncReducers) => { exploreReducer, userReducer, articleReducer, - skuReducer, + toyReducer, stickerReducer, router, ...asyncReducers @@ -57,6 +57,6 @@ export default ( history, initialState ) => { ) store.asyncReducers = {} - + return store }