2023-11-21 11:51:27 +08:00
|
|
|
|
<?php
|
|
|
|
|
// +----------------------------------------------------------------------
|
|
|
|
|
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
|
|
|
|
// +----------------------------------------------------------------------
|
|
|
|
|
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
|
|
|
|
// | 开源版本可自由商用,可去除界面版权logo
|
|
|
|
|
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
|
|
|
|
// | github下载:https://github.com/likeshop-github/likeadmin
|
|
|
|
|
// | 访问官网:https://www.likeadmin.cn
|
|
|
|
|
// | likeadmin团队 版权所有 拥有最终解释权
|
|
|
|
|
// +----------------------------------------------------------------------
|
|
|
|
|
// | author: likeadminTeam
|
|
|
|
|
// +----------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
namespace app\api\controller;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
use app\api\logic\IndexLogic;
|
2023-11-21 16:32:28 +08:00
|
|
|
|
use app\common\enum\notice\NoticeEnum;
|
|
|
|
|
use think\facade\Log;
|
2023-11-21 11:51:27 +08:00
|
|
|
|
use think\response\Json;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* index
|
|
|
|
|
* Class IndexController
|
|
|
|
|
* @package app\api\controller
|
|
|
|
|
*/
|
|
|
|
|
class IndexController extends BaseApiController
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
2023-11-23 11:57:48 +08:00
|
|
|
|
public array $notNeedLogin = ['index', 'config', 'policy', 'decorate','code','suYuan'];
|
2023-11-21 11:51:27 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @notes 首页数据
|
|
|
|
|
* @return Json
|
|
|
|
|
* @throws \think\db\exception\DataNotFoundException
|
|
|
|
|
* @throws \think\db\exception\DbException
|
|
|
|
|
* @throws \think\db\exception\ModelNotFoundException
|
|
|
|
|
* @author 段誉
|
|
|
|
|
* @date 2022/9/21 19:15
|
|
|
|
|
*/
|
|
|
|
|
public function index()
|
|
|
|
|
{
|
|
|
|
|
$result = IndexLogic::getIndexData();
|
|
|
|
|
return $this->data($result);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @notes 全局配置
|
|
|
|
|
* @return Json
|
|
|
|
|
* @throws \think\db\exception\DataNotFoundException
|
|
|
|
|
* @throws \think\db\exception\DbException
|
|
|
|
|
* @throws \think\db\exception\ModelNotFoundException
|
|
|
|
|
* @author 段誉
|
|
|
|
|
* @date 2022/9/21 19:41
|
|
|
|
|
*/
|
|
|
|
|
public function config()
|
|
|
|
|
{
|
|
|
|
|
$result = IndexLogic::getConfigData();
|
|
|
|
|
return $this->data($result);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @notes 政策协议
|
|
|
|
|
* @return Json
|
|
|
|
|
* @author 段誉
|
|
|
|
|
* @date 2022/9/20 20:00
|
|
|
|
|
*/
|
|
|
|
|
public function policy()
|
|
|
|
|
{
|
|
|
|
|
$type = $this->request->get('type/s', '');
|
|
|
|
|
$result = IndexLogic::getPolicyByType($type);
|
|
|
|
|
return $this->data($result);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @notes 装修信息
|
|
|
|
|
* @return Json
|
|
|
|
|
* @author 段誉
|
|
|
|
|
* @date 2022/9/21 18:37
|
|
|
|
|
*/
|
|
|
|
|
public function decorate()
|
|
|
|
|
{
|
|
|
|
|
$id = $this->request->get('id/d');
|
|
|
|
|
$result = IndexLogic::getDecorate($id);
|
|
|
|
|
return $this->data($result);
|
|
|
|
|
}
|
2023-11-21 16:32:28 +08:00
|
|
|
|
|
|
|
|
|
// 获取短信验证码
|
|
|
|
|
public function code(): Json
|
|
|
|
|
{
|
|
|
|
|
//验证请求方式
|
|
|
|
|
if(!$this->request->isPost()){
|
|
|
|
|
return $this->fail('请求方式错误');
|
|
|
|
|
}
|
|
|
|
|
//获取参数
|
|
|
|
|
$params = $this->request->post(['phone','scene']);
|
|
|
|
|
if(empty($params['phone']) || empty($params['scene'])){
|
|
|
|
|
return $this->fail('缺少必要参数');
|
|
|
|
|
}
|
|
|
|
|
if(!in_array($params['scene'],[NoticeEnum::LOGIN_CAPTCHA,NoticeEnum::BIND_MOBILE_CAPTCHA,NoticeEnum::CHANGE_MOBILE_CAPTCHA,NoticeEnum::FIND_LOGIN_PASSWORD_CAPTCHA])){
|
|
|
|
|
return $this->fail('短信场景错误');
|
|
|
|
|
}
|
|
|
|
|
//发送短信
|
|
|
|
|
try {
|
|
|
|
|
$result = event('Notice', [
|
|
|
|
|
'scene_id' => $params['scene'],
|
|
|
|
|
'params' => [
|
|
|
|
|
'mobile' => $params['phone'],
|
|
|
|
|
'code' => mt_rand(100000, 999999),
|
|
|
|
|
]
|
|
|
|
|
]);
|
|
|
|
|
return $this->success($result[0]);
|
|
|
|
|
}catch(\Exception $e){
|
|
|
|
|
//记录日志
|
|
|
|
|
Log::error($e->getMessage());
|
|
|
|
|
return $this->fail($e->getMessage());
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-11-23 11:57:48 +08:00
|
|
|
|
|
|
|
|
|
public function suYuan() {
|
|
|
|
|
|
|
|
|
|
}
|
2023-11-21 11:51:27 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|