Files
Nsfocus_test_ai_project/static/html/list.html
T
2022-02-12 22:48:31 +08:00

137 lines
4.6 KiB
HTML

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<title>思维导图列表</title>
<link rel="shortcut icon" href="/static/favicon.ico"/>
<link rel="stylesheet" href="/static/layui-v2.6.8/layui/css/layui.css" media="all">
<script src="/static/layui-v2.6.8/layui/layui.js"></script>
<script src="/static/js/jquery-1.11.3.min.js"></script>
<script>
let layer //弹层
, laypage //分页
, laydate //日期
, table //表格
, carousel //轮播
, upload //上传
, element //元素操作
, slider //滑块
, dropdown //下拉菜单
//加载模块
layui.use(function () { //亦可加载特定模块:layui.use(['layer', 'laydate', function(){
//得到各种内置组件
layer = layui.layer //弹层
, laypage = layui.laypage //分页
, laydate = layui.laydate //日期
, table = layui.table //表格
, carousel = layui.carousel //轮播
, upload = layui.upload //上传
, element = layui.element //元素操作
, slider = layui.slider //滑块
, dropdown = layui.dropdown //下拉菜单
});
// 定义function
const listView = function (options) {
// 当前页
this.current_page = 1
// 每页条数
this.limit = 50
this.options = options
this.opts = {"h": 'oo'}
}
listView.prototype = {
init: function () {
this.merge_obj(this.opts, this.options)
},
// 获取数据
fetch_data: function () {
console.log(this.opts)
},
// 显示分页组件
auto_page_bar: function () {
const me = this
//执行一个laypage实例
laypage.render({
elem: me.opts.page_bar_elem //注意,这里的 test1 是 ID,不用加 # 号
, count: 50 //数据总数,从服务端得到
, limit: me.limit // 每页显示的条数。
});
},
// 合并属性
merge_obj: function (target, src) {
for (let o in src) {
if (o in target) {
if (typeof target[o] === 'object' && Object.prototype.toString.call(target[o]).toLowerCase() === '[object object]' && !target[o].length) {
this.merge(target[o], src[o]);
} else {
target[o] = src[o];
}
} else {
target[o] = src[o];
}
}
return target;
}
}
$(function () {
// 初始化对象
const view = new listView({'page_bar_elem': 'page_bar'})
view.init()
view.fetch_data()
view.auto_page_bar()
// 绑定事件
$('#c_').click(function () {
const mind_name = $('#mind_name').val()
if (mind_name) {
view.fetch_data()
} else {
layer.msg('请输入导图名称')
}
})
})
</script>
</head>
<body>
<div style="margin-top: 5px;">
<div class="layui-input-inline">
<input type="password" name="password" required lay-verify="required" placeholder="请输入思维导图名称" autocomplete="off" class="layui-input" id="mind_name">
</div>
<button type="button" class="layui-btn" id="c_">创建导图</button>
<button type="button" class="layui-btn">搜索</button>
</div>
<table class="layui-table">
<colgroup>
<col width="150">
<col width="200">
<col>
</colgroup>
<thead>
<tr>
<th>昵称</th>
<th>加入时间</th>
<th>签名</th>
</tr>
</thead>
<tbody>
<tr>
<td>贤心</td>
<td>2016-11-29</td>
<td>人生就像是一场修行</td>
</tr>
<tr>
<td>许闲心</td>
<td>2016-11-28</td>
<td>于千万人之中遇见你所遇见的人,于千万年之中,时间的无涯的荒野里…</td>
</tr>
</tbody>
</table>
<div id="page_bar"></div>
</body>
</html>