省市区接口及文档

Original 2019-03-22 16:49:22 240
abstract:<?phprequire_once ('function.php');$list = select('php_area','*','status=1 and type=1','sort desc');re_json(0,$list);<?phprequire_once ('function.php&

<?php
require_once ('function.php');
$list = select('php_area','*','status=1 and type=1','sort desc');
re_json(0,$list);

<?php
require_once ('function.php');
if(empty($_POST['id']))
{
   re_json(1,'省id不能为空');
}
$pid = $_POST['id'];

$list = select('php_area','*','status=1 and type=2 and area_pid ='.$pid,'sort desc');
re_json(0,$list);


<?php
require_once ('function.php');
if(empty($_POST['id']))
{
   re_json(2,'市id不能为空');
}
$pid = $_POST['id'];

$list = select('php_area','*','status=1 and area_pid ='.$pid,'sort desc');
re_json(0,$list);


接口文档

标题:省级接口

地址:tp.cn/one.php

传值: 无

返回值:    "code": 0,                         //状态码

                 "msg": "success",                                 //返回信息

       "data": [                                                      //返回数据

                  {

                                 "area_id": "1",               //区域ID

                                 "area_pid": "0",             //父级ID

            "area_name": "北京",        //区域名称

            "sort": "0",                       //排序

            "status": "1",                    //状态

            "type": "1"                       //类型

                  },

]}

 

标题:市级接口

地址:tp.cn/two.php

传值: id       //省级ID

返回值:{

    "code": 0,

    "msg": "success",

    "data": [

        {

            "area_id": "2",

            "area_pid": "1",

            "area_name": "北京",

            "sort": "0",

            "status": "1",

            "type": "2"

        }

    ]

}

 

标题:县级接口

地址:tp.cn/three.php

传值: id       //市级ID

返回值:{

    "code": 0,

    "msg": "success",

    "data": [

        {

            "area_id": "3",

            "area_pid": "2",

            "area_name": "东城区",

            "sort": "0",

            "status": "1",

            "type": "3"

        },]}

错误码:

0     请求成功

1     省ID不能为空

2     市ID不能为空


Correcting teacher:查无此人Correction time:2019-03-22 17:24:30
Teacher's summary:完成的不错。php写接口,是一种逻辑思想,它没有页面。所以比较锻炼逻辑。继续加油。

Release Notes

Popular Entries