|
@@ -399,47 +399,6 @@ class User extends Api
|
|
|
return $data;
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 绑定微信手机号
|
|
|
- * @ApiMethod (POST)
|
|
|
- * @ApiParams (name=code,description="获取手机号code")
|
|
|
- */
|
|
|
- public function bind_wechat_phone()
|
|
|
- {
|
|
|
- $this->success('成功');
|
|
|
- $code = $this->request->post("code");
|
|
|
- if (!$code) {
|
|
|
- $this->error('参数错误');
|
|
|
- }
|
|
|
- $access_token_result = \app\common\service\WxService::getWxAccessToken();
|
|
|
- if (!$access_token_result) {
|
|
|
- $this->error('请刷新后重试');
|
|
|
- }
|
|
|
- $access_token = $access_token_result['access_token'];
|
|
|
-
|
|
|
- // 获取手机号
|
|
|
- $phone_info = \app\common\service\WxService::getWxphonenumber($access_token, $code);
|
|
|
- if (!$phone_info) {
|
|
|
- $this->error('请刷新后重试!');
|
|
|
- }
|
|
|
-
|
|
|
- //{"ret":true,"msg":"{\"errcode\":0,\"errmsg\":\"ok\",\"phone_info\":{\"phoneNumber\":\"18206485031\",\"purePhoneNumber\":\"18206485031\",\"countryCode\":\"86\",\"watermark\":{\"timestamp\":1679738067,\"appid\":\"wx20bb65dcc885b693\"}}}"}
|
|
|
-
|
|
|
- $mobile = $phone_info['phone_info']['phoneNumber'];
|
|
|
- $user = $this->auth->getUser();
|
|
|
- if (\app\common\model\User::where('mobile', $mobile)->where('id', '<>', $user->id)->find()) {
|
|
|
- $this->error(__('手机号已存在'));
|
|
|
- }
|
|
|
- // 修改手机号
|
|
|
- $verification = $user->verification;
|
|
|
- $verification->mobile = 1;
|
|
|
- $user->verification = $verification;
|
|
|
- $user->mobile = $mobile;
|
|
|
- $user->save();
|
|
|
-
|
|
|
- $this->success('成功');
|
|
|
- }
|
|
|
-
|
|
|
public function wxapp()
|
|
|
{
|
|
|
$url = url('user/index');
|