85 lines
1.8 KiB
JavaScript
85 lines
1.8 KiB
JavaScript
|
|
let laypage,table,form;
|
||
|
|
|
||
|
|
layui.use(['layer', 'form', 'element','laypage'], function(){
|
||
|
|
getToken();
|
||
|
|
//test2();
|
||
|
|
//test3();
|
||
|
|
var layer = layui.layer; //弹层
|
||
|
|
laypage = layui.laypage; //分页
|
||
|
|
table = layui.table; //表格
|
||
|
|
form=layui.form;
|
||
|
|
// initTable();
|
||
|
|
})
|
||
|
|
//初始化表格
|
||
|
|
function initTable() {
|
||
|
|
table.render({
|
||
|
|
elem: '#cityTable',
|
||
|
|
url: PATH_URL+'/system/sys/sysLog/getSystemLogsTest', // 表单数据的接口
|
||
|
|
height: 470,
|
||
|
|
page: true,
|
||
|
|
cols: [[
|
||
|
|
{field:'cid',title: 'ID'},
|
||
|
|
{field:'ip', title: 'ip'},
|
||
|
|
{field:'failureReason', title: '名称'},
|
||
|
|
{field:'createDate',title: '名称'},
|
||
|
|
{field:'deposit', title: '名称'},
|
||
|
|
{toolbar: '#optionBar', title: '操作'}
|
||
|
|
]]
|
||
|
|
});
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
//POST body 传参
|
||
|
|
function getToken(){
|
||
|
|
$.ajax({
|
||
|
|
url: PATH_URL+'/auth/login',
|
||
|
|
data: JSON.stringify({
|
||
|
|
"username":"guest",
|
||
|
|
"password":"Bonus@admin123",
|
||
|
|
"type":'1'
|
||
|
|
}),
|
||
|
|
type: 'POST',
|
||
|
|
dataType:"json",
|
||
|
|
contentType: "application/json",
|
||
|
|
async: false,
|
||
|
|
success: function (result) {
|
||
|
|
localStorage.setItem("token",result.data.access_token)
|
||
|
|
}, error: function () {
|
||
|
|
}
|
||
|
|
});
|
||
|
|
}
|
||
|
|
//POST 请求 formdata 文件上传加密
|
||
|
|
//www-传参 自动加解密
|
||
|
|
function test2(){
|
||
|
|
$.ajax({
|
||
|
|
url: PATH_URL+'/auth/login2',
|
||
|
|
data:{
|
||
|
|
"username":"guest",
|
||
|
|
"password":"Bonus@admin123"
|
||
|
|
},
|
||
|
|
type: 'POST',
|
||
|
|
async: false,
|
||
|
|
success: function (result) {
|
||
|
|
console.log(result)
|
||
|
|
}, error: function () {
|
||
|
|
}
|
||
|
|
});
|
||
|
|
}
|
||
|
|
//get 请求
|
||
|
|
function test3(){
|
||
|
|
$.ajax({
|
||
|
|
url: PATH_URL+'zhgd/auth/login3',
|
||
|
|
data:{
|
||
|
|
"username":"guest",
|
||
|
|
"password":"Bonus@admin123"
|
||
|
|
},
|
||
|
|
contentType: "application/json",
|
||
|
|
type: 'GET',
|
||
|
|
async: false,
|
||
|
|
success: function (result) {
|
||
|
|
console.log(result)
|
||
|
|
}, error: function () {
|
||
|
|
}
|
||
|
|
});
|
||
|
|
}
|