应用钩子名称优化
parent
01103c7e9c
commit
9fd62d45dc
|
|
@ -81,7 +81,7 @@ class Common extends Controller
|
|||
private function CommonPluginsInit()
|
||||
{
|
||||
// 公共顶部钩子
|
||||
$this->assign('plugins_common_top_data', Hook::listen('plugins_common_top', ['hook_name'=>'plugins_common_top', 'is_control'=>false]));
|
||||
$this->assign('plugins_view_common_top_data', Hook::listen('plugins_view_common_top', ['hook_name'=>'plugins_view_common_top', 'is_control'=>false, 'user'=>$this->user]));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -137,7 +137,7 @@ class User extends Common
|
|||
$this->assign('goods_browse_list', $data['data']);
|
||||
|
||||
// 用户中心顶部钩子
|
||||
$this->assign('plugins_user_center_top_data', Hook::listen('plugins_user_center_top', ['hook_name'=>'plugins_user_center_top', 'is_control'=>false]));
|
||||
$this->assign('plugins_view_user_center_top_data', Hook::listen('plugins_view_user_center_top', ['hook_name'=>'plugins_view_user_center_top', 'is_control'=>false, 'user'=>$this->user]));
|
||||
|
||||
return $this->fetch();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,11 +42,11 @@
|
|||
<!-- 公共顶部钩子 -->
|
||||
{{if isset($shopxo_is_develop) and $shopxo_is_develop eq true and (!isset($is_header) or $is_header eq 1)}}
|
||||
<div class="plugins-tag">
|
||||
<span>plugins_common_top</span>
|
||||
<span>plugins_view_common_top</span>
|
||||
</div>
|
||||
{{/if}}
|
||||
{{if !empty($plugins_common_top_data) and is_array($plugins_common_top_data) and (!isset($is_header) or $is_header eq 1)}}
|
||||
{{foreach $plugins_common_top_data as $hook}}
|
||||
{{if !empty($plugins_view_common_top_data) and is_array($plugins_view_common_top_data) and (!isset($is_header) or $is_header eq 1)}}
|
||||
{{foreach $plugins_view_common_top_data as $hook}}
|
||||
{{if is_string($hook) or is_int($hook)}}
|
||||
{{$hook|raw}}
|
||||
{{/if}}
|
||||
|
|
|
|||
|
|
@ -29,11 +29,11 @@
|
|||
<!-- 用户中心顶部钩子 -->
|
||||
{{if isset($shopxo_is_develop) and $shopxo_is_develop eq true}}
|
||||
<div class="plugins-tag">
|
||||
<span>plugins_user_center_top</span>
|
||||
<span>plugins_view_user_center_top</span>
|
||||
</div>
|
||||
{{/if}}
|
||||
{{if !empty($plugins_user_center_top_data) and is_array($plugins_user_center_top_data)}}
|
||||
{{foreach $plugins_user_center_top_data as $hook}}
|
||||
{{if !empty($plugins_view_user_center_top_data) and is_array($plugins_view_user_center_top_data)}}
|
||||
{{foreach $plugins_view_user_center_top_data as $hook}}
|
||||
{{if is_string($hook) or is_int($hook)}}
|
||||
{{$hook|raw}}
|
||||
{{/if}}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
"is_home":false
|
||||
},
|
||||
"hook":{
|
||||
"plugins_common_top":[
|
||||
"plugins_view_common_top":[
|
||||
"app\\plugins\\commontopmaxpicture\\Hook"
|
||||
]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
"is_home":false
|
||||
},
|
||||
"hook":{
|
||||
"plugins_common_top":[
|
||||
"plugins_view_common_top":[
|
||||
"app\\plugins\\commontopnotice\\Hook"
|
||||
]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
"is_home":false
|
||||
},
|
||||
"hook":{
|
||||
"plugins_user_center_top":[
|
||||
"plugins_view_user_center_top":[
|
||||
"app\\plugins\\usercentertopnotice\\Hook"
|
||||
]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,12 +37,12 @@ class Hook
|
|||
// 是否控制器钩子
|
||||
if(isset($params['is_control']) && $params['is_control'] === true && !empty($params['hook_name']))
|
||||
{
|
||||
if(!empty($params['user']))
|
||||
if(!empty($params['user_id']))
|
||||
{
|
||||
switch($params['hook_name'])
|
||||
{
|
||||
// 用户登录成功后赠送积分
|
||||
case 'plugins_user_login_end' :
|
||||
case 'plugins_control_user_login_end' :
|
||||
$ret = $this->LoginGiveIntegral($params);
|
||||
break;
|
||||
|
||||
|
|
@ -96,7 +96,7 @@ class Hook
|
|||
if(isset($ret['data']['is_day_once']) && $ret['data']['is_day_once'] == 1)
|
||||
{
|
||||
$where = [
|
||||
['user_id', '=', $params['user']['id']],
|
||||
['user_id', '=', $params['user_id']],
|
||||
['add_time', '>=', strtotime(date('Y-m-d 00:00:00'))],
|
||||
['type', '=', 1],
|
||||
['msg', '=', '登录赠送积分'],
|
||||
|
|
@ -113,17 +113,17 @@ class Hook
|
|||
if(!empty($give_integral))
|
||||
{
|
||||
// 用户积分添加
|
||||
$user_integral = Db::name('User')->where(['id'=>$params['user']['id']])->value('integral');
|
||||
if(!Db::name('User')->where(['id'=>$params['user']['id']])->setInc('integral', $give_integral))
|
||||
$user_integral = Db::name('User')->where(['id'=>$params['user_id']])->value('integral');
|
||||
if(!Db::name('User')->where(['id'=>$params['user_id']])->setInc('integral', $give_integral))
|
||||
{
|
||||
return DataReturn('登录赠送积分失败', -10);
|
||||
}
|
||||
|
||||
// 积分日志
|
||||
IntegralService::UserIntegralLogAdd($params['user']['id'], $user_integral, $user_integral+$give_integral, '登录赠送积分', 1);
|
||||
IntegralService::UserIntegralLogAdd($params['user_id'], $user_integral, $user_integral+$give_integral, '登录赠送积分', 1);
|
||||
|
||||
// 更新用户登录缓存数据
|
||||
UserService::UserLoginRecord($params['user']['id']);
|
||||
UserService::UserLoginRecord($params['user_id']);
|
||||
|
||||
return DataReturn('登录赠送积分成功', 0);
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
"is_home":false
|
||||
},
|
||||
"hook":{
|
||||
"plugins_user_login_end":[
|
||||
"plugins_control_user_login_end":[
|
||||
"app\\plugins\\userlogingiveintegral\\Hook"
|
||||
]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -812,7 +812,7 @@ class UserService
|
|||
}
|
||||
|
||||
// 用户登录前钩子
|
||||
$ret = Hook::listen('plugins_user_login_begin', ['hook_name'=>'plugins_user_login_begin', 'is_control'=>true, 'params'=>$params, 'user'=>$user]);
|
||||
$ret = Hook::listen('plugins_control_user_login_begin', ['hook_name'=>'plugins_control_user_login_begin', 'is_control'=>true, 'params'=>$params, 'user_id'=>$user['id']]);
|
||||
if(isset($ret['code']) && $ret['code'] != 0)
|
||||
{
|
||||
return $ret;
|
||||
|
|
@ -831,7 +831,7 @@ class UserService
|
|||
if(self::UserLoginRecord($user['id']))
|
||||
{
|
||||
// 用户登录后钩子
|
||||
$ret = Hook::listen('plugins_user_login_end', ['hook_name'=>'plugins_user_login_end', 'is_control'=>true, 'params'=>$params, 'user'=>$user]);
|
||||
$ret = Hook::listen('plugins_control_user_login_end', ['hook_name'=>'plugins_control_user_login_end', 'is_control'=>true, 'params'=>$params, 'user_id'=>$user['id']]);
|
||||
if(isset($ret['code']) && $ret['code'] != 0)
|
||||
{
|
||||
return $ret;
|
||||
|
|
|
|||
|
|
@ -32,16 +32,16 @@ return array (
|
|||
'log_write' =>
|
||||
array (
|
||||
),
|
||||
'plugins_common_top' =>
|
||||
'plugins_view_common_top' =>
|
||||
array (
|
||||
0 => 'app\\plugins\\commontopmaxpicture\\Hook',
|
||||
1 => 'app\\plugins\\commontopnotice\\Hook',
|
||||
),
|
||||
'plugins_user_center_top' =>
|
||||
'plugins_view_user_center_top' =>
|
||||
array (
|
||||
0 => 'app\\plugins\\usercentertopnotice\\Hook',
|
||||
),
|
||||
'plugins_user_login_end' =>
|
||||
'plugins_control_user_login_end' =>
|
||||
array (
|
||||
0 => 'app\\plugins\\userlogingiveintegral\\Hook',
|
||||
),
|
||||
|
|
|
|||
Loading…
Reference in New Issue