<?php
/**
 * 河长制小程序
 * Created by PhpStorm.
 * User: Kevin
 * Date: 2022/6/28
 * Time: 09:00
 */

namespace app\api\controller\v1;

use app\common\controller\Api;
use think\Db;
use think\Request;

header('Content-type:text/html; Charset=utf-8');
date_default_timezone_set('PRC');

class Base extends Api
{
    protected $noNeedLogin = ['*'];//*无需验证登陆
    protected $AppID;
    protected $AppSecret;
    protected $qiniuUrl;
    protected $all_group_info;
    protected $userLevel;

    public function __construct(Request $request = null)
    {
        parent::__construct($request);
        $this->qiniuUrl = 'https://qiniu.ynzhsk.cn/';
        $this->AppID = 'wx6db1e094fc12126b';//微信小程序AppID
        $this->AppSecret = '2f3c454c7dce953cf4b0fa1bc3a9dc32';//微信小程序密钥
        $this->all_group_info = Db::name("user_group")->where("status", "normal")->column("id,name");
        //判断当前用户身份,普通用户、还是后台巡检员
        $uid = $this->auth->id;
        $data = [];
        if (!empty($uid) && $uid > 0) {
            $info = Db::name('user')
                ->where(['id' => $uid])
                ->field('id,group_id,username,avatar,mobile')
                ->find();
            if ($info['group_id'] > 1) {
                //判断河长身份

            } else {
                $info['user_lv'] = 1;
                $info['user_lv_msg'] = '普通用户';
            }
            $this->userLevel = $info;
        }
    }

}