IndexData.php 3.13 KB
<?php
namespace LibModels\Web\Home;

use Api\Yohobuy;
use Api\Sign;
class IndexData
{
    //分类服务
    const URL_OPERATIONS_CATEGORY = 'operations/service/v1/category';
    //资源位地址
    const URL_OPERATIONS_RESOURCE_GET = 'operations/api/v5/resource/get';
    
    /**
     * 获取导航数据
     * 
     * @param int $status  (default)
     * @param string $fields (default)
     * @return array
     */
    public static function getNavData($status = 1, $fields = 'id,sort_name,sort_name_en,parent_id,sort_url,sort_ico,content_code,is_new,is_hot,separative_sign')
    {
        $params = array('parent_id'=>'','platform'=>'web',
            'status'=> $status,'fields'=> $fields
        );
        return Yohobuy::yarClient(Yohobuy::SERVICE_URL . self::URL_OPERATIONS_CATEGORY,'getCategory', $params, true);
    }
    
    /**
     * 获取资源数据
     * 
     * @param string $content_code
     * @param string $client_type
     * @return array
     */
    public static function getResourceData($content_code, $client_type = 'web') 
    {
        // 构建必传参数
        $params = Yohobuy::param();
        $params['content_code'] =  $content_code;
        $params['client_type'] = $client_type;
        $params['private_key'] = Yohobuy::$privateKeyList[$client_type];
        $params['client_secret'] = Sign::getSign($params);
        return Yohobuy::get(Yohobuy::SERVICE_URL . self::URL_OPERATIONS_RESOURCE_GET, $params);
    }
    
    /**
     * 邮箱订阅
     * 
     * @param string $email
     * @param string $uid
     * @return array
     */
    public static function emailSubscriber($email, $uid = 0)
    {
        //TODO 走老接口
        // 构建必传参数
        $param = Yohobuy::param();
        $param['page'] = 1;
        $param['open_key'] = '12345';
        $param['method'] = 'open.subscriber.subscriber';
        $param['email'] = $email;
        $param['uid'] = $uid;
        $param['client_secret'] = Sign::getSign($param);
        unset($param['app_version']);
        unset($param['client_type']);
        unset($param['os_version']);
        unset($param['screen_size']);
        unset($param['v']);
        return Yohobuy::get(Yohobuy::API_URL, $param);
    }
    
    /**
     * 意见反馈
     * 
     * @param int $feedback_id
     * @param int $question_id
     * @param string $answer
     * @param int $solution
     * @return array
     */
    public static function suggestFeedback($feedback_id, $question_id, $answer, $solution)
    {
        //TODO 走老接口
        $param = Yohobuy::param();
        $param['page'] = 1;
        $param['open_key'] = '12345';
        $param['method'] = 'open.feedback.submit';
        $param['feedback_id'] = $feedback_id;
        $param['question_id'] = $question_id;
        $param['answer'] = $answer;
        $param['solution'] = $solution;
        unset($param['app_version']);
        unset($param['client_type']);
        unset($param['os_version']);
        unset($param['screen_size']);
        unset($param['v']);
        return Yohobuy::get(Yohobuy::API_URL, $param);
    }
    
}