You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
40 lines
1.1 KiB
40 lines
1.1 KiB
var Mock = require("mockjs")
|
|
module.exports={
|
|
//模拟基础数据
|
|
ok:function (message){
|
|
return {
|
|
code:200,
|
|
message:message,
|
|
result:'OK'
|
|
}
|
|
},
|
|
error:function (message){
|
|
return {
|
|
code:200,
|
|
message:message,
|
|
result:'FAIL'
|
|
}
|
|
},
|
|
//模拟分页数据
|
|
page:function (req,message,obj){
|
|
return Mock.mock({...this.ok(message),...{
|
|
body:{
|
|
'totalCount|10-100':0,
|
|
pageSize:req.query.pageSize,
|
|
totalPage:function (){
|
|
return Math.ceil(this.totalCount/this.pageSize)
|
|
},
|
|
currentPage:function (){
|
|
return Mock.Random.natural(1,this.totalPage)
|
|
},
|
|
data:function (){
|
|
let arr=[]
|
|
for(let i=0;i<this.pageSize;i++){
|
|
arr.push(Mock.mock(obj))
|
|
}
|
|
return arr
|
|
}
|
|
}
|
|
}})
|
|
}
|
|
} |