封装
var _mm={
网络请求
request :functin(param){
var _this =this;
$.ajax({
type :parme.method || 'get'
url :parme.url || ''
dataType :parme.type || 'json'
data :parme.data ||'',
success:function(res){
请求成功
if(0==res.status){
typeof parme.success ==='function ' && param.success(res.data,res.msg)
}
没有登录页面需要登录
else if(10 ===res.status){
_this.doLogin()
}
请求数据·错误
else if(1===res.status){
typeof parme.error==='function ' && param.success(res.msg)
}
},
假如请求失败出现 404 503
error :function(err){
typeof parme.success ==='function ' && param.s.error(err.statuText.)
}
})
},
统一登录
doLogin :function (){
编码
window.location.href ="./.login.html?redireat='+ encodeURIComponent(window.location.href)"
}
module.exports= _mm