微信绑定
parent
b5a41ff5d8
commit
d99181673d
|
|
@ -32,7 +32,9 @@
|
|||
<dt>{{$v.name}}</dt>
|
||||
<dd>
|
||||
{{if isset($v['is_ext']) and $v['is_ext'] eq 1}}
|
||||
{{$v.value}}
|
||||
{{if isset($v['value'])}}
|
||||
{{$v.value}}
|
||||
{{/if}}
|
||||
{{else /}}
|
||||
{{if empty($user[$k])}}
|
||||
<span class="items-value-empty">未填写</span>
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
<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>
|
||||
<a href="{{:PluginsHomeUrl('weixinwebauthorization', 'auth', 'index')}}" class="am-icon-weixin am-margin-left-xs am-text-success"> {{if empty($plugins_data['login_name'])}}微信{{else /}}{{$plugins_data.login_name}}{{/if}}</a>
|
||||
|
|
@ -11,6 +11,7 @@
|
|||
namespace app\plugins\weixinwebauthorization;
|
||||
|
||||
use think\Controller;
|
||||
use app\service\UserService;
|
||||
use app\service\PluginsService;
|
||||
|
||||
/**
|
||||
|
|
@ -32,48 +33,64 @@ class Hook extends Controller
|
|||
*/
|
||||
public function run($params = [])
|
||||
{
|
||||
// 目前微信登录只针对手机端
|
||||
if(!empty($params['hook_name']) && IsMobile())
|
||||
$ret = '';
|
||||
if(!empty($params['hook_name']))
|
||||
{
|
||||
// 获取登录用户
|
||||
$user = UserService::LoginUserInfo();
|
||||
switch($params['hook_name'])
|
||||
{
|
||||
// 用户登录页面顶部钩子
|
||||
// 用户注册页面钩子
|
||||
case 'plugins_view_user_login_info_top' :
|
||||
case 'plugins_view_user_reg_info' :
|
||||
$ret = $this->ButtonHtml($params);
|
||||
if(empty($user) && IsMobile())
|
||||
{
|
||||
$ret = $this->ButtonHtml($params);
|
||||
}
|
||||
break;
|
||||
|
||||
// 公共顶部小导航钩子-左侧
|
||||
case 'plugins_view_header_navigation_top_left' :
|
||||
$ret = $this->NavTextHtml($params);
|
||||
if(empty($user) && IsMobile())
|
||||
{
|
||||
$ret = $this->NavTextHtml($params);
|
||||
}
|
||||
break;
|
||||
|
||||
// header代码
|
||||
case 'plugins_common_header' :
|
||||
$ret = $this->Style($params);
|
||||
// 用户中心-个人资料
|
||||
case 'plugins_service_users_personal_show_field_list_handle' :
|
||||
$ret = $this->UserPersonalHtml($params, $user);
|
||||
break;
|
||||
|
||||
default :
|
||||
$ret = '';
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* css
|
||||
* 用户中心-个人资料
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 1.0.0
|
||||
* @datetime 2019-02-06T16:16:34+0800
|
||||
* @param [array] $params [输入参数]
|
||||
* @param [array] $user [用户登录信息]
|
||||
*/
|
||||
public function Style($params = [])
|
||||
public function UserPersonalHtml($params = [], $user = [])
|
||||
{
|
||||
return '<style type="text/css">
|
||||
.plugins-weixinwebauthorization-nav-top-text { color: #3db53d; }
|
||||
</style>';
|
||||
if(empty($user['weixin_web_openid']))
|
||||
{
|
||||
$tips = '<a href="'.PluginsHomeUrl('weixinwebauthorization', 'auth', 'index').'" class="am-text-success am-icon-weixin"> 绑定</a>';
|
||||
} else {
|
||||
$tips = '<a href="javascript:;" class="submit-ajax" data-url="'.PluginsHomeUrl('weixinwebauthorization', 'auth', 'unbind').'" data-id="1" data-view="reload" data-msg="解绑后不可恢复、确认操作吗?"> 解绑</a>';
|
||||
}
|
||||
|
||||
$params['data']['weixin_web_openid'] = [
|
||||
'is_ext' => 1,
|
||||
'name' => '微信绑定',
|
||||
'value' => empty($user['weixin_web_openid']) ? '未绑定' : $user['weixin_web_openid'],
|
||||
'tips' => $tips,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@
|
|||
"plugins_view_header_navigation_top_left":[
|
||||
"app\\plugins\\weixinwebauthorization\\Hook"
|
||||
],
|
||||
"plugins_common_header":[
|
||||
"plugins_service_users_personal_show_field_list_handle":[
|
||||
"app\\plugins\\weixinwebauthorization\\Hook"
|
||||
]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,6 +23,18 @@ use app\plugins\weixinwebauthorization\service\Service;
|
|||
*/
|
||||
class Auth extends Controller
|
||||
{
|
||||
/**
|
||||
* 用户解绑
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 1.0.0
|
||||
* @datetime 2019-05-26T00:55:08+0800
|
||||
* @param array $params [description]
|
||||
*/
|
||||
public function Unbind($params = [])
|
||||
{
|
||||
return Service::WeixinUnbind($params);
|
||||
}
|
||||
/**
|
||||
* 支付提示
|
||||
* @author Devil
|
||||
|
|
|
|||
|
|
@ -23,6 +23,35 @@ use app\service\PluginsService;
|
|||
*/
|
||||
class Service
|
||||
{
|
||||
/**
|
||||
* 微信解绑
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 1.0.0
|
||||
* @datetime 2019-05-26T00:56:04+0800
|
||||
* @param [array] $params [输入参数]
|
||||
*/
|
||||
public static function WeixinUnbind($params = [])
|
||||
{
|
||||
$user = UserService::LoginUserInfo();
|
||||
if(!empty($user))
|
||||
{
|
||||
$data = [
|
||||
'weixin_web_openid' => '',
|
||||
'upd_time' => time(),
|
||||
];
|
||||
if(Db::name('User')->where(['id'=>$user['id']])->update($data))
|
||||
{
|
||||
if(UserService::UserLoginRecord($user['id']))
|
||||
{
|
||||
return DataReturn('解绑成功', 0);
|
||||
}
|
||||
}
|
||||
return DataReturn('解绑失败', -100);
|
||||
}
|
||||
return DataReturn('未登录,不能操作', -1);
|
||||
}
|
||||
|
||||
/**
|
||||
* 微信绑定
|
||||
* @author Devil
|
||||
|
|
|
|||
|
|
@ -0,0 +1,2 @@
|
|||
# 用户-微信web用户openid
|
||||
ALTER TABLE `s_user` drop `weixin_web_openid`;
|
||||
|
|
@ -581,6 +581,10 @@ class NavigationService
|
|||
*/
|
||||
public static function UsersPersonalShowFieldList($params = [])
|
||||
{
|
||||
// is_ext 扩展数据 1, key不存在用户字段中可使用该扩展
|
||||
// name 显示名称
|
||||
// value 扩展自定义值
|
||||
// tips html提示操作内容
|
||||
$data = [
|
||||
'avatar' => [
|
||||
'name' => '头像',
|
||||
|
|
@ -607,7 +611,7 @@ class NavigationService
|
|||
'name' => '注册时间'
|
||||
],
|
||||
'upd_time_text' => [
|
||||
'name' => '最后更新时间'
|
||||
'name' => '更新时间'
|
||||
],
|
||||
];
|
||||
|
||||
|
|
|
|||
|
|
@ -86,7 +86,6 @@ 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 (
|
||||
|
|
@ -151,5 +150,9 @@ return array (
|
|||
array (
|
||||
0 => 'app\\plugins\\wallet\\Hook',
|
||||
),
|
||||
'plugins_service_users_personal_show_field_list_handle' =>
|
||||
array (
|
||||
0 => 'app\\plugins\\weixinwebauthorization\\Hook',
|
||||
),
|
||||
);
|
||||
?>
|
||||
Loading…
Reference in New Issue