Ver código fonte

一些功能

Kirin 4 anos atrás
pai
commit
f4d82a01c6
1 arquivos alterados com 6 adições e 7 exclusões
  1. 6 7
      app/api/controller/PublicController.php

+ 6 - 7
app/api/controller/PublicController.php

@@ -34,32 +34,31 @@ class PublicController
     public function test()
     {
         $province = SystemCity::where('level', 0)->select();
-        $res = "var city = [";
+        $res = "window.province_city_area = [";
         foreach ($province as $k => $v) {
             $child = "";
             $citys = SystemCity::where('level', 1)->where('parent_id', $v['city_id'])->select();
             if (count($citys)) {
-                $child = ", children: [";
+                $child = ', "children": [';
                 foreach ($citys as $kk => $vv) {
                     $childs = "";
                     $dictres = SystemCity::where('level', 2)->where('parent_id', $vv['city_id'])->select();
                     if (count($dictres)) {
-                        $childs = ", children: [";
+                        $childs = ', "children": [';
                         foreach ($dictres as $kkk => $vvv) {
-                            $ress = $kkk == 0 ? ("{value: " . ($kkk + 1) . ", label: '{$vvv['name']}'}") : (",{value: " . ($kkk + 1) . ", label: '{$vvv['name']}'}");
-//                            $ress = ['value' => $kkk + 1, 'label' => $vvv['name']];
+                            $ress = $kkk == 0 ? ('{"value": ' . ($kkk + 1) . ', "label": "' . $vvv['name'] . '"}') : (',{"value": ' . ($kkk + 1) . ', "label": "' . $vvv['name'] . '"}');
                             $childs .= $ress;
                         }
                         $childs .= "]";
                     }
-                    $ress = $kk == 0 ? ("{value: " . ($kk + 1) . ", label: '{$vv['name']}'") : (",{value: " . ($kk + 1) . ", label: '{$vv['name']}'");
+                    $ress = $kk == 0 ? ('{"value": ' . ($kk + 1) . ', "label": "' . $vv['name'] . '"}') : (',{"value": ' . ($kk + 1) . ', "label": "' . $vv['name'] . '"}');
                     if ($childs) $ress .= $childs;
                     $ress .= '}';
                     $child .= $ress;
                 }
                 $child .= "]";
             }
-            $ress = $k == 0 ? ("{value: " . ($k + 1) . ", label: '{$v['name']}'") : (",{value: " . ($k + 1) . ", label: '{$v['name']}'");
+            $ress = $k == 0 ? ('{"value": ' . ($k + 1) . ', "label": "' . $v['name'] . '"}') : (',{"value": ' . ($k + 1) . ', "label": "' . $v['name'] . '"}');
             if ($child) $ress .= $child;
             $ress .= '}';
             $res .= $ress;