add:okFly(ajax网络请求)

master
zhizous 2019-12-12 02:14:04 +08:00
parent aae4c59e7e
commit aaa03fa2fa
6 changed files with 214 additions and 5 deletions

View File

@ -7,6 +7,12 @@
"spread": true,
"isCheck": true
},
{
"title": "测试",
"href": "pages/help/test.html",
"fontFamily": "ok-icon",
"icon": ""
},
{
"title": "控制台示例",
"href": "",
@ -67,7 +73,14 @@
"href": "pages/help/okLayer.html",
"icon": "",
"spread": false
},
{
"title": "okFly",
"href": "pages/help/okFly.html",
"icon": "",
"spread": false
}
]
},
{

View File

File diff suppressed because one or more lines are too long

View File

@ -29,6 +29,7 @@ if (!Object.assign) {
"okTab": "okmodules/okTab",
"okCountUp": "okmodules/okCountUp",
"okUtils": "okmodules/okUtils",
"okFly": "okmodules/okFly",
"okGVerify": "okmodules/okGVerify",
"qrcode": "okmodules/qrcode",
"okQrcode": "okmodules/okQrcode",

132
pages/help/okFly.html Normal file
View File

@ -0,0 +1,132 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>okFly</title>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<link rel="stylesheet" href="../../css/oksub.css">
<style>
.ok-body {
padding: 20px;
}
</style>
</head>
<body>
<div class="ok-body">
<!--########################okLayer.confirm()########################-->
<blockquote class="layui-elem-quote">
<p>okFly网络请求</p>
</blockquote>
<blockquote class="layui-elem-quote layui-quote-nm">
okFly.get(url, params, options).then(function(res){
console.log(res);
});
</blockquote>
<pre>
/**get请求*/
okFly.get("/test", {a:1,b:2});
/**post请求*/
okFly.post("/test", {a:1,b:2}).then(function(res){
console.log(res);
}).catch(function(err) {
console.log(err);
});
</pre>
<table class="layui-table">
<colgroup>
<col>
<col>
<col>
</colgroup>
<thead>
<tr>
<th>参数</th>
<th>类型</th>
<th>描述</th>
</tr>
</thead>
<tbody>
<tr>
<td>url</td>
<td>String</td>
<td>请求地址</td>
</tr>
<tr>
<td>params</td>
<td>JSON</td>
<td>请求参数</td>
</tr>
<tr>
<td>options</td>
<td>JSON</td>
<td>配置项</td>
</tr>
</tbody>
</table>
<blockquote class="layui-elem-quote layui-quote-nm">
options: 配置说明
</blockquote>
<table class="layui-table">
<colgroup>
<col>
<col>
<col>
</colgroup>
<thead>
<tr>
<th>参数</th>
<th>类型</th>
<th>描述</th>
</tr>
</thead>
<tbody>
<tr>
<td>headers</td>
<td>JSON</td>
<td>配置请求头</td>
</tr>
</tbody>
</table>
</div>
</body>
</html>
<script src="../../lib/layui/layui.js"></script>
<script type="text/javascript">
layui.use(["util", "code", "okFly"], function () {
let util = layui.util;
let code = layui.code;
let okFly = layui.okFly;
util.fixbar({});
code({
elem: 'pre',
title: "代码示例"
});
okFly.get("api/music/listmusic", {
id: 8,
a: "1",
b: 2
}, {
headers: {
"adfasd": 456465
}
}).then(function (res) {
console.log(res);
})
okFly.post("api/music/listmusic", {
id: 8,
a: "1",
b: 2
}, {
headers: {
"hello": 456465
}
}).then(function (res) {
console.log(res);
})
});
</script>

View File

@ -4,8 +4,6 @@
<meta charset="UTF-8">
<title>Title</title>
<link rel="stylesheet" href="../../lib/layui/css/layui.css"/>
<link rel="stylesheet" href="../../lib/loading/okLoading.css"/>
<script type="text/javascript" src="../../lib/loading/okLoading.js"></script>
</head>
<body>
@ -14,8 +12,26 @@ dsafasdf
</html>
<script src="../../lib/layui/layui.js"></script>
<script type="text/javascript">
layui.use(["jquery"], function () {
let $ = layui.jquery;
okLoading.close($);
layui.use(["jquery","okFly"], function () {
let $ = layui.jquery,
okFly = layui.okFly;
okFly.post("/test", {
a: "as",
b: 125
}).then(function (res) {
console.log(res);
}).catch(function (err) {
console.log(err);
});
okFly.get("/test", {
a: "as",
b: 125
}).then(function (res) {
console.log(res);
}).catch(function (err) {
console.log(err);
});
});
</script>