79 lines
2.3 KiB
PHP
79 lines
2.3 KiB
PHP
<?php
|
|
|
|
namespace app\api\controller;
|
|
|
|
use app\common\controller\BaseCom;
|
|
use think\Db;
|
|
|
|
class Index extends BaseCom
|
|
{
|
|
//进入首页弹出的房间
|
|
public function index_recommend_room()
|
|
{
|
|
$reslut = model('Room')->index_recommend_room();
|
|
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
|
}
|
|
|
|
//房间列表
|
|
public function room_list()
|
|
{
|
|
$is_top = input('is_top', 0); //1非置顶2置顶
|
|
$label_id = input('label_id');
|
|
$page = input('page', 1);
|
|
$page_limit = input('page_limit', 20);
|
|
|
|
$reslut = model('Room')->room_list($label_id,$is_top, $page, $page_limit);
|
|
return V($reslut['code'], $reslut['msg'], $reslut['data'], $reslut['api_version']);
|
|
}
|
|
|
|
//房间类型列表
|
|
public function room_type_list()
|
|
{
|
|
$list = db::name('vs_room_label')
|
|
->where(['status' => 1])
|
|
->field('id,label_name,default_index,sort')->order('sort asc')->select();
|
|
if($list){
|
|
$default_index = 0;
|
|
$label_name = '';
|
|
$sort = 99;
|
|
foreach ($list as $k => $v) {
|
|
if($v['id'] == 3 || $v['id'] == 4){
|
|
$label_name = '亲密/真爱拍';
|
|
if($v['default_index'] == 1){
|
|
$default_index = 1;
|
|
}
|
|
$sort = min($sort, $v['sort']);
|
|
unset($list[$k]);
|
|
}
|
|
}
|
|
if($label_name){
|
|
//添加到列表后面
|
|
$list[] = [
|
|
'id' => 0,
|
|
'label_name' => $label_name,
|
|
'default_index' => $default_index,
|
|
'sort' => $sort
|
|
];
|
|
}
|
|
//数据重组避免乱序 再根据sort 排序 越小的越靠前
|
|
$list = array_values($list);
|
|
usort($list, function ($a, $b) {
|
|
return $a['sort'] - $b['sort'];
|
|
});
|
|
}
|
|
|
|
//给前面添加一组数据
|
|
array_unshift($list, ['id' => -1, 'label_name' => '热门']);
|
|
return V(1, '获取成功', $list);
|
|
}
|
|
|
|
//首页轮播图
|
|
public function index_banner()
|
|
{
|
|
$type = input('type', 3);//首页轮播图
|
|
$reslut = model('Banner')->banner_list($type);
|
|
return V(1, '成功', $reslut);
|
|
}
|
|
|
|
}
|