更新若干bug
This commit is contained in:
@@ -14,6 +14,8 @@ use think\db\exception\DbException;
|
||||
use think\facade\Env;
|
||||
use think\facade\Request;
|
||||
use app\model\Cms\TemplateSiteConfig;
|
||||
use app\model\Tenant\Tenant;
|
||||
use app\model\Cms\Demand;
|
||||
|
||||
class Index extends BaseController
|
||||
{
|
||||
@@ -347,4 +349,95 @@ class Index extends BaseController
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取企业信息
|
||||
* @return \think\response\Json
|
||||
*/
|
||||
public function getCompanyInfos()
|
||||
{
|
||||
// 从基类获取租户ID
|
||||
$tid = $this->tenantId;
|
||||
|
||||
try {
|
||||
$companyInfo = Tenant::where('delete_time', null)
|
||||
->where('id', $tid)
|
||||
->field('contact_phone, contact_email, address, worktime')
|
||||
->find();
|
||||
|
||||
return json([
|
||||
'code' => 200,
|
||||
'msg' => 'success',
|
||||
'data' => $companyInfo ?: null
|
||||
]);
|
||||
} catch (DbException $e) {
|
||||
return json([
|
||||
'code' => 500,
|
||||
'msg' => 'fail:' . $e->getMessage(),
|
||||
'data' => null
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 客户需求接口
|
||||
* post /index/requirement
|
||||
* @param string $title 标题
|
||||
* @param string $desc 描述
|
||||
* @param string $applicant 申请人
|
||||
* @param string $phone 手机号
|
||||
* @return \think\response\Json
|
||||
*/
|
||||
public function requirement()
|
||||
{
|
||||
// 获取参数
|
||||
$title = Request::param('title', '');
|
||||
$desc = Request::param('desc', '');
|
||||
$applicant = Request::param('applicant', '');
|
||||
$phone = Request::param('phone', '');
|
||||
|
||||
// 验证必填字段
|
||||
if (empty($title)) {
|
||||
return json([
|
||||
'code' => 400,
|
||||
'msg' => '标题不能为空',
|
||||
'data' => null
|
||||
]);
|
||||
}
|
||||
if (empty($desc)) {
|
||||
return json([
|
||||
'code' => 400,
|
||||
'msg' => '描述不能为空',
|
||||
'data' => null
|
||||
]);
|
||||
}
|
||||
|
||||
// 从基类获取租户ID
|
||||
$tid = $this->tenantId;
|
||||
|
||||
try {
|
||||
// 保存到需求表
|
||||
$id = Demand::insertGetId([
|
||||
'tid' => $tid,
|
||||
'title' => $title,
|
||||
'desc' => $desc,
|
||||
'applicant' => $applicant,
|
||||
'phone' => $phone,
|
||||
'status' => 1,
|
||||
'create_time' => date('Y-m-d H:i:s')
|
||||
]);
|
||||
|
||||
return json([
|
||||
'code' => 200,
|
||||
'msg' => '提交成功',
|
||||
'data' => ['id' => $id]
|
||||
]);
|
||||
} catch (DbException $e) {
|
||||
return json([
|
||||
'code' => 500,
|
||||
'msg' => '提交失败:' . $e->getMessage(),
|
||||
'data' => null
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,8 +8,12 @@ Route::get('index/index', 'app\index\controller\Index@index');
|
||||
// --- 模板初始化接口 ---
|
||||
Route::get('init', 'app\index\controller\Index@init');
|
||||
|
||||
// --- 前端底部数据路由 ---
|
||||
// --- 前端其他数据路由 ---
|
||||
Route::get('footerdata', 'app\index\controller\Index@getFooterData');
|
||||
Route::get('companyInfos', 'app\index\controller\Index@getCompanyInfos');
|
||||
Route::post('requirement', 'app\index\controller\Index@requirement');
|
||||
|
||||
// --- 客户需求路由 ---
|
||||
|
||||
// --- 文章列表路由 ---
|
||||
Route::get('getCenterNews', 'app\index\controller\Article\NewsCenterController@getCenterNews');
|
||||
|
||||
Reference in New Issue
Block a user