<?php
namespace App\Api\Controller;
use Biz\Account\AccountManager;
use App\Api\Model\AccountNews as AccountNewsModel;
use App\Api\Model\Article as ArticleModel;

/**
 * 个人中心-消息通知
 */
class Information extends BaseController
{
    public function init() {
        $this->accountManager = new AccountManager();
        $this->commonFunction =  C()->get('commonFunction');

         //获取用户token
         $token = $_REQUEST['token'];
         $UserInfo = $this->getAgent($token);
         //获取用户信息
         $this->UserInfo = $UserInfo;
         //获取用户uuid
         $this->account_identity = $UserInfo['account_identity'];
    }

    /**
     * 获取所有 消息通知
     */
    public function getAll(){
       
        dd( $this->UserInfo);

        //获取投注信息
        $BetNews = $this->getUserNews();
    }
    /**
     * 获取通知消息1
     */
    public function getUserNews(){
        //获取当前用户投注信息
        $UserNews = AccountNewsModel::getUserNews($this->UserInfo);

        Render($UserNews, '1', lang('Tips','Sports')->get('success'));
    }

    /**
     * 获取系统通知
     */
    public function getArticle(){
        $Article = ArticleModel::getArticle($this->UserInfo);

        Render($Article, '1', lang('Tips','Sports')->get('success'));
    }
    /**
     * 删除消息
     */
    public function delUserNews(){
        $delUserNews = AccountNewsModel::delUserNews();
       
        Render($delUserNews, '1', lang('Tips','Sports')->get('success'));

    }

    /**
     * 修改读取状态
     */
     public function upStatus(){
        $upStatus = AccountNewsModel::upStatus();
       
        Render($upStatus, '1', lang('Tips','Sports')->get('success'));
     }

    /**
     * token获取用户详情
     */
    public function getAgent($token = '') {
        $checkToken = $this->accountManager->checkEffectiveTime($token);
        if ($checkToken['status'] != 1) {
            Render($checkToken['data'], $checkToken['status'], lang('commons')->get('user does login'));
        };
        $result = $this->accountManager->refreshToken($token);
        return $result['data'];
    }



}
?>