Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
纵之格
ShopXO
提交
886d34ff
ShopXO
项目概览
纵之格
/
ShopXO
通知
394
Star
16
Fork
11
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
ShopXO
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
886d34ff
编写于
3月 15, 2019
作者:
D
devil_gong
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
新增qq登录
上级
b3832b67
变更
22
展开全部
隐藏空白更改
内联
并排
Showing
22 changed file
with
1444 addition
and
266 deletion
+1444
-266
application/index/controller/Common.php
application/index/controller/Common.php
+7
-10
application/index/controller/Personal.php
application/index/controller/Personal.php
+2
-1
application/index/controller/Safety.php
application/index/controller/Safety.php
+2
-1
application/index/controller/User.php
application/index/controller/User.php
+6
-0
application/index/lang/zh-cn.php
application/index/lang/zh-cn.php
+1
-136
application/index/view/default/personal/index.html
application/index/view/default/personal/index.html
+11
-7
application/index/view/default/public/header_top_nav.html
application/index/view/default/public/header_top_nav.html
+53
-66
application/index/view/default/safety/index.html
application/index/view/default/safety/index.html
+2
-2
application/plugins/shopoauth/Admin.php
application/plugins/shopoauth/Admin.php
+73
-0
application/plugins/shopoauth/Auth.php
application/plugins/shopoauth/Auth.php
+146
-0
application/plugins/shopoauth/Hook.php
application/plugins/shopoauth/Hook.php
+190
-0
application/plugins/shopoauth/LoginEvent.php
application/plugins/shopoauth/LoginEvent.php
+33
-0
application/plugins/shopoauth/ThinkOauth.php
application/plugins/shopoauth/ThinkOauth.php
+285
-0
application/plugins/shopoauth/config.json
application/plugins/shopoauth/config.json
+32
-0
application/plugins/shopoauth/sdk/QqSDK.php
application/plugins/shopoauth/sdk/QqSDK.php
+98
-0
application/plugins/view/shopoauth/admin/index.html
application/plugins/view/shopoauth/admin/index.html
+61
-0
application/plugins/view/shopoauth/admin/saveinfo.html
application/plugins/view/shopoauth/admin/saveinfo.html
+55
-0
application/service/NavigationService.php
application/service/NavigationService.php
+311
-2
application/tags.php
application/tags.php
+10
-0
config/shopxo.sql
config/shopxo.sql
+55
-41
public/static/plugins/css/shopoauth/admin.css
public/static/plugins/css/shopoauth/admin.css
+11
-0
public/static/upload/images/plugins_shopoauth/2019/03/13/1552472848865750.png
.../images/plugins_shopoauth/2019/03/13/1552472848865750.png
+0
-0
未找到文件。
application/index/controller/Common.php
浏览文件 @
886d34ff
...
...
@@ -98,6 +98,9 @@ class Common extends Controller
// 公共底部钩子
$this
->
assign
(
'plugins_view_common_bottom_data'
,
Hook
::
listen
(
'plugins_view_common_bottom'
,
[
'hook_name'
=>
'plugins_view_common_bottom'
,
'is_backend'
=>
false
,
'user'
=>
$this
->
user
]));
// 公共顶部小导航钩子-左侧
$this
->
assign
(
'plugins_service_header_navigation_top_left_data'
,
Hook
::
listen
(
'plugins_service_header_navigation_top_left'
,
[
'hook_name'
=>
'plugins_service_header_navigation_top_left'
,
'is_backend'
=>
false
,
'user'
=>
$this
->
user
]));
}
/**
...
...
@@ -211,20 +214,11 @@ class Common extends Controller
$this
->
assign
(
'user'
,
$this
->
user
);
// 用户中心菜单
$this
->
assign
(
'user_left_menu'
,
lang
(
'user_left_menu'
));
$this
->
assign
(
'user_left_menu'
,
NavigationService
::
UsersCenterLeftList
(
));
// 商品大分类
$this
->
assign
(
'goods_category_list'
,
GoodsService
::
GoodsCategory
());
// 购物车商品总数
$common_cart_total
=
BuyService
::
UserCartTotal
([
'user'
=>
$this
->
user
]);
$this
->
assign
(
'common_cart_total'
,
(
$common_cart_total
>
99
)
?
'99+'
:
$common_cart_total
);
// 未读消息总数
$params
=
[
'user'
=>
$this
->
user
,
'is_more'
=>
1
,
'is_read'
=>
0
,
'user_type'
=>
'user'
];
$common_message_total
=
MessageService
::
UserMessageTotal
(
$params
);
$this
->
assign
(
'common_message_total'
,
(
$common_message_total
>
99
)
?
'99+'
:
$common_message_total
);
// 搜索框下热门关键字
$home_search_keywords
=
[];
switch
(
intval
(
MyC
(
'home_search_keywords_type'
,
0
)))
...
...
@@ -244,6 +238,9 @@ class Common extends Controller
// 开发模式
$this
->
assign
(
'shopxo_is_develop'
,
config
(
'shopxo.is_develop'
));
// 顶部右侧导航
$this
->
assign
(
'common_nav_top_right_list'
,
NavigationService
::
HomeHavTopRight
([
'user'
=>
$this
->
user
]));
}
/**
...
...
application/index/controller/Personal.php
浏览文件 @
886d34ff
...
...
@@ -11,6 +11,7 @@
namespace
app\index\controller
;
use
app\service\UserService
;
use
app\service\NavigationService
;
/**
* 个人资料
...
...
@@ -46,7 +47,7 @@ class Personal extends Common
*/
public
function
Index
()
{
$this
->
assign
(
'personal_show_list'
,
lang
(
'personal_show_list'
));
$this
->
assign
(
'personal_show_list'
,
NavigationService
::
UsersPersonalShowFieldList
(
));
return
$this
->
fetch
();
}
...
...
application/index/controller/Safety.php
浏览文件 @
886d34ff
...
...
@@ -11,6 +11,7 @@
namespace
app\index\controller
;
use
app\service\SafetyService
;
use
app\service\NavigationService
;
/**
* 安全
...
...
@@ -47,7 +48,7 @@ class Safety extends Common
public
function
Index
()
{
// 安全信息列表
$this
->
assign
(
'safety_panel_list'
,
lang
(
'safety_panel_list'
));
$this
->
assign
(
'safety_panel_list'
,
NavigationService
::
UsersSafetyPanelList
(
));
// 数据列表
$data
=
array
(
...
...
application/index/controller/User.php
浏览文件 @
886d34ff
...
...
@@ -16,6 +16,7 @@ use app\service\GoodsService;
use
app\service\UserService
;
use
app\service\BuyService
;
use
app\service\SeoService
;
use
app\service\MessageService
;
/**
* 用户
...
...
@@ -93,6 +94,11 @@ class User extends Common
$user_order_status
=
OrderService
::
OrderStatusStepTotal
([
'user_type'
=>
'user'
,
'user'
=>
$this
->
user
,
'is_comments'
=>
1
]);
$this
->
assign
(
'user_order_status'
,
$user_order_status
[
'data'
]);
// 未读消息总数
$params
=
[
'user'
=>
$this
->
user
,
'is_more'
=>
1
,
'is_read'
=>
0
,
'user_type'
=>
'user'
];
$common_message_total
=
MessageService
::
UserMessageTotal
(
$params
);
$this
->
assign
(
'common_message_total'
,
(
$common_message_total
>
99
)
?
'99+'
:
$common_message_total
);
// 获取进行中的订单列表
$params
=
array_merge
(
$_POST
,
$_GET
);
$params
[
'user'
]
=
$this
->
user
;
...
...
application/index/lang/zh-cn.php
浏览文件 @
886d34ff
...
...
@@ -16,140 +16,5 @@
* @version 0.0.1
* @datetime 2016-12-01T21:51:08+0800
*/
return
array
(
// 用户中心菜单, is_show = [0禁用, 1启用]
'user_left_menu'
=>
array
(
array
(
'control'
=>
'user'
,
'action'
=>
'index'
,
'name'
=>
'个人中心'
,
'is_show'
=>
1
,
'icon'
=>
'am-icon-home'
,
),
array
(
'name'
=>
'交易管理'
,
'is_show'
=>
1
,
'icon'
=>
'am-icon-cube'
,
'item'
=>
array
(
array
(
'control'
=>
'order'
,
'action'
=>
'index'
,
'name'
=>
'订单管理'
,
'is_show'
=>
1
,
'icon'
=>
'am-icon-th-list'
,
),
array
(
'control'
=>
'userfavor'
,
'action'
=>
'goods'
,
'name'
=>
'我的收藏'
,
'is_show'
=>
1
,
'icon'
=>
'am-icon-heart-o'
,
),
)
),
array
(
'name'
=>
'资料管理'
,
'is_show'
=>
1
,
'icon'
=>
'am-icon-user'
,
'item'
=>
array
(
array
(
'control'
=>
'personal'
,
'action'
=>
'index'
,
'name'
=>
'个人资料'
,
'is_show'
=>
1
,
'icon'
=>
'am-icon-gear'
,
),
array
(
'control'
=>
'useraddress'
,
'action'
=>
'index'
,
'name'
=>
'我的地址'
,
'is_show'
=>
1
,
'icon'
=>
'am-icon-street-view'
,
),
array
(
'control'
=>
'safety'
,
'action'
=>
'index'
,
'name'
=>
'安全设置'
,
'is_show'
=>
1
,
'icon'
=>
'am-icon-user-secret'
,
),
array
(
'control'
=>
'message'
,
'action'
=>
'index'
,
'name'
=>
'我的消息'
,
'is_show'
=>
1
,
'icon'
=>
'am-icon-bell-o'
,
),
array
(
'control'
=>
'userintegral'
,
'action'
=>
'index'
,
'name'
=>
'我的积分'
,
'is_show'
=>
1
,
'icon'
=>
'am-icon-fire'
,
),
array
(
'control'
=>
'usergoodsbrowse'
,
'action'
=>
'index'
,
'name'
=>
'我的足迹'
,
'is_show'
=>
1
,
'icon'
=>
'am-icon-lastfm'
,
),
array
(
'control'
=>
'answer'
,
'action'
=>
'index'
,
'name'
=>
'问答/留言'
,
'is_show'
=>
1
,
'icon'
=>
'am-icon-question'
,
),
array
(
'control'
=>
'user'
,
'action'
=>
'logout'
,
'name'
=>
'安全退出'
,
'is_show'
=>
1
,
'icon'
=>
'am-icon-power-off'
,
),
)
),
),
// 个人资料展示列表
'personal_show_list'
=>
array
(
'avatar'
=>
array
(
'name'
=>
'头像'
,
'tips'
=>
'<a href="javascript:;" data-am-modal="{target:\'#user-avatar-popup\'}">修改</a>'
),
'nickname'
=>
array
(
'name'
=>
'昵称'
),
'gender_text'
=>
array
(
'name'
=>
'性别'
),
'birthday_text'
=>
array
(
'name'
=>
'生日'
),
'mobile_security'
=>
array
(
'name'
=>
'手机号码'
,
'tips'
=>
'<a href="{path}">修改</a>'
,
'path'
=>
'index/safety/mobileinfo'
),
'email_security'
=>
array
(
'name'
=>
'电子邮箱'
,
'tips'
=>
'<a href="{path}">修改</a>'
,
'path'
=>
'index/safety/mobileinfo'
),
'add_time_text'
=>
array
(
'name'
=>
'注册时间'
),
'upd_time_text'
=>
array
(
'name'
=>
'最后更新时间'
),
),
// 安全项列表
'safety_panel_list'
=>
array
(
array
(
'title'
=>
'登录密码'
,
'msg'
=>
'互联网存在被盗风险,建议您定期更改密码以保护安全。'
,
'path'
=>
'index/safety/loginpwdinfo'
,
'type'
=>
'loginpwd'
,
),
array
(
'title'
=>
'手机号码'
,
'no_msg'
=>
'您还没有绑定手机号码'
,
'ok_msg'
=>
'已绑定手机 #accounts#'
,
'tips'
=>
'可用于登录,密码找回,账户安全管理校验,接受账户提醒通知。'
,
'path'
=>
'index/safety/mobileinfo'
,
'type'
=>
'mobile'
,
),
array
(
'title'
=>
'电子邮箱'
,
'no_msg'
=>
'您还没有绑定电子邮箱'
,
'ok_msg'
=>
'已绑定电子邮箱 #accounts#'
,
'tips'
=>
'可用于登录,密码找回,账户安全管理校验,接受账户提醒邮件。'
,
'path'
=>
'index/safety/emailinfo'
,
'type'
=>
'email'
,
),
),
);
return
[];
?>
\ No newline at end of file
application/index/view/default/personal/index.html
浏览文件 @
886d34ff
...
...
@@ -28,16 +28,20 @@
</legend>
<dl
class=
"dl-content"
>
{{foreach $personal_show_list as $k=>$v}}
{{if isset($user[$k])}}
{{if isset($user[$k])
or (isset($v['is_ext']) and $v['is_ext'] eq 1)
}}
<dt>
{{$v.name}}
</dt>
<dd>
{{if empty($user[$k])}}
<span
class=
"items-value-empty"
>
未填写
</span>
{{elseif $k eq 'avatar' /}}
<img
src=
"{{$user[$k]}}"
width=
"50"
height=
"50"
/>
{{if isset($v['is_ext']) and $v['is_ext'] eq 1}}
{{$v.value}}
{{else /}}
{{$user[$k]}}
{{/if}}
{{if empty($user[$k])}}
<span
class=
"items-value-empty"
>
未填写
</span>
{{elseif $k eq 'avatar' /}}
<img
src=
"{{$user[$k]}}"
width=
"50"
height=
"50"
/>
{{else /}}
{{$user[$k]}}
{{/if}}
{{/if}}
{{if !empty($v['tips'])}}
{{if !empty($v['path'])}}
<span
class=
"span-edit"
>
{{:str_replace('{path}', MyUrl($v['path']), $v['tips'])}}
</span>
...
...
application/index/view/default/public/header_top_nav.html
浏览文件 @
886d34ff
...
...
@@ -16,76 +16,63 @@
<span>
您好 {{$user.user_name_view}},欢迎来到 {{:MyC('home_site_name')}}
</span>
[
<a
href=
"{{:MyUrl('index/user/logout')}}"
>
退出
</a>
]
{{/if}}
</div>
</div>
</ul>
<ul
class=
"top-nav-right"
>
<div
class=
"top-nav-items"
>
<div
class=
"menu-hd {{if empty($user)}}login-event{{/if}}"
>
<a
href=
"{{if empty($user)}}javascript:;{{else /}}{{:MyUrl('index/user/index')}}{{/if}}"
target=
"_top"
>
<i
class=
"am-icon-user am-icon-fw"
></i>
<span>
个人中心
</span>
</a>
</div>
</div>
<div
class=
"top-nav-items"
>
<div
class=
"am-dropdown menu-hd {{if empty($user)}}login-event{{/if}}"
data-am-dropdown
>
<a
class=
"am-dropdown-toggle"
href=
"javascript:;"
target=
"_top"
data-am-dropdown-toggle
>
<i
class=
"am-icon-cube am-icon-fw"
></i>
<span>
我的交易
</span>
<i
class=
"am-icon-caret-down"
></i>
</a>
{{if !empty($user)}}
<ul
class=
"am-dropdown-content"
>
<li>
<a
href=
"{{if empty($user)}}javascript:;{{else /}}{{:MyUrl('index/order/index')}}{{/if}}"
>
我的订单
</a>
</li>
</ul>
{{/if}}
</div>
</div>
<div
class=
"top-nav-items"
>
<div
class=
"am-dropdown menu-hd {{if empty($user)}}login-event{{/if}}"
data-am-dropdown
>
<a
class=
"am-dropdown-toggle"
href=
"javascript:;"
target=
"_top"
data-am-dropdown-toggle
>
<i
class=
"am-icon-heart am-icon-fw"
></i>
<span>
我的收藏
</span>
<i
class=
"am-icon-caret-down"
></i>
</a>
{{if !empty($user)}}
<ul
class=
"am-dropdown-content"
>
<li>
<a
href=
"{{if empty($user)}}javascript:;{{else /}}{{:MyUrl('index/userfavor/goods')}}{{/if}}"
>
商品收藏
</a>
</li>
</ul>
<!-- 公共顶部小导航钩子-左侧 -->
{{if isset($shopxo_is_develop) and $shopxo_is_develop eq true}}
<div
class=
"plugins-tag"
>
<span>
plugins_service_header_navigation_top_left
</span>
</div>
{{/if}}
{{if !empty($plugins_service_header_navigation_top_left_data) and is_array($plugins_service_header_navigation_top_left_data) and (!isset($is_footer) or $is_footer eq 1)}}
{{foreach $plugins_service_header_navigation_top_left_data as $hook}}
{{if is_string($hook) or is_int($hook)}}
{{$hook|raw}}
{{/if}}
{{/foreach}}
{{/if}}
</div>
</div>
<div
class=
"top-nav-items top-nav-mini-cart"
>
<div
class=
"menu-hd {{if empty($user)}}login-event{{/if}}"
>
<a
id=
"mc-menu-hd"
href=
"{{if empty($user)}}javascript:;{{else /}}{{:MyUrl('index/cart/index')}}{{/if}}"
target=
"_top"
>
<i
class=
"am-icon-shopping-cart am-icon-fw"
></i>
<span>
购物车
</span>
{{if $common_cart_total gt 0}}
<strong
class=
"am-badge am-badge-danger am-round common-cart-total"
>
{{$common_cart_total}}
</strong>
{{else /}}
<strong
class=
"common-cart-total am-round"
>
{{$common_cart_total}}
</strong>
{{/if}}
</a>
</div>
</div>
<div
class=
"top-nav-items top-nav-mini-cart"
>
<div
class=
"menu-hd {{if empty($user)}}login-event{{/if}}"
>
<a
id=
"mc-menu-hd"
href=
"{{if empty($user)}}javascript:;{{else /}}{{:MyUrl('index/message/index')}}{{/if}}"
target=
"_top"
>
<i
class=
"am-icon-bell am-icon-fw"
></i>
<span>
消息
</span>
{{if $common_message_total gt 0}}
<strong
class=
"am-badge am-badge-danger am-round"
>
{{$common_message_total}}
</strong>
{{/if}}
</a>
</div>
</div>
</ul>
<ul
class=
"top-nav-right"
>
{{foreach $common_nav_top_right_list as $nav}}
{{if empty($nav['items'])}}
<div
class=
"top-nav-items"
>
<div
class=
"menu-hd {{if isset($nav['is_login']) and $nav['is_login'] eq 1 and empty($user)}}login-event{{/if}}"
>
<a
href=
"{{if empty($user)}}javascript:;{{else /}}{{$nav.url}}{{/if}}"
target=
"_top"
>
<i
class=
"am-icon-fw {{$nav.icon}}"
></i>
<span>
{{$nav.name}}
</span>
{{if isset($nav['badge']) and $nav['badge'] gt -1}}
{{if $nav['badge'] gt 0}}
<strong
class=
"am-badge am-badge-danger am-round common-cart-total"
>
{{$nav.badge}}
</strong>
{{else /}}
<strong
class=
"common-cart-total am-round"
>
{{$nav.badge}}
</strong>
{{/if}}
{{/if}}
</a>
</div>
</div>
{{else /}}
<div
class=
"top-nav-items"
>
<div
class=
"am-dropdown menu-hd {{if isset($nav['is_login']) and $nav['is_login'] eq 1 and empty($user)}}login-event{{/if}}"
data-am-dropdown
>
<a
class=
"am-dropdown-toggle"
href=
"javascript:;"
target=
"_top"
data-am-dropdown-toggle
>
<i
class=
"am-icon-fw {{$nav.icon}}"
></i>
<span>
{{$nav.name}}
</span>
<i
class=
"am-icon-caret-down"
></i>
</a>
{{if !empty($user)}}
<ul
class=
"am-dropdown-content"
>
{{foreach $nav.items as $navs}}
<li>
<a
href=
"{{if empty($user)}}javascript:;{{else /}}{{$navs.url}}{{/if}}"
>
{{$navs.name}}
</a>
</li>
{{/foreach}}
</ul>
{{/if}}
</div>
</div>
{{/if}}
{{/foreach}}
</ul>
</div>
</div>
<!-- 顶部导航条 end -->
\ No newline at end of file
<!-- 顶部导航条 end
\ No newline at end of file
application/index/view/default/safety/index.html
浏览文件 @
886d34ff
...
...
@@ -44,9 +44,9 @@
{{/if}}
</div>
{{if empty($data[$v['type']]) and empty($v['msg'])}}
<a
href=
"{{
:MyUrl($v['path'])
}}"
class=
"am-btn am-btn-danger am-radius am-btn-xs am-fr"
>
绑定
</a>
<a
href=
"{{
$v.url
}}"
class=
"am-btn am-btn-danger am-radius am-btn-xs am-fr"
>
绑定
</a>
{{else /}}
<a
href=
"{{
:MyUrl($v['path'])
}}"
class=
"am-btn am-btn-secondary am-radius am-btn-xs am-fr"
>
修改
</a>
<a
href=
"{{
$v.url
}}"
class=
"am-btn am-btn-secondary am-radius am-btn-xs am-fr"
>
修改
</a>
{{/if}}
</div>
</section>
...
...
application/plugins/shopoauth/Admin.php
0 → 100644
浏览文件 @
886d34ff
<?php
namespace
app\plugins\shopoauth
;
use
think\Controller
;
use
app\plugins\shopoauth\ThinkOauth
;
use
app\service\PluginsService
;
/**
* 第三方登入 API - 钩子入口
* @author Guoguo
* @blog http://gadmin.cojz8.com
* @version 1.0.0
* @datetime 2019年3月14日
*/
class
Admin
extends
Controller
{
/**
* 后台首页
* @author Guoguo
* @blog http://gadmin.cojz8.com
* @version 1.0.0
* @datetime 2019年3月14日
*/
public
function
index
(
$params
=
[])
{
$ret
=
PluginsService
::
PluginsData
(
'shopoauth'
);
if
(
$ret
[
'code'
]
==
0
)
{
$this
->
assign
(
'data'
,
$ret
[
'data'
]);
return
$this
->
fetch
(
'../../../plugins/view/shopoauth/admin/index'
);
}
else
{
return
$ret
[
'msg'
];
}
}
/**
* 参数配置
* @author Guoguo
* @blog http://gadmin.cojz8.com
* @version 1.0.0
* @datetime 2019年3月14日
*/
public
function
saveinfo
(
$params
=
[])
{
$ret
=
PluginsService
::
PluginsData
(
'shopoauth'
);
if
(
$ret
[
'code'
]
==
0
)
{
// 是否
$is_whether_list
=
[
0
=>
array
(
'id'
=>
0
,
'name'
=>
'否'
),
1
=>
array
(
'id'
=>
1
,
'name'
=>
'是'
,
'checked'
=>
true
),
];
$this
->
assign
(
'is_whether_list'
,
$is_whether_list
);
$this
->
assign
(
'data'
,
$ret
[
'data'
]);
return
$this
->
fetch
(
'../../../plugins/view/shopoauth/admin/saveinfo'
);
}
else
{
return
$ret
[
'msg'
];
}
}
/**
* 数据编辑
* @author Guoguo
* @blog http://gadmin.cojz8.com
* @version 1.0.0
* @datetime 2019年3月14日
*/
public
function
save
(
$params
=
[])
{
return
PluginsService
::
PluginsDataSave
([
'plugins'
=>
'shopoauth'
,
'data'
=>
$params
]);
}
}
?>
\ No newline at end of file
application/plugins/shopoauth/Auth.php
0 → 100644
浏览文件 @
886d34ff
<?php
namespace
app\plugins\shopoauth
;
use
think\Db
;
use
think\Controller
;
use
app\service\UserService
;
use
app\service\PluginsService
;
use
app\plugins\shopoauth\ThinkOauth
;
use
app\plugins\shopoauth\LoginEvent
;
/**
* 第三方登入 API - 钩子入口
* @author Guoguo
* @blog http://gadmin.cojz8.com
* @version 1.0.0
* @datetime 2019年3月14日
*/
class
Auth
extends
Controller
{
/**
* 解绑
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2019-03-15
* @desc description
* @param array $params [description]
* @return [type] [description]
*/
public
function
remove
(
$params
=
[])
{
if
(
!
empty
(
$params
[
'type'
]))
{
$user
=
UserService
::
LoginUserInfo
();
if
(
!
empty
(
$user
[
'id'
]))
{
Db
::
name
(
'PluginsShopoauthOauth'
)
->
where
([
'platform'
=>
$params
[
'type'
],
'user_id'
=>
$user
[
'id'
]])
->
delete
();
}
}
$this
->
redirect
(
MyUrl
(
'user/personal/index'
));
}
/**
* 跳转授权登入
* @author Guoguo
* @blog http://gadmin.cojz8.com
* @version 1.0.0
* @datetime 2019年3月14日
*/
public
function
login
(
$params
=
[]){
$sns
=
ThinkOauth
::
getInstance
(
$params
[
'type'
]);
$this
->
redirect
(
$sns
->
getRequestCodeURL
());
}
/**
* 授权回调地址
* @author Guoguo
* @blog http://gadmin.cojz8.com
* @version 1.0.0
* @datetime 2019年3月14日
*/
public
function
callback
(
$params
=
[])
{
if
(
empty
(
$params
[
'code'
])
||
empty
(
$params
[
'type'
]))
{
return
'ERROR-10001——参数出错!'
;
exit
;
}
$sns
=
ThinkOauth
::
getInstance
(
$params
[
'type'
]);
$token
=
$sns
->
getAccessToken
(
$params
[
'code'
],
[]);
$type
=
$params
[
'type'
];
//获取当前登录用户信息
if
(
is_array
(
$token
))
{
$even
=
new
LoginEvent
();
$result
=
$even
->
$type
(
$token
);
/*校验是否登入*/
$user
=
UserService
::
LoginUserInfo
();
$user_id
=
empty
(
$user
[
'id'
])
?
0
:
$user
[
'id'
];
//登入后返回信息
if
(
!
empty
(
$result
))
{
$oauth
=
[
'user_id'
=>
$user_id
,
'platform'
=>
$result
[
'type'
],
'openid'
=>
$result
[
'token'
][
'openid'
],
'openname'
=>
$result
[
'name'
],
'access_token'
=>
$result
[
'token'
][
'access_token'
],
'refresh_token'
=>
$result
[
'token'
][
'refresh_token'
],
'expires_in'
=>
$result
[
'token'
][
'expires_in'
],
'createtime'
=>
time
(),
'updatetime'
=>
time
(),
'logintime'
=>
time
()
];
//判断或者写入oauth表
$where
=
[
'openid'
=>
$oauth
[
'openid'
]];
$oauth_user
=
Db
::
name
(
'PluginsShopoauthOauth'
)
->
where
(
$where
)
->
find
();
if
(
!
empty
(
$oauth_user
))
{
$up_data
=
[
'access_token'
=>
$result
[
'token'
][
'access_token'
],
'refresh_token'
=>
$result
[
'token'
][
'refresh_token'
],
'expires_in'
=>
$result
[
'token'
][
'expires_in'
],
'updatetime'
=>
time
(),
'logintime'
=>
time
()
];
//更新表数据
//用户是否已绑定账号
if
(
!
empty
(
$oauth_user
[
'user_id'
]))
{
Db
::
name
(
'PluginsShopoauthOauth'
)
->
where
(
$where
)
->
update
(
$up_data
);
//更新用户登录缓存数据
UserService
::
UserLoginRecord
(
$oauth_user
[
'user_id'
]);
$this
->
redirect
(
'/'
);
}
else
{
Db
::
name
(
'PluginsShopoauthOauth'
)
->
where
(
$where
)
->
update
(
$up_data
);
session
(
'oauth_id'
,
$oauth
[
'openid'
]);
//跳转注册页面
$this
->
success
(
'登入成功,请绑定或注册账号~'
,
MyUrl
(
'/index/user/reginfo'
));
}
}
else
{
$id
=
Db
::
name
(
'PluginsShopoauthOauth'
)
->
insertGetId
(
$oauth
);
if
(
$user_id
>
0
)
{
UserService
::
UserLoginRecord
(
$user_id
);
$this
->
redirect
(
'/'
);
}
else
{
session
(
'oauth_id'
,
$oauth
[
'openid'
]);
$this
->
success
(
'登入成功,请绑定或注册账号~'
,
MyUrl
(
'/index/user/reginfo'
));
}
}
}
else
{
$this
->
error
(
'系统出错~'
);
}
}
else
{
$this
->
error
(
'TOKEN-ERROR-10001——参数出错!~'
);
}
}
}
?>
\ No newline at end of file
application/plugins/shopoauth/Hook.php
0 → 100644
浏览文件 @
886d34ff
<?php
namespace
app\plugins\shopoauth
;
use
think\Db
;
use
app\service\PluginsService
;
use
app\service\UserService
;
/**
* 第三方登入 API - 钩子入口
* @author Guoguo
* @blog http://gadmin.cojz8.com
* @version 1.0.0
* @datetime 2019年3月14日
*/
class
Hook
{
/**
* 钩子入口
* @author Guoguo
* @blog http://gadmin.cojz8.com
* @version 1.0.0
* @datetime 2019年3月14日
*/
public
function
run
(
$params
=
[])
{
// 是否后端钩子
if
(
!
empty
(
$params
[
'hook_name'
]))
{
switch
(
$params
[
'hook_name'
])
{
// 用户登录后更新关联表登录时间
case
'plugins_service_user_login_end'
:
$ret
=
$this
->
LoginUpdate
(
$params
);
break
;
// 顶部登录入口/登录信息
case
'plugins_service_header_navigation_top_left'
:
$ret
=
$this
->
LoginNavTopHtml
(
$params
);
break
;
// header代码
case
'plugins_common_header'
:
$ret
=
$this
->
Style
(
$params
);
break
;
// 用户中心资料列表
case
'plugins_service_users_personal_show_field_list_handle'
:
$ret
=
$this
->
UserPersonal
(
$params
);
break
;
default
:
$ret
=
DataReturn
(
'无需处理'
,
0
);
}
return
$ret
;
// 默认返回视图
}
else
{
return
''
;
}
}
/**
* 用户中心资料
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2019-03-15
* @param [array] $params [输入参数]
* @desc description
*/
public
function
UserPersonal
(
$params
=
[])
{
if
(
!
empty
(
$params
[
'data'
]))
{
//读取用户信息
$user
=
UserService
::
LoginUserInfo
();
if
(
!
empty
(
$user
[
'id'
]))
{
//读取当前已经有的数据
$ret
=
PluginsService
::
PluginsData
(
'shopoauth'
);
if
(
!
empty
(
$ret
[
'data'
][
'auth'
]))
{
$html
=
''
;
foreach
(
$ret
[
'data'
][
'auth'
]
as
$k
=>
$v
)
{
if
(
isset
(
$v
[
'open'
])
&&
$v
[
'open'
]
==
1
)
{
$icon
=
strtoupper
(
$k
);
$name
=
empty
(
$v
[
'name'
])
?
$k
:
$v
[
'name'
];
$oauth
=
Db
::
name
(
'PluginsShopoauthOauth'
)
->
where
([
'platform'
=>
$icon
,
'user_id'
=>
$user
[
'id'
]])
->
find
();
$value
=
'未绑定'
;
if
(
!
empty
(
$oauth
))
{
$value
=
$name
.
'('
.
$oauth
[
'openname'
]
.
')'
;
$html
.
=
'<a href="'
.
PluginsHomeUrl
(
'shopoauth'
,
'auth'
,
'remove'
,[
'type'
=>
$k
])
.
'">解绑</a>'
;
}
else
{
$html
.
=
'<a href="'
.
PluginsHomeUrl
(
'shopoauth'
,
'auth'
,
'login'
,[
'type'
=>
$k
])
.
'"><i class="am-icon-'
.
$icon
.
'"></i> 前去绑定</a>'
;
}
$params
[
'data'
][]
=
[
'is_ext'
=>
1
,
'name'
=>
$name
,
'value'
=>
$value
,
'tips'
=>
$html
,
];
}
}
}
}
}
return
DataReturn
(
'处理成功'
,
0
);
}
/**
* 前端顶部小导航展示登入
* @author Guoguo
* @blog http://gadmin.cojz8.com
* @version 1.0.0
* @datetime 2019年3月14日
* @param [array] $params [输入参数]
*/
public
function
LoginNavTopHtml
(
$params
=
[])
{
// 获取已登录用户信息,已登录则不展示入口
$user
=
UserService
::
LoginUserInfo
();
if
(
empty
(
$user
))
{
// 获取插件信息
$ret
=
PluginsService
::
PluginsData
(
'shopoauth'
);
$html
=
'<div class="am-dropdown menu-hd plugins-shopoauth-nav-top" data-am-dropdown>
<a class="am-dropdown-toggle" href="javascript:;" target="_top" data-am-dropdown-toggle>
<i class="am-icon-cube am-icon-link"></i>
<span>第三方登入</span>
<i class="am-icon-caret-down"></i>
</a><ul class="am-dropdown-content">'
;
if
(
!
empty
(
$ret
[
'data'
][
'auth'
]))
{
foreach
(
$ret
[
'data'
][
'auth'
]
as
$k
=>
$v
)
{
if
(
isset
(
$v
[
'open'
])
&&
$v
[
'open'
]
==
1
)
{
$name
=
empty
(
$v
[
'name'
])
?
$k
:
$v
[
'name'
];
$html
.
=
'<li><a href="'
.
PluginsHomeUrl
(
'shopoauth'
,
'auth'
,
'login'
,[
'type'
=>
$k
])
.
'"><i class="am-icon-cube am-icon-qq"></i> '
.
$name
.
'</a></li>'
;
}
}
$html
.
=
'</ul></div>'
;
return
$html
;
}
}
return
''
;
}
/**
* 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-shopoauth-nav-top { margin-left: 10px; }
</style>'
;
}
/**
* 更新登录时间
* @author Guoguo
* @blog http://gadmin.cojz8.com
* @version 1.0.0
* @datetime 2019年3月14日
*/
private
function
LoginUpdate
(
$params
)
{
$oauth_id
=
session
(
'oauth_id'
);
if
(
!
empty
(
$oauth_id
)
&&
!
empty
(
$params
[
'user_id'
]))
{
$up_data
=
[
'user_id'
=>
$params
[
'user_id'
],
'logintime'
=>
time
()
];
Db
::
name
(
'PluginsShopoauthOauth'
)
->
where
([
'openid'
=>
$oauth_id
])
->
update
(
$up_data
);
}
return
DataReturn
(
'处理成功'
,
0
);
}
}
?>
\ No newline at end of file
application/plugins/shopoauth/LoginEvent.php
0 → 100644
浏览文件 @
886d34ff
<?php
namespace
app\plugins\shopoauth
;
use
app\plugins\shopoauth\ThinkOauth
;
/**
* 登入事件
* @author Guoguo
* @blog http://gadmin.cojz8.com
* @version 1.0.0
* @datetime 2019年3月14日
*/
class
LoginEvent
{
//登录成功,获取腾讯QQ用户信息
public
function
qq
(
$token
)
{
$qq
=
ThinkOauth
::
getInstance
(
'qq'
,
$token
);
$data
=
$qq
->
call
(
'user/get_user_info'
);
if
(
$data
[
'ret'
]
==
0
)
{
$userInfo
[
'type'
]
=
'QQ'
;
$userInfo
[
'name'
]
=
$data
[
'nickname'
];
$userInfo
[
'nick'
]
=
$data
[
'nickname'
];
$userInfo
[
'head'
]
=
$data
[
'figureurl_2'
];
$userInfo
[
'openid'
]
=
$qq
->
openid
();
$userInfo
[
'token'
]
=
$token
;
return
$userInfo
;
}
else
{
throw
new
\
think\Exception
(
"获取腾讯QQ用户信息失败:
{
$data
[
'msg'
]
}
"
);
}
}
}
\ No newline at end of file
application/plugins/shopoauth/ThinkOauth.php
0 → 100644
浏览文件 @
886d34ff
<?php
namespace
app\plugins\shopoauth
;
use
app\service\PluginsService
;
use
app\plugins\shopoauth\LoginEvent
;
/**
* ThinkOauth
* @author Guoguo
* @blog http://gadmin.cojz8.com
* @version 1.0.0
* @datetime 2019年3月14日
*/
abstract
class
ThinkOauth
{
/**
* oauth版本
* @var string
*/
protected
$Version
=
'3.0'
;
/**
* 申请应用时分配的app_key
* @var string
*/
protected
$AppKey
=
''
;
/**
* 申请应用时分配的 app_secret
* @var string
*/
protected
$AppSecret
=
''
;
/**
* 授权类型 response_type 目前只能为code
* @var string
*/
protected
$ResponseType
=
'code'
;
/**
* grant_type 目前只能为 authorization_code
* @var string
*/
protected
$GrantType
=
'authorization_code'
;
/**
* 回调页面URL 可以通过配置文件配置
* @var string
*/
protected
$Callback
=
''
;
/**
* 获取request_code的额外参数 URL查询字符串格式
* @var srting
*/
protected
$Authorize
=
''
;
/**
* 获取request_code请求的URL
* @var string
*/
protected
$GetRequestCodeURL
=
''
;
/**
* 获取access_token请求的URL
* @var string
*/
protected
$GetAccessTokenURL
=
''
;
/**
* API根路径
* @var string
*/
protected
$ApiBase
=
''
;
/**
* 授权后获取到的TOKEN信息
* @var array
*/
protected
$Token
=
null
;
/**
* 调用接口类型
* @var string
*/
private
$Type
=
''
;
/**
* 构造方法,配置应用信息
* @param array $token
*/
public
function
__construct
(
$token
=
null
)
{
$class
=
get_class
(
$this
);
$this
->
Type
=
explode
(
'\\'
,
strtoupper
(
substr
(
$class
,
0
,
strlen
(
$class
)
-
3
)))[
4
];
$ret
=
PluginsService
::
PluginsData
(
'shopoauth'
);
foreach
(
$ret
[
'data'
][
'auth'
]
as
$k
=>
$v
){
if
(
$v
[
'open'
]
==
1
){
$configs
[
strtoupper
(
$k
)]
=
$v
;
$configs
[
strtoupper
(
$k
)][
'CALLBACK'
]
=
PluginsHomeUrl
(
'shopoauth'
,
'Auth'
,
'callback'
,[
'type'
=>
$k
]);
}
}
$config
=
$configs
[
$this
->
Type
];
if
(
empty
(
$config
[
'app_key'
])
||
empty
(
$config
[
'app_secret'
]))
{
throw
new
\
think\Exception
(
'请配置您申请的APP_KEY和APP_SECRET'
,
100001
);
}
else
{
$this
->
AppKey
=
$config
[
'app_key'
];
$this
->
AppSecret
=
$config
[
'app_secret'
];
$this
->
Token
=
$token
;
//设置获取到的TOKEN
}
}
/**
* 取得Oauth实例
* @static
* @return mixed 返回Oauth
*/
public
static
function
getInstance
(
$type
,
$token
=
null
)
{
$name
=
ucfirst
(
strtolower
(
$type
))
.
'SDK'
;
if
(
class_exists
(
"app\plugins\shopoauth\sdk
\\
{
$name
}
"
))
{
$class_name
=
"\app\plugins\shopoauth\sdk
\\
{
$name
}
"
;
return
new
$class_name
(
$token
);
}
else
{
throw
new
\
think\Exception
(
'CLASS_NOT_EXIST:'
.
$name
,
100002
);
}
}
/**
* 请求code
*/
public
function
getRequestCodeURL
()
{
$this
->
config
();
//Oauth 标准参数
$params
=
array
(
'client_id'
=>
$this
->
AppKey
,
'redirect_uri'
=>
$this
->
Callback
,
'response_type'
=>
$this
->
ResponseType
,
);
//获取额外参数
if
(
$this
->
Authorize
)
{
parse_str
(
$this
->
Authorize
,
$_param
);
if
(
is_array
(
$_param
))
{
$params
=
array_merge
(
$params
,
$_param
);
}
else
{
throw
new
\
think\Exception
(
'AUTHORIZE配置不正确!'
,
100003
);
}
}
return
$this
->
GetRequestCodeURL
.
'?'
.
http_build_query
(
$params
);
}
/**
* 初始化配置
*/
private
function
config
()
{
$class
=
get_class
(
$this
);
$this
->
Type
=
explode
(
'\\'
,
strtoupper
(
substr
(
$class
,
0
,
strlen
(
$class
)
-
3
)))[
4
];
$ret
=
PluginsService
::
PluginsData
(
'shopoauth'
);
foreach
(
$ret
[
'data'
][
'auth'
]
as
$k
=>
$v
){
if
(
$v
[
'open'
]
==
1
){
$configs
[
strtoupper
(
$k
)]
=
$v
;
$configs
[
strtoupper
(
$k
)][
'CALLBACK'
]
=
PluginsHomeUrl
(
'shopoauth'
,
'Auth'
,
'callback'
,[
'type'
=>
$k
]);
}
}
$config
=
$configs
[
$this
->
Type
];
if
(
!
empty
(
$config
[
'AUTHORIZE'
]))
$this
->
Authorize
=
$config
[
'AUTHORIZE'
];
if
(
!
empty
(
$config
[
'CALLBACK'
]))
$this
->
Callback
=
$config
[
'CALLBACK'
];
else
throw
new
\
think\Exception
(
'请配置回调页面地址'
,
100004
);
}
/**
* 获取access_token
* @param string $code 上一步请求到的code
* $code = $_GET['code']
*/
public
function
getAccessToken
(
$code
,
$extend
=
null
)
{
$this
->
config
();
$params
=
array
(
'client_id'
=>
$this
->
AppKey
,
'client_secret'
=>
$this
->
AppSecret
,
'grant_type'
=>
$this
->
GrantType
,
'code'
=>
$code
,
'redirect_uri'
=>
$this
->
Callback
,
);
$data
=
$this
->
http
(
$this
->
GetAccessTokenURL
,
$params
,
'POST'
);
$this
->
Token
=
$this
->
parseToken
(
$data
,
$extend
);
return
$this
->
Token
;
}
/**
* 发送HTTP请求方法,目前只支持CURL发送请求
* @param string $url 请求URL
* @param array $params 请求参数
* @param string $method 请求方法GET/POST
* @return array $data 响应数据
*/
protected
function
http
(
$url
,
$params
,
$method
=
'GET'
,
$header
=
array
(),
$multi
=
false
)
{
$opts
=
array
(
CURLOPT_TIMEOUT
=>
30
,
CURLOPT_RETURNTRANSFER
=>
1
,
CURLOPT_SSL_VERIFYPEER
=>
false
,
CURLOPT_SSL_VERIFYHOST
=>
false
,
CURLOPT_HTTPHEADER
=>
$header
);
/* 根据请求类型设置特定参数 */
switch
(
strtoupper
(
$method
))
{
case
'GET'
:
$opts
[
CURLOPT_URL
]
=
$url
.
'?'
.
http_build_query
(
$params
);
break
;
case
'POST'
:
//判断是否传输文件
$params
=
$multi
?
$params
:
http_build_query
(
$params
);
$opts
[
CURLOPT_URL
]
=
$url
;
$opts
[
CURLOPT_POST
]
=
1
;
$opts
[
CURLOPT_POSTFIELDS
]
=
$params
;
break
;
default
:
throw
new
\
think\Exception
(
'不支持的请求方式!'
,
100005
);
}
/* 初始化并执行curl请求 */
$ch
=
curl_init
();
curl_setopt_array
(
$ch
,
$opts
);
$data
=
curl_exec
(
$ch
);
$error
=
curl_error
(
$ch
);
curl_close
(
$ch
);
if
(
$error
)
throw
new
\
think\Exception
(
'请求发生错误:'
.
$error
,
100006
);
return
$data
;
}
/**
* 抽象方法,在SNSSDK中实现
* 解析access_token方法请求后的返回值
*/
abstract
protected
function
parseToken
(
$result
,
$extend
);
/**
* 抽象方法,在SNSSDK中实现
* 获取当前授权用户的SNS标识
*/
abstract
public
function
openid
();
/**
* 合并默认参数和额外参数
* @param array $params 默认参数
* @param array /string $param 额外参数
* @return array:
*/
protected
function
param
(
$params
,
$param
)
{
if
(
is_string
(
$param
))
parse_str
(
$param
,
$param
);
return
array_merge
(
$params
,
$param
);
}
/**
* 获取指定API请求的URL
* @param string $api API名称
* @param string $fix api后缀
* @return string 请求的完整URL
*/
protected
function
url
(
$api
,
$fix
=
''
)
{
return
$this
->
ApiBase
.
$api
.
$fix
;
}
/**
* 抽象方法,在SNSSDK中实现
* 组装接口调用参数 并调用接口
*/
abstract
protected
function
call
(
$api
,
$param
=
''
,
$method
=
'GET'
,
$multi
=
false
);
}
application/plugins/shopoauth/config.json
0 → 100644
浏览文件 @
886d34ff
{
"base"
:{
"plugins"
:
"shopoauth"
,
"name"
:
"第三方账号登陆"
,
"logo"
:
"
\/
static
\/
upload
\/
images
\/
plugins_shopoauth
\/
2019
\/
03
\/
13
\/
1552472848865750.png"
,
"author"
:
"guoguo"
,
"author_url"
:
"http:
\/\/
gadmin.cojz8.com"
,
"version"
:
"1.0.0"
,
"desc"
:
"第三方账号登陆"
,
"apply_terminal"
:[
"pc"
],
"apply_version"
:[
"1.4.0"
],
"is_home"
:
false
},
"hook"
:{
"plugins_common_header"
:[
"app
\\
plugins
\\
shopoauth
\\
Hook"
],
"plugins_service_user_login_end"
:[
"app
\\
plugins
\\
shopoauth
\\
Hook"
],
"plugins_service_header_navigation_top_left"
:[
"app
\\
plugins
\\
shopoauth
\\
Hook"
],
"plugins_service_users_personal_show_field_list_handle"
:[
"app
\\
plugins
\\
shopoauth
\\
Hook"
]
}
}
\ No newline at end of file
application/plugins/shopoauth/sdk/QqSDK.php
0 → 100644
浏览文件 @
886d34ff
<?php
namespace
app\plugins\shopoauth\sdk
;
use
app\plugins\shopoauth\ThinkOauth
;
/**
* QQ类库
* @author Guoguo
* @blog http://gadmin.cojz8.com
* @version 1.0.0
* @datetime 2019年3月14日
*/
class
QqSDK
extends
ThinkOauth
{
/**
* 获取requestCode的api接口
* @var string
*/
protected
$GetRequestCodeURL
=
'https://graph.qq.com/oauth2.0/authorize'
;
/**
* 获取access_token的api接口
* @var string
*/
protected
$GetAccessTokenURL
=
'https://graph.qq.com/oauth2.0/token'
;
/**
* 获取request_code的额外参数,可在配置中修改 URL查询字符串格式
* @var srting
*/
protected
$Authorize
=
'scope=get_user_info,add_share'
;
/**
* API根路径
* @var string
*/
protected
$ApiBase
=
'https://graph.qq.com/'
;
/**
* 组装接口调用参数 并调用接口
* @param string $api 微博API
* @param string $param 调用API的额外参数
* @param string $method HTTP请求方法 默认为GET
* @return json
*/
public
function
call
(
$api
,
$param
=
''
,
$method
=
'GET'
,
$multi
=
false
)
{
/* 腾讯QQ调用公共参数 */
$params
=
array
(
'oauth_consumer_key'
=>
$this
->
AppKey
,
'access_token'
=>
$this
->
Token
[
'access_token'
],
'openid'
=>
$this
->
openid
(),
'format'
=>
'json'
);
$data
=
$this
->
http
(
$this
->
url
(
$api
),
$this
->
param
(
$params
,
$param
),
$method
);
return
json_decode
(
$data
,
true
);
}
/**
* 解析access_token方法请求后的返回值
* @param string $result 获取access_token的方法的返回值
*/
protected
function
parseToken
(
$result
,
$extend
)
{
parse_str
(
$result
,
$data
);
if
(
$data
[
'access_token'
]
&&
$data
[
'expires_in'
])
{
$this
->
Token
=
$data
;
$data
[
'openid'
]
=
$this
->
openid
();
return
$data
;
}
else
throw
new
\
think\Exception
(
"获取腾讯QQ ACCESS_TOKEN 出错:
{
$result
}
"
);
}
/**
* 获取当前授权应用的openid
* @return string
*/
public
function
openid
()
{
$data
=
$this
->
Token
;
if
(
isset
(
$data
[
'openid'
]))
return
$data
[
'openid'
];
elseif
(
$data
[
'access_token'
])
{
$data
=
$this
->
http
(
$this
->
url
(
'oauth2.0/me'
),
array
(
'access_token'
=>
$data
[
'access_token'
]));
$data
=
json_decode
(
trim
(
substr
(
$data
,
9
),
" );
\n
"
),
true
);
if
(
isset
(
$data
[
'openid'
]))
return
$data
[
'openid'
];
else
throw
new
\
think\Exception
(
"获取用户openid出错:
{
$data
[
'error_description'
]
}
"
);
}
else
{
throw
new
\
think\Exception
(
'没有获取到openid!'
);
}
}
}
application/plugins/view/shopoauth/admin/index.html
0 → 100644
浏览文件 @
886d34ff
{{include file="public/header" /}}
<!-- right content start -->
<div
class=
"content-right"
>
<div
class=
"content"
>
<div
class=
"shopoauth-content"
>
<legend>
<span
class=
"fs-16"
>
第三方账号登陆
</span>
<a
href=
'https://connect.qq.com'
target=
_blank
>
点击申请
</a>
<a
href=
"{{:MyUrl('admin/pluginsadmin/index')}}"
class=
"fr fs-14 m-t-5 am-icon-mail-reply"
>
返回
</a>
</legend>
<div
class=
"items"
>
<label>
QQ互联平台 显示名称
</label>
<div>
{{if empty($data['auth']['qq']['name'])}}
qq
{{else /}}
{{$data.auth.qq.name}}
{{/if}}
</div>
</div>
<div
class=
"items"
>
<label>
QQ互联平台 APP ID
</label>
<div>
{{if empty($data['auth']['qq']['app_key'])}}
未填写
{{else /}}
{{$data.auth.qq.app_key}}
{{/if}}
</div>
</div>
<div
class=
"items"
>
<label>
QQ互联平台 APP KEY
</label>
<div>
{{if empty($data['auth']['qq']['app_secret'])}}
未填写
{{else /}}
{{$data.auth.qq.app_secret}}
{{/if}}
</div>
</div>
<div
class=
"items"
>
<label>
QQ互联平台 是否开启
</label>
<div>
{{if isset($data['auth']['qq']['open']) and $data['auth']['qq']['open'] eq 1}}
已开启
{{else /}}
未开启
{{/if}}
</div>
</div>
<a
href=
"{{:PluginsAdminUrl('shopoauth', '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 -->
\ No newline at end of file
application/plugins/view/shopoauth/admin/saveinfo.html
0 → 100644
浏览文件 @
886d34ff
{{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('shopoauth', 'admin', 'save')}}"
method=
"POST"
request-type=
"ajax-url"
request-value=
"{{:PluginsAdminUrl('shopoauth', 'admin', 'index')}}"
enctype=
"multipart/form-data"
>
<legend>
<span
class=
"fs-16"
>
第三方账号登陆
</span>
<a
href=
"{{:PluginsAdminUrl('shopoauth', 'admin', 'index')}}"
class=
"fr fs-14 m-t-5 am-icon-mail-reply"
>
返回
</a>
</legend>
<div
class=
"am-panel am-panel-default"
>
<div
class=
"am-panel-hd"
>
<h3
class=
"am-panel-title"
>
QQ
</h3>
</div>
<div
class=
"am-panel-bd"
>
<div
class=
"am-form-group"
>
<label>
QQ互联平台 显示名称
</label>
<input
type=
"text"
name=
"auth[qq][name]"
placeholder=
"显示名称"
maxlength=
"16"
class=
"am-radius"
value=
"{{if !empty($data['auth']['qq']['name'])}}{{$data.auth.qq.name}}{{else /}}QQ{{/if}}"
data-validation-message=
"请填写QQ互联显示名称"
required
/>
</div>
<div
class=
"am-form-group"
>
<label>
QQ互联平台 APP ID
</label>
<input
type=
"text"
name=
"auth[qq][app_key]"
placeholder=
"APP ID"
maxlength=
"16"
class=
"am-radius"
value=
"{{if !empty($data['auth']['qq']['app_key'])}}{{$data.auth.qq.app_key}}{{/if}}"
/>
</div>
<div
class=
"am-form-group"
>
<label
class=
"block"
>
QQ互联平台 APP KEY
</label>
<input
type=
"text"
name=
"auth[qq][app_secret]"
placeholder=
"APP KEY"
maxlength=
"80"
class=
"am-radius"
value=
"{{if !empty($data['auth']['qq']['app_secret'])}}{{$data.auth.qq.app_secret}}{{/if}}"
/>
</div>
<div
class=
"am-form-group"
>
<label>
是否开启
<span
class=
"am-form-group-label-tips"
></span></label>
<div>
{{foreach $is_whether_list as $v}}
<label
class=
"am-radio-inline m-r-10"
>
<input
type=
"radio"
name=
"auth[qq][open]"
value=
"{{$v.id}}"
{{
if
isset
($
data
['
auth
']['
qq
']['
open
'])
and
$
data
['
auth
']['
qq
']['
open
']
eq
$
v
['
id
']}}
checked=
"checked"
{{
else
/}}{{
if
!
isset
($
data
['
auth
']['
qq
']['
open
'])
and
isset
($
v
['
checked
'])
and
$
v
['
checked
']
eq
true
}}
checked=
"checked"
{{/
if
}}{{/
if
}}
data-am-ucheck
/>
{{$v.name}}
</label>
{{/foreach}}
</div>
</div>
</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 w100"
data-am-loading=
"{loadingText:'处理中...'}"
>
保存
</button>
</div>
</form>
<!-- form end -->
</div>
</div>
<!-- right content end -->
<!-- footer start -->
{{include file="public/footer" /}}
<!-- footer end -->
\ No newline at end of file
application/service/NavigationService.php
浏览文件 @
886d34ff
...
...
@@ -56,7 +56,7 @@ class NavigationService
$hook_name
=
'plugins_service_navigation_header_handle'
;
$ret
=
Hook
::
listen
(
$hook_name
,
[
'hook_name'
=>
$hook_name
,
'is_backend'
=>
fals
e
,
'is_backend'
=>
tru
e
,
'params'
=>
&
$params
,
'header'
=>
&
$header
,
]);
...
...
@@ -80,7 +80,7 @@ class NavigationService
$hook_name
=
'plugins_service_navigation_footer_handle'
;
$ret
=
Hook
::
listen
(
$hook_name
,
[
'hook_name'
=>
$hook_name
,
'is_backend'
=>
fals
e
,
'is_backend'
=>
tru
e
,
'params'
=>
&
$params
,
'footer'
=>
&
$footer
,
]);
...
...
@@ -479,5 +479,314 @@ class NavigationService
}
return
DataReturn
(
'编辑失败或数据未改变'
,
-
100
);
}
/**
* 获取前端顶部右侧导航
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2019-03-15
* @desc description
* @param array $params [description]
*/
public
static
function
HomeHavTopRight
(
$params
=
[])
{
$common_cart_total
=
0
;
$common_message_total
=
-
1
;
if
(
!
empty
(
$params
[
'user'
]))
{
// 购物车商品总数
$common_cart_total
=
BuyService
::
UserCartTotal
([
'user'
=>
$params
[
'user'
]]);
$common_cart_total
=
(
$common_cart_total
>
99
)
?
'99+'
:
$common_cart_total
;
// 未读消息总数
$message_params
=
[
'user'
=>
$params
[
'user'
],
'is_more'
=>
1
,
'is_read'
=>
0
,
'user_type'
=>
'user'
];
$common_message_total
=
MessageService
::
UserMessageTotal
(
$message_params
);
$common_message_total
=
(
$common_message_total
>
99
)
?
'99+'
:
((
$common_message_total
<=
0
)
?
-
1
:
$common_message_total
);
}
// 列表
$data
=
[
[
'name'
=>
'个人中心'
,
'is_login'
=>
1
,
'badge'
=>
null
,
'icon'
=>
'am-icon-user'
,
'url'
=>
MyUrl
(
'index/user/index'
),
'items'
=>
[],
],
[
'name'
=>
'我的交易'
,
'is_login'
=>
1
,
'badge'
=>
null
,
'icon'
=>
'am-icon-cube'
,
'url'
=>
''
,
'items'
=>
[
[
'name'
=>
'我的订单'
,
'url'
=>
MyUrl
(
'index/order/index'
),
],
],
],
[
'name'
=>
'我的收藏'
,
'is_login'
=>
1
,
'badge'
=>
null
,
'icon'
=>
'am-icon-heart'
,
'url'
=>
''
,
'items'
=>
[
[
'name'
=>
'商品收藏'
,
'url'
=>
MyUrl
(
'index/userfavor/goods'
),
],
],
],
[
'name'
=>
'购物车'
,
'is_login'
=>
1
,
'badge'
=>
$common_cart_total
,
'icon'
=>
'am-icon-shopping-cart'
,
'url'
=>
MyUrl
(
'index/cart/index'
),
'items'
=>
[],
],
[
'name'
=>
'消息'
,
'is_login'
=>
1
,
'badge'
=>
$common_message_total
,
'icon'
=>
'am-icon-bell'
,
'url'
=>
MyUrl
(
'index/message/index'
),
'items'
=>
[],
],
];
// 顶部小导航右侧钩子
$hook_name
=
'plugins_service_header_navigation_top_right_handle'
;
$ret
=
Hook
::
listen
(
$hook_name
,
[
'hook_name'
=>
$hook_name
,
'is_backend'
=>
true
,
'params'
=>
&
$params
,
'data'
=>
&
$data
,
]);
return
$data
;
}
/**
* 用户中心资料修改展示字段
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2019-03-15
* @desc description
* @param array $params [description]
*/
public
static
function
UsersPersonalShowFieldList
(
$params
=
[])
{
$data
=
[
'avatar'
=>
[
'name'
=>
'头像'
,
'tips'
=>
'<a href="javascript:;" data-am-modal="{target:\'#user-avatar-popup\'}">修改</a>'
],
'nickname'
=>
[
'name'
=>
'昵称'
],
'gender_text'
=>
[
'name'
=>
'性别'
],
'birthday_text'
=>
[
'name'
=>
'生日'
],
'mobile_security'
=>
[
'name'
=>
'手机号码'
,
'tips'
=>
'<a href="'
.
MyUrl
(
'index/safety/mobileinfo'
)
.
'">修改</a>'
],
'email_security'
=>
[
'name'
=>
'电子邮箱'
,
'tips'
=>
'<a href="'
.
MyUrl
(
'index/safety/emailinfo'
)
.
'">修改</a>'
],
'add_time_text'
=>
[
'name'
=>
'注册时间'
],
'upd_time_text'
=>
[
'name'
=>
'最后更新时间'
],
];
// 用户中心资料修改展示字段钩子
$hook_name
=
'plugins_service_users_personal_show_field_list_handle'
;
$ret
=
Hook
::
listen
(
$hook_name
,
[
'hook_name'
=>
$hook_name
,
'is_backend'
=>
true
,
'params'
=>
&
$params
,
'data'
=>
&
$data
,
]);
return
$data
;
}
/**
* 用户安全项列表
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2019-03-15
* @desc description
* @param array $params [description]
*/
public
static
function
UsersSafetyPanelList
(
$params
=
[])
{
$data
=
[
[
'title'
=>
'登录密码'
,
'msg'
=>
'互联网存在被盗风险,建议您定期更改密码以保护安全。'
,
'url'
=>
MyUrl
(
'index/safety/loginpwdinfo'
),
'type'
=>
'loginpwd'
,
],
[
'title'
=>
'手机号码'
,
'no_msg'
=>
'您还没有绑定手机号码'
,
'ok_msg'
=>
'已绑定手机 #accounts#'
,
'tips'
=>
'可用于登录,密码找回,账户安全管理校验,接受账户提醒通知。'
,
'url'
=>
MyUrl
(
'index/safety/mobileinfo'
),
'type'
=>
'mobile'
,
],
[
'title'
=>
'电子邮箱'
,
'no_msg'
=>
'您还没有绑定电子邮箱'
,
'ok_msg'
=>
'已绑定电子邮箱 #accounts#'
,
'tips'
=>
'可用于登录,密码找回,账户安全管理校验,接受账户提醒邮件。'
,
'url'
=>
MyUrl
(
'index/safety/emailinfo'
),
'type'
=>
'email'
,
],
];
// 用户安全项列表钩子
$hook_name
=
'plugins_service_users_safety_panel_list_handle'
;
$ret
=
Hook
::
listen
(
$hook_name
,
[
'hook_name'
=>
$hook_name
,
'is_backend'
=>
true
,
'params'
=>
&
$params
,
'data'
=>
&
$data
,
]);
return
$data
;
}
/**
* 用户中心左侧菜单
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2019-03-15
* @desc description
* @param array $params [description]
*/
public
static
function
UsersCenterLeftList
(
$params
=
[])
{
$data
=
[
[
'control'
=>
'user'
,
'action'
=>
'index'
,
'name'
=>
'个人中心'
,
'is_show'
=>
1
,
'icon'
=>
'am-icon-home'
,
],
[
'name'
=>
'交易管理'
,
'is_show'
=>
1
,
'icon'
=>
'am-icon-cube'
,
'item'
=>
[
[
'control'
=>
'order'
,
'action'
=>
'index'
,
'name'
=>
'订单管理'
,
'is_show'
=>
1
,
'icon'
=>
'am-icon-th-list'
,
],
[
'control'
=>
'userfavor'
,
'action'
=>
'goods'
,
'name'
=>
'我的收藏'
,
'is_show'
=>
1
,
'icon'
=>
'am-icon-heart-o'
,
],
]
],
[
'name'
=>
'资料管理'
,
'is_show'
=>
1
,
'icon'
=>
'am-icon-user'
,
'item'
=>
[
[
'control'
=>
'personal'
,
'action'
=>
'index'
,
'name'
=>
'个人资料'
,
'is_show'
=>
1
,
'icon'
=>
'am-icon-gear'
,
],
[
'control'
=>
'useraddress'
,
'action'
=>
'index'
,
'name'
=>
'我的地址'
,
'is_show'
=>
1
,
'icon'
=>
'am-icon-street-view'
,
],
[
'control'
=>
'safety'
,
'action'
=>
'index'
,
'name'
=>
'安全设置'
,
'is_show'
=>
1
,
'icon'
=>
'am-icon-user-secret'
,
],
[
'control'
=>
'message'
,
'action'
=>
'index'
,
'name'
=>
'我的消息'
,
'is_show'
=>
1
,
'icon'
=>
'am-icon-bell-o'
,
],
[
'control'
=>
'userintegral'
,
'action'
=>
'index'
,
'name'
=>
'我的积分'
,
'is_show'
=>
1
,
'icon'
=>
'am-icon-fire'
,
],
[
'control'
=>
'usergoodsbrowse'
,
'action'
=>
'index'
,
'name'
=>
'我的足迹'
,
'is_show'
=>
1
,
'icon'
=>
'am-icon-lastfm'
,
],
[
'control'
=>
'answer'
,
'action'
=>
'index'
,
'name'
=>
'问答/留言'
,
'is_show'
=>
1
,
'icon'
=>
'am-icon-question'
,
],
[
'control'
=>
'user'
,
'action'
=>
'logout'
,
'name'
=>
'安全退出'
,
'is_show'
=>
1
,
'icon'
=>
'am-icon-power-off'
,
],
]
],
];
// 用户中心左侧菜单钩子
$hook_name
=
'plugins_service_users_center_left_menu_handle'
;
$ret
=
Hook
::
listen
(
$hook_name
,
[
'hook_name'
=>
$hook_name
,
'is_backend'
=>
true
,
'params'
=>
&
$params
,
'data'
=>
&
$data
,
]);
return
$data
;
}
}
?>
\ No newline at end of file
application/tags.php
浏览文件 @
886d34ff
...
...
@@ -44,6 +44,7 @@ return array (
'plugins_service_user_login_end'
=>
array
(
0
=>
'app\\plugins\\userloginrewardintegral\\Hook'
,
1
=>
'app\\plugins\\shopoauth\\Hook'
,
),
'plugins_css'
=>
array
(
...
...
@@ -88,6 +89,7 @@ return array (
'plugins_common_header'
=>
array
(
0
=>
'app\\plugins\\expressforkdn\\Hook'
,
1
=>
'app\\plugins\\shopoauth\\Hook'
,
),
'plugins_admin_common_header'
=>
array
(
...
...
@@ -97,5 +99,13 @@ return array (
array
(
0
=>
'app\\plugins\\expressforkdn\\Hook'
,
),
'plugins_service_header_navigation_top_left'
=>
array
(
0
=>
'app\\plugins\\shopoauth\\Hook'
,
),
'plugins_service_users_personal_show_field_list_handle'
=>
array
(
0
=>
'app\\plugins\\shopoauth\\Hook'
,
),
);
?>
\ No newline at end of file
config/shopxo.sql
浏览文件 @
886d34ff
此差异已折叠。
点击以展开。
public/static/plugins/css/shopoauth/admin.css
0 → 100644
浏览文件 @
886d34ff
/**
* 首页
*/
.shopoauth-content
.items
{
margin
:
10px
0
20px
0
;
border-bottom
:
1px
dashed
#f1f1f1
;
padding-bottom
:
20px
;
}
.shopoauth-content
.edit-submit
{
margin-bottom
:
20px
;
}
\ No newline at end of file
public/static/upload/images/plugins_shopoauth/2019/03/13/1552472848865750.png
0 → 100644
浏览文件 @
886d34ff
5.1 KB
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录