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.
|
|
|
var express = require('express');
|
|
|
|
var router = express.Router();
|
|
|
|
var Mock = require("mockjs")
|
|
|
|
|
|
|
|
router.post('/login',function(req, res, next) {
|
|
|
|
console.log(req.body);
|
|
|
|
//调用mock方法模拟数据
|
|
|
|
var data = Mock.mock({
|
|
|
|
code:/200|500/,
|
|
|
|
result:function (){
|
|
|
|
if(this.code==='200'){
|
|
|
|
this.message='登陆成功'
|
|
|
|
this.body={username:Mock.Random.cname(),sessionId:Mock.Random.guid()}
|
|
|
|
return 'OK'
|
|
|
|
}else{
|
|
|
|
this.message='登陆失败'
|
|
|
|
return 'FAIL'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
message:''
|
|
|
|
}
|
|
|
|
)
|
|
|
|
return res.json(data);
|
|
|
|
})
|
|
|
|
|
|
|
|
router.post('/register',function(req, res, next) {
|
|
|
|
console.log(req.body);
|
|
|
|
//调用mock方法模拟数据
|
|
|
|
var data = Mock.mock({
|
|
|
|
code:/200|500/,
|
|
|
|
result:function (context){
|
|
|
|
return context.context.root.code==='200'?'OK':'FAIL'
|
|
|
|
},
|
|
|
|
message:function (context){
|
|
|
|
return context.context.root.code==='200'?'注册成功':'注册失败'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
)
|
|
|
|
return res.json(data);
|
|
|
|
})
|
|
|
|
|
|
|
|
module.exports=router
|