xiaogang vor 4 Jahren
Ursprung
Commit
0e094ee43a
6 geänderte Dateien mit 305 neuen und 5 gelöschten Zeilen
  1. 85 0
      app/Http/Controllers/Api/AuthorizationsController.php
  2. 1 0
      composer.json
  3. 160 1
      composer.lock
  4. 3 0
      config/app.php
  5. 50 0
      config/captcha.php
  6. 6 4
      routes/api.php

+ 85 - 0
app/Http/Controllers/Api/AuthorizationsController.php

xqd xqd xqd
@@ -76,6 +76,10 @@ class AuthorizationsController extends Controller
         return response()->json($resdata);
     }
 
+    public function captcha(){
+      return  response(captcha_src());
+    }
+
     /**
      * 根据用户ID生成唯一邀请码
      * @param $user_id
@@ -164,6 +168,73 @@ class AuthorizationsController extends Controller
         }
     }
 
+    public function reg_h5(Request $request){
+        $validator = Validator::make($request->all(), [
+            'mobile' => ['required', 'regex:/^1[3456789]\d{9}$/'],
+            'password' => 'bail|required',
+            'smsCode' => 'bail|required',
+        ],[
+            'mobile.required'=>"手机号码必须",
+            'mobile.regex'=>"手机号码格式错误",
+            'password.required'=>"密码必须",
+            'smsCode.required'=>"短信验证码必须",
+        ]);
+        if ($validator->fails()){
+            return response()->json([
+                'code'=>0,
+                'message'=>$validator->messages()->first()
+            ]);
+        }
+        try {
+            //验证短信验证码
+            SmsService::checkSmsCodeByVerifyKey($request->verifyKey, $request->smsCode);
+        } catch (SmsException $e) {
+            return response()->json([
+                'code'=>0,
+                'message'=>$e->getMessage()
+            ]);
+        } catch (\Exception $e) {
+            return response()->json([
+                'code'=>0,
+                'message'=>'短信校验失败'
+            ]);
+        }
+        if(User::where(['mobile'=>$request->mobile])->first()){
+            return response()->json([
+                'code'=>0,
+                'message'=>'该手机号码已使用'
+            ]);
+        }
+        //邀请码设置
+        $pid = 0;
+        if(isset($request->ycode) && $request->ycode!=""){
+            if(!$puser = User::where(['ycode'=>$request->ycode])->first()){
+                return response()->json([
+                    'code'=>0,
+                    'message'=>'邀请码不存在'
+                ]);
+            }
+            $pid = $puser->id;
+        }
+
+        $ins = array();
+        $ins['mobile'] = $request->mobile;
+        $ins['password'] = $request->password;
+        $ins['pid'] = $pid;
+        if(User::create($ins)){
+            return response()->json([
+                'code'=>1,
+                'message'=>'注册成功'
+            ]);
+        }else{
+            return response()->json([
+                'code'=>0,
+                'message'=>'注册失败'
+            ]);
+        }
+
+    }
+
 
 
     /**
@@ -218,6 +289,20 @@ class AuthorizationsController extends Controller
         }
     }
 
+    public function xieyi_content(Request $request){
+        if(isset($request->cont) && $request->cont==1){
+            $data = DB::table("document")->where(['id'=>$request->type])->first();
+            return response()->json(['data'=>$data]);
+        }else{
+            if($request->type==1){
+                $url = "https://".$_SERVER['HTTP_HOST'].'/xieyi/yhxy.html';
+            }else{
+                $url = "https://".$_SERVER['HTTP_HOST'].'/xieyi/yszc.html';
+            }
+            return response()->json(['url'=>$url]);
+        }
+    }
+
     /**
      * Get the authenticated User.
      *

+ 1 - 0
composer.json

xqd
@@ -16,6 +16,7 @@
         "laravel/framework": "^8.40",
         "laravel/tinker": "^2.5",
         "liyu/dingo-serializer-switch": "^0.3.2",
+        "mews/captcha": "^3.2",
         "overtrue/easy-sms": "^1.3",
         "spatie/laravel-activitylog": "^3.17",
         "tencent/tls-sig-api-v2": "1.0",

+ 160 - 1
composer.lock

xqd xqd xqd
@@ -4,7 +4,7 @@
         "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
         "This file is @generated automatically"
     ],
-    "content-hash": "f3829b02f8675b9295af662a517408f8",
+    "content-hash": "e180b9cf77529837305b6a4f11f142a9",
     "packages": [
         {
             "name": "aliyuncs/oss-sdk-php",
@@ -1371,6 +1371,86 @@
             },
             "time": "2021-04-26T09:17:50+00:00"
         },
+        {
+            "name": "intervention/image",
+            "version": "2.5.1",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/Intervention/image.git",
+                "reference": "abbf18d5ab8367f96b3205ca3c89fb2fa598c69e"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/Intervention/image/zipball/abbf18d5ab8367f96b3205ca3c89fb2fa598c69e",
+                "reference": "abbf18d5ab8367f96b3205ca3c89fb2fa598c69e",
+                "shasum": "",
+                "mirrors": [
+                    {
+                        "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
+                        "preferred": true
+                    }
+                ]
+            },
+            "require": {
+                "ext-fileinfo": "*",
+                "guzzlehttp/psr7": "~1.1",
+                "php": ">=5.4.0"
+            },
+            "require-dev": {
+                "mockery/mockery": "~0.9.2",
+                "phpunit/phpunit": "^4.8 || ^5.7"
+            },
+            "suggest": {
+                "ext-gd": "to use GD library based image processing.",
+                "ext-imagick": "to use Imagick based image processing.",
+                "intervention/imagecache": "Caching extension for the Intervention Image library"
+            },
+            "type": "library",
+            "extra": {
+                "branch-alias": {
+                    "dev-master": "2.4-dev"
+                },
+                "laravel": {
+                    "providers": [
+                        "Intervention\\Image\\ImageServiceProvider"
+                    ],
+                    "aliases": {
+                        "Image": "Intervention\\Image\\Facades\\Image"
+                    }
+                }
+            },
+            "autoload": {
+                "psr-4": {
+                    "Intervention\\Image\\": "src/Intervention/Image"
+                }
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "MIT"
+            ],
+            "authors": [
+                {
+                    "name": "Oliver Vogel",
+                    "email": "oliver@olivervogel.com",
+                    "homepage": "http://olivervogel.com/"
+                }
+            ],
+            "description": "Image handling and manipulation library with support for Laravel integration",
+            "homepage": "http://image.intervention.io/",
+            "keywords": [
+                "gd",
+                "image",
+                "imagick",
+                "laravel",
+                "thumbnail",
+                "watermark"
+            ],
+            "support": {
+                "issues": "https://github.com/Intervention/image/issues",
+                "source": "https://github.com/Intervention/image/tree/master"
+            },
+            "time": "2019-11-02T09:15:47+00:00"
+        },
         {
             "name": "jacobcyl/ali-oss-storage",
             "version": "2.1.0",
@@ -2152,6 +2232,85 @@
             },
             "time": "2020-06-24T04:09:03+00:00"
         },
+        {
+            "name": "mews/captcha",
+            "version": "3.2.6",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/mewebstudio/captcha.git",
+                "reference": "42c1b320e4cad1f6ec9a395da36d7eda5b67d122"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/mewebstudio/captcha/zipball/42c1b320e4cad1f6ec9a395da36d7eda5b67d122",
+                "reference": "42c1b320e4cad1f6ec9a395da36d7eda5b67d122",
+                "shasum": "",
+                "mirrors": [
+                    {
+                        "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
+                        "preferred": true
+                    }
+                ]
+            },
+            "require": {
+                "ext-gd": "*",
+                "illuminate/config": "~5|^6|^7|^8",
+                "illuminate/filesystem": "~5|^6|^7|^8",
+                "illuminate/hashing": "~5|^6|^7|^8",
+                "illuminate/session": "~5|^6|^7|^8",
+                "illuminate/support": "~5|^6|^7|^8",
+                "intervention/image": "~2.5",
+                "php": "^7.2|^8.0"
+            },
+            "require-dev": {
+                "mockery/mockery": "^1.0",
+                "phpunit/phpunit": "^8.5"
+            },
+            "type": "package",
+            "extra": {
+                "laravel": {
+                    "providers": [
+                        "Mews\\Captcha\\CaptchaServiceProvider"
+                    ],
+                    "aliases": {
+                        "Captcha": "Mews\\Captcha\\Facades\\Captcha"
+                    }
+                }
+            },
+            "autoload": {
+                "psr-4": {
+                    "Mews\\Captcha\\": "src/"
+                },
+                "files": [
+                    "src/helpers.php"
+                ]
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "MIT"
+            ],
+            "authors": [
+                {
+                    "name": "Muharrem ERİN",
+                    "email": "me@mewebstudio.com",
+                    "homepage": "https://github.com/mewebstudio",
+                    "role": "Developer"
+                }
+            ],
+            "description": "Laravel 5 & 6 Captcha Package",
+            "homepage": "https://github.com/mewebstudio/captcha",
+            "keywords": [
+                "captcha",
+                "laravel5 Security",
+                "laravel6 Captcha",
+                "laravel6 Security"
+            ],
+            "support": {
+                "issues": "https://github.com/mewebstudio/captcha/issues",
+                "source": "https://github.com/mewebstudio/captcha/tree/3.2.6"
+            },
+            "time": "2021-04-22T18:42:48+00:00"
+        },
         {
             "name": "monolog/monolog",
             "version": "2.2.0",

+ 3 - 0
config/app.php

xqd xqd
@@ -177,6 +177,8 @@ return [
         Dingo\Api\Provider\LaravelServiceProvider::class,
 
         Jacobcyl\AliOSS\AliOssServiceProvider::class,
+
+        Mews\Captcha\CaptchaServiceProvider::class,
     ],
 
     /*
@@ -229,6 +231,7 @@ return [
         'URL' => Illuminate\Support\Facades\URL::class,
         'Validator' => Illuminate\Support\Facades\Validator::class,
         'View' => Illuminate\Support\Facades\View::class,
+        'Captcha' => Mews\Captcha\Facades\Captcha::class,
 
     ],
 

+ 50 - 0
config/captcha.php

xqd
@@ -0,0 +1,50 @@
+<?php
+
+return [
+    'characters' => ['2', '3', '4', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'j', 'm', 'n', 'p', 'q', 'r', 't', 'u', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'J', 'M', 'N', 'P', 'Q', 'R', 'T', 'U', 'X', 'Y', 'Z'],
+    'default' => [
+        'length' => 4,
+        'width' => 120,
+        'height' => 36,
+        'quality' => 90,
+        'math' => false,
+        'expire' => 120,
+        'encrypt' => false,
+    ],
+    'math' => [
+        'length' => 9,
+        'width' => 120,
+        'height' => 36,
+        'quality' => 90,
+        'math' => true,
+    ],
+
+    'flat' => [
+        'length' => 6,
+        'width' => 160,
+        'height' => 46,
+        'quality' => 90,
+        'lines' => 6,
+        'bgImage' => false,
+        'bgColor' => '#ecf2f4',
+        'fontColors' => ['#2c3e50', '#c0392b', '#16a085', '#c0392b', '#8e44ad', '#303f9f', '#f57c00', '#795548'],
+        'contrast' => -5,
+    ],
+    'mini' => [
+        'length' => 3,
+        'width' => 60,
+        'height' => 32,
+    ],
+    'inverse' => [
+        'length' => 5,
+        'width' => 120,
+        'height' => 36,
+        'quality' => 90,
+        'sensitive' => true,
+        'angle' => 12,
+        'sharpen' => 10,
+        'blur' => 2,
+        'invert' => true,
+        'contrast' => -5,
+    ]
+];

+ 6 - 4
routes/api.php

xqd xqd
@@ -34,6 +34,8 @@ $api->version('v1', [
             $api->post('/forget_password', 'AuthorizationsController@forget_password')->name('login.forget');
             $api->post('/register', 'AuthorizationsController@register')->name('login.register');
             $api->get('/xieyi', 'AuthorizationsController@xieyi')->name('login.xieyi');
+            $api->get('/captcha', 'AuthorizationsController@captcha')->name('login.captcha');
+            $api->get('/reg_h5', 'AuthorizationsController@reg_h5')->name('login.reg_h5');
         });
 
         /*
@@ -136,10 +138,10 @@ $api->version('v1', [
     });
 
     /*
-        |--------------------------------------------------------------
-        |  支付回调
-        |--------------------------------------------------------------
-        */
+    |--------------------------------------------------------------
+    |  支付回调
+    |--------------------------------------------------------------
+    */
     $api->any('/wx_notify', 'PayNotifyController@wx_notify')->name('wx_notify');
     $api->any('/ali_notify', 'PayNotifyController@ali_notify')->name('ali_notify');