You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
yanzong/app/api/controller/Index.php

71 lines
1.8 KiB

11 months ago
<?php
namespace app\api\controller;
9 months ago
8 months ago
use app\api\model\City;
10 months ago
use app\common\model\Banner;
9 months ago
use think\db\exception\DataNotFoundException;
use think\db\exception\DbException;
use think\db\exception\ModelNotFoundException;
use think\response\Json;
8 months ago
11 months ago
/**
* 默认控制器
* Class Index
* @package app\api\controller
*/
10 months ago
class Index extends Controller
11 months ago
{
public function index()
{
echo '当前访问的index.php,请将index.html设为默认站点入口';
}
10 months ago
9 months ago
public function getBannerList()
{
8 months ago
$list = Banner::where("status", 10)->with(['image'])->select()->toArray();
10 months ago
foreach ($list as &$value) {
8 months ago
unset($value['image']);
$value['image'] = $value['image_url'];
10 months ago
}
return $this->renderSuccess($list);
}
9 months ago
/**
* @notes:获取小程序配置
* @return Json
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
* @author: wanghousheng
*/
public function wxAppSetting(): Json
{
$data = (new \app\api\model\wxapp\Setting())->info();
return $this->renderSuccess($data);
}
8 months ago
/**
* @return mixed
*/
public function cityList($search = "")
{
8 months ago
8 months ago
$model = City::withoutGlobalScope()->where('status', 1);
if ($search) {
$model = $model->where('name|first_letter', 'like', "%$search%");
}
$city_list = $model->select();
$hotList = [];
$list = [];
foreach ($city_list as $seq => &$item) {
if ($item['is_hot'] == 1) {
$hotList[] = $item;
}
$list[$item['first_letter']][] = $item;
}
8 months ago
$result = ['hotList' => $hotList, "cityList" => $list];
8 months ago
return $this->renderSuccess($result);
}
11 months ago
}