Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
纵之格
ShopXO
提交
81eb6a5f
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 搜索 >>
提交
81eb6a5f
编写于
4月 14, 2022
作者:
G
gongfuxiang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
手机一键绑定适配系统用户类型
上级
c3f5f6c0
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
84 addition
and
70 deletion
+84
-70
app/api/controller/User.php
app/api/controller/User.php
+1
-70
app/service/AppMiniUserService.php
app/service/AppMiniUserService.php
+83
-0
未找到文件。
app/api/controller/User.php
浏览文件 @
81eb6a5f
...
@@ -786,76 +786,7 @@ class User extends Common
...
@@ -786,76 +786,7 @@ class User extends Common
*/
*/
public
function
OnekeyUserMobileBind
()
public
function
OnekeyUserMobileBind
()
{
{
// 参数校验
return
ApiService
::
ApiDataReturn
(
AppMiniUserService
::
AppMiniOnekeyUserMobileBind
(
$this
->
data_post
));
$p
=
[
[
'checked_type'
=>
'empty'
,
'key_name'
=>
'openid'
,
'error_msg'
=>
'openid为空'
,
],
[
'checked_type'
=>
'empty'
,
'key_name'
=>
'encrypted_data'
,
'error_msg'
=>
'解密数据为空'
,
],
[
'checked_type'
=>
'empty'
,
'key_name'
=>
'iv'
,
'error_msg'
=>
'iv为空,请重试'
,
]
];
$ret
=
ParamsChecked
(
$this
->
data_post
,
$p
);
if
(
$ret
===
true
)
{
// 根据不同平台处理数据解密逻辑
$mobile
=
''
;
$error_msg
=
''
;
switch
(
APPLICATION_CLIENT_TYPE
)
{
// 微信
case
'weixin'
:
$result
=
(
new
\
base\Wechat
(
MyC
(
'common_app_mini_weixin_appid'
),
MyC
(
'common_app_mini_weixin_appsecret'
)))
->
DecryptData
(
$this
->
data_post
[
'encrypted_data'
],
$this
->
data_post
[
'iv'
],
$this
->
data_post
[
'openid'
]);
if
(
$result
[
'status'
]
==
0
&&
!
empty
(
$result
[
'data'
])
&&
!
empty
(
$result
[
'data'
][
'purePhoneNumber'
]))
{
$mobile
=
$result
[
'data'
][
'purePhoneNumber'
];
}
else
{
$error_msg
=
$result
[
'msg'
];
}
break
;
// 百度
case
'baidu'
:
$config
=
[
'appid'
=>
MyC
(
'common_app_mini_baidu_appid'
),
'key'
=>
MyC
(
'common_app_mini_baidu_appkey'
),
'secret'
=>
MyC
(
'common_app_mini_baidu_appsecret'
),
];
$result
=
(
new
\
base\Baidu
(
$config
))
->
DecryptData
(
$this
->
data_post
[
'encrypted_data'
],
$this
->
data_post
[
'iv'
],
$this
->
data_post
[
'openid'
],
'mobile_bind'
);
if
(
$result
[
'status'
]
==
0
&&
!
empty
(
$result
[
'data'
])
&&
!
empty
(
$result
[
'data'
][
'mobile'
]))
{
$mobile
=
$result
[
'data'
][
'mobile'
];
}
else
{
$error_msg
=
$result
[
'msg'
];
}
break
;
// 默认
default
:
$error_msg
=
APPLICATION_CLIENT_TYPE
.
'平台还未开发手机一键登录'
;
}
if
(
empty
(
$mobile
)
||
!
empty
(
$error_msg
))
{
$ret
=
DataReturn
(
empty
(
$error_msg
)
?
'数据解密失败'
:
$error_msg
,
-
1
);
}
else
{
// 用户信息处理
$this
->
data_post
[
'mobile'
]
=
$mobile
;
$this
->
data_post
[
'is_onekey_mobile_bind'
]
=
1
;
$ret
=
UserService
::
AuthUserProgram
(
$this
->
data_post
,
APPLICATION_CLIENT_TYPE
.
'_openid'
);
}
}
else
{
$ret
=
DataReturn
(
$ret
,
-
1
);
}
return
ApiService
::
ApiDataReturn
(
$ret
);
}
}
}
}
?>
?>
\ No newline at end of file
app/service/AppMiniUserService.php
浏览文件 @
81eb6a5f
...
@@ -591,5 +591,88 @@ class AppMiniUserService
...
@@ -591,5 +591,88 @@ class AppMiniUserService
}
}
return
$ret
;
return
$ret
;
}
}
/**
* 小程序用户手机一键绑定
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2022-04-14
* @desc description
* @param [array] $params [输入参数]
*/
public
static
function
AppMiniOnekeyUserMobileBind
(
$params
=
[])
{
// 参数校验
$p
=
[
[
'checked_type'
=>
'empty'
,
'key_name'
=>
'openid'
,
'error_msg'
=>
'openid为空'
,
],
[
'checked_type'
=>
'empty'
,
'key_name'
=>
'encrypted_data'
,
'error_msg'
=>
'解密数据为空'
,
],
[
'checked_type'
=>
'empty'
,
'key_name'
=>
'iv'
,
'error_msg'
=>
'iv为空,请重试'
,
]
];
$ret
=
ParamsChecked
(
$params
,
$p
);
if
(
$ret
===
true
)
{
// 根据不同平台处理数据解密逻辑
$mobile
=
''
;
$error_msg
=
''
;
switch
(
APPLICATION_CLIENT_TYPE
)
{
// 微信
case
'weixin'
:
$result
=
(
new
\
base\Wechat
(
self
::
AppMiniConfig
(
'common_app_mini_weixin_appid'
),
self
::
AppMiniConfig
(
'common_app_mini_weixin_appsecret'
)))
->
DecryptData
(
$params
[
'encrypted_data'
],
$params
[
'iv'
],
$params
[
'openid'
]);
if
(
$result
[
'status'
]
==
0
&&
!
empty
(
$result
[
'data'
])
&&
!
empty
(
$result
[
'data'
][
'purePhoneNumber'
]))
{
$mobile
=
$result
[
'data'
][
'purePhoneNumber'
];
}
else
{
$error_msg
=
$result
[
'msg'
];
}
break
;
// 百度
case
'baidu'
:
$config
=
[
'appid'
=>
self
::
AppMiniConfig
(
'common_app_mini_baidu_appid'
),
'key'
=>
self
::
AppMiniConfig
(
'common_app_mini_baidu_appkey'
),
'secret'
=>
self
::
AppMiniConfig
(
'common_app_mini_baidu_appsecret'
),
];
$result
=
(
new
\
base\Baidu
(
$config
))
->
DecryptData
(
$params
[
'encrypted_data'
],
$params
[
'iv'
],
$params
[
'openid'
],
'mobile_bind'
);
if
(
$result
[
'status'
]
==
0
&&
!
empty
(
$result
[
'data'
])
&&
!
empty
(
$result
[
'data'
][
'mobile'
]))
{
$mobile
=
$result
[
'data'
][
'mobile'
];
}
else
{
$error_msg
=
$result
[
'msg'
];
}
break
;
// 默认
default
:
$error_msg
=
APPLICATION_CLIENT_TYPE
.
'平台还未开发手机一键登录'
;
}
if
(
empty
(
$mobile
)
||
!
empty
(
$error_msg
))
{
$ret
=
DataReturn
(
empty
(
$error_msg
)
?
'数据解密失败'
:
$error_msg
,
-
1
);
}
else
{
// 用户信息处理
$params
[
'mobile'
]
=
$mobile
;
$params
[
'is_onekey_mobile_bind'
]
=
1
;
$ret
=
UserService
::
AuthUserProgram
(
$params
,
APPLICATION_CLIENT_TYPE
.
'_openid'
);
}
}
else
{
$ret
=
DataReturn
(
$ret
,
-
1
);
}
return
ApiService
::
ApiDataReturn
(
$ret
);
}
}
}
?>
?>
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录