diff --git a/static/html/list.html b/static/html/list.html index d2cf2ff..3e1a994 100644 --- a/static/html/list.html +++ b/static/html/list.html @@ -32,22 +32,75 @@ , 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: 'page_bar' //注意,这里的 test1 是 ID,不用加 # 号 + , count: 50 //数据总数,从服务端得到 + , limit: me.limit // 每页显示的条数。 + }); + }, + merge_obj: function (target, src) { + for (var 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 () { - //执行一个laypage实例 - laypage.render({ - elem: 'page_bar' //注意,这里的 test1 是 ID,不用加 # 号 - , count: 50 //数据总数,从服务端得到 - , limit: 20 // 每页显示的条数。 - }); + // 初始化对象 + const list_view = new listView({'s': 'p'}) + list_view.init() + list_view.fetch_data() + + // 绑定事件 + $('#c_').click(function () { + const mind_name = $('#mind_name').val() + if (mind_name) { + list_view.fetch_data() + } else { + layer.msg('请输入导图名称') + } + }) })
- +
- +