123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
- <?php
- namespace app\common\controller;
- use think\Controller;
- use app\common\model\SystemWeb;
- use app\common\model\SystemMemberMiniapp;
- use filter\Filter;
- class Base extends Controller{
- protected $web;
- protected $token = 0;
- protected $is_mp = false;
- protected $is_lightapp = false;
- protected $is_minapp = false;
- protected function initialize(){
- $this->web = SystemWeb::config();
- $this->assign(['web'=> $this->web]);
- }
-
- public function _empty(){
- return $this->error('访问的页面不存在');
- }
-
- protected function isAppTyes($apptyes){
- switch ($apptyes) {
- case 'mp':
- $this->is_mp = true;
- break;
- case 'program':
- $this->is_weapp = true;
- break;
- case 'app':
- $this->is_lapp = true;
- break;
- case 'mp_program':
- $this->is_mp = true;
- $this->is_weapp = true;
- break;
- case 'mp_program_app':
- $this->is_mp = true;
- $this->is_lapp = true;
- $this->is_weapp = true;
- break;
- }
- }
-
- protected function apiAccess() {
- $appid = $this->request->param('app/d',0);
- $condition = [];
- if(empty($appid)){
- $header = $this->request->header();
- if(empty($header['request-miniapp']) && empty($header['request-time'])){
- return false;
- }
- $condition['service_id'] = Filter::filter_escape($header['request-miniapp']);
- }else{
- $condition['id'] = (int)$appid;
- }
- $condition['is_lock'] = 0;
- $this->token = $header['request-token'] ?? 0;
- return SystemMemberMiniapp::where($condition)->field('id,member_id,appname,service_id,navbar_color,navbar_style,create_time,update_time,miniapp_appid,miniapp_id,mp_appid,is_psp,sdk_app_id,sdk_url')->find();
- }
- }
|