123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274 |
- <?php
- namespace app\api\controller;
- use app\common\model\Config;
- use app\common\model\User;
- use app\common\controller\Api;
- use think\Db;
- use think\facade\Validate;
- class Login extends Api
- {
-
- public function register(){
- $phone = input('phone');
- $password = input('password');
- $ver_code = input('ver_code');
- $invite_code = input('invite_code');
- if (!$phone || !$password){
- $this->error('参数错误');
- }
- if (!Validate::regex($phone, "^1\d{10}$")) {
- $this->error('手机号格式错误');
- }
- $us = User::register($phone,$password,$ver_code,$invite_code);
- if ($us['code']){
- $this->success($us['msg'],$us['data']);
- }else{
- $this->error($us['msg']);
- }
- }
-
- public function login(){
- $phone = input('phone');
- $type = input('type',1);
- $password = input('password');
- $ver_code = input('ver_code');
- $come = input('come',1);
- if (!$phone || !Validate::regex($phone, "^1\d{10}$")) {
- $this->error('手机号格式错误');
- }
- if (!in_array($type,['1','2'])){
- $this->error('非法操作');
- }
- if ($type==1){
- if (!$password){
- $this->error('密码为空');
- }
- }elseif ($type==2){
- if (!$ver_code){
- $this->error('短信验证码为空');
- }
- }
- $result = User::login($phone,$password,$type,$ver_code,$come);
- if ($result['code']){
- $this->success($result['msg'],$result['data']);
- }else{
- $this->error($result['msg']);
- }
- }
-
- public function forgot_password(){
- $phone = input('phone');
- $password = input('password');
- $ver_code = input('ver_code');
- if (!$phone || !$password){
- $this->error('参数错误');
- }
- if (!$phone || !Validate::regex($phone, "^1\d{10}$")) {
- $this->error('手机号格式错误');
- }
- $result = User::forgotPassword($phone,$password,$ver_code);
- if ($result['code']){
- $this->success($result['msg'],$result['data']);
- }else{
- $this->error($result['msg']);
- }
- }
-
- public function wechat_login(){
- $code = input('code');
- if (!$code) $this->error('code为空');
- $result = User::wechatLogin($code);
- if ($result['code']){
- $this->success($result['msg'],$result['data']);
- }else{
- $this->error($result['msg']);
- }
- }
-
- public function wechat_login_bind_phone(){
- $code = input('code');
- if (!$code) $this->error('code为空');
- $rawData = input('rawData');
- $phone = input('phone');
- $ver_code = input('ver_code');
- $password = input('password');
- if (!$phone || !Validate::regex($phone, "^1\d{10}$")) {
- $this->error('手机号格式错误');
- }
- if (!$ver_code){
- $this->error('短信验证码为空');
- }
- if (!$password){
- $this->error('密码为空');
- }
- $result = User::wechatLoginBindPhone($code,$rawData,$phone,$ver_code,$password);
- if ($result['code']){
- $this->success($result['msg'],$result['data']);
- }else{
- $this->error($result['msg']);
- }
- }
-
- public function designer_register(){
- $phone = input('phone');
- $password = input('password');
- $ver_code = input('ver_code');
- $type = input('type');
- if (!$phone || !Validate::regex($phone, "^1\d{10}$")) {
- $this->error('手机号格式错误');
- }
- if (!in_array($type,['1','2'])){
- $this->error('非法操作');
- }
- if ($type==1){
- if (!$phone || !$password || !$password){
- $this->error('参数错误');
- }
- $result = User::designer_register_one($phone,$ver_code);
- }else{
- $data['phone'] = $phone;
- $data['name'] = input('name');
- $data['design_classifi'] = input('design_classifi');
- $data['skills_label'] = input('skills_label');
- $data['good_type'] = input('good_type');
- $data['province'] = input('province');
- $data['city'] = input('city');
- $data['area'] = input('area');
- $data['work_year'] = input('work_year');
- $data['identity_card_zheng'] = input('identity_card_zheng');
- $data['identity_card_fan'] = input('identity_card_fan');
- $data['related_certificate'] = input('related_certificate');
- $data['works'] = input('works');
- $data['wd'] = input('wd');
- $data['jd'] = input('jd');
- if (!$data['name'] || !$data['design_classifi'] || !$data['design_classifi'] || !$data['skills_label'] || !$data['good_type'] || !$data['identity_card_zheng'] || !$data['identity_card_fan'] || !$data['province']
- || !$data['city'] || !$data['area'] || !$data['work_year'] || !$data['works']){
- $this->error('参数错误');
- }
- $data['related_certificate'] = implode(',',$data['related_certificate']);
- $data['works'] = implode(',',$data['works']);
- $data['skills_label'] = implode(',',$data['skills_label']);
- $data['good_type'] = implode(',',$data['good_type']);
- $result = User::designer_register_two($data);
- }
- if ($result['code']){
- $this->success($result['msg'],$result['data']);
- }else{
- $this->error($result['msg']);
- }
- }
- }
|