<?php
namespace app\index\controller;
use think\facade\Db;
use think\facade\View;
use think\facade\Cookie;
use app\BaseController;

class Base extends BaseController
{
    public function __construct()
    {
        $user_hash = input('user_hash');
        $user_id = input('user_id');
        if(empty($user_id)) {
            exit(json_encode(['status' => -99, 'msg' => '未输入user_id！', 'data' => []]));
        }
        if(empty($user_hash)) {
            exit(json_encode(['status' => -99, 'msg' => '未输入user_id！', 'data' => []]));
        }
        if($user_hash === md5(md5('e81feb5867d6a0c'.$user_id.'e81feb5867d6a0c'))) {
            $user = Db::name('user') -> where('user_id', $user_id) -> find();
            if($user) {
                return $user['user_id'];
            } else {
                exit(json_encode(['status' => -98, 'msg' => '账号已被删除', 'data' => []]));
            }
        } else {
            exit(json_encode(['status' => -98, 'msg' => '账号异常', 'data' => []]));
        }
    }
}