From 40e4236af20a039fa40063e82c7fbd515f61e767 Mon Sep 17 00:00:00 2001 From: YunaiV <> Date: Mon, 25 Mar 2019 18:46:51 +0800 Subject: [PATCH] =?UTF-8?q?=E5=89=8D=E7=AB=AF=EF=BC=9A=E5=95=86=E5=93=81?= =?UTF-8?q?=E5=88=86=E7=B1=BB=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- admin-web/README.md | 6 +- .../src/components/GlobalFooter/index.js | 28 ++-- admin-web/src/defaultSettings.js | 2 +- admin-web/src/layouts/UserLayout.js | 8 +- admin-web/src/pages/Admin/AdminList.js | 9 +- admin-web/src/pages/User/Login.js | 89 +++++------ admin-web/src/pages/document.ejs | 2 +- mobile-web/src/api/product.js | 11 ++ mobile-web/src/config/request.js | 140 +++++++++--------- mobile-web/src/page/category/index.vue | 138 +++++++++++------ .../application/config/MVCConfiguration.java | 14 +- .../users/UsersProductCategoryController.java | 5 +- 12 files changed, 249 insertions(+), 203 deletions(-) create mode 100644 mobile-web/src/api/product.js diff --git a/admin-web/README.md b/admin-web/README.md index b40101c02..4dfb4acc8 100644 --- a/admin-web/README.md +++ b/admin-web/README.md @@ -31,4 +31,8 @@ http://www.tuicool.com/articles/YrQ7j2a #### 5.注释 1.route目录下的文件需要加上文件头部注释(写清楚文件是什么功能) -2.component文件需要加上头部注释 (写清楚改控件的用处) \ No newline at end of file +2.component文件需要加上头部注释 (写清楚改控件的用处) + +## 补充规范 + +1. services 目录中,每个 api 文件,对应后端一个 api 服务。主要考虑是 \ No newline at end of file diff --git a/admin-web/src/components/GlobalFooter/index.js b/admin-web/src/components/GlobalFooter/index.js index 1c2fb74ef..f98f51d9e 100644 --- a/admin-web/src/components/GlobalFooter/index.js +++ b/admin-web/src/components/GlobalFooter/index.js @@ -6,20 +6,20 @@ const GlobalFooter = ({ className, links, copyright }) => { const clsString = classNames(styles.globalFooter, className); return ( ); diff --git a/admin-web/src/defaultSettings.js b/admin-web/src/defaultSettings.js index 4ba7eb390..8809961b6 100644 --- a/admin-web/src/defaultSettings.js +++ b/admin-web/src/defaultSettings.js @@ -9,7 +9,7 @@ module.exports = { menu: { disableLocal: false, }, - title: 'Ant Design Pro', + title: '小商城管理平台', pwa: true, // your iconfont Symbol Scrip Url // eg://at.alicdn.com/t/font_1039637_btcrd5co4w.js diff --git a/admin-web/src/layouts/UserLayout.js b/admin-web/src/layouts/UserLayout.js index f17467fce..b3ddd0430 100644 --- a/admin-web/src/layouts/UserLayout.js +++ b/admin-web/src/layouts/UserLayout.js @@ -29,9 +29,7 @@ const links = [ ]; const copyright = ( - - Copyright 2018 蚂蚁金服体验技术部出品 - + 请使用谷歌浏览器(Chrome)获取最佳用户体验 ); class UserLayout extends Component { @@ -63,10 +61,10 @@ class UserLayout extends Component {
logo - 后台管理系统 + 小商城管理平台
-
TODO....
+ {/*
TODO....
*/} {children} diff --git a/admin-web/src/pages/Admin/AdminList.js b/admin-web/src/pages/Admin/AdminList.js index 59f821553..e0d080f7d 100644 --- a/admin-web/src/pages/Admin/AdminList.js +++ b/admin-web/src/pages/Admin/AdminList.js @@ -105,7 +105,7 @@ function List ({ dataSource, loading, pagination, searchParams, dispatch, handleDelete(record)}> 删除 - : '' + : null } ); @@ -379,13 +379,14 @@ const RoleAssignModal = Form.create()(props => { ); }); -@connect(({ adminList, loading }) => ({ + +@connect(({ adminList }) => ({ // list: adminList.list, // pagination: adminList.pagination, ...adminList, - loading: loading.models.resourceList, })) +// 主界面 @Form.create() class AdminList extends PureComponent { state = { @@ -499,4 +500,4 @@ class AdminList extends PureComponent { } } -export default AdminList; +export default AdminList; \ No newline at end of file diff --git a/admin-web/src/pages/User/Login.js b/admin-web/src/pages/User/Login.js index 12f97a96c..bb734a7c9 100644 --- a/admin-web/src/pages/User/Login.js +++ b/admin-web/src/pages/User/Login.js @@ -108,62 +108,45 @@ class LoginPage extends Component { }} /> - - {login.status === 'error' && - login.type === 'mobile' && - !submitting && - this.renderMessage( - formatMessage({ id: 'app.login.message-invalid-verification-code' }) - )} - - - -
- - - - - - -
+ {/**/} + {/*{login.status === 'error' &&*/} + {/*login.type === 'mobile' &&*/} + {/*!submitting &&*/} + {/*this.renderMessage(*/} + {/*formatMessage({ id: 'app.login.message-invalid-verification-code' })*/} + {/*)}*/} + {/**/} + {/**/} + {/**/} -
- - - - - - - -
); diff --git a/admin-web/src/pages/document.ejs b/admin-web/src/pages/document.ejs index cf09effa0..9900e4aaf 100644 --- a/admin-web/src/pages/document.ejs +++ b/admin-web/src/pages/document.ejs @@ -7,7 +7,7 @@ name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" /> - Ant Design Pro + 小商城管理平台 diff --git a/mobile-web/src/api/product.js b/mobile-web/src/api/product.js new file mode 100644 index 000000000..8813dda5f --- /dev/null +++ b/mobile-web/src/api/product.js @@ -0,0 +1,11 @@ +import request from "../config/request"; + +export function getProductCategoryList(pid) { + return request({ + url: 'product-api/users/category/list', + method: 'get', + params: { + pid + } + }); +} \ No newline at end of file diff --git a/mobile-web/src/config/request.js b/mobile-web/src/config/request.js index 49da3fd34..f52ad525c 100644 --- a/mobile-web/src/config/request.js +++ b/mobile-web/src/config/request.js @@ -1,24 +1,23 @@ - import axios from 'axios' -import {baseUrl,dataSources} from './env'; +import {baseUrl, dataSources} from './env'; import datas from '../data/data'; -const service =axios.create({ +const service = axios.create({ baseURL: baseUrl, // api 的 base_url timeout: 5000, // request timeout }); - -const servicef =function(parameter){ - if(dataSources=='local'){ +const servicef = function (parameter) { + // debugger; + if (dataSources == 'local') { //定义回调函数和axios一致 - const promist = new Promise(function(resolve,reject){ - var data=datas[parameter.url]; - if(typeof data=='string'){ - data= JSON.parse(data); - } - resolve(data); + const promist = new Promise(function (resolve, reject) { + var data = datas[parameter.url]; + if (typeof data == 'string') { + data = JSON.parse(data); + } + resolve(data); }) return promist; } @@ -26,69 +25,72 @@ const servicef =function(parameter){ } - service.interceptors.request.use( - config => { - // Do something before request is sent +service.interceptors.request.use( + config => { + // Do something before request is sent // if (store.getters.token) { // // 让每个请求携带token-- ['X-Token']为自定义key 请根据实际情况自行修改 // config.headers['X-Token'] = getToken() // } - return config - }, - error => { - // Do something with request error - console.log(error) // for debug - Promise.reject(error) - } - ) + return config + }, + error => { + // Do something with request error + console.log(error) // for debug + Promise.reject(error) + } +) - // response interceptor +// response interceptor service.interceptors.response.use( - //response => response, - /** - * 下面的注释为通过在response里,自定义code来标示请求状态 - * 当code返回如下情况则说明权限有问题,登出并返回到登录页 - * 如想通过 xmlhttprequest 来状态码标识 逻辑可写在下面error中 - * 以下代码均为样例,请结合自生需求加以修改,若不需要,则可删除 - */ - response => { - const res = response.data; - if (res.ResultCode !== 200) { - // Message({ - // message: res.message, - // type: 'error', - // duration: 5 * 1000 - // }) - // // 50008:非法的token; 50012:其他客户端登录了; 50014:Token 过期了; - // if (res.code === 50008 || res.code === 50012 || res.code === 50014) { - // // 请自行在引入 MessageBox - // // import { Message, MessageBox } from 'element-ui' - // MessageBox.confirm('你已被登出,可以取消继续留在该页面,或者重新登录', '确定登出', { - // confirmButtonText: '重新登录', - // cancelButtonText: '取消', - // type: 'warning' - // }).then(() => { - // store.dispatch('FedLogOut').then(() => { - // location.reload() // 为了重新实例化vue-router对象 避免bug - // }) - // }) - // } - console.log(1); - return Promise.reject('error') - } else { - if(typeof response.data.Tag=='string'){ - return JSON.parse(response.data.Tag); - }else{ - return response.data.Tag; - } - } - }, - error => { - - return Promise.reject(error) + //response => response, + /** + * 下面的注释为通过在response里,自定义code来标示请求状态 + * 当code返回如下情况则说明权限有问题,登出并返回到登录页 + * 如想通过 xmlhttprequest 来状态码标识 逻辑可写在下面error中 + * 以下代码均为样例,请结合自生需求加以修改,若不需要,则可删除 + */ + response => { + // debugger; + const res = response.data; + if (res.code !== 0) { + // Message({ + // message: res.message, + // type: 'error', + // duration: 5 * 1000 + // }) + // // 50008:非法的token; 50012:其他客户端登录了; 50014:Token 过期了; + // if (res.code === 50008 || res.code === 50012 || res.code === 50014) { + // // 请自行在引入 MessageBox + // // import { Message, MessageBox } from 'element-ui' + // MessageBox.confirm('你已被登出,可以取消继续留在该页面,或者重新登录', '确定登出', { + // confirmButtonText: '重新登录', + // cancelButtonText: '取消', + // type: 'warning' + // }).then(() => { + // store.dispatch('FedLogOut').then(() => { + // location.reload() // 为了重新实例化vue-router对象 避免bug + // }) + // }) + // } + console.log(1); + return Promise.reject('error') + } else { + // if (typeof response.data.Tag == 'string') { + // return JSON.parse(response.data.Tag); + // } else { + // return response.data.Tag; + // } + // debugger; + return res.data; } - ) - + }, + error => { - export default servicef \ No newline at end of file + return Promise.reject(error) + } +) + + +export default servicef \ No newline at end of file diff --git a/mobile-web/src/page/category/index.vue b/mobile-web/src/page/category/index.vue index c1e2f6cc9..1d3282821 100644 --- a/mobile-web/src/page/category/index.vue +++ b/mobile-web/src/page/category/index.vue @@ -6,63 +6,71 @@ show-action @search="onSearch" > -
搜索
+
搜索
- - - - - - - - - - - - - - - + + + + + + + + + + + + + + +
- + + + + + + + + + + + + + + + + + + + + +
-

常用分类

-
-
-

热门分类

- @@ -74,6 +82,8 @@ diff --git a/product/product-application/src/main/java/cn/iocoder/mall/product/application/config/MVCConfiguration.java b/product/product-application/src/main/java/cn/iocoder/mall/product/application/config/MVCConfiguration.java index 4e50c7d49..6bb15b388 100644 --- a/product/product-application/src/main/java/cn/iocoder/mall/product/application/config/MVCConfiguration.java +++ b/product/product-application/src/main/java/cn/iocoder/mall/product/application/config/MVCConfiguration.java @@ -3,10 +3,7 @@ package cn.iocoder.mall.product.application.config; import cn.iocoder.common.framework.config.GlobalExceptionHandler; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; -import org.springframework.web.servlet.config.annotation.EnableWebMvc; -import org.springframework.web.servlet.config.annotation.InterceptorRegistry; -import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; -import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; +import org.springframework.web.servlet.config.annotation.*; @EnableWebMvc @Configuration @@ -31,4 +28,13 @@ public class MVCConfiguration implements WebMvcConfigurer { registry.addResourceHandler("webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/"); } + // TODO 芋艿,允许跨域 + @Override + public void addCorsMappings(CorsRegistry registry) { + registry.addMapping("/**") + .allowedHeaders("*") + .allowedMethods("*") + .allowedOrigins("*"); + } + } \ No newline at end of file diff --git a/product/product-application/src/main/java/cn/iocoder/mall/product/application/controller/users/UsersProductCategoryController.java b/product/product-application/src/main/java/cn/iocoder/mall/product/application/controller/users/UsersProductCategoryController.java index 5eeec51db..cee54b337 100644 --- a/product/product-application/src/main/java/cn/iocoder/mall/product/application/controller/users/UsersProductCategoryController.java +++ b/product/product-application/src/main/java/cn/iocoder/mall/product/application/controller/users/UsersProductCategoryController.java @@ -1,5 +1,6 @@ package cn.iocoder.mall.product.application.controller.users; +import cn.iocoder.common.framework.vo.CommonResult; import cn.iocoder.mall.product.api.ProductCategoryService; import cn.iocoder.mall.product.api.bo.ProductCategoryBO; import cn.iocoder.mall.product.application.convert.ProductCategoryConvert; @@ -26,9 +27,9 @@ public class UsersProductCategoryController { @GetMapping("/list") @ApiOperation("获得指定编号下的子分类的数组") @ApiImplicitParam(name = "pid", value = "指定分类编号", required = true, example = "0") - public List list(@RequestParam("pid") Integer pid) { + public CommonResult> list(@RequestParam("pid") Integer pid) { List result = productCategoryService.getListByPid(pid); - return ProductCategoryConvert.INSTANCE.convertToVO(result); + return CommonResult.success(ProductCategoryConvert.INSTANCE.convertToVO(result)); } } \ No newline at end of file