<?php
/**
 * Created by PhpStorm.
 * User: chenkuan
 * Date: 2017/11/7
 * Time: 下午2:09
 */

namespace backend\models;


class LoginApi extends BaseApi
{
    public $apiUrl = 'login';

    public function loginPost($data = [])
    {
        $data['ip'] = \Yii::$app->request->getUserIP();
        $result = $this->post($this->apiUrl.'/login-post', $data);
        if ($result['code'] == 1) {
            return $this->returnArray(1, $result['data'], '登录成功');
        } else {
            return $this->returnArray(0, [], $result['message']);
        }
    }

    public function pwd1($data = [])
    {
        $result = $this->post($this->apiUrl.'/pwd1', $data);
        if ($result['code'] == 1) {
            return $this->returnArray(1, $result['data'], '成功');
        } else {
            return $this->returnArray(0, [], $result['message']);
        }
    }

    public function modifyPwd1($data = [])
    {
        $result = $this->post($this->apiUrl.'/modify-pwd1', $data);
        if ($result['code'] == 1) {
            return $this->returnArray(1, $result['data'], '修改成功');
        } else {
            return $this->returnArray(0, [], $result['message']);
        }
    }

    public function loginByIdPassword($id, $password)
    {
        $data = ['id' => $id, 'password' => $password];
        $result = $this->post($this->apiUrl.'/login-by-id-password', $data);
        if ($result['code'] == 1) {
            return $this->returnArray(1, $result['data'], '登录成功');
        } else {
            return $this->returnArray(0, [], $result['message']);
        }
    }
}
