|
|
<?php
|
|
|
/**
|
|
|
* Created by PhpStorm.
|
|
|
* User: 86132
|
|
|
* Date: 2020/7/14
|
|
|
* Time: 8:59
|
|
|
*/
|
|
|
|
|
|
namespace app\api\controller;
|
|
|
|
|
|
use think\Db;
|
|
|
use app\common\controller\Api;
|
|
|
|
|
|
/**
|
|
|
* 地址接口
|
|
|
*/
|
|
|
class Address extends Api
|
|
|
{
|
|
|
protected $noNeedLogin = ['*'];
|
|
|
protected $noNeedRight = '*';
|
|
|
|
|
|
public function _initialize()
|
|
|
{
|
|
|
parent::_initialize();
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* @ApiTitle (地址接口-我的地址页面渲染)
|
|
|
* @ApiSummary (我的地址页面渲染)
|
|
|
* @ApiMethod (POST)
|
|
|
* @ApiRoute (/api/address/MyAddressPageRendering)
|
|
|
* @ApiParams (name="token", type="string", required=true, description="token")
|
|
|
* @ApiReturnParams (name="code", type="integer", required=true, sample="0")
|
|
|
* @ApiReturnParams (name="msg", type="string", required=true, sample="返回成功")
|
|
|
* @ApiReturn ({
|
|
|
'code':'1',
|
|
|
'msg':'返回成功'
|
|
|
"data": [
|
|
|
{
|
|
|
"name": "收件人",
|
|
|
"address": "所在地址",
|
|
|
"address_con": "详细地址",
|
|
|
"mobile": "联系手机",
|
|
|
"id":"id",
|
|
|
"status":"是否默认地址:1=是,0=否"
|
|
|
}
|
|
|
]
|
|
|
})
|
|
|
*/
|
|
|
public function MyAddressPageRendering()
|
|
|
{
|
|
|
$user_id = $this->is_token($this->request->header());
|
|
|
$address_arr = Db::name('address')->where(['user_id' => $user_id])->select();
|
|
|
if (empty($address_arr)) {
|
|
|
$return = [];
|
|
|
$this->success('成功', $return);
|
|
|
}
|
|
|
foreach ($address_arr as $k => $v) {
|
|
|
$return[$k]['name'] = $v['name'];
|
|
|
$return[$k]['address'] = $v['address'];
|
|
|
$return[$k]['address_con'] = $v['address_con'];
|
|
|
$return[$k]['mobile'] = $v['mobile'];
|
|
|
$return[$k]['id'] = $v['id'];
|
|
|
$return[$k]['status'] = $v['status'];
|
|
|
}
|
|
|
$this->success('成功', $return);
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* @ApiTitle (地址接口-根据地址ID渲染地址)
|
|
|
* @ApiSummary (根据地址ID渲染地址)
|
|
|
* @ApiMethod (POST)
|
|
|
* @ApiRoute (/api/address/RenderAddressBasedOnAddressID)
|
|
|
* @ApiParams (name="token", type="string", required=true, description="token")
|
|
|
* @ApiParams (name="id", type="int", required=true, description="地址ID")
|
|
|
* @ApiReturnParams (name="code", type="integer", required=true, sample="0")
|
|
|
* @ApiReturnParams (name="msg", type="string", required=true, sample="返回成功")
|
|
|
* @ApiReturn ({
|
|
|
'code':'1',
|
|
|
'msg':'返回成功'
|
|
|
"data": {
|
|
|
"name": "王二蛋",
|
|
|
"address": "天津市",
|
|
|
"address_con": "天津市西青区",
|
|
|
"mobile": "13223332122",
|
|
|
"id": 1,
|
|
|
"status":"是否默认地址:1=是,0=否"
|
|
|
}
|
|
|
})
|
|
|
*/
|
|
|
public function RenderAddressBasedOnAddressID()
|
|
|
{
|
|
|
$user_id = $this->is_token($this->request->header());
|
|
|
$id = input('id');
|
|
|
$address_arr = Db::name('address')->where(['user_id' => $user_id])->where(['id' => $id])->find();
|
|
|
$return = [
|
|
|
'name' => $address_arr['name'],
|
|
|
'address' => $address_arr['address'],
|
|
|
'address_con' => $address_arr['address_con'],
|
|
|
'mobile' => $address_arr['mobile'],
|
|
|
'id' => $address_arr['id'],
|
|
|
'status' => $address_arr['status'],
|
|
|
];
|
|
|
$this->success('成功', $return);
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* @ApiTitle (地址接口-新增地址)
|
|
|
* @ApiSummary (新增地址)
|
|
|
* @ApiMethod (POST)
|
|
|
* @ApiRoute (/api/address/NewAddress)
|
|
|
* @ApiParams (name="token", type="string", required=true, description="token")
|
|
|
* @ApiParams (name="address", type="string", required=true, description="地址信息")
|
|
|
* @ApiParams (name="address_con", type="int", required=true, description="详细地址")
|
|
|
* @ApiParams (name="name", type="int", required=true, description="姓名")
|
|
|
* @ApiParams (name="id", type="int", required=true, description="地址ID")
|
|
|
* @ApiReturnParams (name="code", type="integer", required=true, sample="0")
|
|
|
* @ApiReturnParams (name="msg", type="string", required=true, sample="返回成功")
|
|
|
* @ApiReturn ({
|
|
|
'code':'1',
|
|
|
'msg':'返回成功'
|
|
|
"data": {
|
|
|
"name": "王二蛋",
|
|
|
"address": "天津市",
|
|
|
"address_con": "天津市西青区",
|
|
|
"mobile": "13223332122",
|
|
|
"id": 1
|
|
|
}
|
|
|
})
|
|
|
*/
|
|
|
} |
|
|
\ No newline at end of file |
...
|
...
|
|