123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- <?php
- namespace app\api\controller;
- class Area extends MobileMall
- {
- public function initialize()
- {
- parent::initialize();
- }
-
- 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));
- }
- }
|