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

前端:商品分类列表

上级 e9b5adea
......@@ -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
......@@ -6,20 +6,20 @@ const GlobalFooter = ({ className, links, copyright }) => {
const clsString = classNames(styles.globalFooter, className);
return (
<footer className={clsString}>
{links && (
<div className={styles.links}>
{links.map(link => (
<a
key={link.key}
title={link.key}
target={link.blankTarget ? '_blank' : '_self'}
href={link.href}
>
{link.title}
</a>
))}
</div>
)}
{/*{links && (*/}
{/*<div className={styles.links}>*/}
{/*{links.map(link => (*/}
{/*<a*/}
{/*key={link.key}*/}
{/*title={link.key}*/}
{/*target={link.blankTarget ? '_blank' : '_self'}*/}
{/*href={link.href}*/}
{/*>*/}
{/*{link.title}*/}
{/*</a>*/}
{/*))}*/}
{/*</div>*/}
{/*)}*/}
{copyright && <div className={styles.copyright}>{copyright}</div>}
</footer>
);
......
......@@ -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
......
......@@ -29,9 +29,7 @@ const links = [
];
const copyright = (
<Fragment>
Copyright <Icon type="copyright" /> 2018 蚂蚁金服体验技术部出品
</Fragment>
<a href='https://pc.qq.com/detail/1/detail_2661.html'>请使用谷歌浏览器(Chrome)获取最佳用户体验</a>
);
class UserLayout extends Component {
......@@ -63,10 +61,10 @@ class UserLayout extends Component {
<div className={styles.header}>
<Link to="/">
<img alt="logo" className={styles.logo} src={logo} />
<span className={styles.title}>后台管理系统</span>
<span className={styles.title}>小商城管理平台</span>
</Link>
</div>
<div className={styles.desc}>TODO....</div>
{/*<div className={styles.desc}>TODO....</div>*/}
</div>
{children}
</div>
......
......@@ -105,7 +105,7 @@ function List ({ dataSource, loading, pagination, searchParams, dispatch,
<a className={styles.tableDelete} onClick={() => handleDelete(record)}>
删除
</a>
</span> : ''
</span> : null
}
</Fragment>
);
......@@ -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
......@@ -108,62 +108,45 @@ class LoginPage extends Component {
}}
/>
</Tab>
<Tab key="mobile" tab={formatMessage({ id: 'app.login.tab-login-mobile' })}>
{login.status === 'error' &&
login.type === 'mobile' &&
!submitting &&
this.renderMessage(
formatMessage({ id: 'app.login.message-invalid-verification-code' })
)}
<Mobile
name="username"
placeholder={formatMessage({ id: 'form.phone-number.placeholder' })}
rules={[
{
required: true,
message: formatMessage({ id: 'validation.phone-number.required' }),
},
{
pattern: /^1\d{10}$/,
message: formatMessage({ id: 'validation.phone-number.wrong-format' }),
},
]}
/>
<Captcha
name="password"
placeholder={formatMessage({ id: 'form.verification-code.placeholder' })}
countDown={120}
onGetCaptcha={this.onGetCaptcha}
getCaptchaButtonText={formatMessage({ id: 'form.get-captcha' })}
getCaptchaSecondText={formatMessage({ id: 'form.captcha.second' })}
rules={[
{
required: true,
message: formatMessage({ id: 'validation.verification-code.required' }),
},
]}
/>
</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>
{/*<Tab key="mobile" tab={formatMessage({ id: 'app.login.tab-login-mobile' })}>*/}
{/*{login.status === 'error' &&*/}
{/*login.type === 'mobile' &&*/}
{/*!submitting &&*/}
{/*this.renderMessage(*/}
{/*formatMessage({ id: 'app.login.message-invalid-verification-code' })*/}
{/*)}*/}
{/*<Mobile*/}
{/*name="username"*/}
{/*placeholder={formatMessage({ id: 'form.phone-number.placeholder' })}*/}
{/*rules={[*/}
{/*{*/}
{/*required: true,*/}
{/*message: formatMessage({ id: 'validation.phone-number.required' }),*/}
{/*},*/}
{/*{*/}
{/*pattern: /^1\d{10}$/,*/}
{/*message: formatMessage({ id: 'validation.phone-number.wrong-format' }),*/}
{/*},*/}
{/*]}*/}
{/*/>*/}
{/*<Captcha*/}
{/*name="password"*/}
{/*placeholder={formatMessage({ id: 'form.verification-code.placeholder' })}*/}
{/*countDown={120}*/}
{/*onGetCaptcha={this.onGetCaptcha}*/}
{/*getCaptchaButtonText={formatMessage({ id: 'form.get-captcha' })}*/}
{/*getCaptchaSecondText={formatMessage({ id: 'form.captcha.second' })}*/}
{/*rules={[*/}
{/*{*/}
{/*required: true,*/}
{/*message: formatMessage({ id: 'validation.verification-code.required' }),*/}
{/*},*/}
{/*]}*/}
{/*/>*/}
{/*</Tab>*/}
<Submit loading={submitting}>
<FormattedMessage id="app.login.login" />
</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>
</div>
);
......
......@@ -7,7 +7,7 @@
name="viewport"
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" />
</head>
<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 {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 => {
return Promise.reject(error)
}
)
export default servicef
\ No newline at end of file
export default servicef
\ No newline at end of file
......@@ -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
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<UsersProductCategoryVO> list(@RequestParam("pid") Integer pid) {
public CommonResult<List<UsersProductCategoryVO>> list(@RequestParam("pid") Integer 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 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论