layer.open增添模板效果子级页面(layui模板渲染数据)

//alert.html
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>随访结论模板</title> <meta name="renderer" content="webkit"> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"> <meta name="apple-mobile-web-app-status-bar-style" content="black"> <meta name="apple-mobile-web-app-capable" content="yes"> <meta name="format-detection" content="telephone=no"> <link rel="stylesheet" href="../plugins/layui/css/layui.css" media="all" /> <link rel="stylesheet" href="../plugins/font-awesome/css/font-awesome.min.css"> <link rel="stylesheet" href="../css/btable.css" /> <link rel="stylesheet" href="../css/global.css" media="all"> </head> <style> .oy-tablehead{ background-color:#538ED5 ; font-size: 20px; color: white; text-align: center; font-weight: 800; line-height:50px; } input[type=checkbox]{ display: block; 18px; height: 18px; font-size: 12px; -webkit-transition: .1s linear; transition: .1s linear; line-height: 16px; border: 1px solid #d2d2d2; font-size: 12px; border-radius: 2px; background-color: #fff; margin: auto; } </style> <body> <div style="margin:0px; background-color: white; margin:0 10px;"> <table class="site-table table-hover"> <thead> <tr> <th>标题</th> <th>内容</th> <th>选择</th> </tr> </thead> <!--内容容器--> <tbody id="con"> </tbody> </table> <!--分页容器--> <div id="paged" style="text-align: center;"></div> </div> <!--模板--> <script type="text/html" id="conTemp"> {{# layui.each(d.list, function(index, item){ }} <tr> <td>{{ item.title }}</td> <td>{{ item.content }}</td> <td> <input type="checkbox" name="chk"></td> </td> </tr> {{# }); }} </script> <script src="../js/jquery-1.7.2.min.js"></script> <script type="text/javascript" src="../plugins/layui/layui.js"></script> <script type="text/javascript" src="../js/oycommon.js" ></script> <script> //var G_APP_USRGUID = window.localStorage.getItem("XMIDWARE_APP_USRGUID"); //医生 var moban = ""; var url= "https://tsch.fromfuture.cn:7714/GZ/Docpre/queryPageFollow?userid=174BD3D5879C3BF0E050007F010077DC&type=3"; layui.config({ base: '../js/' }).use(['paging'], function() { var $ = layui.jquery, paging = layui.paging(); paging.init({ openWait: true, url:url, //地址 elem: '#con', //内容容器 type:'get', params: { //发送到服务端的参数 //t: Math.random(), //token:'F8F5AE2137BFAEF77FF7408476AF6C64', //pageIndex: 1 }, tempElem: '#conTemp', //模块容器 pageConfig: { //分页参数配置 elem: '#paged', //分页容器 pageSize: 10 ,//分页大小 pageNo:1 }, success: function() { //渲染成功的回调 //alert('渲染成功'); $("input[name='chk']").click(function () { if ($(this).attr('checked')) { moban= $(this).parent().prev().text(); alert(moban); } //这里拿到值存储 localStorage.setItem("name1",moban); }); }, fail: function(msg) { //获取数据失败的回调 //alert('获取数据失败') }, complate: function(res) { //完成的回调 //alert('处理完成'); console.log(res); }, }); }); </script> </body> </html>
json返回格式{
    "code": "000",
    "data": {
        "parameterType": [
            {
                "id": "451D34C65FDBC7FCE050007F01005BDA",
                "userid": "174BD3D5879C3BF0E050007F010077DC",
                "title": "注意事项模板",
                "content": "是知道消费观察观察发现GV",
                "type": "3",
                "state": "1",
                "createdate": "",
                "createname": "",
                "updatedate": "",
                "updatename": ""
            },
            {
                "id": "45278236d9f14d2697bea0a3b5d39b61",
                "userid": "174BD3D5879C3BF0E050007F010077DC",
                "title": "注意事项模板",
                "content": "uysdhbkjz摸啊速度很方便查看你都发扬光大",
                "type": "3",
                "state": "1",
                "createdate": "",
                "createname": "",
                "updatedate": "",
                "updatename": ""
            }
        ],
        "pageNo": 1,
        "totalPage": 1,
        "pageSize": 15,
        "totalRecord": 2
    },
    "message": "成功"
}
原文地址:https://www.cnblogs.com/hjptopshow/p/7809204.html