layui table thinkphp 结合

HTML代码



<table class="layui-hide" id="specialCall">table>
<script>
    layui.use('table', function(){
        var table = layui.table;
        var phone = "";
        table.render({
            elem: '#specialCall'
            ,url:"/index/user/specialCall"
            ,where:{phone: phone}
            ,cols: [[
                {field:'id', width:180, title: '编号', sort: true}
                ,{field:'phone', width:200, title: '号码', sort: true}
                ,{field:'phone_info', width:200, title: '通话机构'}
                ,{field:'talk_cnt', width:200, title: '通话次数(次)', sort: true}
                ,{field:'talk_seconds', width:180, title: '通话时长(分钟)'}
                ,{field:'call_cnt', title: '主叫次数(次)', minWidth: 180}
                ,{field:'call_seconds', width:180, title: '主叫时长(分钟)', sort: true}
                ,{field:'called_cnt', width:180, title: '被叫次数(次)', sort: true}
                ,{field:'called_seconds', width:180, title: '被叫时长(分钟)'}
            ]]
            ,page: true

        });
    });
script>

php 代码


public  function specialCall($phone='')
{
   $calllog = model('RongMobileReport')->where('cellphone',$phone)->value('calllog');
   $calllog = json_decode($calllog,true);
    $res = array();
    $data = array();
    $i = 0;
   foreach($calllog as $key=>$val){
        $phone_info = $val['phone_info'];
        if($phone_info!=''){
            $res[$key]['id'] = $key;
            $res[$key]['phone'] = $val['phone'];
            $res[$key]['phone_info'] = $val['phone_info'];
            $res[$key]['talk_cnt'] = $val['talk_cnt'];
            $res[$key]['talk_seconds'] = $val['talk_seconds'];
            $res[$key]['call_cnt'] = $val['call_cnt'];
            $res[$key]['call_seconds'] = $val['call_seconds'];
            $res[$key]['called_cnt'] = $val['called_cnt'];
            $res[$key]['called_seconds'] = $val['called_seconds'];
            $i=++$i;
        }
   }
   sort($res);
    $data['code'] = 0;
    $data['msg'] = '';
    $data['count'] =$i ;
    $data['data'] = $res;
    return $data;
   }

你可能感兴趣的:(layui,layui.table)