Explorar el Código

Wesmiler 人人车 初始化项目 0816

APPLE hace 3 años
padre
commit
3ed8fcb08f

+ 52 - 0
application/api/controller/v1/taxiUser/Auth.php

@@ -0,0 +1,52 @@
+<?php
+
+namespace app\api\controller\v1\taxiUser;
+
+use app\common\controller\BaseController;
+use app\http\IResponse;
+use Lettered\Support\Auth as IAuth;
+use think\App;
+
+class Auth extends BaseController
+{
+    protected $auth;
+
+    /**
+     * Auth constructor.
+     * @param App $app
+     * @param IAuth $auth
+     */
+    public function __construct(App $app, IAuth $auth)
+    {
+        parent::__construct($app);
+        $this->auth = $auth;
+    }
+
+    /**
+     * 司机端登录
+     *
+     * @return \think\response\Json
+     * @throws \Lettered\Support\Exceptions\FailedException
+     */
+    public function login()
+    {
+        // 接收数据
+        $param = $this->request->param();
+        // 内置验证
+        $valid = $this->validate($param, [
+            'mobile|手机号' => 'require|mobile',
+            'password|密码' => 'require',
+        ]);
+        // 错误
+        if (true !== $valid){
+            return IResponse::failure($valid);
+        }
+
+        // attempt
+        $token = $this->auth->guard('taxi_user')->attempt($param);
+
+        return $token ? IResponse::success([
+            'token' => 'Bearer ' . $token,
+        ], '登录成功') : IResponse::failure('登录失败');
+    }
+}

+ 6 - 2
application/api/validate/taxi/User.php

@@ -9,11 +9,13 @@ use think\Validate;
 class User extends Validate
 {
     protected $regex = [
-        'mobile' => '/^1[34578]\d{9}$/'
+        'mobile' => '/^1[34578]\d{9}$/',
+        'password' => '/^[a-zA-Z0-9\w]{6,20}$/',
     ];
 
     protected $rule = [
         'uname'  =>  'require',
+        'password'  =>  'require|regex:password',
         'id_card' =>  'require',
         'id_card_img' =>  'require',
         'mobile' =>  'require|number|regex:mobile',
@@ -23,6 +25,8 @@ class User extends Validate
 
     protected $message = [
         'uname.require'  =>  '用户名必须',
+        'password.require'  =>  '登录密码必须',
+        'password.regex'  =>  '登录密码格式错误',
         'id_card.require'  =>  '身份证号必须',
         'id_card_img.require'  =>  '身份证照必须',
         'mobile.require'  =>  '手机号必须',
@@ -33,7 +37,7 @@ class User extends Validate
     ];
 
     protected $scene = [
-        'save'   =>  ['uname','id_card','id_card_img','mobile','address','dr_license'],
+        'save'   =>  ['uname','password','id_card','id_card_img','mobile','address','dr_license'],
         'edit'  =>  ['email'],
     ];
 }

+ 10 - 0
config/mni.php

@@ -27,6 +27,11 @@ return [
                 'driver' => 'jwt',
                 'provider' => 'agent_system_users',
             ],
+            // agent 认证
+            'taxi_user' => [
+                'driver' => 'jwt',
+                'provider' => 'taxi_user',
+            ],
         ],
         // 服务提供
         'providers' => [
@@ -44,6 +49,11 @@ return [
                 'driver' => 'orm',
                 'model' => \app\agent\model\auth\User::class,
             ],
+            // agent 认证
+            'taxi_user' => [
+                'driver' => 'jwt',
+                'model' => \app\common\model\TaxiUser::class,
+            ],
         ],
     ],
 

La diferencia del archivo ha sido suprimido porque es demasiado grande
+ 71 - 57
public/manage/pages/store/hotel.html


+ 7 - 5
public/manage/pages/store/store.html

@@ -38,7 +38,7 @@
 </script>
 <!-- 表单弹窗 -->
 <script type="text/html" id="modelStore">
-    <form id="modelStoreForm" lay-filter="modelStoreForm" class="layui-form model-form">
+    <form id="modelStoreForm" lay-filter="modelStoreForm" class="layui-form model-form" onsubmit="return false;">
         <input name="id" type="hidden"/>
         <input name="type" type="hidden" value="1"/>
         <div class="layui-form-item">
