no message

Former-commit-id: 66c8d923d6df01d2ca74b9b3ca202c690acf39ac
Former-commit-id: 46a19530f77533109925e5a908b2203be2037458
Former-commit-id: e606a89c274d2ac9c38e837a91cc25343a2ce3d5
This commit is contained in:
李杨
2018-02-18 11:29:09 +08:00
parent 7317d13d7f
commit 809c971605
2 changed files with 15 additions and 15 deletions

View File

@@ -4,10 +4,18 @@ const r = (add = 0) => {
return Math.round(Math.random() * 100) + add
}
const returnMaker = (data = []) => {
return {
code: 0,
msg: '请求成功',
data
}
}
Mock.mock('/api/chart/G2Line', 'post', ({body, type, url}) => {
const _body = JSON.parse(body)
switch (_body.code) {
case 1: {
switch (_body.type) {
case 'base': {
let lastValue = 0
const year = ['1991', '1992', '1993', '1994', '1995', '1996', '1997', '1998', '1999']
const data = year.map(y => ({
@@ -19,13 +27,9 @@ Mock.mock('/api/chart/G2Line', 'post', ({body, type, url}) => {
return e
})
lastValue = 0
return {
code: 0,
msg: '请求成功',
data
}
return returnMaker(data)
}
case 2: {
case 'step': {
const month = ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月']
const data = month.map(y => ({
month: y,
@@ -34,11 +38,7 @@ Mock.mock('/api/chart/G2Line', 'post', ({body, type, url}) => {
e.value = r()
return e
})
return {
code: 0,
msg: '请求成功',
data
}
return returnMaker(data)
}
default:
return {}