<?php
/**
 *
 * User: anyluck
 * Date: 2020/6/2
 * Time: 17:36
 */

namespace app\admin\controller;


use app\common\controller\Backend;
use app\common\model\UserLevel;
use think\facade\Db;
use think\facade\Request;
use think\facade\View;

class Agent extends Backend
{
 // 代理商

    /**
     * 代理商列表
     */
    public function index()
    {
        if (Request::isPost()) {
            $keys = Request::post('keys', '', 'trim');
            $page = Request::post('page') ? Request::post('page') : 1;
            $limit=input("limit")?:10;

            $where["is_admin"]=1;
            $list = Db::name('user')
                ->where('mail|phone|name','like',"%".$keys."%")
                ->where($where)
                ->order('id desc')
                ->paginate(['list_rows' =>$limit, 'page' => $page])
                ->toArray();
            foreach ($list['data'] as $k=>$v){
                if ($v['update_time']){
                    $list['data'][$k]['update_time'] = date('Y-m-d H:i',$v['update_time']);
                }
            }
            return $result = ['code' => 0, 'msg' => lang('get info success'), 'data' => $list['data'], 'count' => $list['total']];
        }

        $vip=UserLevel::select();
        View::assign("vip",$vip);
        return View::fetch();
    }

    /**
     * 代理商详情
     */
    public function show()
    {

    }

    /**
     * 停用代理商
     */
    public function update_status()
    {

    }

    /**
     * 下级用户列表
     */
    public function xiaji()
    {
        
    }

    /**
     * 代理充值
     */
    public function chongzhi()
    {

    }
}