1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- <?php
- namespace app\api\controller;
- /**
- * ============================================================================
- *
- * ============================================================================
- * 版权所有 2014-2028 浙江惠利玛产业互联网有限公司,并保留所有权利。
- * 网站地址: https://www.valimart.net/
- * ----------------------------------------------------------------------------
- *
- * ============================================================================
- * 地区控制器
- */
- class Area extends MobileMall
- {
- public function initialize()
- {
- parent::initialize(); // TODO: Change the autogenerated stub
- }
- /**
- * @api {POST} api/Area/area_app 地区列表
- * @apiVersion 1.0.0
- * @apiGroup Area
- *
- * @apiSuccess {String} code 返回码,10000为成功
- * @apiSuccess {String} message 返回消息
- * @apiSuccess {Object} result 返回数据
- * @apiSuccess {Object[]} result.area_list 地区列表
- * @apiSuccess {String} result.area_list.area_name 地区名称
- * @apiSuccess {Int} result.area_list.area_id 地区ID
- * @apiSuccess {Object[]} result.area_list.child 子地区列表
- */
- public function area_app(){
- $cache_key = "api-area";
- $area_list = rcache($cache_key);
- if (empty($area_list)) {
- $area_model = model('area');
- $lev1 = $area_model->getTopLevelAreas();
- foreach ($lev1 as $k => $v) {
- $lev3 = $lev2[$k]['area_id'] = $area_model->GetChildName($k);
- foreach ($lev3 as $val) {
- $lev4[$k]['area_name'] = $v;
- $lev4[$k]['area_id'] = $k;
- $lev4[$k]['child'][$val['area_id']]['area_name'] = $val['area_name'];
- $lev4[$k]['child'][$val['area_id']]['area_id'] = $val['area_id'];
- $lev4[$k]['child'][$val['area_id']]['child'] = $area_model->GetChildName($val['area_id']);
- }
- }
- $area_list = array();
- foreach ($lev4 as $key => $val) {
- $val['child'] = array_values($val['child']);
- $area_list[] = $val;
- }
- wcache($cache_key,$area_list);
- }
- ds_json_encode(10000, '',array('area_list' => $area_list));
- }
-
- public function area_list(){
- $areas = model('area')->getAreas();
- ds_json_encode(10000, '',array('area_list' => $areas));
- }
- }
|