@@ -146,14 +146,14 @@
             cellMinWidth: 100,
             cols: [[
                 {type: 'checkbox'},
-                {field: 'name', title: '服务项目', width: 200},
+                {field: 'name', title: '摊点名称', width: 200},
                 {field: 'phone', title: '联系电话', width: 100},
                 {
                     field: 'cover_img', title: '展示图片', templet: function (d) {
                         return '<img src="' + (d.cover_img || '../../assets/images/placeholder-refund.png') + '" style="height: 100%;margin-right:2px"  class="input-img-preview"/>'
                     }, width: 200
                 },
-                {field: 'intro', title: '服务内容'},
+                {field: 'intro', title: '介绍内容'},
                 {field: 'location', title: '位置'},
                 {field: 'time_slot', title: '服务时间', width: 200},
                 {
@@ -212,7 +212,7 @@
                 id: 'LAY_StoreModel',
                 type: 1,
                 area: '620px', //宽高
-                title: (data ? '修改' : '添加') + '技能服务',
+                title: (data ? '修改' : '添加') + '摊点',
                 content: $('#modelStore').html(),
                 success: function (layero, dIndex) {
                     $(layero).children('.layui-layer-content').css('overflow', 'visible');
@@ -281,7 +281,9 @@
                     form.val('modelStoreForm', data);
                     // 表单提交事件
                     form.on('submit(modelSubmitSkill)', function (form) {
-                        console.log(form.field)
+                        var coordinate = data && typeof(data.latitude) !='undefined' && data.latitude? data.latitude+','+data.longitude : '';
+                        form.field.coordinate = form.field.coordinate? form.field.coordinate : coordinate
+                        form.field.location = form.field.location? form.field.location : data.location
                         if (form.field.coordinate == "" || form.field.location == '') {
                             notice.msg("位置信息不能为空", {icon: 2});
                             return false;

+ 16 - 1
route/route.php

@@ -41,6 +41,12 @@ Route::group('api',function (){
 //Route::domain('api',function (){
     // API V1
     Route::group(':ver',function () {
+        // 管理登录 -- 独立跨域处理,验证码处理
+        Route::post('login','api/:ver.taxiUser/Auth/login')
+            ->header('Access-Control-Allow-Origin', 'http://'.request()->rootDomain().'/api')
+            ->header('Access-Control-Allow-Credentials', 'true')
+            ->allowCrossDomain();
+
         // 公共
         Route::group('common',function (){
             Route::get('/call','api/:ver.common/motorAgentPhone');
@@ -60,7 +66,16 @@ Route::group('api',function (){
                 'code' => -1,
                 'message' => '发送失败!' . $mobile
             ]);
-        });
+        })->header('Access-Control-Allow-Origin', 'http://'.request()->rootDomain().'/api')
+            ->header('Access-Control-Allow-Credentials', 'true')
+            ->allowCrossDomain();
+
+        // 司机找回密码
+        Route::post('taxiuser/forget','api/:ver.taxiUser/Auth/forget')
+            ->header('Access-Control-Allow-Origin', 'http://'.request()->rootDomain().'/api')
+            ->header('Access-Control-Allow-Credentials', 'true')
+            ->allowCrossDomain();
+
         // 系统信息
         Route::group('system',function (){
             // 公告

+ 1 - 1
vendor/workerman/_usr_local_develop_php_www_waibao_NN2022081301_NN2022081301_socket.php.pid

@@ -1 +1 @@
-38754
+49188

+ 6 - 0
vendor/workerman/workerman.log

@@ -335,3 +335,9 @@
 2021-05-07 18:16:31 pid:26224 Workerman[think] start in DEBUG mode
 2022-08-23 07:10:57 pid:5790 Workerman[socket.php] start in DEBUG mode
 2022-09-11 11:41:13 pid:38754 Workerman[socket.php] start in DEBUG mode
+2022-09-11 15:47:44 pid:38754 Workerman[socket.php] stopping ...
+2022-09-11 15:47:44 pid:38754 Workerman[socket.php] has been stopped
+2022-09-11 16:57:18 pid:47697 Workerman[socket.php] start in DEBUG mode
+2022-09-11 17:52:01 pid:47697 Workerman[socket.php] stopping ...
+2022-09-11 17:52:01 pid:47697 Workerman[socket.php] has been stopped
+2022-09-11 17:52:49 pid:49188 Workerman[socket.php] start in DEBUG mode