Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
jcy2004x
ShopXO
提交
2cbc9ec1
ShopXO
项目概览
jcy2004x
/
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,体验更适合开发者的 AI 搜索 >>
提交
2cbc9ec1
编写于
6月 21, 2021
作者:
D
Devil
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
微信小程序用户授权优化
上级
4e1af35b
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
35 addition
and
2 deletion
+35
-2
application/api/controller/User.php
application/api/controller/User.php
+13
-0
application/service/UserService.php
application/service/UserService.php
+22
-2
未找到文件。
application/api/controller/User.php
浏览文件 @
2cbc9ec1
...
...
@@ -277,6 +277,19 @@ class User extends Common
if
(
empty
(
$user
))
{
return
DataReturn
(
'授权登录成功'
,
0
,
[
'is_user_exist'
=>
0
,
'openid'
=>
$result
[
'data'
][
'openid'
],
'unionid'
=>
$unionid
]);
}
else
{
// 如果用户openid为空则绑定到用户下面
if
(
empty
(
$user
[
'weixin_openid'
]))
{
if
(
UserService
::
UserOpenidBind
(
$user
[
'id'
],
$result
[
'data'
][
'openid'
],
'weixin_openid'
))
{
// 登录数据更新
self
::
UserLoginRecord
(
$user
[
'id'
],
true
);
// openid加入用户数据
$user
[
'weixin_openid'
]
=
$result
[
'data'
][
'openid'
];
}
}
}
// 用户状态
...
...
application/service/UserService.php
浏览文件 @
2cbc9ec1
...
...
@@ -1814,6 +1814,26 @@ class UserService
return
DataReturn
(
'授权成功'
,
0
,
self
::
AppUserInfoHandle
(
null
,
null
,
null
,
$data
));
}
/**
* 用户openid绑定
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2021-06-21
* @desc description
* @param [int] $user_id [用户id]
* @param [string] $openid [openid]
* @param [string] $field [openid 字段]
*/
public
static
function
UserOpenidBind
(
$user_id
,
$openid
,
$field
)
{
$data
=
[
$field
=>
$openid
,
'upd_time'
=>
time
(),
];
return
Db
::
name
(
'User'
)
->
where
([
'id'
=>
$user_id
])
->
update
(
$data
);
}
/**
* 用户unionid处理
* @author Devil
...
...
@@ -1823,7 +1843,7 @@ class UserService
* @desc description
* @param [array] $params [输入参数]
*/
p
rivate
static
function
UserUnionidHandle
(
$params
=
[])
p
ublic
static
function
UserUnionidHandle
(
$params
=
[])
{
// 用户unionid列表
// 微信用户unionid
...
...
@@ -1858,7 +1878,7 @@ class UserService
public
static
function
AppUserInfoHandle
(
$user_id
=
null
,
$where_field
=
null
,
$where_value
=
null
,
$user
=
[])
{
// 获取用户信息
$field
=
'id,username,nickname,mobile,email,avatar,alipay_openid,weixin_openid,weixin_unionid,weixin_web_openid,baidu_openid,toutiao_openid,qq_openid,qq_unionid,integral,locking_integral,referrer,add_time'
;
$field
=
'id,username,nickname,mobile,email,avatar,
status,
alipay_openid,weixin_openid,weixin_unionid,weixin_web_openid,baidu_openid,toutiao_openid,qq_openid,qq_unionid,integral,locking_integral,referrer,add_time'
;
if
(
!
empty
(
$user_id
))
{
$user
=
self
::
UserInfo
(
'id'
,
$user_id
,
$field
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录