diff --git a/go/controller/category/category.go b/go/controller/category/category.go
index c8ed13f7..4084451b 100644
--- a/go/controller/category/category.go
+++ b/go/controller/category/category.go
@@ -212,8 +212,16 @@ func List(ctx *iris.Context) {
pageNo = 1
}
+ //默认按创建时间,降序来排序
+ var orderStr = "created_at"
+ if ctx.FormValue("asc") == "1" {
+ orderStr += " asc"
+ } else {
+ orderStr += " desc"
+ }
+
offset := (pageNo - 1) * config.ServerConfig.PageSize
- queryErr := db.Offset(offset).Limit(config.ServerConfig.PageSize).Find(&categories).Error
+ queryErr := db.Offset(offset).Limit(config.ServerConfig.PageSize).Order(orderStr).Find(&categories).Error
if queryErr != nil {
ctx.JSON(iris.StatusOK, iris.Map{
diff --git a/nodejs/static/javascripts/admin/actions/changeCategoryStatus.js b/nodejs/static/javascripts/admin/actions/changeCategoryStatus.js
new file mode 100644
index 00000000..26c20c2e
--- /dev/null
+++ b/nodejs/static/javascripts/admin/actions/changeCategoryStatus.js
@@ -0,0 +1,31 @@
+import {
+ CHANGE_CATEGORY_STATUS
+} from '../constants';
+
+function receiveCategoryStatus(data) {
+ return {
+ type : CHANGE_CATEGORY_STATUS,
+ id : data.id,
+ status : data.status
+ };
+}
+
+export default function(reqData) {
+ return dispatch => {
+ var url = pageConfig.apiURL + '/admin/category/status/update';
+ return fetch(url, {
+ method: 'POST',
+ headers: {
+ 'Accept': 'application/json',
+ 'Content-Type': 'application/json'
+ },
+ body: JSON.stringify({
+ id : reqData.id,
+ status : reqData.status
+ })
+ })
+ .then(response => response.json())
+ .then(json => dispatch(receiveCategoryStatus(json.data)));
+ };
+};
+
diff --git a/nodejs/static/javascripts/admin/actions/changeProductStatus.js b/nodejs/static/javascripts/admin/actions/changeProductStatus.js
new file mode 100644
index 00000000..46b6d262
--- /dev/null
+++ b/nodejs/static/javascripts/admin/actions/changeProductStatus.js
@@ -0,0 +1,22 @@
+import {
+ CHANGE_PRODUCT_STATUS
+} from '../constants';
+
+function receiveProductStatus(data) {
+ return {
+ type : CHANGE_PRODUCT_STATUS,
+ id : data.id,
+ status : data.status
+ };
+}
+
+export default function(reqData) {
+ return dispatch => {
+ var url = pageConfig.apiURL + '/admin/product/status/update/:id/:status';
+ url = url.replace(':id', reqData.id);
+ url = url.replace(':status', reqData.status);
+ return fetch(url)
+ .then(response => response.json())
+ .then(json => dispatch(receiveProductStatus(json.data)));
+ };
+}
\ No newline at end of file
diff --git a/nodejs/static/javascripts/admin/actions/requestCategoryList.js b/nodejs/static/javascripts/admin/actions/requestCategoryList.js
new file mode 100644
index 00000000..fb872162
--- /dev/null
+++ b/nodejs/static/javascripts/admin/actions/requestCategoryList.js
@@ -0,0 +1,19 @@
+import {
+ REQUEST_CATEGORY_LIST
+} from '../constants';
+
+function receiveCategories(data) {
+ return {
+ type: REQUEST_CATEGORY_LIST,
+ categories: data.categories
+ };
+}
+
+export default function() {
+ return dispatch => {
+ var url = pageConfig.apiURL + '/admin/categories';
+ return fetch(url)
+ .then(response => response.json())
+ .then(json => dispatch(receiveCategories(json.data)))
+ };
+}
\ No newline at end of file
diff --git a/nodejs/static/javascripts/admin/components/Sidebar.js b/nodejs/static/javascripts/admin/components/Sidebar.js
index eb269eff..e52e5d76 100644
--- a/nodejs/static/javascripts/admin/components/Sidebar.js
+++ b/nodejs/static/javascripts/admin/components/Sidebar.js
@@ -60,7 +60,6 @@ class Sidebar extends React.Component {
this.setState({
current: event.key
});
-
hashHistory.push(url.substr(1));
}
onMouseEnterSubMenu(event) {
diff --git a/nodejs/static/javascripts/admin/config/index.js b/nodejs/static/javascripts/admin/config/index.js
index 35860032..6991358c 100644
--- a/nodejs/static/javascripts/admin/config/index.js
+++ b/nodejs/static/javascripts/admin/config/index.js
@@ -64,7 +64,7 @@ var sidebarData = [
{
id : getId(),
title : '商品分类管理',
- url : '/admin/category/list'
+ url : '/category/manage'
},
{
id : getId(),
diff --git a/nodejs/static/javascripts/admin/constants/index.js b/nodejs/static/javascripts/admin/constants/index.js
index 0358d809..34cd44bd 100644
--- a/nodejs/static/javascripts/admin/constants/index.js
+++ b/nodejs/static/javascripts/admin/constants/index.js
@@ -16,4 +16,9 @@ export const REQUEST_HOT_PRODUCT_LIST = 'requestHotProductList';
export const REQUEST_PRODUCT_LIST = 'requestProductList';
+export const CHANGE_PRODUCT_STATUS = 'changeProductStatus';
+
+export const REQUEST_CATEGORY_LIST = 'requestCategoryList';
+
+export const CHANGE_CATEGORY_STATUS = 'changeCategoryStatus';
diff --git a/nodejs/static/javascripts/admin/containers/CategoryManage.js b/nodejs/static/javascripts/admin/containers/CategoryManage.js
new file mode 100644
index 00000000..3dc7b0f6
--- /dev/null
+++ b/nodejs/static/javascripts/admin/containers/CategoryManage.js
@@ -0,0 +1,146 @@
+import React, { Component } from 'react';
+import { connect } from 'react-redux';
+import { Link } from 'react-router';
+
+import {
+ Icon,
+ Row,
+ Col,
+ Popconfirm,
+ Table
+} from 'antd';
+
+import requestCategoryList from '../actions/requestCategoryList';
+import changeCategoryStatus from '../actions/changeCategoryStatus';
+import Software from './Software';
+import analyze from '../../sdk/analyze';
+import '../../../styles/admin/categoryManage.css';
+
+/*
+ * 管理后台,商品分类管理
+ */
+class CategoryManage extends Component {
+ constructor(props) {
+ super(props);
+ var self = this;
+ this.state = {
+ columns: [
+ {
+ title: '分类名称',
+ dataIndex: 'name'
+ },
+ {
+ title: '排序',
+ dataIndex: 'order'
+ },
+ {
+ title: '创建时间',
+ dataIndex: 'createdAt'
+ },
+ {
+ title: '操作',
+ render: (text, record) => {
+ let openEnabled = false;
+ let closeEnabled = false;
+ //1: 已开启
+ //2: 已关闭
+ if (record.status == 1) {
+ closeEnabled = true;
+ } else if (record.status == 2) {
+ openEnabled = true;
+ }
+ return (
+
+
+