Func_model->check_session(true); $this->load->model('admin/City_model'); } /* 获取城市列表 */ public function lst() { $pagecurrent = isset($_POST['pagecurrent'])?stripslashes($_POST['pagecurrent']):""; $type = isset($_POST['citytype'])?$_POST['citytype']:1; $cityid = isset($_POST['cityid'])?$_POST['cityid']:""; if ($pagecurrent == "") { return false; }else { $data = array(); $num = $this->Config_model->getPageNum(); if ($type == 1) { $like = array(); $where = array(); $data = $this->Db_model->getPage("city",$where,$like,$pagecurrent); $msg = $this->Db_model->getSearchData("city",$where,$like,"id","DESC",((int)$pagecurrent-1)*$num,$num); $len = count($data); }else if ($type == 2) { $like = array(); //$where = array('cityid' => $cityid); $where = array(); $data = $this->Db_model->getPage("area",$where,$like,$pagecurrent); $msg = $this->Db_model->getSearchData("area",$where,$like,"id","DESC",((int)$pagecurrent-1)*$num,$num); $len = count($data); }else if ($type == 3) { $like = array(); $where = array('areaid' => $cityid); $data = $this->Db_model->getPage("community",$where,$like,$pagecurrent); $msg = $this->Db_model->getSearchData("community",$where,$like,"id","DESC",((int)$pagecurrent-1)*$num,$num); $len = count($data); } foreach ($msg as $row) { $data[$len][] = $this->City_model->setCityMsg($row,$type); } $this->Func_model->toJsFunc("cityList",$this->Func_model->decodeUnicode($data)); return; } } /* 编辑城市信息 */ public function editCity() { $type = isset($_POST['citytype'])?$_POST['citytype']:""; $name = isset($_POST['name'])?$_POST['name']:""; $id = isset($_POST['id'])?$_POST['id']:""; if ($id == "") return; if ($type == 1) { $data = array('name' => $name); $where = array('name' => $name); $infor = $this->Db_model->getSpecificData("city",$where); if (count($infor) > 0) { if ((int)$infor[0]->id != (int)$id) { $this->Func_model->setTip("city_tip",$this->Config_model->msg[7]); return; } } $where = array('id' => $id); $this->Db_model->updateData("city",$data,$where); }else if ($type == 2) { $data = array('name' => $name); $where = array('name' => $name); $infor = $this->Db_model->getSpecificData("area",$where); if (count($infor) > 0) { if ((int)$infor[0]->id != (int)$id) { $this->Func_model->setTip("city_tip",$this->Config_model->msg[7]); return; } } $where = array('id' => $id); $this->Db_model->updateData("area",$data,$where); }else if ($type == 3) { $data = array('name' => $name); $where = array('name' => $name); /* $data = array('citydess' => $citydess); $where = array('citydess' => $citydess); */ $infor = $this->Db_model->getSpecificData("community",$where); if (count($infor) > 0) { if ((int)$infor[0]->id != (int)$id) { $this->Func_model->setTip("city_tip",$this->Config_model->msg[7]); return; } } $where = array('id' => $id); $this->Db_model->updateData("community",$data,$where); } $this->Func_model->setAlert($this->Config_model->msg[0]); } /* 获取城市信息 */ public function cityInfor() { $type = isset($_POST['citytype'])?$_POST['citytype']:""; $id = isset($_POST['id'])?$_POST['id']:""; if ($id == "") return ; $where = array('id' => $id); if ($type == 1) { $infor = $this->Db_model->getSpecificData("city",$where); $data = $this->City_model->setCityMsg($infor[0]); $this->Func_model->toJsFunc("cityInfor",$this->Func_model->decodeUnicode($data)); }else if ($type == 2) { $infor = $this->Db_model->getSpecificData("area",$where); $data = $this->City_model->setCityMsg($infor[0], $type); $this->Func_model->toJsFunc("areaInfor",$this->Func_model->decodeUnicode($data)); }else if ($type == 3) { $infor = $this->Db_model->getSpecificData("community",$where); $data = $this->City_model->setCityMsg($infor[0], $type); $this->Func_model->toJsFunc("communityInfor",$this->Func_model->decodeUnicode($data)); } //$this->Func_model->sendServiceMsg($this->Func_model->decodeUnicode($data)); } /* 删除城市 */ public function delCity() { $id = isset($_POST['id'])?$_POST['id']:""; $type = isset($_POST['citytype'])?$_POST['citytype']:""; if ($id == "") return ; $where = array('id' => $id); if ($type == 1) { $this->Db_model->delData("city",$where); $this->Func_model->toJsFunc("disCity",""); }else if ($type == 2) { $this->Db_model->delData("area",$where); $this->Func_model->toJsFunc("disArea",""); }else if ($type == 3) { $this->Db_model->delData("community",$where); $this->Func_model->toJsFunc("disCommunity",""); } $this->Func_model->setAlert($this->Config_model->msg[0]); } /* 增加城市 */ public function addCity() { $type = isset($_POST['citytype'])?$_POST['citytype']:""; $data = $this->City_model->receiveCityMsg(); if ($type == 1) { $where = array('name' => $data['name']); $infor = $this->Db_model->getSpecificData("city",$where); if (count($infor) > 0) { $this->Func_model->setTip("city_tip",$this->Config_model->msg[7]); return; } $this->Db_model->insertData("city",$data); $this->Func_model->toJsFunc("disCity",""); }else if ($type == 2) { //$data['cityid'] = $_POST['cityid']; $data['cityid'] = 0; $where = array('name' => $data['name']); $infor = $this->Db_model->getSpecificData("area",$where); if (count($infor) > 0) { $this->Func_model->setTip("city_tip",$this->Config_model->msg[7]); return; } $this->Db_model->insertData("area",$data); $this->Func_model->toJsFunc("disArea",""); }else if ($type == 3) { $data['cityid'] = $_POST['cityid']; $data['areaid'] = $_POST['areaid']; $where = array('name' => $data['name']); $infor = $this->Db_model->getSpecificData("community",$where); if (count($infor) > 0) { $this->Func_model->setTip("city_tip",$this->Config_model->msg[7]); return; } //$msg = $this->Func_model->do_upload("file", $this->Config_model->fileMsg); //$data['img'] = $msg['file_name']; $this->Db_model->insertData("community",$data); $this->Func_model->toJsFunc("disCommunity",""); } $this->Func_model->setAlert($this->Config_model->msg[0]); } /* 编辑社区封面 */ public function editImg() { $id = isset($_POST['id'])?$_POST['id']:""; $msg = $this->Func_model->do_upload("file", $this->Config_model->fileMsg); $img = $msg['file_name']; $where = array('id' => $id); $infor = $this->Db_model->getSpecificData("community",$where); if ($infor[0]->img == "") { $data['img'] = $img; }else { $data['img'] = $infor[0]->img . "|" . $img; } $this->Db_model->updateData("community",$data,$where); $this->Func_model->toJsFunc("editCommunity",""); $this->Func_model->setAlert($this->Config_model->msg[0]); } /* 删除封面图片 */ public function delImg() { $id = isset($_POST['id'])?$_POST['id']:""; $img = isset($_POST['img'])?$_POST['img']:""; $where = array('id' => $id); $infor = $this->Db_model->getSpecificData("community",$where); $imgarr = explode('|', $infor[0]->img); foreach($imgarr as $k=>$v){ if ($v == $img) { array_splice($imgarr,$k,1); break; } } $data['img'] = implode('|', $imgarr); $this->Db_model->updateData("community",$data,$where); $this->Func_model->toJsFunc("editCommunity",""); $this->Func_model->setAlert($this->Config_model->msg[0]); } /* 获得城市 */ public function getCity() { $data = $this->City_model->getCity(); $this->Func_model->toJsFunc("setCity",$this->Func_model->decodeUnicode($data)); } /* 获得城区 */ public function getArea() { $cityid = isset($_POST['cityid'])?$_POST['cityid']:""; $data = $this->City_model->getArea($cityid); $this->Func_model->toJsFunc("setArea",$this->Func_model->decodeUnicode($data)); } /* 获得小区 */ public function getCommunity() { $areaid = isset($_POST['areaid'])?$_POST['areaid']:""; $data = $this->City_model->getCommunity($areaid); $this->Func_model->toJsFunc("setCommunity",$this->Func_model->decodeUnicode($data)); } }