微信授权
parent
692cc64258
commit
a66301c756
|
|
@ -0,0 +1,48 @@
|
|||
{{include file="public/header" /}}
|
||||
|
||||
<!-- right content start -->
|
||||
<div class="content-right">
|
||||
<div class="content">
|
||||
<legend>
|
||||
<span class="fs-16">微信登录</span>
|
||||
<a href="{{:MyUrl('admin/pluginsadmin/index')}}" class="fr fs-14 m-t-5 am-icon-mail-reply"> 返回</a>
|
||||
</legend>
|
||||
|
||||
<div class="weixinwebauthorization-content">
|
||||
<div class="items">
|
||||
<label>AppID</label>
|
||||
<div>
|
||||
{{if !empty($data['appid'])}}
|
||||
{{$data.appid}}
|
||||
{{else /}}
|
||||
未填写
|
||||
{{/if}}
|
||||
</div>
|
||||
</div>
|
||||
<div class="items">
|
||||
<label>授权方式</label>
|
||||
<div>
|
||||
{{if isset($data['auth_type']) and $data['auth_type'] eq 1}}
|
||||
弹出授权
|
||||
{{else /}}
|
||||
静默授权
|
||||
{{/if}}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="items">
|
||||
<label>登录授权地址</label>
|
||||
<div>
|
||||
<a href="{{:PluginsHomeUrl('weixinwebauthorization', 'auth', 'index')}}" target="_blank">{{:PluginsHomeUrl('weixinwebauthorization', 'auth', 'index')}}</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<a href="{{:PluginsAdminUrl('weixinwebauthorization', 'admin', 'saveinfo')}}" class="am-btn am-btn-secondary am-radius btn-loading-example am-btn-sm am-btn-block edit-submit">编辑</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- right content end -->
|
||||
|
||||
<!-- footer start -->
|
||||
{{include file="public/footer" /}}
|
||||
<!-- footer end -->
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
{{include file="public/header" /}}
|
||||
|
||||
<!-- right content start -->
|
||||
<div class="content-right">
|
||||
<div class="content">
|
||||
<!-- form start -->
|
||||
<form class="am-form form-validation view-save" action="{{:PluginsAdminUrl('weixinwebauthorization', 'admin', 'save')}}" method="POST" request-type="ajax-url" request-value="{{:PluginsAdminUrl('weixinwebauthorization', 'admin', 'index')}}" enctype="multipart/form-data">
|
||||
<legend>
|
||||
<span class="fs-16">微信登录</span>
|
||||
<a href="{{:PluginsAdminUrl('weixinwebauthorization', 'admin', 'index')}}" class="fr fs-14 m-t-5 am-icon-mail-reply"> 返回</a>
|
||||
</legend>
|
||||
|
||||
<div class="am-form-group">
|
||||
<label>appid<span class="am-form-group-label-tips">公众号/服务号AppID</span></label>
|
||||
<input type="text" name="appid" placeholder="appid" maxlength="30" data-validation-message="appid格式最多 30 个字符" class="am-radius" {{if !empty($data['appid'])}} value="{{$data.appid}}"{{/if}} />
|
||||
</div>
|
||||
|
||||
<div class="am-form-group">
|
||||
<label>授权方式<span class="am-form-group-label-tips">默认 静默授权方式</span></label>
|
||||
<div>
|
||||
{{foreach $is_auth_type_list as $v}}
|
||||
<label class="am-radio-inline m-r-10">
|
||||
<input type="radio" name="auth_type" value="{{$v.id}}" {{if isset($data['auth_type']) and $data['auth_type'] eq $v['id']}}checked="checked"{{else /}}{{if !isset($data['auth_type']) and isset($v['checked']) and $v['checked'] eq true}}checked="checked"{{/if}}{{/if}} data-am-ucheck /> {{$v.name}}
|
||||
</label>
|
||||
{{/foreach}}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="am-form-group am-form-group-refreshing">
|
||||
<button type="submit" class="am-btn am-btn-primary am-radius btn-loading-example am-btn-sm am-btn-block" data-am-loading="{loadingText:'处理中...'}">保存</button>
|
||||
</div>
|
||||
</form>
|
||||
<!-- form end -->
|
||||
</div>
|
||||
</div>
|
||||
<!-- right content end -->
|
||||
|
||||
<!-- footer start -->
|
||||
{{include file="public/footer" /}}
|
||||
<!-- footer end -->
|
||||
|
|
@ -0,0 +1 @@
|
|||
<a href="{{:PluginsHomeUrl('weixinwebauthorization', 'auth', 'index')}}" class="am-btn am-btn-warning am-btn-xs am-radius plugins-touristbuy-login-info-btn">微信登录</a>
|
||||
|
|
@ -0,0 +1 @@
|
|||
<a href="{{:PluginsHomeUrl('weixinwebauthorization', 'auth', 'index')}}">微信登录</a>
|
||||
|
|
@ -0,0 +1,85 @@
|
|||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | ShopXO 国内领先企业级B2C免费开源电商系统
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2011~2019 http://shopxo.net All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: Devil
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\plugins\weixinwebauthorization;
|
||||
|
||||
use think\Controller;
|
||||
|
||||
/**
|
||||
* 微信登录 - 钩子入口
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 0.0.1
|
||||
* @datetime 2016-12-01T21:51:08+0800
|
||||
*/
|
||||
class Hook extends Controller
|
||||
{
|
||||
/**
|
||||
* 应用响应入口
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 1.0.0
|
||||
* @datetime 2019-02-09T14:25:44+0800
|
||||
* @param [array] $params [输入参数]
|
||||
*/
|
||||
public function run($params = [])
|
||||
{
|
||||
if(!empty($params['hook_name']))
|
||||
{
|
||||
switch($params['hook_name'])
|
||||
{
|
||||
// 用户登录页面顶部钩子
|
||||
// 用户注册页面钩子
|
||||
case 'plugins_view_user_login_info_top' :
|
||||
case 'plugins_view_user_reg_info_top' :
|
||||
$ret = $this->ButtonHtml($params);
|
||||
break;
|
||||
|
||||
// 公共顶部小导航钩子-左侧
|
||||
case 'plugins_view_header_navigation_top_left' :
|
||||
$ret = $this->NavTextHtml($params);
|
||||
break;
|
||||
|
||||
default :
|
||||
$ret = '';
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 登录登录html
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 1.0.0
|
||||
* @date 2019-05-24
|
||||
* @desc description
|
||||
* @param array $params [description]
|
||||
*/
|
||||
private function ButtonHtml($params = [])
|
||||
{
|
||||
return $this->fetch('../../../plugins/view/weixinwebauthorization/index/public/auth_button');
|
||||
}
|
||||
|
||||
/**
|
||||
* 文字登录html
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 1.0.0
|
||||
* @date 2019-05-24
|
||||
* @desc description
|
||||
* @param array $params [description]
|
||||
*/
|
||||
private function NavTextHtml($params = [])
|
||||
{
|
||||
return $this->fetch('../../../plugins/view/weixinwebauthorization/index/public/auth_text');
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
@ -0,0 +1,85 @@
|
|||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | ShopXO 国内领先企业级B2C免费开源电商系统
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2011~2019 http://shopxo.net All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: Devil
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\plugins\weixinwebauthorization\admin;
|
||||
|
||||
use think\Controller;
|
||||
use app\service\PluginsService;
|
||||
|
||||
/**
|
||||
* 微信登录 - 后台管理
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 0.0.1
|
||||
* @datetime 2016-12-01T21:51:08+0800
|
||||
*/
|
||||
class Admin extends Controller
|
||||
{
|
||||
/**
|
||||
* 首页
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 1.0.0
|
||||
* @datetime 2019-02-07T08:21:54+0800
|
||||
* @param [array] $params [输入参数]
|
||||
*/
|
||||
public function index($params = [])
|
||||
{
|
||||
$ret = PluginsService::PluginsData('weixinwebauthorization');
|
||||
if($ret['code'] == 0)
|
||||
{
|
||||
$this->assign('data', $ret['data']);
|
||||
return $this->fetch('../../../plugins/view/weixinwebauthorization/admin/admin/index');
|
||||
} else {
|
||||
return $ret['msg'];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑页面
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 1.0.0
|
||||
* @datetime 2019-02-07T08:21:54+0800
|
||||
* @param [array] $params [输入参数]
|
||||
*/
|
||||
public function saveinfo($params = [])
|
||||
{
|
||||
$ret = PluginsService::PluginsData('weixinwebauthorization');
|
||||
if($ret['code'] == 0)
|
||||
{
|
||||
// 授权方式
|
||||
$is_auth_type_list = [
|
||||
0 => array('id' => 0, 'name' => '静默授权', 'checked' => true),
|
||||
1 => array('id' => 1, 'name' => '弹出授权'),
|
||||
];
|
||||
|
||||
$this->assign('is_auth_type_list', $is_auth_type_list);
|
||||
$this->assign('data', $ret['data']);
|
||||
return $this->fetch('../../../plugins/view/weixinwebauthorization/admin/admin/saveinfo');
|
||||
} else {
|
||||
return $ret['msg'];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 数据保存
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 1.0.0
|
||||
* @datetime 2019-02-07T08:21:54+0800
|
||||
* @param [array] $params [输入参数]
|
||||
*/
|
||||
public function save($params = [])
|
||||
{
|
||||
return PluginsService::PluginsDataSave(['plugins'=>'weixinwebauthorization', 'data'=>$params]);
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
{
|
||||
"base":{
|
||||
"plugins":"weixinwebauthorization",
|
||||
"name":"微信登录",
|
||||
"logo":"\/static\/upload\/images\/plugins_weixinwebauthorization\/2019\/05\/24\/1558681549248354.jpg",
|
||||
"author":"Devil",
|
||||
"author_url":"https:\/\/shopxo.net\/",
|
||||
"version":"1.0.0",
|
||||
"desc":"微信授权登录、注册",
|
||||
"apply_terminal":[
|
||||
"pc",
|
||||
"h5"
|
||||
],
|
||||
"apply_version":[
|
||||
"1.5.0"
|
||||
],
|
||||
"is_home":false
|
||||
},
|
||||
"hook":{
|
||||
"plugins_view_user_login_info_top":[
|
||||
"app\\plugins\\weixinwebauthorization\\Hook"
|
||||
],
|
||||
"plugins_view_user_reg_info_top":[
|
||||
"app\\plugins\\weixinwebauthorization\\Hook"
|
||||
],
|
||||
"plugins_view_header_navigation_top_left":[
|
||||
"app\\plugins\\weixinwebauthorization\\Hook"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,75 @@
|
|||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | ShopXO 国内领先企业级B2C免费开源电商系统
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2011~2019 http://shopxo.net All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: Devil
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\plugins\weixinwebauthorization\index;
|
||||
|
||||
use think\Controller;
|
||||
use app\service\PluginsService;
|
||||
|
||||
/**
|
||||
* 微信登录 - 登录授权
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 0.0.1
|
||||
* @datetime 2016-12-01T21:51:08+0800
|
||||
*/
|
||||
class Auth extends Controller
|
||||
{
|
||||
/**
|
||||
* 授权
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 1.0.0
|
||||
* @datetime 2019-02-07T08:21:54+0800
|
||||
* @param [array] $params [输入参数]
|
||||
*/
|
||||
public function index($params = [])
|
||||
{
|
||||
$ret = PluginsService::PluginsData('weixinwebauthorization');
|
||||
if($ret['code'] == 0)
|
||||
{
|
||||
// 参数校验
|
||||
if(empty($ret['data']['appid']))
|
||||
{
|
||||
$this->assign('msg', 'appid未配置');
|
||||
return $this->fetch('public/tips_error');
|
||||
}
|
||||
|
||||
// 回调地址
|
||||
$redirect_uri = urlencode(PluginsHomeUrl('weixinwebauthorization', 'auth', 'callback'));
|
||||
|
||||
// 授权方式
|
||||
$auth_type = (isset($ret['data']['auth_type']) && $ret['data']['auth_type'] == 1) ? 'snsapi_userinfo' : 'snsapi_base';
|
||||
|
||||
// 授权code
|
||||
$url = 'https://open.weixin.qq.com/connect/oauth2/authorize?appid='.$ret['data']['appid'].'&redirect_uri='.$redirect_uri.'&response_type=code&scope='.$auth_type.'&state=login#wechat_redirect';
|
||||
return redirect($url);
|
||||
} else {
|
||||
$this->assign('msg', $ret['msg']);
|
||||
return $this->fetch('public/tips_error');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 回调
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 1.0.0
|
||||
* @datetime 2019-02-07T08:21:54+0800
|
||||
* @param [array] $params [输入参数]
|
||||
*/
|
||||
public function callback($params = [])
|
||||
{
|
||||
echo '<pre>';
|
||||
print_r($params);
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
|
|
@ -103,10 +103,12 @@ return array (
|
|||
'plugins_view_header_navigation_top_left' =>
|
||||
array (
|
||||
0 => 'app\\plugins\\touristbuy\\Hook',
|
||||
1 => 'app\\plugins\\weixinwebauthorization\\Hook',
|
||||
),
|
||||
'plugins_view_user_login_info_top' =>
|
||||
array (
|
||||
0 => 'app\\plugins\\touristbuy\\Hook',
|
||||
1 => 'app\\plugins\\weixinwebauthorization\\Hook',
|
||||
),
|
||||
'plugins_view_user_reg_info' =>
|
||||
array (
|
||||
|
|
@ -154,5 +156,9 @@ return array (
|
|||
array (
|
||||
0 => 'app\\plugins\\wallet\\Hook',
|
||||
),
|
||||
'plugins_view_user_reg_info_top' =>
|
||||
array (
|
||||
0 => 'app\\plugins\\weixinwebauthorization\\Hook',
|
||||
),
|
||||
);
|
||||
?>
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
/**
|
||||
* 首页
|
||||
*/
|
||||
.weixinwebauthorization-content .items {
|
||||
margin: 10px 0 20px 0;
|
||||
border-bottom: 1px dashed #f1f1f1;
|
||||
padding-bottom: 20px;
|
||||
}
|
||||
.weixinwebauthorization-content .edit-submit {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 8.7 KiB |
Loading…
Reference in New Issue