chengkun
2025-08-29 73cdff843994b42beef7a22844326f83fee104de
app/admin/controller/Login.php
@@ -2,6 +2,8 @@
namespace app\admin\controller;
use app\admin\util\Opadmin;
use think\Exception;
use think\facade\Db;
use think\facade\View;
use think\facade\Request;
@@ -9,55 +11,60 @@
use think\captcha\facade\Captcha;
use app\BaseController;
class Login extends BaseController
{
    public function index()
    {
class Login extends BaseController {
    public function index() {
        header('Content-Type:text/html;charset=utf-8');
        $Opadmin = new \app\admin\util\Opadmin();
        $Opadmin = new Opadmin();
        if ($Opadmin->islogin()) {
            $this->redirect(url('/admin/')->build());
        }
        return View::fetch();
    }
    public function login()
    {
        if (request()->isPost()) {
            $Opadmin = new \app\admin\util\Opadmin(Request::post('username'), Request::post('password')); //////企业账号/////////////
            $returnmsg = $Opadmin->login();
            if ($returnmsg['code'] == 400) {
                return $returnmsg;
            } elseif ($returnmsg['code'] == 200) {
    /**
     * 登录
     * @return bool|array
     */
    public function login(): bool|array {
        try {
            if (!request()->isPost()) {
                throw new Exception("请求方式错误!");
            }
            $Opadmin = new Opadmin(Request::post('username'), Request::post('password')); //////企业账号/////////////
            $result = $Opadmin->login();
            if ($result['code'] == 400) {
                throw new Exception($result['message'], $result['code']);
            }
            if ($result['code'] == 200) {
                $backurl = Request::post('backurl');
                if (empty($backurl)) {
                    $returnmsg['url'] = url('/admin/index/index')->build();
                    $result['url'] = url('/admin/index/index')->build();
                } else {
                    $returnmsg['url'] = $backurl;
                    $result['url'] = $backurl;
                }
                return $returnmsg;
            }
        } else {
            $d['code'] = 0;
            $d['des'] = '参数有误!';
            return $d;
        } catch (Exception $exc) {
            $result = [
                'code' => $exc->getCode(),
                'des'  => $exc->getMessage(),
            ];
        }
        return $result;
    }
    public function logout()
    {
        $Opadmin = new \app\admin\util\Opadmin();
    public function logout() {
        $Opadmin = new Opadmin();
        $Opadmin->loginout();
        $this->redirect(url('/admin/login/index')->build());
    }
    public function captcha()
    {
    public function captcha() {
        return Captcha::create();
    }
    public function captchaCheck()
    {
    public function captchaCheck() {
        if (!Request::isPost()) {
            return $this->errorResponse(lang('request_method_incorrect'));
        }
@@ -72,8 +79,7 @@
        return $this->successResponse(lang('captcha_success'));
    }
    public function captchaCheckAndMsg()
    {
    public function captchaCheckAndMsg() {
        if (!Request::isPost()) {
            return $this->errorResponse(lang('request_method_incorrect'));
        }
@@ -139,10 +145,10 @@
            // 模板 ID 可前往 [国内短信](https://console.cloud.tencent.com/smsv2/csms-template) 或 [国际/港澳台短信](https://console.cloud.tencent.com/smsv2/isms-template) 的正文模板管理查看
            $req->TemplateId = Config::get('qcloud.Qcloud.TemplateId');
            /* 模板参数: 模板参数的个数需要与 TemplateId 对应模板的变量个数保持一致,若无模板参数,则设置为空*/
            $req->TemplateParamSet = array($phoneCode, '2');
            $req->TemplateParamSet = [$phoneCode, '2'];
            /* 下发手机号码,采用 E.164 标准,+[国家或地区码][手机号]
             * 示例如:+8613711112222, 其中前面有一个+号 ,86为国家码,13711112222为手机号,最多不要超过200个手机号*/
            $req->PhoneNumberSet = array("+86" . $phone);
            $req->PhoneNumberSet = ["+86" . $phone];
            /* 用户的 session 内容(无需要可忽略): 可以携带用户侧 ID 等上下文信息,server 会原样返回 */
            $req->SessionContext = "";
            /* 短信码号扩展号(无需要可忽略): 默认未开通,如需开通请联系 [腾讯云短信小助手] */
@@ -176,8 +182,7 @@
        }
    }
    public function getLanguageList()
    {
    public function getLanguageList() {
        ////////
        try {
            if (!Request::isPost()) {