提交 b405c34d 编写于 作者: D devil_gong

微信授权

上级 ab3ffb7f
......@@ -26,7 +26,7 @@
<div class="forgetpwd-top">
{{if in_array('sms', MyC('home_user_reg_state')) or in_array('email', MyC('home_user_reg_state'))}}
<span class="">还没有帐号?</span>
<a href="{{:MyUrl('index/user/reginfo')}}" class="am-btn am-btn-secondary am-btn-xs am-radius">立即注册</a>
<a href="{{:MyUrl('index/user/reginfo')}}" class="am-btn am-btn-secondary am-btn-xs am-radius">注册</a>
{{/if}}
<!-- 用户登录页面顶部钩子 -->
......
......@@ -137,8 +137,7 @@ class Hook extends Controller
public function Style($params = [])
{
return '<style type="text/css">
.plugins-touristbuy-nav-top, .plugins-touristbuy-login-info-btn { margin-left: 10px; }
.plugins-touristbuy-nav-top { color: #FF5722; }
.plugins-touristbuy-nav-top { color: #FF5722; }
</style>';
}
......@@ -166,8 +165,8 @@ class Hook extends Controller
// 获取应用数据
$ret = PluginsService::PluginsData('touristbuy');
$login_name = empty($ret['data']['login_name']) ? '游客登录' : $ret['data']['login_name'];
return '<a href="'.PluginsHomeUrl('touristbuy', 'index', 'login', ['is_parent'=>$is_parent]).'" class="am-btn am-btn-warning am-btn-xs am-radius plugins-touristbuy-login-info-btn">'.$login_name.'</a>';
$login_name = empty($ret['data']['login_name']) ? '游客' : $ret['data']['login_name'];
return '<a href="'.PluginsHomeUrl('touristbuy', 'index', 'login', ['is_parent'=>$is_parent]).'" class="am-btn am-btn-warning am-btn-xs am-radius am-margin-left-xs">'.$login_name.'</a>';
}
return '';
}
......@@ -188,8 +187,8 @@ class Hook extends Controller
{
// 获取应用数据
$ret = PluginsService::PluginsData('touristbuy');
$login_name = empty($ret['data']['login_name']) ? '游客登录' : $ret['data']['login_name'];
return '<a href="'.PluginsHomeUrl('touristbuy', 'index', 'login').'" class="plugins-touristbuy-nav-top">'.$login_name.'</a>';
$login_name = empty($ret['data']['login_name']) ? '游客' : $ret['data']['login_name'];
return '<a href="'.PluginsHomeUrl('touristbuy', 'index', 'login').'" class="plugins-touristbuy-nav-top am-margin-left-xs">'.$login_name.'</a>';
}
return '';
}
......
......@@ -25,7 +25,7 @@
{{if !empty($data['login_name'])}}
{{$data.login_name}}
{{else /}}
游客登录
游客
{{/if}}
</div>
</div>
......
......@@ -16,13 +16,13 @@
</div>
<div class="am-form-group">
<label>登录入口名称<span class="am-form-group-label-tips">默认 游客登录</span></label>
<input type="text" name="login_name" placeholder="登录入口名称" maxlength="30" data-validation-message="登录入口名称格式最多 30 个字符" class="am-radius" value="{{if !empty($data['login_name'])}}{{$data.login_name}}{{else /}}游客登录{{/if}}" />
<label>登录入口名称<span class="am-form-group-label-tips">默认 游客</span></label>
<input type="text" name="login_name" placeholder="登录入口名称" maxlength="30" data-validation-message="登录入口名称格式最多 30 个字符" class="am-radius" value="{{if !empty($data['login_name'])}}{{$data.login_name}}{{else /}}游客{{/if}}" />
</div>
<div class="am-form-group">
<label>游客用户名<span class="am-form-group-label-tips">默认 游客</span></label>
<input type="text" name="nickname" placeholder="游客用户名" maxlength="16" data-validation-message="游客用户名格式最多 16 个字符" class="am-radius" value="{{if !empty($data['nickname'])}}{{$data.nickname}}{{else /}}游客{{/if}}" />
<label>游客用户名前缀<span class="am-form-group-label-tips">默认 游客</span></label>
<input type="text" name="nickname" placeholder="游客用户名前缀" maxlength="6" data-validation-message="游客用户名前缀格式最多 6 个字符" class="am-radius" value="{{if !empty($data['nickname'])}}{{$data.nickname}}{{else /}}游客{{/if}}" />
</div>
<div class="am-form-group">
......
......@@ -40,6 +40,27 @@
</div>
</div>
<div class="items">
<label>登录入口名称</label>
<div>
{{if !empty($data['login_name'])}}
{{$data.login_name}}
{{else /}}
微信
{{/if}}
</div>
</div>
<div class="items">
<label>微信用户名前缀</label>
<div>
{{if !empty($data['nickname'])}}
{{$data.nickname}}
{{else /}}
微信
{{/if}}
</div>
</div>
<div class="items">
<label>登录授权地址</label>
<div>
......
......@@ -20,6 +20,16 @@
<input type="text" name="secret" placeholder="secret" maxlength="60" data-validation-message="secret格式最多 60 个字符" class="am-radius" {{if !empty($data['secret'])}} value="{{$data.secret}}"{{/if}} />
</div>
<div class="am-form-group">
<label>登录入口名称<span class="am-form-group-label-tips">默认 微信</span></label>
<input type="text" name="login_name" placeholder="登录入口名称" maxlength="30" data-validation-message="登录入口名称格式最多 30 个字符" class="am-radius" value="{{if !empty($data['login_name'])}}{{$data.login_name}}{{else /}}微信{{/if}}" />
</div>
<div class="am-form-group">
<label>微信用户名前缀<span class="am-form-group-label-tips">默认 微信</span></label>
<input type="text" name="nickname" placeholder="微信用户名" maxlength="6" data-validation-message="微信用户名前缀格式最多 6 个字符" class="am-radius" value="{{if !empty($data['nickname'])}}{{$data.nickname}}{{else /}}微信{{/if}}" />
</div>
<div class="am-form-group">
<label>授权方式<span class="am-form-group-label-tips">默认 静默授权方式</span></label>
<div>
......
<a href="{{:PluginsHomeUrl('weixinwebauthorization', 'auth', 'index')}}" class="am-btn am-btn-warning am-btn-xs am-radius plugins-touristbuy-login-info-btn">微信登录</a>
\ No newline at end of file
<a href="{{:PluginsHomeUrl('weixinwebauthorization', 'auth', 'index')}}" class="am-btn am-btn-success am-btn-xs am-radius am-margin-left-xs">{{if empty($plugins_data['login_name'])}}微信{{else /}}{{$plugins_data.login_name}}{{/if}}</a>
\ No newline at end of file
<a href="{{:PluginsHomeUrl('weixinwebauthorization', 'auth', 'index')}}">微信登录</a>
\ No newline at end of file
<a href="{{:PluginsHomeUrl('weixinwebauthorization', 'auth', 'index')}}" class="am-icon-weixin am-margin-left-xs plugins-weixinwebauthorization-nav-top-text"> {{if empty($plugins_data['login_name'])}}微信{{else /}}{{$plugins_data.login_name}}{{/if}}</a>
\ No newline at end of file
......@@ -11,6 +11,7 @@
namespace app\plugins\weixinwebauthorization;
use think\Controller;
use app\service\PluginsService;
/**
* 微信登录 - 钩子入口
......@@ -31,14 +32,15 @@ class Hook extends Controller
*/
public function run($params = [])
{
if(!empty($params['hook_name']))
// 目前微信登录只针对手机端
if(!empty($params['hook_name']) && IsMobile())
{
switch($params['hook_name'])
{
// 用户登录页面顶部钩子
// 用户注册页面钩子
case 'plugins_view_user_login_info_top' :
case 'plugins_view_user_reg_info_top' :
case 'plugins_view_user_reg_info' :
$ret = $this->ButtonHtml($params);
break;
......@@ -47,6 +49,11 @@ class Hook extends Controller
$ret = $this->NavTextHtml($params);
break;
// header代码
case 'plugins_common_header' :
$ret = $this->Style($params);
break;
default :
$ret = '';
}
......@@ -54,6 +61,21 @@ class Hook extends Controller
}
}
/**
* css
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @datetime 2019-02-06T16:16:34+0800
* @param [array] $params [输入参数]
*/
public function Style($params = [])
{
return '<style type="text/css">
.plugins-weixinwebauthorization-nav-top-text { color: #3db53d; }
</style>';
}
/**
* 登录登录html
* @author Devil
......@@ -65,6 +87,8 @@ class Hook extends Controller
*/
private function ButtonHtml($params = [])
{
$ret = PluginsService::PluginsData('weixinwebauthorization');
$this->assign('plugins_data', $ret['data']);
return $this->fetch('../../../plugins/view/weixinwebauthorization/index/public/auth_button');
}
......@@ -79,6 +103,8 @@ class Hook extends Controller
*/
private function NavTextHtml($params = [])
{
$ret = PluginsService::PluginsData('weixinwebauthorization');
$this->assign('plugins_data', $ret['data']);
return $this->fetch('../../../plugins/view/weixinwebauthorization/index/public/auth_text');
}
}
......
......@@ -20,11 +20,14 @@
"plugins_view_user_login_info_top":[
"app\\plugins\\weixinwebauthorization\\Hook"
],
"plugins_view_user_reg_info_top":[
"plugins_view_user_reg_info":[
"app\\plugins\\weixinwebauthorization\\Hook"
],
"plugins_view_header_navigation_top_left":[
"app\\plugins\\weixinwebauthorization\\Hook"
],
"plugins_common_header":[
"app\\plugins\\weixinwebauthorization\\Hook"
]
}
}
\ No newline at end of file
......@@ -87,6 +87,7 @@ return array (
0 => 'app\\plugins\\expressforkdn\\Hook',
1 => 'app\\plugins\\touristbuy\\Hook',
2 => 'app\\plugins\\homemiddleadv\\Hook',
3 => 'app\\plugins\\weixinwebauthorization\\Hook',
),
'plugins_admin_common_header' =>
array (
......@@ -113,6 +114,7 @@ return array (
'plugins_view_user_reg_info' =>
array (
0 => 'app\\plugins\\touristbuy\\Hook',
1 => 'app\\plugins\\weixinwebauthorization\\Hook',
),
'plugins_service_buy_handle' =>
array (
......@@ -156,9 +158,5 @@ return array (
array (
0 => 'app\\plugins\\wallet\\Hook',
),
'plugins_view_user_reg_info_top' =>
array (
0 => 'app\\plugins\\weixinwebauthorization\\Hook',
),
);
?>
\ No newline at end of file
......@@ -233,15 +233,25 @@ class Weixin
return DataReturn('支付类型不匹配', -1);
}
// openid
if(APPLICATION == 'app')
{
$openid = isset($params['user']['weixin_openid']) ? $params['user']['weixin_openid'] : '';
} else {
$openid = isset($params['user']['weixin_web_openid']) ? $params['user']['weixin_web_openid'] : '';
}
// appid
$appid = (APPLICATION_CLIENT_TYPE == 'weixin') ? $this->config['mini_appid'] : $this->config['appid'];
$appid = (APPLICATION == 'app') ? $this->config['mini_appid'] : $this->config['appid'];
// 请求参数
$data = [
'appid' => $appid,
'mch_id' => $this->config['mch_id'],
'body' => $params['site_name'].'-'.$params['name'],
'nonce_str' => md5(time().rand().$params['order_no']),
'notify_url' => (__MY_HTTP__ == 'https') ? 'http'.mb_substr($params['notify_url'], 5, null, 'utf-8') : $params['notify_url'],
'openid' => ($trade_type == 'JSAPI') ? $params['user']['weixin_openid'] : '',
'openid' => ($trade_type == 'JSAPI') ? $openid : '',
'out_trade_no' => $params['order_no'].GetNumberCode(6),
'spbill_create_ip' => GetClientIP(),
'total_fee' => intval($params['total_price']*100),
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册