<?php

namespace Platform\Api\Authorization;

use Platform\Common\Api;

/**
 * 第三方登录
 */
class Authorization extends Api {

    public function getRules() {
        return array(
            //微信登录回调
            'weChatLogin' => array(
            ),
        );
    }


    /**
     * 第三方配置
     * @desc 第三方配置
     */
    public function authorizationConfig(){

        $authorization_app = \PhalApi\DI()->config->get('app.authorization_app');

        if (empty($authorization_app)){
            return [];
        }

        $quickLogin = [];
        foreach ($authorization_app as $k=>$v){
            $callback = new  $v['app_callback_url']();
            $callback_url = $callback->$k();
            $quickLogin[] = [
                'icon'=>PHALAPI_SERVER_HOST. $v['icon'],//图标添加域名
                'callback_url'=>$callback_url, //回调跳转王者
                'desc'=>$v['desc']
            ];
        }
        return [
            'quick_login'=>$quickLogin,
        ];
    }

    /**
     * 微信登录
     * @desc 获取微信登录链接
     */
    public function weChatLogin(){
      $authorizationDomain = new \Base\Domain\Authorization();
      $result = $authorizationDomain->weChat();
      return $result;
   }


    /**
     * 登录后微信扫码绑定接口
     * @desc 登录后微信扫码绑定接口
     */
   public function weChatLoginBind(){
       $authorizationDomain = new \Base\Domain\Authorization();
       $result = $authorizationDomain->weChat();
       return $result;
   }



}
