Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
starsw001
ShopXO
提交
a19878be
ShopXO
项目概览
starsw001
/
ShopXO
与 Fork 源项目一致
Fork自
纵之格 / ShopXO
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
ShopXO
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
a19878be
编写于
5月 25, 2019
作者:
G
gongfuxiang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
wx pay
上级
62edc518
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
43 addition
and
30 deletion
+43
-30
application/plugins/weixinwebauthorization/index/Auth.php
application/plugins/weixinwebauthorization/index/Auth.php
+14
-2
application/plugins/weixinwebauthorization/service/Service.php
...cation/plugins/weixinwebauthorization/service/Service.php
+25
-13
extend/payment/Weixin.php
extend/payment/Weixin.php
+4
-15
未找到文件。
application/plugins/weixinwebauthorization/index/Auth.php
浏览文件 @
a19878be
...
...
@@ -23,6 +23,19 @@ use app\plugins\weixinwebauthorization\service\Service;
*/
class
Auth
extends
Controller
{
/**
* 支付授权
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @datetime 2019-05-25T14:44:32+0800
* @param [array] $params [输入参数]
*/
public
function
Pay
(
$params
=
[])
{
return
$this
->
Index
(
$params
);
}
/**
* 授权
* @author Devil
...
...
@@ -92,7 +105,7 @@ class Auth extends Controller
}
// 处理用户数据
$ret
=
Service
::
WeixinAuth
Reg
(
$ret
[
'data'
]);
$ret
=
Service
::
WeixinAuth
Bind
(
$ret
[
'data'
]);
if
(
$ret
[
'code'
]
==
0
)
{
$this
->
assign
(
'msg'
,
$ret
[
'msg'
]);
...
...
@@ -186,6 +199,5 @@ class Auth extends Controller
return
DataReturn
(
$ret
[
'msg'
],
-
1
);
}
}
}
?>
\ No newline at end of file
application/plugins/weixinwebauthorization/service/Service.php
浏览文件 @
a19878be
...
...
@@ -24,7 +24,7 @@ use app\service\PluginsService;
class
Service
{
/**
* 微信
登录注册
* 微信
绑定
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
...
...
@@ -32,26 +32,38 @@ class Service
* @desc description
* @param [array] $params [输入参数]
*/
public
static
function
WeixinAuth
Reg
(
$params
=
[])
public
static
function
WeixinAuth
Bind
(
$params
=
[])
{
// openid
if
(
empty
(
$params
[
'openid'
]))
{
return
DataReturn
(
'用户openid为空'
,
-
1
);
}
// 获取登录用户
$user
=
UserService
::
LoginUserInfo
();
if
(
!
empty
(
$user
))
{
return
DataReturn
(
'已登录,请先退出'
,
-
1
);
}
// 是否已绑定
if
(
!
empty
(
$user
[
'weixin_web_openid'
]))
{
return
DataReturn
(
'该帐号已绑定微信,请先解绑'
,
-
1
);
}
// 是否有登录纪录
if
(
!
empty
(
$params
[
'openid'
]))
{
$user
=
UserService
::
UserInfo
(
'weixin_web_openid'
,
$params
[
'openid'
]);
if
(
!
empty
(
$user
))
// 绑定
if
(
Db
::
name
(
'User'
)
->
where
([
'id'
=>
$user
[
'id'
]])
->
update
([
'weixin_web_openid'
=>
$params
[
'openid'
],
'upd_time'
=>
time
()]))
{
// 用户登录
return
UserService
::
UserLoginHandle
(
$user
[
'id'
],
$params
);
return
DataReturn
(
'绑定成功'
,
0
);
}
}
else
{
return
DataReturn
(
'用户openid为空'
,
-
1
);
return
DataReturn
(
'绑定失败'
,
-
100
);
}
// openid登录
$user
=
UserService
::
UserInfo
(
'weixin_web_openid'
,
$params
[
'openid'
]);
if
(
!
empty
(
$user
))
{
// 用户登录
return
UserService
::
UserLoginHandle
(
$user
[
'id'
],
$params
);
}
// 用户名
...
...
extend/payment/Weixin.php
浏览文件 @
a19878be
...
...
@@ -143,21 +143,10 @@ class Weixin
}
// 微信中打开
// if(!empty($_SERVER['HTTP_USER_AGENT']) && stripos($_SERVER['HTTP_USER_AGENT'], 'MicroMessenger') !== false)
// {
// $input = input();
// if(empty($input['code']))
// {
// $this->GetUserOpenId($params);
// } else {
// $ret = $this->Callback($input);
// if($ret['code'] != 0)
// {
// return $ret;
// }
// $params['user']['weixin_web_openid'] = $ret['data'];
// }
// }
if
(
!
empty
(
$_SERVER
[
'HTTP_USER_AGENT'
])
&&
stripos
(
$_SERVER
[
'HTTP_USER_AGENT'
],
'MicroMessenger'
)
!==
false
&&
empty
(
$params
[
'user'
][
'weixin_web_openid'
]))
{
exit
(
header
(
'location:'
.
PluginsHomeUrl
(
'weixinwebauthorization'
,
'auth'
,
'pay'
,
input
())));
}
// 获取支付参数
$ret
=
$this
->
GetPayParams
(
$params
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录