Useraddress.php 3.5 KB
Newer Older
D
v1.2.0  
devil_gong 已提交
1 2 3 4
<?php
// +----------------------------------------------------------------------
// | ShopXO 国内领先企业级B2C免费开源电商系统
// +----------------------------------------------------------------------
D
devil_gong 已提交
5
// | Copyright (c) 2011~2019 http://shopxo.net All rights reserved.
D
v1.2.0  
devil_gong 已提交
6 7 8 9 10 11 12
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: Devil
// +----------------------------------------------------------------------
namespace app\index\controller;

D
devil_gong 已提交
13
use app\service\SeoService;
14
use app\service\UserAddressService;
D
v1.2.0  
devil_gong 已提交
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37

/**
 * 用户地址管理
 * @author   Devil
 * @blog     http://gong.gg/
 * @version  0.0.1
 * @datetime 2016-12-01T21:51:08+0800
 */
class UserAddress extends Common
{
    /**
     * 构造方法
     * @author   Devil
     * @blog    http://gong.gg/
     * @version 1.0.0
     * @date    2018-11-30
     * @desc    description
     */
    public function __construct()
    {
        parent::__construct();

        // 是否登录
38
        $this->IsLogin();
D
v1.2.0  
devil_gong 已提交
39 40 41 42 43 44 45 46 47 48 49
    }
    
    /**
     * [Index 首页]
     * @author   Devil
     * @blog     http://gong.gg/
     * @version  0.0.1
     * @datetime 2017-02-22T16:50:32+0800
     */
    public function Index()
    {
D
devil_gong 已提交
50
        // 用户地址列表
51
        $data = UserAddressService::UserAddressList(['user'=>$this->user]);
D
v1.2.0  
devil_gong 已提交
52
        $this->assign('user_address_list', $data['data']);
D
devil_gong 已提交
53 54 55 56

        // 浏览器名称
        $this->assign('home_seo_site_title', SeoService::BrowserSeoTitle('我的地址', 1));

D
v1.2.0  
devil_gong 已提交
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
        return $this->fetch();
    }

    /**
     * [SaveInfo 地址添加/编辑页面]
     * @author   Devil
     * @blog     http://gong.gg/
     * @version  0.0.1
     * @datetime 2016-12-14T21:37:02+0800
     */
    public function SaveInfo()
    {
        $this->assign('is_header', 0);
        $this->assign('is_footer', 0);
        
D
devil 已提交
72 73
        $data = [];
        if(!empty($this->data_request))
D
v1.2.0  
devil_gong 已提交
74
        {
D
devil 已提交
75
            $params = $this->data_request;
D
v1.2.0  
devil_gong 已提交
76
            $params['user'] = $this->user;
77
            $ret = UserAddressService::UserAddressRow($params);
D
devil 已提交
78
            $data = $ret['data'];
D
v1.2.0  
devil_gong 已提交
79
        }
D
devil 已提交
80

D
devil 已提交
81 82 83
        // 编辑器文件存放地址
        $this->assign('editor_path_type', 'user_address-'.intval($this->user['id']%(3*24)/24));

D
devil 已提交
84 85 86
        // 加载百度地图api
        $this->assign('is_load_baidu_map_api', 1);
        $this->assign('data', $data);
D
v1.2.0  
devil_gong 已提交
87 88 89 90 91 92 93 94 95 96 97 98
        return $this->fetch();
    }

    /**
     * [Save 用户地址保存]
     * @author   Devil
     * @blog     http://gong.gg/
     * @version  1.0.0
     * @datetime 2018-09-23T22:36:18+0800
     */
    public function Save()
    {
D
devil 已提交
99
        $params = $this->data_post;
D
v1.2.0  
devil_gong 已提交
100
        $params['user'] = $this->user;
101
        return UserAddressService::UserAddressSave($params);
D
v1.2.0  
devil_gong 已提交
102 103 104 105 106 107 108 109 110 111 112 113
    }

    /**
     * 删除地址
     * @author   Devil
     * @blog    http://gong.gg/
     * @version 1.0.0
     * @date    2018-07-18
     * @desc    description
     */
    public function Delete()
    {
D
devil 已提交
114
        $params = $this->data_post;
D
v1.2.0  
devil_gong 已提交
115
        $params['user'] = $this->user;
116
        return UserAddressService::UserAddressDelete($params);
D
v1.2.0  
devil_gong 已提交
117 118 119 120 121 122 123 124 125 126 127 128
    }

    /**
     * 默认地址设置
     * @author   Devil
     * @blog    http://gong.gg/
     * @version 1.0.0
     * @date    2018-07-18
     * @desc    description
     */
    public function SetDefault()
    {
D
devil 已提交
129
        $params = $this->data_post;
D
v1.2.0  
devil_gong 已提交
130
        $params['user'] = $this->user;
131
        return UserAddressService::UserAddressDefault($params);
D
v1.2.0  
devil_gong 已提交
132 133 134
    }
}
?>