<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Index extends Api_Controller {

    public function __construct()
    {
        parent::__construct();
        
    }


    public function index(){
        

        $page = intval($this->input->post('page'));
        $pagesize = intval($this->input->post('pagesize'));

        $page = $page < 1 ? 1 : $page;
        $pagesize = $pagesize < 1 ? 10 : $pagesize;

        $data = array(
            'user' => array(
                'status' => '0',
                'username' => '',
                'uid' => '0',
                'level' => '1',
                'code_image' => '',
                'end_time' => 0,
                'end_timestamp' => 0

            ),
            'shop_list' => array(
            )
        );


        //判断是否登录
        if($this->user->checkLogin()
            && $this->user->getUserInfo()){     
            $data['user']['username'] = $this->user->username;
            $data['user']['uid'] = $this->user->uid;
            $data['user']['level'] = $this->user->level;
            $data['user']['code_image'] = $this->user->codeImage();
            $data['user']['end_time'] = $this->user->end_time;
            $data['user']['end_timestamp'] = $this->user->end_timestamp;

        }
        $data['user']['status'] = $this->user->status;

        $this->load->library('shop_service', array(), 'shop');

        $data['shop_list'] = $this->shop->getList($page, $pagesize,  0, 0,  'create_time', 2);

        $this->json('0', '成功', $data); 
    }


}
