quanwei
2025-12-09 ca425b889f3c1b5847ffc26a0229307f7f8ef43e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<?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('提交失败');
    }
}