shish 4 lat temu
rodzic
commit
6dec9941b1
1 zmienionych plików z 50 dodań i 0 usunięć
  1. 50 0
      app-ghs/controllers/AuthController.php

+ 50 - 0
app-ghs/controllers/AuthController.php

@@ -251,6 +251,8 @@ class AuthController extends PublicController
         $token = jwt::getNewToken($adminId);
         $showDemo = 1;
         $remind = getenv('GHS_UPDATE_REMIND') == false ? 0 : getenv('GHS_UPDATE_REMIND');
+
+        //注意这里的输出内容和actionAppLogin一样,要修改需要同步修改!!!!!!!!
         util::success([
             'token' => $token,
             'admin' => $admin,
@@ -264,4 +266,52 @@ class AuthController extends PublicController
         ]);
     }
 
+    //app登陆 shish 20211219
+    public function actionAppLogin()
+    {
+        $get = Yii::$app->request->get();
+        $mobile = isset($get['mobile']) ? $get['mobile'] : 0;
+        if (stringUtil::isMobile($mobile) == false) {
+            util::fail('请填写正常的手机号');
+        }
+        $password = isset($get['password']) && !empty($get['password']) ? $get['password'] : '';
+        if (empty($password)) {
+            util::fail('请输入密码');
+        }
+        $admin = AdminService::getByCondition(['mobile' => $mobile, 'style' => AdminClass::STYLE_GHS]);
+        if (password_verify($password, $admin['password']) == false) {
+            util::fail('密码错误');
+        }
+        $adminId = $admin['id'];
+        $shopAdmin = ShopAdminService::getByCondition(['adminId' => $adminId, 'delStatus' => 0], true);
+        if ($shopAdmin->status == 0) {
+            util::fail("您的账号还未激活");
+        }
+        $shopId = $shopAdmin->shopId ?? 0;
+        if (empty($shopId)) {
+            util::fail('您不是管理员');
+        }
+        $token = jwt::getNewToken($adminId);
+        $shopAdminId = $shopAdmin->id ?? 0;
+        $currentShopId = $admin['currentShopId'] ?? 0;
+        //是否有切换门店的权限
+        $switchShop = \biz\shop\classes\ShopAdminClass::hasSwitchShopRight($shopAdmin->attributes);
+        //1没有开店 2已申请待审核 3已开店
+        $openShop = $admin['openShop'] ?? 1;
+        $showDemo = 1;
+
+        //注意这里的输出内容和actionMiniInfo一样,要修改需要同步修改!!!!!!!!
+        util::success([
+            'token' => $token,
+            'admin' => $admin,
+            'shopAdminId' => $shopAdminId,
+            'shopId' => $currentShopId,
+            'switchShop' => $switchShop,
+            'openShop' => $openShop,
+            'showDemo' => $showDemo,
+            //有小程序新版本提示更新
+            'update' => 0,
+        ]);
+    }
+
 }