Base.php
1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?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;
}
}
}