修改table.js
a.contentType && 0 == a.contentType.indexOf("application/json") && (d = JSON.stringify(d)), i.loading(), t.ajax({
type: a.method || "get",
url: a.url,
contentType: a.contentType,
data: d,
dataType: "json",
headers: {//table带入token
Authorization: layui.data(layui.setter.tableName)[layui.setter.request.tokenName],
refreshToken: layui.data(layui.setter.tableName)[layui.setter.request.refreshToken]
},
success: function (t) {
if (t.code == 401) {
layer.msg('请重新登陆', {
offset: '15px'
, icon: 2
, time: 2000
}, function () {
top.location.href = '/Home/login'; //后台主页
});
} else {
"function" == typeof a.parseData && (t = a.parseData(t) || t), t[n.statusName] != n.statusCode ? (i.renderForm(), i.errorView(t[n.msgName] || '返回的数据不符合规范,正确的成功状态码应为:"' + n.statusName + '": ' + n.statusCode)) : (i.renderData(t, e, t[n.countName]), o(), a.time = (new Date)
.getTime() - i.startTime + " ms"), i.setColsWidth(), "function" == typeof a.done && a.done(t, e, t[n.countName])
}
},
error: function (e, t) {
layer.msg('系统退出', {
offset: '15px'
, icon: 2
, time: 2000
}, function () {
top.location.href = '/Home/login'; //后台主页
});
i.errorView("数据接口请求异常:" + t), i.renderForm(), i.setColsWidth()
},
complete: function (xhr, data) {
layui.data(layui.setter.tableName, {
key: layui.setter.request.tokenName,
value: xhr.getResponseHeader(layui.setter.request.tokenName) == null ? layui.data(layui.setter.tableName)[layui.setter.request.tokenName] : "Bearer " + xhr.getResponseHeader(layui.setter.request.tokenName)
})
}
})
} else if (a.data && a.data.constructor === Array) {
var c = {},
s = e * a.limit - a.limit;
c[n.dataName] = a.data.concat()
.splice(s, a.limit), c[n.countName] = a.data.length, "object" == typeof a.totalRow && (c[n.totalRowName] = t.extend({}, a.totalRow)), i.renderData(c, e, c[n.countName]), o(), i.setColsWidth(), "function" == typeof a.done && a.done(c, e, c[n.countName])
}