<?php

namespace app\api\controller;

use app\api\lists\HomeServiceLists;
use app\api\lists\HomeSpecialLists;
use app\api\logic\HomeSpecialLogic;
use app\api\validate\HomeSpecialValidate;
use app\common\model\home_service\HomeSpecial;

class HomeServiceController extends BaseApiController
{
    public array $notNeedLogin = ['lists','specialHot','specialLists','specialDetail'];
    public function lists()
    {
        return $this->dataLists(new HomeServiceLists());
    }

    public function specialHot()
    {
        //活动专题页：special_type = 0
        $result['special_type_0'] = [
            'title'=>'活动专题',
            'special_type'=>0,
            'status'=>1,
            'data'=>HomeSpecialLogic::getLists(['special_type'=>0,'status'=>1],6,$this->userInfo,$this->request->domain())
        ];
        //热销服务：special_type = 1
        $result['special_type_1'] = [
            'title'=>'热销服务',
            'special_type'=>1,
            'status'=>1,
            'data'=>HomeSpecialLogic::getLists(['special_type'=>1,'status'=>1],6,$this->userInfo,$this->request->domain())
        ];

        //当季精选:special_type = 2
        $result['special_type_2'] = [
            'title'=>'当季精选',
            'special_type'=>2,
            'status'=>1,
            'data'=>HomeSpecialLogic::getLists(['special_type'=>2,'status'=>1],6,$this->userInfo,$this->request->domain())
        ];

        return $this->data($result);
    }

    public function specialLists()
    {
        return $this->dataLists(new HomeSpecialLists());
    }

    public function specialDetail()
    {
        $params = (new HomeSpecialValidate())->goCheck('detail');
        $result = HomeSpecialLogic::detail($params);
        return $this->data($result);
    }
}