切换导航条
此项目
正在载入...
登录
李忠强
/
temporaryfood
·
提交
转到一个项目
GitLab
转到仪表盘
项目
活动
文件
提交
管道
0
构建
0
图表
里程碑
问题
0
合并请求
0
成员
标记
维基
派生
网络
创建新的问题
下载为
邮件补丁
差异文件
浏览文件
作者
李忠强
3 years ago
提交
892c96f3f61e82906256eab3433a7c7e10aa7acd
1 个父辈
429e6621
更新
隐藏空白字符变更
内嵌
并排对比
正在显示
2 个修改的文件
包含
45 行增加
和
0 行删除
application/api/controller/User.php
application/common/controller/Api.php
application/api/controller/User.php
查看文件 @
892c96f
...
...
@@ -129,6 +129,35 @@ class User extends Api
}
}
/**
* 获取微信手机号
*
* @ApiMethod (POST)
* @param string $token token
* @param string $code Code码
*/
public
function
thirdMobile
()
{
$code
=
$this
->
request
->
post
(
'code'
);
if
(
!
$code
){
$this
->
error
(
'后台所需参数缺失请完善参数'
);
}
$token
=
$this
->
getToken
();
$param
=
[];
$param
[
'access_token'
]
=
$token
;
$param
[
'code'
]
=
$code
;
$wxapi
=
Http
::
post
(
'https://api.weixin.qq.com/wxa/business/getuserphonenumber?access_token='
.
$token
,
$param
);
//请求openid
$wxapi
=
json_decode
(
$wxapi
,
true
);
if
(
$wxapi
[
'errcode'
]
!=
0
){
$this
->
error
(
$wxapi
[
'errmsg'
]);
}
$mobile
=
$wxapi
[
'phone_info'
][
'purePhoneNumber'
];
$user
=
$this
->
auth
->
getUser
();
$user
->
mobile
=
$mobile
;
$user
->
isUpdate
()
->
save
();
}
/**
* @ApiTitle (用户优惠券)
* @ApiMethod (POST)
...
...
application/common/controller/Api.php
查看文件 @
892c96f
...
...
@@ -3,6 +3,7 @@
namespace
app\common\controller
;
use
app\common\library\Auth
;
use
fast\Http
;
use
think\Config
;
use
think\Db
;
use
think\exception\HttpResponseException
;
...
...
@@ -403,4 +404,19 @@ class Api
}
return
$sum_price
;
}
/**
* 获取微信token
*/
protected
function
getToken
()
{
$param
=
[
'grant_type'
=>
'client_credential'
,
'appid'
=>
Config
::
get
(
'site.appid'
),
'secret'
=>
Config
::
get
(
'site.secret'
)
];
$http
=
Http
::
get
(
'https://api.weixin.qq.com/cgi-bin/token'
,
$param
);
$http
=
json_decode
(
$http
,
true
);
return
$http
[
'access_token'
];
}
}
...
...
请
注册
或
登录
后发表评论