wangtengyu
2018-12-14 dabb259bdecd9ace73a97b28d40f425a108aceab
用户列表调整 by 王腾宇
3 files modified
225 ■■■■ changed files
application/admin/controller/UserList.php 29 ●●●● patch | view | raw | blame | history
application/admin/template/user_list/index.htm 161 ●●●● patch | view | raw | blame | history
application/common/util/interface.func.php 35 ●●●●● patch | view | raw | blame | history
application/admin/controller/UserList.php
@@ -13,21 +13,34 @@
class UserList extends Base
{
    // 页面初始化
    public function _initialize()
    {}
    public function index()
    {
        $retData = toPost($GLOBALS["user_list_path"],array(
            "invitationCode"=>$GLOBALS["invitation_code"]
        ),"1000001");
        echo($retData);
        $list = array();
        if ($retData["rspCode"]==="e00000") {
            $list = $retData["rspData"];
        $param = I('get.');
        $param['invitationCode'] = $GLOBALS['invitation_code'];
        if ($param["min_date"] != null && $param["min_date"] != "") {
            $param["min_date"] = strtotime($param["min_date"]);
        }
        $this->assign('list',$list);
        if ($param["max_date"] != null && $param["max_date"] != "") {
            $param["max_date"] = strtotime($param["max_date"]);
        }
        $retData = toPost($GLOBALS["user_list_path"],$param,'1000001');
        if ($retData["rspCode"]==="e00000") {
            $this->assign('list',array_map(function ($row) {
                $row["status"] = $row["status"] == "2"? "有效":"无效";
                $row["joindate"] = date('Y-m-d H:i:s', $row["joindate"]);
                $row["starttime"] = date('Y-m-d H:i:s', $row["starttime"]);
                $row["endtime"] = $row["endtime"] == "0"? "永久有效":date('Y-m-d H:i:s', $row["endtime"]);
                return $row;
            },$retData["rspData"]));
        } else {
            $this->assign('list',array());
        }
        return $this->fetch();
    }
}
application/admin/template/user_list/index.htm
@@ -11,23 +11,66 @@
                <h3>用户列表</h3>
            </div>
            <div title="刷新数据" class="pReload"><i class="fa fa-refresh"></i></div>
            <form class="navbar-form form-inline" action="/login.php" method="get" onsubmit="layer_loading('正在处理');">
                <div class="sDiv">
                    <span style="font-size: 3px;">登录用户名:</span>
                    <div class="sDiv2">
                        <input type="text" size="30" name="user_name"  class="qsbox" >
                    </div>
                    <span style="font-size: 3px">手机号:</span>
                    <div class="sDiv2">
                        <input type="text" size="30" name="phone_number"  class="qsbox" >
                    </div>
                    <span style="font-size: 3px">注册时间:</span>
                    <div class="sDiv2">
                        <input type="text" id="min_date" name="min_date"  class="qsbox" readonly="readonly" >
                    </div>
                    <span style="font-size: 3px">~</span>
                    <div class="sDiv2">
                        <input type="text" id="max_date" name="max_date"  class="qsbox"  readonly="readonly">
                    </div>
                    <input type="hidden" name="m" value="admin">
                    <input type="hidden" name="c" value="UserList">
                    <input type="hidden" name="a" value="index">
                    <span style="font-size: 3px">状态:</span>
                    <div class="sDiv2">
                        <select name="status" class="qsbox">
                            <option value =""></option>
                            <option value ="0">无效</option>
                            <option value ="2">有效</option>
                        </select>
                    </div>
                    <div class="sDiv2">
                        <input type="submit" class="btn" value="搜索">
                    </div>
                </div>
            </form>
        </div>
        <div class="hDiv">
            <div class="hDivBox">
                <table cellspacing="0" cellpadding="0" style="width: 100%">
                    <thead>
                    <tr>
                        <th abbr="article_title" style="width: 25%">
                            <div style="text-align:center">ID</div>
                        <th abbr="article_title" style="width: 11%">
                            <div style="text-align:center">登录用户名</div>
                        </th>
                        <th abbr="article_title" style="width: 25%">
                            <div style="text-align:center">用户名</div>
                        <th abbr="article_title" style="width: 11%">
                            <div style="text-align:center">电话</div>
                        </th>
                        <th abbr="article_title" style="width: 25%">
                            <div style="text-align:center">电子邮箱</div>
                        <th abbr="article_title" style="width: 11%" >
                            <div style="text-align:center">QQ</div>
                        </th>
                        <th abbr="article_title" style="width: 25%" >
                            <div style="text-align:center">电话号码</div>
                        <th abbr="article_title" style="width: 11%" >
                            <div style="text-align:center">注册时间</div>
                        </th>
                        <th abbr="article_title" style="width: 11%" >
                            <div style="text-align:center">到期时间</div>
                        </th>
                        <th abbr="article_title" style="width: 11%" >
                            <div style="text-align:center">上次登录时间</div>
                        </th>
                        <th abbr="article_title" style="width: 11%" >
                            <div style="text-align:center">状态</div>
                        </th>
                    </tr>
                    </thead>
@@ -47,24 +90,39 @@
                    {else/}
                        {foreach name="list" item="vo" key="k" }
                        <tr>
                            <td style="width: 23.91%">
                            <td style="width: 10%">
                                <div style="text-align:center">
                                    {$vo.user_id}
                                    {$vo.username}
                                </div>
                            </td>
                            <td style="width: 24.7%">
                            <td style="width: 10%">
                                <div style="text-align:center">
                                    {$vo.user_name}
                                    {$vo.mobile}
                                </div>
                            </td>
                            <td style="width: 24.6%">
                            <td style="width: 10%">
                                <div style="text-align:center">
                                    {$vo.email}
                                    {$vo.qq}
                                </div>
                            </td>
                            <td style="width: 24.3%">
                            <td style="width: 10%">
                                <div style="text-align:center">
                                    {$vo.mobile_phone}
                                    {$vo.starttime}
                                </div>
                            </td>
                            <td style="width: 10%">
                                <div style="text-align:center">
                                    {$vo.endtime}
                                </div>
                            </td>
                            <td style="width: 10%">
                                <div style="text-align:center">
                                    {$vo.joindate}
                                </div>
                            </td>
                            <td style="width: 10%">
                                <div style="text-align:center">
                                    {$vo.status}
                                </div>
                            </td>
                        </tr>
@@ -79,4 +137,73 @@
    </div>
</div>
{include file="public/footer" /}
{include file="public/footer" /}
<script>
    // 暂时没有日历控件先写个临时的
    jQuery(function($){
     $.datepicker.regional['zh-CN'] = {
        clearText: '清除',
        clearStatus: '清除已选日期',
        closeText: '关闭',
        closeStatus: '不改变当前选择',
        prevText: '< 上月',
        prevStatus: '显示上月',
        prevBigText: '<<',
        prevBigStatus: '显示上一年',
        nextText: '下月>',
        nextStatus: '显示下月',
        nextBigText: '>>',
        nextBigStatus: '显示下一年',
        currentText: '今天',
        currentStatus: '显示本月',
        monthNames: ['一月','二月','三月','四月','五月','六月', '七月','八月','九月','十月','十一月','十二月'],
        monthNamesShort: ['一月','二月','三月','四月','五月','六月', '七月','八月','九月','十月','十一月','十二月'],
        monthStatus: '选择月份',
        yearStatus: '选择年份',
        weekHeader: '周',
        weekStatus: '年内周次',
        dayNames: ['星期日','星期一','星期二','星期三','星期四','星期五','星期六'],
        dayNamesShort: ['周日','周一','周二','周三','周四','周五','周六'],
        dayNamesMin: ['日','一','二','三','四','五','六'],
        dayStatus: '设置 DD 为一周起始',
        dateStatus: '选择 m月 d日, DD',
        dateFormat: 'yy-mm-dd',
        firstDay: 1,
        initStatus: '请选择日期',
        isRTL: false};
        $.datepicker.setDefaults($.datepicker.regional['zh-CN']);
    });
    $.datepicker.setDefaults({
        showButtonPanel: true,
        beforeShow : function( input ) {
            setTimeout(function() {
                var buttonPane = $(input)
                .datepicker( "widget" )
                .find( ".ui-datepicker-buttonpane" );
                $( "<button>", {
                    text: "清除",
                    click: function() {
                        $.datepicker._clearDate(input);
                    }
                }).addClass("ui-state-default ui-priority-primary ui-corner-all").appendTo( buttonPane );
            }, 1 );
        }
    });
    $(() => {
        const dateConf = {
            showOtherMonths: true,
            selectOtherMonths: true,
            showButtonPanel: true,
            showOn: "both",
            buttonImageOnly: true,
            buttonImage: "calendar.gif",
            buttonText: "",
            changeMonth: true,
            changeYear: true,
        }
        $("#min_date").datepicker(dateConf);
        $("#max_date").datepicker(dateConf);
    });
</script>
application/common/util/interface.func.php
@@ -115,21 +115,28 @@
}
function toPost($url, $param, $appId){
    return send_post($url."?".makeInterfaceParam($param,$appId), array());
    return doCurlPostRequest($url,makeInterfaceParam($param,$appId));
}
function send_post($url, $post_data) {
    $postdata = http_build_query($post_data);
    $options = array(
        'http' => array(
            'method' => 'POST',
            'header' => 'Content-type:application/x-www-form-urlencoded',
            'content' => $postdata,
            'timeout' => 15 * 60
        )
    );
    $context = stream_context_create($options);
    $result = file_get_contents($url, false, $context);
    return json_decode($result,true);
function doCurlPostRequest($url,$requestString,$timeout = 5){
    if($url == '' || $requestString == '' || $timeout <=0){
        return false;
    }
    $con = curl_init((string)$url);
    curl_setopt($con, CURLOPT_HEADER, false);
    curl_setopt($con, CURLOPT_POSTFIELDS, $requestString);
    curl_setopt($con, CURLOPT_POST,true);
    curl_setopt($con, CURLOPT_RETURNTRANSFER,true);
    curl_setopt($con, CURLOPT_TIMEOUT,(int)$timeout);
    if (strpos($url, 'https') !==false){
        curl_setopt($con, CURLOPT_SSL_VERIFYPEER, false);
    }
    $data = curl_exec($con);
    if (curl_errno($con)) {
        return curl_error($con);
    } else {
        curl_close($con);
        return json_decode($data,true);
    }
}