<?php
namespace MpSmi\Controller;

use Think\Controller;

header("Content-Type:text/html;CharSet=utf-8");
class LoginController extends Controller
{
    /**
     * 登陆页
     */
    public function login()
    {
        if (session('?store')) {
            $this->redirect('Index/index');die;
        }
        $this->display("login");die;
    }

    /**
     * 提交登陆信息
     */
    public function doLogin()
    {
        $time = time();
        $recieve = I();
        // 表单验证
        $result = D("Stores")->check($recieve['mobile'], $recieve['password']);
        if ($result['status'] == -1) {
            // 登陆有误，提示信息
            $this->error($result['msg']);die;
        } elseif ($result['status'] == 1) {
            // 登陆成功，跳转最近访问页 或 后台首页
            $this->redirect("Index/index");die;
        }
    }

    /**
     * 登出
     */
    public function logout()
    {
        session(null);
        $this->redirect('Login/login');die;
    }
}