Exemplo n.º 1
0
 /**
  * Displays homepage.
  *
  * @return 首页
  */
 public function actionIndex()
 {
     $cache = \Yii::$app->cache;
     if (!$cache->get('city')) {
         $Region = new FinRegion();
         $dependency = new \yii\caching\FileDependency(['fileName' => 'example.txt']);
         $regionval = $Region->getProvince();
         $cache->set('city', json_encode($regionval, JSON_UNESCAPED_UNICODE), 3600, $dependency);
     }
     return $this->render('index');
 }
Exemplo n.º 2
0
 /**
  * @return string
  * 获取地区信息
  */
 public function actionRegion()
 {
     $region_id = Yii::$app->request->get("region_id");
     $type = Yii::$app->request->get("type");
     $region = new FinRegion();
     $getregion = $region->getRegion($region_id);
     $option = "";
     foreach ($getregion as $k => $v) {
         $option .= "<option class='" . $type . "' value='" . $v['region_id'] . "'>" . $v['region_name'] . "</option>";
     }
     echo $option;
 }