|
|
@@ -73,7 +73,7 @@ class User extends BaseController
|
|
|
['avatar',''],
|
|
|
['nickname',''],
|
|
|
['name',''],
|
|
|
- ['mobile',''],
|
|
|
+// ['mobile',''],
|
|
|
['sex', ''],
|
|
|
],$request);
|
|
|
$save=[];
|
|
|
@@ -86,12 +86,12 @@ class User extends BaseController
|
|
|
if(!empty($post["name"])){
|
|
|
$save["name"] = $post["name"];
|
|
|
}
|
|
|
- if(!empty($post["mobile"])){
|
|
|
- if(is_mobile($post["mobile"])){
|
|
|
- return app("json")->fail("请输入正确的手机号码");
|
|
|
- }
|
|
|
- $save["mobile"] = $post["mobile"];
|
|
|
- }
|
|
|
+// if(!empty($post["mobile"])){
|
|
|
+// if(is_mobile($post["mobile"])){
|
|
|
+// return app("json")->fail("请输入正确的手机号码");
|
|
|
+// }
|
|
|
+// $save["mobile"] = $post["mobile"];
|
|
|
+// }
|
|
|
if(in_array((string)$post["sex"],["0","1","2"])){
|
|
|
$save["sex"] = (int)$post["sex"];
|
|
|
}
|
|
|
@@ -122,7 +122,38 @@ class User extends BaseController
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
+ /**
|
|
|
+ * 绑定手机号
|
|
|
+ * @param Request $request
|
|
|
+ */
|
|
|
+ public function bindMobile(Request $request){
|
|
|
+ [$code] = UtilService::getMore([
|
|
|
+ ['code', '', 'empty', 'code参数错误'],
|
|
|
+ ], $request, true);
|
|
|
+ if(!empty($request->user['mobile'])){
|
|
|
+ return app('json')->fail("当前账户已绑定过手机号码");
|
|
|
+ }
|
|
|
+ $weixinA = new weixina();
|
|
|
+ $data=$weixinA->getPhoneNumber($code);//新版
|
|
|
+ if(empty($data) || empty($data['purePhoneNumber'])) {
|
|
|
+ return app('json')->fail("绑定失败,请重新绑定01".$weixinA->error);
|
|
|
+ }
|
|
|
+ $save=[
|
|
|
+ "countryCode"=>empty($data['countryCode'])?"":$data['countryCode'],
|
|
|
+ "mobile"=>$data['purePhoneNumber'],
|
|
|
+ ];
|
|
|
+ $r = (new UserModel)->where('uid', $request->user['uid'])->update($save);
|
|
|
+ if(!$r){
|
|
|
+ return app('json')->fail("绑定失败,请重新绑定02");
|
|
|
+ }
|
|
|
+ $result = [];
|
|
|
+ $result['nickname'] = $request->user['nickname'];
|
|
|
+ $result['avatar'] = $request->user['avatar'];
|
|
|
+ $result['token'] = $request->user['token'];
|
|
|
+ $result['uip'] = $request->user['uip'];
|
|
|
+ $result['is_mobile'] = 1;
|
|
|
+ return app('json')->success($result);
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
* 获取名片信息
|