<?php
/**
 * Created by PhpStorm.
 * User: chenkuan
 * Date: 2017/11/9
 * Time: 下午3:02
 */

namespace frontend\models;


class IndexApi extends BaseApi
{
    public $apiUrl = 'article';

    public function getArticleList($data = [])
    {
        $result = $this->get($this->apiUrl.'/get-article-list', $data);
        if ($result['code'] == 1) {
            return $this->returnArray(1, $result['data']);
        } else {
            return $this->returnArray(0, []);
        }
    }

    public function getArticleDetail($id)
    {
        $result = $this->get($this->apiUrl.'/article-detail', ['id' => $id]);
        if ($result['code'] == 1) {
            return $this->returnArray(1, $result['data']);
        } else {
            return $this->returnArray(0, [], $result['message']);
        }
    }

    public function saveRegister($data = [])
    {
        $result = $this->post('/register/save-register', $data);
        if ($result['code'] == 1) {
            return $this->returnArray(1, $result['data'], '申请成功');
        } else {
            return $this->returnArray(0, []);
        }
    }
    
    public function savePartnerApply($data = [])
    {
        $result = $this->post('/register/save-partner-apply', $data);
        if ($result['code'] == 1) {
            return $this->returnArray(1, $result['data'], '申请成功');
        } else {
            return $this->returnArray(0, []);
        }
    }

    public function saveEnroll($data = [])
    {
        $data['domain'] = \Yii::$app->request->referrer;
        $result = $this->post('/register/save-enroll', $data);
        if ($result['code'] == 1) {
            return $this->returnArray(1, $result['data'], '申请成功');
        } else {
            return $this->returnArray(0, []);
        }
    }

}