Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
starsw001
ShopXO
提交
9328c626
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,发现更多精彩内容 >>
提交
9328c626
编写于
5月 25, 2019
作者:
G
gongfuxiang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
wx pay
上级
0284b4ed
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
4 addition
and
78 deletion
+4
-78
extend/payment/Weixin.php
extend/payment/Weixin.php
+4
-78
未找到文件。
extend/payment/Weixin.php
浏览文件 @
9328c626
...
...
@@ -22,7 +22,6 @@ class Weixin
{
// 插件配置参数
private
$config
;
private
$weixin_web_openid
;
/**
* 构造方法
...
...
@@ -36,7 +35,6 @@ class Weixin
public
function
__construct
(
$params
=
[])
{
$this
->
config
=
$params
;
$this
->
config
[
'secret'
]
=
'fc480bd4a543c0340f90093db8f3fc6b'
;
}
/**
...
...
@@ -67,10 +65,10 @@ class Weixin
'type'
=>
'text'
,
'default'
=>
''
,
'name'
=>
'appid'
,
'placeholder'
=>
'公众号ID'
,
'title'
=>
'公众号
ID (用于web/h5)
'
,
'placeholder'
=>
'公众号
/服务号App
ID'
,
'title'
=>
'公众号
/服务号AppID
'
,
'is_required'
=>
0
,
'message'
=>
'请填写微信分配的
公众号
ID'
,
'message'
=>
'请填写微信分配的
App
ID'
,
],
[
'element'
=>
'input'
,
...
...
@@ -157,7 +155,7 @@ class Weixin
// {
// return $ret;
// }
// $
this->weixin_web_openid
= $ret['data'];
// $
params['user']['weixin_web_openid']
= $ret['data'];
// }
// }
...
...
@@ -337,7 +335,6 @@ class Weixin
{
$openid
=
isset
(
$params
[
'user'
][
'weixin_openid'
])
?
$params
[
'user'
][
'weixin_openid'
]
:
''
;
}
else
{
$openid
=
$this
->
weixin_web_openid
;
$openid
=
isset
(
$params
[
'user'
][
'weixin_web_openid'
])
?
$params
[
'user'
][
'weixin_web_openid'
]
:
''
;
}
...
...
@@ -562,76 +559,5 @@ class Weixin
curl_close
(
$ch
);
return
$result
;
}
/**
* 授权
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @datetime 2019-02-07T08:21:54+0800
* @param [array] $params [输入参数]
*/
public
function
GetUserOpenId
(
$params
=
[])
{
// 参数
$input
=
input
();
// 回调地址
$redirect_uri
=
urlencode
(
MyUrl
(
'index/order/pay'
));
//$redirect_uri = urlencode('http://test.shopxo.net/index/order/pay.html');
//die($redirect_uri);
// 授权code
$url
=
'https://open.weixin.qq.com/connect/oauth2/authorize?appid='
.
$this
->
config
[
'appid'
]
.
'&redirect_uri='
.
$redirect_uri
.
'&response_type=code&scope=snsapi_base&state=callback#wechat_redirect'
;
//die($url);
exit
(
header
(
'location:'
.
$url
));
}
/**
* 回调
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @datetime 2019-02-07T08:21:54+0800
* @param [array] $params [输入参数]
*/
public
function
Callback
(
$params
=
[])
{
// 参数校验
if
(
empty
(
$params
[
'code'
]))
{
return
DataReturn
(
'授权code为空'
,
-
1
);
}
// 远程获取access_token
return
$this
->
RemoteUserOpenId
(
$params
);
}
/**
* 远程获取access_token
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2019-05-24
* @desc description
* @param [array] $params [输入参数]
*/
private
function
RemoteUserOpenId
(
$params
=
[])
{
// 获取access_token
$url
=
'https://api.weixin.qq.com/sns/oauth2/access_token?appid='
.
$this
->
config
[
'appid'
]
.
'&secret='
.
$this
->
config
[
'secret'
]
.
'&code='
.
$params
[
'code'
]
.
'&grant_type=authorization_code'
;
$data
=
json_decode
(
file_get_contents
(
$url
),
true
);
if
(
empty
(
$data
[
'access_token'
]))
{
if
(
empty
(
$data
[
'errmsg'
]))
{
return
DataReturn
(
'获取access_token失败'
,
-
100
);
}
else
{
return
DataReturn
(
$data
[
'errmsg'
],
-
100
);
}
}
return
DataReturn
(
'获取成功'
,
0
,
$data
[
'openid'
]);
}
}
?>
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录