<?php
 namespace TechSoft\Laravel\Admin\Traits; use TechOnline\Laravel\Http\Request; use TechOnline\Laravel\Http\Response; use TechSoft\Laravel\Admin\Cms\ConfigCms; use TechSoft\Laravel\Admin\Cms\Field\FieldSwitch; use TechSoft\Laravel\Admin\Cms\Field\FieldText; trait ConfigOauthTrait { public function oauthWechatMobile(ConfigCms $configCms) { return $configCms->execute($this, [ 'group' => 'oauthWechatMobile', 'pageTitle' => '微信手机授权登录', 'fields' => [ 'oauthWechatMobileEnable' => ['type' => FieldSwitch::class, 'title' => '[手机] 开启微信授权登录', 'desc' => ''], 'oauthWechatMobileProxy' => ['type' => FieldText::class, 'title' => '[手机] 授权回调域名代理', 'desc' => '如不清楚此参数意义,请留空'], 'oauthWechatMobileAppId' => ['type' => FieldText::class, 'title' => '[手机] AppId', 'desc' => ''], 'oauthWechatMobileAppSecret' => ['type' => FieldText::class, 'title' => '[手机] AppSecret', 'desc' => ''], ] ]); } public function oauthWechat(ConfigCms $configCms) { return $configCms->execute($this, [ 'group' => 'oauthWechat', 'pageTitle' => '微信PC授权登录', 'fields' => [ 'oauthWechatEnable' => ['type' => FieldSwitch::class, 'title' => '[PC端] 开启PC微信扫码登录', 'desc' => '回调域名请填写 <code>' . Request::server('HTTP_HOST') . '</code>'], 'oauthWechatProxy' => ['type' => FieldText::class, 'title' => '[PC端] 授权回调域名代理', 'desc' => '如不清楚此参数意义,请留空'], 'oauthWechatAppId' => ['type' => FieldText::class, 'title' => '[PC端] AppId', 'desc' => ''], 'oauthWechatAppSecret' => ['type' => FieldText::class, 'title' => '[PC端] AppSecret', 'desc' => ''], ] ]); } public function oauthQQ(ConfigCms $configCms) { return $configCms->execute($this, [ 'group' => 'oauthQQ', 'pageTitle' => 'QQ授权登录', 'fields' => [ 'oauthQQEnable' => ['type' => FieldSwitch::class, 'title' => '开启QQ授权登录', 'desc' => '回调地址请填写 <code>' . Request::schema() . '://' . Request::server('HTTP_HOST') . '/oauth_callback_qq</code>'], 'oauthQQKey' => ['type' => FieldText::class, 'title' => 'APP ID', 'desc' => ''], 'oauthQQAppSecret' => ['type' => FieldText::class, 'title' => 'APP KEY', 'desc' => ''], ] ]); } public function oauthWeibo(ConfigCms $configCms) { return $configCms->execute($this, [ 'group' => 'oauthWeibo', 'pageTitle' => '微博授权登录', 'fields' => [ 'oauthWeiboEnable' => ['type' => FieldSwitch::class, 'title' => '开启微博授权登录', 'desc' => '回调地址请填写 <code>' . Request::schema() . '://' . Request::server('HTTP_HOST') . '/oauth_callback_weibo</code>'], 'oauthWeiboKey' => ['type' => FieldText::class, 'title' => 'Key', 'desc' => ''], 'oauthWeiboAppSecret' => ['type' => FieldText::class, 'title' => 'AppSecret', 'desc' => ''], ] ]); } public function oauthWechatMiniProgram(ConfigCms $configCms) { return $configCms->execute($this, [ 'group' => 'wechatMiniProgram', 'pageTitle' => '微信小程序', 'fields' => [ 'oauthWechatMiniProgramEnable' => ['type' => FieldSwitch::class, 'title' => '启用小程序', 'desc' => ''], 'oauthWechatMiniProgramAppId' => ['type' => FieldText::class, 'title' => 'AppId', 'desc' => ''], 'oauthWechatMiniProgramAppSecret' => ['type' => FieldText::class, 'title' => 'AppSecret', 'desc' => ''], ] ]); } public function oauthWechatServer(ConfigCms $configCms) { $descs = []; $descs[] = '<div style="line-height:2em;">'; $descs[] = '配置信息参照如下'; $descs[] = '登录授权的发起页域名:' . Request::server('HTTP_HOST'); $descs[] = '授权事件接收URL:' . Request::schema() . '://' . Request::server('HTTP_HOST') . '/wx/notify'; $descs[] = '公众号消息与事件接收URL:' . Request::schema() . '://' . Request::server('HTTP_HOST') . '/wx/handle/$APPID$'; $descs[] = '公众号开发域名:' . Request::server('HTTP_HOST'); $descs[] = '</div>'; return $configCms->execute($this, [ 'group' => 'oauthWechatServer', 'pageTitle' => '微信第三方平台设置', 'fields' => [ 'wechatAuthorizationEnable' => ['type' => FieldSwitch::class, 'title' => '开启授权', 'desc' => ''], 'wechatAuthorizationAppId' => ['type' => FieldText::class, 'title' => 'AppID', 'desc' => ''], 'wechatAuthorizationAppSecret' => ['type' => FieldText::class, 'title' => 'AppSecret', 'desc' => ''], 'wechatAuthorizationToken' => ['type' => FieldText::class, 'title' => '公众号消息校验Token', 'desc' => ''], 'wechatAuthorizationEncodingKey' => ['type' => FieldText::class, 'title' => '公众号消息加解密Key', 'desc' => join("<br/>", $descs)], ] ]); } }