<?php
|
|
namespace app\api\controller\user;
|
|
use app\api\model\user\UserAuth;
|
use app\api\controller\Controller;
|
use app\common\model\settings\Region as RegionModel;
|
|
/**
|
* 收货地址控制器
|
*/
|
class Auth extends Controller
|
{
|
/**
|
* 列表
|
*/
|
public function lists()
|
{
|
$user = $this->getUser();
|
$model = new UserAuth;
|
$list = $model->getList($user['user_id']);
|
return $this->renderSuccess('', [
|
'list' => $list,
|
'default_id' => $user['auth_id'],
|
]);
|
}
|
|
/**
|
* 详情
|
*/
|
public function detail($auth_id)
|
{
|
$user = $this->getUser();
|
$detail = UserAuth::detail($user['user_id']);
|
$region = array_values($detail['region']);
|
$regionData = RegionModel::getRegionForApi();
|
$dateData = array( 'nowdate' => date('Y-m-d'), 'startdate' => date('Y') - 20 .'-01-01', 'enddate' => date('Y') + 20 .'-12-31' );
|
return $this->renderSuccess('', compact('detail', 'region', 'regionData', 'dateData'));
|
}
|
|
/**
|
* 保存
|
*/
|
public function save()
|
{
|
$data = $this->request->post();
|
if ($data['account_name'] == '') {
|
return $this->renderError('真实姓名不能为空');
|
}
|
if ($data['residence_address'] == '') {
|
return $this->renderError('户籍地址不能为空');
|
}
|
if ($data['id_card_no'] == '') {
|
return $this->renderError('身份证号不能为空');
|
}
|
$user = $this->getUser();
|
$model = UserAuth::detail($user['user_id']);
|
if ($model['auth_id']) {
|
$data['auth_id'] = $model['auth_id'];
|
}
|
if ($model->edit($data)) {
|
return $this->renderSuccess('提交成功');
|
}
|
return $this->renderError('提交失败');
|
}
|
}
|