qingjian/app/controller/api/Base.php

27 lines
718 B
PHP

<?php
namespace app\controller\api;
use app\controller\BaseController;
use app\model\User;
use app\model\WeixinAccountMini;
/**
* 控制器基础类
*/
class Base extends BaseController
{
protected $data = [];
protected $token;//小程序token
protected $openid;//主用户token
protected $user;//小程序用户id
protected function initialize()
{
$allHeader = $this->request->header();
$this->token = isset($allHeader["wechattoken"]) ? $allHeader["wechattoken"] : "";
$this->openid = isset($allHeader["openid"]) ? $allHeader["openid"] : "";
$this->user = User::userTokenVerification($this->token, $this->openid);
}
}