1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- <?php
- namespace app\api\controller;
- use app\common\controller\Api;
- use app\common\service\CategoryService;
- use fast\Tree;
- use think\exception\HttpResponseException;
- use think\Validate;
- class Catalog extends Api
- {
- protected $noNeedLogin = ['index'];
- protected $noNeedRight = ['*'];
- /**
- * 分类列表
- *
- * @ApiMethod (POST)
- * @param string $desc 需求描述
- * @param array $images 图片数组
- * @param array $files 文件数组
- * @param string $contact 联系方式
- */
- public function index()
- {
- try {
- $params = $this->request->get();
- $cateList = CategoryService::getOptions();
- $res = [
- ['text' => '全部', 'key' => 0]
- ];
- foreach ($cateList as $key => $val) {
- $res[] = ['text' => $val, 'key' => $key];
- }
- $this->success('', $res);
- } catch (\Exception $e) {
- if ($e instanceof HttpResponseException) {
- throw $e;
- }
- $this->error($e->getMessage());
- }
- }
- }
|