提交 40e4236a authored 作者: YunaiV's avatar YunaiV

前端:商品分类列表

上级 e9b5adea
...@@ -32,3 +32,7 @@ http://www.tuicool.com/articles/YrQ7j2a ...@@ -32,3 +32,7 @@ http://www.tuicool.com/articles/YrQ7j2a
1.route目录下的文件需要加上文件头部注释(写清楚文件是什么功能) 1.route目录下的文件需要加上文件头部注释(写清楚文件是什么功能)
2.component文件需要加上头部注释 (写清楚改控件的用处) 2.component文件需要加上头部注释 (写清楚改控件的用处)
## 补充规范
1. services 目录中,每个 api 文件,对应后端一个 api 服务。主要考虑是
\ No newline at end of file
...@@ -6,20 +6,20 @@ const GlobalFooter = ({ className, links, copyright }) => { ...@@ -6,20 +6,20 @@ const GlobalFooter = ({ className, links, copyright }) => {
const clsString = classNames(styles.globalFooter, className); const clsString = classNames(styles.globalFooter, className);
return ( return (
<footer className={clsString}> <footer className={clsString}>
{links && ( {/*{links && (*/}
<div className={styles.links}> {/*<div className={styles.links}>*/}
{links.map(link => ( {/*{links.map(link => (*/}
<a {/*<a*/}
key={link.key} {/*key={link.key}*/}
title={link.key} {/*title={link.key}*/}
target={link.blankTarget ? '_blank' : '_self'} {/*target={link.blankTarget ? '_blank' : '_self'}*/}
href={link.href} {/*href={link.href}*/}
> {/*>*/}
{link.title} {/*{link.title}*/}
</a> {/*</a>*/}
))} {/*))}*/}
</div> {/*</div>*/}
)} {/*)}*/}
{copyright && <div className={styles.copyright}>{copyright}</div>} {copyright && <div className={styles.copyright}>{copyright}</div>}
</footer> </footer>
); );
......
...@@ -9,7 +9,7 @@ module.exports = { ...@@ -9,7 +9,7 @@ module.exports = {
menu: { menu: {
disableLocal: false, disableLocal: false,
}, },
title: 'Ant Design Pro', title: '小商城管理平台',
pwa: true, pwa: true,
// your iconfont Symbol Scrip Url // your iconfont Symbol Scrip Url
// eg://at.alicdn.com/t/font_1039637_btcrd5co4w.js // eg://at.alicdn.com/t/font_1039637_btcrd5co4w.js
......
...@@ -29,9 +29,7 @@ const links = [ ...@@ -29,9 +29,7 @@ const links = [
]; ];
const copyright = ( const copyright = (
<Fragment> <a href='https://pc.qq.com/detail/1/detail_2661.html'>请使用谷歌浏览器(Chrome)获取最佳用户体验</a>
Copyright <Icon type="copyright" /> 2018 蚂蚁金服体验技术部出品
</Fragment>
); );
class UserLayout extends Component { class UserLayout extends Component {
...@@ -63,10 +61,10 @@ class UserLayout extends Component { ...@@ -63,10 +61,10 @@ class UserLayout extends Component {
<div className={styles.header}> <div className={styles.header}>
<Link to="/"> <Link to="/">
<img alt="logo" className={styles.logo} src={logo} /> <img alt="logo" className={styles.logo} src={logo} />
<span className={styles.title}>后台管理系统</span> <span className={styles.title}>小商城管理平台</span>
</Link> </Link>
</div> </div>
<div className={styles.desc}>TODO....</div> {/*<div className={styles.desc}>TODO....</div>*/}
</div> </div>
{children} {children}
</div> </div>
......
...@@ -105,7 +105,7 @@ function List ({ dataSource, loading, pagination, searchParams, dispatch, ...@@ -105,7 +105,7 @@ function List ({ dataSource, loading, pagination, searchParams, dispatch,
<a className={styles.tableDelete} onClick={() => handleDelete(record)}> <a className={styles.tableDelete} onClick={() => handleDelete(record)}>
删除 删除
</a> </a>
</span> : '' </span> : null
} }
</Fragment> </Fragment>
); );
...@@ -379,13 +379,14 @@ const RoleAssignModal = Form.create()(props => { ...@@ -379,13 +379,14 @@ const RoleAssignModal = Form.create()(props => {
); );
}); });
@connect(({ adminList, loading }) => ({
@connect(({ adminList }) => ({
// list: adminList.list, // list: adminList.list,
// pagination: adminList.pagination, // pagination: adminList.pagination,
...adminList, ...adminList,
loading: loading.models.resourceList,
})) }))
// 主界面
@Form.create() @Form.create()
class AdminList extends PureComponent { class AdminList extends PureComponent {
state = { state = {
......
...@@ -108,62 +108,45 @@ class LoginPage extends Component { ...@@ -108,62 +108,45 @@ class LoginPage extends Component {
}} }}
/> />
</Tab> </Tab>
<Tab key="mobile" tab={formatMessage({ id: 'app.login.tab-login-mobile' })}> {/*<Tab key="mobile" tab={formatMessage({ id: 'app.login.tab-login-mobile' })}>*/}
{login.status === 'error' && {/*{login.status === 'error' &&*/}
login.type === 'mobile' && {/*login.type === 'mobile' &&*/}
!submitting && {/*!submitting &&*/}
this.renderMessage( {/*this.renderMessage(*/}
formatMessage({ id: 'app.login.message-invalid-verification-code' }) {/*formatMessage({ id: 'app.login.message-invalid-verification-code' })*/}
)} {/*)}*/}
<Mobile {/*<Mobile*/}
name="username" {/*name="username"*/}
placeholder={formatMessage({ id: 'form.phone-number.placeholder' })} {/*placeholder={formatMessage({ id: 'form.phone-number.placeholder' })}*/}
rules={[ {/*rules={[*/}
{ {/*{*/}
required: true, {/*required: true,*/}
message: formatMessage({ id: 'validation.phone-number.required' }), {/*message: formatMessage({ id: 'validation.phone-number.required' }),*/}
}, {/*},*/}
{ {/*{*/}
pattern: /^1\d{10}$/, {/*pattern: /^1\d{10}$/,*/}
message: formatMessage({ id: 'validation.phone-number.wrong-format' }), {/*message: formatMessage({ id: 'validation.phone-number.wrong-format' }),*/}
}, {/*},*/}
]} {/*]}*/}
/> {/*/>*/}
<Captcha {/*<Captcha*/}
name="password" {/*name="password"*/}
placeholder={formatMessage({ id: 'form.verification-code.placeholder' })} {/*placeholder={formatMessage({ id: 'form.verification-code.placeholder' })}*/}
countDown={120} {/*countDown={120}*/}
onGetCaptcha={this.onGetCaptcha} {/*onGetCaptcha={this.onGetCaptcha}*/}
getCaptchaButtonText={formatMessage({ id: 'form.get-captcha' })} {/*getCaptchaButtonText={formatMessage({ id: 'form.get-captcha' })}*/}
getCaptchaSecondText={formatMessage({ id: 'form.captcha.second' })} {/*getCaptchaSecondText={formatMessage({ id: 'form.captcha.second' })}*/}
rules={[ {/*rules={[*/}
{ {/*{*/}
required: true, {/*required: true,*/}
message: formatMessage({ id: 'validation.verification-code.required' }), {/*message: formatMessage({ id: 'validation.verification-code.required' }),*/}
}, {/*},*/}
]} {/*]}*/}
/> {/*/>*/}
</Tab> {/*</Tab>*/}
<div>
<Checkbox checked={autoLogin} onChange={this.changeAutoLogin}>
<FormattedMessage id="app.login.remember-me" />
</Checkbox>
<a style={{ float: 'right' }} href="">
<FormattedMessage id="app.login.forgot-password" />
</a>
</div>
<Submit loading={submitting}> <Submit loading={submitting}>
<FormattedMessage id="app.login.login" /> <FormattedMessage id="app.login.login" />
</Submit> </Submit>
<div className={styles.other}>
<FormattedMessage id="app.login.sign-in-with" />
<Icon type="alipay-circle" className={styles.icon} theme="outlined" />
<Icon type="taobao-circle" className={styles.icon} theme="outlined" />
<Icon type="weibo-circle" className={styles.icon} theme="outlined" />
<Link className={styles.register} to="/user/register">
<FormattedMessage id="app.login.signup" />
</Link>
</div>
</Login> </Login>
</div> </div>
); );
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
name="viewport" name="viewport"
content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0"
/> />
<title>Ant Design Pro</title> <title>小商城管理平台</title>
<link rel="icon" href="/favicon.png" type="image/x-icon" /> <link rel="icon" href="/favicon.png" type="image/x-icon" />
</head> </head>
<body> <body>
......
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
import axios from 'axios' import axios from 'axios'
import {baseUrl,dataSources} from './env'; import {baseUrl, dataSources} from './env';
import datas from '../data/data'; import datas from '../data/data';
const service =axios.create({ const service = axios.create({
baseURL: baseUrl, // api 的 base_url baseURL: baseUrl, // api 的 base_url
timeout: 5000, // request timeout timeout: 5000, // request timeout
}); });
const servicef = function (parameter) {
const servicef =function(parameter){ // debugger;
if(dataSources=='local'){ if (dataSources == 'local') {
//定义回调函数和axios一致 //定义回调函数和axios一致
const promist = new Promise(function(resolve,reject){ const promist = new Promise(function (resolve, reject) {
var data=datas[parameter.url]; var data = datas[parameter.url];
if(typeof data=='string'){ if (typeof data == 'string') {
data= JSON.parse(data); data = JSON.parse(data);
} }
resolve(data); resolve(data);
}) })
...@@ -26,7 +25,7 @@ const servicef =function(parameter){ ...@@ -26,7 +25,7 @@ const servicef =function(parameter){
} }
service.interceptors.request.use( service.interceptors.request.use(
config => { config => {
// Do something before request is sent // Do something before request is sent
// if (store.getters.token) { // if (store.getters.token) {
...@@ -41,9 +40,9 @@ const servicef =function(parameter){ ...@@ -41,9 +40,9 @@ const servicef =function(parameter){
console.log(error) // for debug console.log(error) // for debug
Promise.reject(error) Promise.reject(error)
} }
) )
// response interceptor // response interceptor
service.interceptors.response.use( service.interceptors.response.use(
//response => response, //response => response,
/** /**
...@@ -53,8 +52,9 @@ service.interceptors.response.use( ...@@ -53,8 +52,9 @@ service.interceptors.response.use(
* 以下代码均为样例,请结合自生需求加以修改,若不需要,则可删除 * 以下代码均为样例,请结合自生需求加以修改,若不需要,则可删除
*/ */
response => { response => {
// debugger;
const res = response.data; const res = response.data;
if (res.ResultCode !== 200) { if (res.code !== 0) {
// Message({ // Message({
// message: res.message, // message: res.message,
// type: 'error', // type: 'error',
...@@ -77,18 +77,20 @@ service.interceptors.response.use( ...@@ -77,18 +77,20 @@ service.interceptors.response.use(
console.log(1); console.log(1);
return Promise.reject('error') return Promise.reject('error')
} else { } else {
if(typeof response.data.Tag=='string'){ // if (typeof response.data.Tag == 'string') {
return JSON.parse(response.data.Tag); // return JSON.parse(response.data.Tag);
}else{ // } else {
return response.data.Tag; // return response.data.Tag;
} // }
// debugger;
return res.data;
} }
}, },
error => { error => {
return Promise.reject(error) return Promise.reject(error)
} }
) )
export default servicef export default servicef
\ No newline at end of file \ No newline at end of file
...@@ -3,10 +3,7 @@ package cn.iocoder.mall.product.application.config; ...@@ -3,10 +3,7 @@ package cn.iocoder.mall.product.application.config;
import cn.iocoder.common.framework.config.GlobalExceptionHandler; import cn.iocoder.common.framework.config.GlobalExceptionHandler;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import; import org.springframework.context.annotation.Import;
import org.springframework.web.servlet.config.annotation.EnableWebMvc; import org.springframework.web.servlet.config.annotation.*;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@EnableWebMvc @EnableWebMvc
@Configuration @Configuration
...@@ -31,4 +28,13 @@ public class MVCConfiguration implements WebMvcConfigurer { ...@@ -31,4 +28,13 @@ public class MVCConfiguration implements WebMvcConfigurer {
registry.addResourceHandler("webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/"); 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
package cn.iocoder.mall.product.application.controller.users; 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.ProductCategoryService;
import cn.iocoder.mall.product.api.bo.ProductCategoryBO; import cn.iocoder.mall.product.api.bo.ProductCategoryBO;
import cn.iocoder.mall.product.application.convert.ProductCategoryConvert; import cn.iocoder.mall.product.application.convert.ProductCategoryConvert;
...@@ -26,9 +27,9 @@ public class UsersProductCategoryController { ...@@ -26,9 +27,9 @@ public class UsersProductCategoryController {
@GetMapping("/list") @GetMapping("/list")
@ApiOperation("获得指定编号下的子分类的数组") @ApiOperation("获得指定编号下的子分类的数组")
@ApiImplicitParam(name = "pid", value = "指定分类编号", required = true, example = "0") @ApiImplicitParam(name = "pid", value = "指定分类编号", required = true, example = "0")
public List<UsersProductCategoryVO> list(@RequestParam("pid") Integer pid) { public CommonResult<List<UsersProductCategoryVO>> list(@RequestParam("pid") Integer pid) {
List<ProductCategoryBO> result = productCategoryService.getListByPid(pid); List<ProductCategoryBO> result = productCategoryService.getListByPid(pid);
return ProductCategoryConvert.INSTANCE.convertToVO(result); return CommonResult.success(ProductCategoryConvert.INSTANCE.convertToVO(result));
} }
} }
\ No newline at end of file
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论