no message

Former-commit-id: 0cdf814303614e8577d56874f9384888b1c9e613
Former-commit-id: e676ef372115ff3ffebe667096553dc506f5c798
Former-commit-id: 0bb4e736a85e70b4d741d9256d3ee2c1b3fe9019
This commit is contained in:
李杨
2018-02-17 20:25:11 +08:00
parent 690447fd2c
commit 02ad740fe8
6 changed files with 68 additions and 15 deletions

View File

@@ -1,23 +1,35 @@
import Mock from 'mockjs'
const r = (add = 0) => {
return Math.round(Math.random() * 100) + add
}
Mock.mock('/api/chart/G2Line', 'post', ({body, type, url}) => {
const _body = JSON.parse(body)
switch (_body.code) {
case 1:
let lastValue = 0
const temp = [
{ year: '1991', value: 0 },
{ year: '1992', value: 0 },
{ year: '1993', value: 0 },
{ year: '1994', value: 0 },
{ year: '1995', value: 0 },
{ year: '1996', value: 0 },
{ year: '1997', value: 0 },
{ year: '1998', value: 0 },
{ year: '1999', value: 0 }
]
const data = temp.map(e => {
e.value = lastValue + r()
lastValue = e.value
return e
})
lastValue = 0
return {
code: 0,
msg: '请求成功',
data: [
{ year: '1991', value: 3 },
{ year: '1992', value: 4 },
{ year: '1993', value: 3.5 },
{ year: '1994', value: 5 },
{ year: '1995', value: 4.9 },
{ year: '1996', value: 6 },
{ year: '1997', value: 7 },
{ year: '1998', value: 9 },
{ year: '1999', value: 13 }
]
data
}
default:
return {}