<?php


namespace App\Client;


class Site
{
    protected $site;

    public function __construct()
    {
        $this->site = app()->make('siteData');
    }

    /**
     * 获取用户id
     *
     * @return mixed
     */
    public function getUid()
    {
        return (int)getProp($this->site, 'uid');
    }

    /**
     * 获取用户channel_id
     *
     * @return mixed
     */
    public function getChannelId()
    {
        return (int)getProp($this->site, 'channel_id');
    }

    /**
     * 获取站点类型
     *
     * @return mixed
     */
    public function getChannelType()
    {
        return (string)getProp($this->site, 'channel_type');
    }

    /**
     * 获取站点充值模板id
     *
     * @return mixed
     */
    public function getChannelPayId()
    {
        return (int)getProp($this->site, 'channel_pay_id');
    }

    /**
     * 获取用户send_order_id
     *
     * @return mixed
     */
    public function getSendOrderId()
    {
        return (int)getProp($this->site, 'send_order_id');
    }

    /**
     * 获取用户from_uid
     *
     * @return mixed
     */
    public function getFromUid()
    {
        return (int)getProp($this->site, 'from_uid');
    }

    /**
     * 获取用户token
     *
     * @return mixed
     */
    public function getToken()
    {
        return (string)getProp($this->site, 'token');
    }

    /**
     * 获取用户account
     *
     * @return mixed
     */
    public function getAccount()
    {
        return (string)getProp($this->site, 'account');
    }

    /**
     * 获取用户phone
     *
     * @return mixed
     */
    public function getPhone()
    {
        return (string)getProp($this->site, 'phone');
    }

    /**
     * 获取用户阅读记录
     *
     * @return array
     */
    public function getRecentBooks()
    {
        return (array)getProp($this->site, 'recent_books');
    }

    /**
     * 获取当前阅读章节
     *
     * @return array
     */
    public function getCurrentChapter()
    {
        return (array)getProp($this->site, 'current_chapter');
    }

    /**
     * 获取当前阅读章节
     *
     * @return int
     */
    public function getRecentBid()
    {
        return (int)getProp($this->site, 'recent_bid');
    }

    /**
     * @return int
     */
    public function getCurrentChannelId()
    {
        return (int)getProp($this->site, 'current_channel_id');
    }

    /**
     * @return string
     */
    public function getCurrentChannelName()
    {
        return getProp($this->site, 'current_channel_name');
    }

    /**
     * 设置全局返回报错数据
     *
     * @param $data
     */
    public function setErrorResponseData($data)
    {
        $this->site->errorResponseData = $data;
    }

    /**
     * 获取全局返回报错数据
     *
     * @return mixed|string
     */
    public function getErrorResponseData()
    {
        return getProp($this->site, 'errorResponseData', []);
    }
}
