Commit 3414a351 by felix

每日一更

parent 5cfde9dd
<?php
require_once(PLUGIN_DIR . 'Dao/SearchDao.php');
require_once(PLUGIN_DIR . 'Dao/InsertDao.php');
require_once(PLUGIN_DIR . 'Tools/Image.php');
require_once(PLUGIN_DIR . 'Tools/Core.php');
require_once(PLUGIN_DIR . 'Admin/Tospur_House.php');
class House extends Tospur_House{
public static function init_view(){
wp_enqueue_script('jquery-ui');
wp_enqueue_script('bootstrapjs');
wp_enqueue_script('validate');
wp_enqueue_style('jquery-ui_css');
wp_enqueue_style('bootstrapcss');
wp_enqueue_style('bootstrapMinCss');
global $wpdb;
$type = $_POST["type"];
$context = array();
$context['siteUrl'] = get_site_url();
if($type==1){
$insert_tospur_house_array = array(
'name' => $_POST['housename'],
'average_price' => $_POST['average_price'],
'latest_news' => $_POST['latest_news'],
'address' => $_POST['address'],
'traffic' => $_POST['traffic'],
'periphery' => $_POST['periphery'],
'developer' => $_POST['developers'],
'check_in_time' => $_POST['check_in_time'],
'property_age' => $_POST['property_age'],
'decoration' => $_POST['decoration'],
'covered_area' => $_POST['covered_area'],
'volume_rate' => $_POST['volume_rate'],
'greening_rate' => $_POST['greening_rate'],
'households' => $_POST['households'],
'parking_spaces' => $_POST['parking_spaces'],
'property_management' => $_POST['property_management'],
'overview' => $_POST['overview'],
'city_id' => $_POST['baseCity'],
'district_id' => $_POST['baseAreaId'],
'plate_id' => $_POST["basePlateId"],
'room_id' => $_POST['baseRoom'],
"location" => $_POST["location"],
'status' =>$_POST['status'],
"property_money" => $_POST["property_money"],
'community_name' => $_POST["community_name"],
);
$wpdb->query("START TRANSACTION");
if(isset($_POST['houseId'])){
$result = House::data_update($_POST['houseId'],$insert_tospur_house_array);
if($result != 203){
$wpdb->query("ROLLBACK");
print_r($result);
echo "新房房源修改失败";
}else{
$wpdb->query("COMMIT");
echo "新房房源修改成功";
}
}else{
$result = House::data_insert($insert_tospur_house_array);
if($result != 200){
$wpdb->query("ROLLBACK");
print_r($result);;
echo "新增房源失败";
}else{
$wpdb->query("COMMIT");
echo "新增房源成功";
}
}
exit;
}else if(isset($_GET['edit'])){
$context['houseId'] = $_GET['id'];
$context = array_merge($context,SearchDao::getDetailInfo($_GET['id'],"edit"));
$context["district"] = SearchDao::searchCity($context['result']->city_id);
$context["plate"] = SearchDao::searchCity($context['result']->city_id,$context['result']->district_id);
$context["mark"] = SearchDao::searchHouseTag($_GET['id']);
}
$context['role'] = SecHandHouse::getCurrentRole();
$context["city"] = SearchDao::searchCity();
$context["buildProperty"] = SearchDao::searchBuildProperty();
$context["room"] = SearchDao::searchRoom();
$context["photoType"] = SearchDao::searchPhotoType();
$context["status"] = searchDao::searchStatusType(1);
Timber::render("newhouse.html",$context);
}
public static function data_update($houseId,$insert_tospur_house_array){
global $wpdb;
$data = $_POST["data"];
$wpdb->update(Config::TOSPUR_HOUSE_TABLE,$insert_tospur_house_array,array("id" => $houseId));
$result = 203;
$exist_ids = array();
if(isset($_POST['exists'])){
foreach($_POST['exists'] as $id => $item){
$wpdb->update(Config::A_DISTRICT_AREA_TABLE,array(
"buildproperty_id" => $item['buildProperty'],
"house_area" => $item['housearea']
),array("image_id" => $id));
$exist_ids[] = $id;
}
$old_exists_ids = explode(",",$_POST['exists_ids']);
$delete_ids = array();
foreach(array_diff($old_exists_ids,$exist_ids) as $key => $id){
$delete_ids[] = $id;
}
$delete_ids = implode(",",$delete_ids);
$wpdb->query("delete from ".Config::A_DISTRICT_AREA_TABLE." where house_id = {$houseId} and image_id in ({$delete_ids});");
$wpdb->query("delete from ".Config::A_HOUSE_IMAGE_TABLE." where house_id = {$houseId} and image_id in ({$delete_ids});");
}
InsertDao::addMainImage($houseId,$data);
$exists_photo_ids = array();
if(isset($_POST['exists_photo'])){
foreach($_POST['exists_photo'] as $id => $item){
$wpdb->update(Config::TOSPUR_IMAGE_TABLE,array(
"image_type" => $item['type'],
),array("id" => $id));
$exists_photo_ids[] = $id;
}
}
$old_exists_photo_ids = explode(",",$_POST['exists_photo_ids']);
$delete_photo_ids = array();
foreach(array_diff($old_exists_photo_ids,$exists_photo_ids) as $key => $id){
$delete_photo_ids[] = $id;
}
$delete_photo_ids = implode(",",$delete_photo_ids);
$wpdb->query("delete from ".Config::A_HOUSE_IMAGE_TABLE." where house_id = {$houseId} and image_id in ({$delete_photo_ids});");
$wpdb->delete(Config::A_HOUSE_RECOMMEND_TABLE,array("house_id" => $houseId));
$res = InsertDao::addRecommend($houseId,$data);
if($res == 504){
$result = $res;
echo "推荐房源修改失败";
}
$wpdb->delete(Config::A_HOUSE_USER_TABLE,array("house_id" => $houseId));
$res = InsertDao::addRecConsultant($houseId,$data);
if($res == 505){
$result = $res;
echo "推荐置业顾问修改失败";
}
InsertDao::addHouseTag($_POST['mark'],$houseId);
return $result;
}
public static function data_insert($params){
global $wpdb;
//房源与类型以及面积信息
$data = $_POST["data"];
//获取新房信息,存入tospur_house表
$params['user_id'] = get_current_user_id();
$params['creattime'] = date("Y-m-d H:i:s");
$params['house_type'] = 0;
$res = $wpdb->get_results('SELECT * FROM tospur_house WHERE name="' . $_POST['housename'] . '" and address="' . $_POST['address'] . '" and house_type=0', OBJECT);
if (!$res) {
$houseId = InsertDao::insert_tospur_house($params);
InsertDao::addMainImage($houseId,$data);
InsertDao::addRecommend($houseId,$data);
InsertDao::addRecConsultant($houseId,$data);
InsertDao::addHouseTag($_POST['mark'],$houseId);
}else{
return 506;
}
return 200;
}
<?php
require_once(PLUGIN_DIR . 'Dao/SearchDao.php');
require_once(PLUGIN_DIR . 'Dao/InsertDao.php');
require_once(PLUGIN_DIR . 'Tools/Image.php');
require_once(PLUGIN_DIR . 'Tools/Core.php');
require_once(PLUGIN_DIR . 'Admin/Tospur_House.php');
class House extends Tospur_House{
public static function init_view(){
wp_enqueue_script('jquery-ui');
wp_enqueue_script('bootstrapjs');
wp_enqueue_script('publicjs');
wp_enqueue_script('validate');
wp_enqueue_style('jquery-ui_css');
wp_enqueue_style('bootstrapMinCss');
global $wpdb;
$type = $_POST["type"];
$context = array();
$context['siteUrl'] = get_site_url();
if($type==1){
$insert_tospur_house_array = array(
'name' => $_POST['housename'],
'average_price' => $_POST['average_price'],
'latest_news' => $_POST['latest_news'],
'address' => $_POST['address'],
'traffic' => $_POST['traffic'],
'periphery' => $_POST['periphery'],
'developer' => $_POST['developers'],
'check_in_time' => $_POST['check_in_time'],
'property_age' => $_POST['property_age'],
'decoration' => $_POST['decoration'],
'covered_area' => $_POST['covered_area'],
'volume_rate' => $_POST['volume_rate'],
'greening_rate' => $_POST['greening_rate'],
'households' => $_POST['households'],
'parking_spaces' => $_POST['parking_spaces'],
'property_management' => $_POST['property_management'],
'overview' => $_POST['overview'],
'city_id' => $_POST['baseCity'],
'district_id' => $_POST['baseAreaId'],
'plate_id' => $_POST["basePlateId"],
'room_id' => $_POST['baseRoom'],
"location" => $_POST["location"],
"property_money" => $_POST["property_money"],
'community_name' => $_POST["community_name"],
);
$wpdb->query("START TRANSACTION");
if(isset($_POST['houseId'])){
$insert_tospur_house_array['status'] = 0;
$result = House::data_update($_POST['houseId'],$insert_tospur_house_array);
if($result != 203){
$wpdb->query("ROLLBACK");
print_r($result);
echo "新房房源修改失败";
}else{
$wpdb->query("COMMIT");
echo "新房房源修改成功";
}
}else{
$insert_tospur_house_array['status'] = $_POST['status'];
$result = House::data_insert($insert_tospur_house_array);
if($result != 200){
$wpdb->query("ROLLBACK");
print_r($result);;
echo "新增房源失败";
}else{
$wpdb->query("COMMIT");
echo "新增房源成功";
}
}
exit;
}else if(isset($_GET['edit'])){
$context['houseId'] = $_GET['id'];
$context = array_merge($context,SearchDao::getDetailInfo($_GET['id'],"edit"));
$context["district"] = SearchDao::searchCity($context['result']->city_id);
$context["plate"] = SearchDao::searchCity($context['result']->city_id,$context['result']->district_id);
$context["mark"] = SearchDao::searchHouseTag($_GET['id']);
$context["searchStatus"] = SearchDao::searchStatus($_GET['id'],1);
}
$context['role'] = House::getCurrentRole();
$context["city"] = SearchDao::searchCity();
$context["buildProperty"] = SearchDao::searchBuildProperty();
$context["room"] = SearchDao::searchRoom();
$context["photoType"] = SearchDao::searchPhotoType();
$context["status"] = searchDao::searchStatusType(1);
Timber::render("newhouse.html",$context);
}
public static function data_update($houseId,$insert_tospur_house_array){
global $wpdb;
$data = $_POST["data"];
$wpdb->update(Config::TOSPUR_HOUSE_TABLE,$insert_tospur_house_array,array("id" => $houseId));
$result = 203;
$exist_ids = array();
if(isset($_POST['exists'])){
foreach($_POST['exists'] as $id => $item){
$wpdb->update(Config::A_DISTRICT_AREA_TABLE,array(
"buildproperty_id" => $item['buildProperty'],
"house_area" => $item['housearea']
),array("image_id" => $id));
$exist_ids[] = $id;
}
$old_exists_ids = explode(",",$_POST['exists_ids']);
$delete_ids = array();
foreach(array_diff($old_exists_ids,$exist_ids) as $key => $id){
$delete_ids[] = $id;
}
$delete_ids = implode(",",$delete_ids);
$wpdb->query("delete from ".Config::A_DISTRICT_AREA_TABLE." where house_id = {$houseId} and image_id in ({$delete_ids});");
$wpdb->query("delete from ".Config::A_HOUSE_IMAGE_TABLE." where house_id = {$houseId} and image_id in ({$delete_ids});");
}
InsertDao::addMainImage($houseId,$data);
$exists_photo_ids = array();
if(isset($_POST['exists_photo'])){
foreach($_POST['exists_photo'] as $id => $item){
$wpdb->update(Config::TOSPUR_IMAGE_TABLE,array(
"image_type" => $item['type'],
),array("id" => $id));
$exists_photo_ids[] = $id;
}
}
$old_exists_photo_ids = explode(",",$_POST['exists_photo_ids']);
$delete_photo_ids = array();
foreach(array_diff($old_exists_photo_ids,$exists_photo_ids) as $key => $id){
$delete_photo_ids[] = $id;
}
$delete_photo_ids = implode(",",$delete_photo_ids);
$wpdb->query("delete from ".Config::A_HOUSE_IMAGE_TABLE." where house_id = {$houseId} and image_id in ({$delete_photo_ids});");
$wpdb->delete(Config::A_HOUSE_RECOMMEND_TABLE,array("house_id" => $houseId));
$res = InsertDao::addRecommend($houseId,$data);
if($res == 504){
$result = $res;
echo "推荐房源修改失败";
}
$wpdb->delete(Config::A_HOUSE_USER_TABLE,array("house_id" => $houseId));
$res = InsertDao::addRecConsultant($houseId,$data);
if($res == 505){
$result = $res;
echo "推荐置业顾问修改失败";
}
InsertDao::addHouseTag($_POST['mark'],$houseId);
return $result;
}
public static function data_insert($params){
global $wpdb;
//房源与类型以及面积信息
$data = $_POST["data"];
//获取新房信息,存入tospur_house表
$params['user_id'] = get_current_user_id();
$params['creattime'] = date("Y-m-d H:i:s");
$params['house_type'] = 0;
$res = $wpdb->get_results('SELECT * FROM tospur_house WHERE name="' . $_POST['housename'] . '" and address="' . $_POST['address'] . '" and house_type=0', OBJECT);
if (!$res) {
$houseId = InsertDao::insert_tospur_house($params);
InsertDao::addMainImage($houseId,$data);
InsertDao::addRecommend($houseId,$data);
InsertDao::addRecConsultant($houseId,$data);
InsertDao::addHouseTag($_POST['mark'],$houseId);
}else{
return 506;
}
return 200;
}
}
\ No newline at end of file
......@@ -38,18 +38,13 @@ class feature
public static function add_feature_html()
{
$context = array();
$context['url'] = home_url();
$context['admin_url'] = admin_url();
Timber::render('add_feature.html', $context);
}
public static function feature_list_html()
{
wp_enqueue_style('bootstrapMinCss');
$context = array();
$context['view'] = plugins_url() . '/tospur/Admin/views';
$context['result'] = feature::search_feature();
Timber::render('feature_list.html', $context);
$context['url'] = home_url();
$context['admin_url'] = admin_url();
Timber::render('feature.html', $context);
}
}
......
<?php
require_once(PLUGIN_DIR . 'Dao/SearchDao.php');
require_once(PLUGIN_DIR . 'Dao/InsertDao.php');
require_once(PLUGIN_DIR . 'Tools/Image.php');
class RentHouse extends Tospur_House{
//二手房信息
public static function rentHouse_html(){
wp_enqueue_script('bootstrapjs');
wp_enqueue_style('bootstrapcss');
global $wpdb;
$type = $_POST["type"];
$context = array();
$context['siteUrl'] = get_site_url();
//获取新房信息,存入tospur_house表
$insert_tospur_house_array = array(
'name' => $_POST['housename'],
'house_number' =>$_POST['house_number'],
'rent'=>$_POST['rent'],
'buildproperty_id'=>$_POST['buildproperty_id'],
'covered_area' =>$_POST['covered_area'],
'floor' =>$_POST['floor'],
'faceto'=>$_POST['faceto'],
'decoration' => $_POST['decoration'],
'age'=>$_POST['age'],
'matching_facilities'=>$_POST['matching_facilities'],
'flat'=>$_POST['flat'],
'suite'=>$_POST["suite"],
'overview' => $_POST['overview'],
'city_id' => $_POST['baseCity'],
'district_id' => $_POST['baseAreaId'],
'plate_id' => $_POST["basePlateId"],
'address' => $_POST['address'],
'community_name'=>$_POST['community_name'],
'traffic' => $_POST['traffic'],
'periphery' => $_POST['periphery'],
'status' =>$_POST['status'],
'owner_name'=>$_POST['owner_name'],
'owner_phone'=>$_POST['owner_phone'],
"location" => $_POST["location"],
);
if($type==3){
$wpdb->query("START TRANSACTION");
if(isset($_POST['houseId'])){
$result = RentHouse::data_update($_POST['houseId'],$insert_tospur_house_array);
if($result != 202){
$wpdb->query("ROLLBACK");
print_r($result);;
echo "租房房源修改失败";
}else{
$wpdb->query("COMMIT");
echo "租房房源修改成功";
}
}else {
$result = RentHouse::rentHouseData_insert($insert_tospur_house_array);
if ($result != 200) {
$wpdb->query("ROLLBACK");
print_r($result);;
echo "租房房源新增失败";
} else {
$wpdb->query("COMMIT");
echo "租房房源新增成功";
}
}
exit;
}else if(isset($_GET['edit'])){
$context['houseId'] = $_GET['id'];
$context = array_merge($context,SearchDao::getDetailInfo($_GET['id']));
$context["district"] = SearchDao::searchCity($context['result']->city_id);
$context["plate"] = SearchDao::searchCity($context['result']->city_id,$context['result']->district_id);
$context["mark"] = SearchDao::searchHouseTag($_GET['id']);
}
$context['role'] = SecHandHouse::getCurrentRole();
$context["city"] = SearchDao::searchCity();
$context["buildProperty"] = SearchDao::searchBuildProperty();
$context["room"] = SearchDao::searchRoom();
$context["photoType"] = SearchDao::searchPhotoType();
$context["status"] = searchDao::searchStatusType(2);
Timber::render("rentHouse.html",$context);
}
public static function rentHouseData_insert($params)
{
global $wpdb;
//房源与类型以及面积信息
$data = $_POST["data"];
$params['user_id'] = get_current_user_id();
$params['creattime'] = date("Y-m-d H:i:s");
$params['house_type'] = 2;
$res = $wpdb->get_results('SELECT * FROM tospur_house WHERE address="' .$params['address'] . '" and owner_name="' .$params['owner_name'] . '" and owner_phone="'.$params['owner_phone'].'" and house_type=2', OBJECT);
if(!$res){
$houseId = InsertDao::insert_tospur_house($params);
InsertDao::addMainImage($houseId,$data);
InsertDao::addRecommend($houseId,$data);
InsertDao::addRecConsultant($houseId,$data);
InsertDao::addHouseTag($_POST['mark'],$houseId);
}else{
return 508;
}
return 200;
}
public static function data_update($houseId,$params){
global $wpdb;
$data = $_POST["data"];
$res = $wpdb->update(Config::TOSPUR_HOUSE_TABLE,$params,array("id" => $houseId));
$result = 202;
InsertDao::addMainImage($houseId,$data);
$exists_photo_ids = array();
if(isset($_POST['exists_photo'])){
foreach($_POST['exists_photo'] as $id => $item){
$wpdb->update(Config::TOSPUR_IMAGE_TABLE,array(
"image_type" => $item['type'],
),array("id" => $id));
$exists_photo_ids[] = $id;
}
}
$old_exists_photo_ids = explode(",",$_POST['exists_photo_ids']);
$delete_photo_ids = array();
foreach(array_diff($old_exists_photo_ids,$exists_photo_ids) as $key => $id){
$delete_photo_ids[] = $id;
}
$delete_photo_ids = implode(",",$delete_photo_ids);
$wpdb->query("delete from ".Config::A_HOUSE_IMAGE_TABLE." where house_id = {$houseId} and image_id in ({$delete_photo_ids});");
$wpdb->delete(Config::A_HOUSE_RECOMMEND_TABLE,array("house_id" => $houseId));
InsertDao::addRecommend($houseId,$data);
$wpdb->delete(Config::A_HOUSE_USER_TABLE,array("house_id" => $houseId));
InsertDao::addRecConsultant($houseId,$data);
InsertDao::addHouseTag($_POST['mark'],$houseId);
return $result;
}
}
<?php
require_once(PLUGIN_DIR . 'Dao/SearchDao.php');
require_once(PLUGIN_DIR . 'Dao/InsertDao.php');
require_once(PLUGIN_DIR . 'Tools/Image.php');
class RentHouse extends Tospur_House{
//二手房信息
public static function rentHouse_html(){
wp_enqueue_script('bootstrapjs');
wp_enqueue_script('publicjs');
wp_enqueue_script('validate');
wp_enqueue_style('bootstrapMinCss');
global $wpdb;
$type = $_POST["type"];
$context = array();
$context['siteUrl'] = get_site_url();
//获取新房信息,存入tospur_house表
$insert_tospur_house_array = array(
'name' => $_POST['housename'],
'house_number' =>$_POST['house_number'],
'rent'=>$_POST['rent'],
'buildproperty_id'=>$_POST['buildproperty_id'],
'covered_area' =>$_POST['covered_area'],
'floor' =>$_POST['floor'],
'faceto'=>$_POST['faceto'],
'decoration' => $_POST['decoration'],
'age'=>$_POST['age'],
'matching_facilities'=>$_POST['matching_facilities'],
'flat'=>$_POST['flat'],
'suite'=>$_POST["suite"],
'overview' => $_POST['overview'],
'city_id' => $_POST['baseCity'],
'district_id' => $_POST['baseAreaId'],
'plate_id' => $_POST["basePlateId"],
'address' => $_POST['address'],
'community_name'=>$_POST['community_name'],
'traffic' => $_POST['traffic'],
'periphery' => $_POST['periphery'],
'owner_name'=>$_POST['owner_name'],
'owner_phone'=>$_POST['owner_phone'],
"location" => $_POST["location"],
"totalFloor"=>$_POST["totalFloor"],
"useArea"=>$_POST["useArea"],
"street"=>$_POST["street"],
"propertyProof"=>$_POST["propertyProof"],
"roomNum"=>$_POST["roomNum"],
"livingRoom"=>$_POST["livingRoom"],
"bathRoom"=>$_POST["bathRoom"],
"kitchen"=>$_POST["kitchen"],
"balcony"=>$_POST["balcony"],
"propertyRight"=>$_POST["propertyRight"],
"structure"=>$_POST["structure"],
"key"=>$_POST["key"],
"garage"=>$_POST["garage"]
);
if($type==3){
$wpdb->query("START TRANSACTION");
if(isset($_POST['houseId'])){
$insert_tospur_house_array['status'] = 0;
$result = RentHouse::data_update($_POST['houseId'],$insert_tospur_house_array);
if($result != 202){
$wpdb->query("ROLLBACK");
print_r($result);;
echo "租房房源修改失败";
}else{
$wpdb->query("COMMIT");
echo "租房房源修改成功";
}
}else {
$insert_tospur_house_array['status'] = $_POST['status'];
$result = RentHouse::rentHouseData_insert($insert_tospur_house_array);
if ($result != 200) {
$wpdb->query("ROLLBACK");
print_r($result);
echo "租房房源新增失败";
} else {
$wpdb->query("COMMIT");
echo "租房房源新增成功";
}
}
exit;
}else if(isset($_GET['edit'])){
$context['houseId'] = $_GET['id'];
$context = array_merge($context,SearchDao::getDetailInfo($_GET['id']));
$context["district"] = SearchDao::searchCity($context['result']->city_id);
$context["plate"] = SearchDao::searchCity($context['result']->city_id,$context['result']->district_id);
$context["mark"] = SearchDao::searchHouseTag($_GET['id']);
$context["searchStatus"] = SearchDao::searchStatus($_GET['id'],2);
$context["rent"] = SearchDao::searchRent($_GET['id']);
}
$context['role'] = RentHouse::getCurrentRole();
$context["city"] = SearchDao::searchCity();
$context["buildProperty"] = SearchDao::searchBuildProperty();
$context["room"] = SearchDao::searchRoom();
$context["photoType"] = SearchDao::searchPhotoType();
$context["status"] = searchDao::searchStatusType(2);
for($i = 1981; $i<= 2020; $i++){
$context["age"][]=$i;
}
Timber::render("rentHouse.html",$context);
}
public static function rentHouseData_insert($params)
{
global $wpdb;
//房源与类型以及面积信息
$data = $_POST["data"];
$params['user_id'] = get_current_user_id();
$params['creattime'] = date("Y-m-d H:i:s");
$params['house_type'] = 2;
$res = $wpdb->get_results('SELECT * FROM tospur_house WHERE address="' .$params['address'] . '" and owner_name="' .$params['owner_name'] . '" and owner_phone="'.$params['owner_phone'].'" and house_type=2', OBJECT);
if(!$res){
$houseId = InsertDao::insert_tospur_house($params);
InsertDao::addMainImage($houseId,$data);
InsertDao::addRecommend($houseId,$data);
InsertDao::addRecConsultant($houseId,$data);
InsertDao::addHouseTag($_POST['mark'],$houseId);
}else{
return 508;
}
return 200;
}
public static function data_update($houseId,$params){
global $wpdb;
$data = $_POST["data"];
$res = $wpdb->update(Config::TOSPUR_HOUSE_TABLE,$params,array("id" => $houseId));
$result = 202;
InsertDao::addMainImage($houseId,$data);
$exists_photo_ids = array();
if(isset($_POST['exists_photo'])){
foreach($_POST['exists_photo'] as $id => $item){
$wpdb->update(Config::TOSPUR_IMAGE_TABLE,array(
"image_type" => $item['type'],
),array("id" => $id));
$exists_photo_ids[] = $id;
}
}
$old_exists_photo_ids = explode(",",$_POST['exists_photo_ids']);
$delete_photo_ids = array();
foreach(array_diff($old_exists_photo_ids,$exists_photo_ids) as $key => $id){
$delete_photo_ids[] = $id;
}
$delete_photo_ids = implode(",",$delete_photo_ids);
$wpdb->query("delete from ".Config::A_HOUSE_IMAGE_TABLE." where house_id = {$houseId} and image_id in ({$delete_photo_ids});");
$wpdb->delete(Config::A_HOUSE_RECOMMEND_TABLE,array("house_id" => $houseId));
InsertDao::addRecommend($houseId,$data);
$wpdb->delete(Config::A_HOUSE_USER_TABLE,array("house_id" => $houseId));
InsertDao::addRecConsultant($houseId,$data);
InsertDao::addHouseTag($_POST['mark'],$houseId);
return $result;
}
}
<?php
require_once(PLUGIN_DIR . 'Dao/SearchDao.php');
require_once(PLUGIN_DIR . 'Dao/InsertDao.php');
require_once(PLUGIN_DIR . 'Tools/Image.php');
class SecHandHouse extends Tospur_House{
//二手房信息
public static function secHandHouse_html(){
wp_enqueue_script('bootstrapjs');
wp_enqueue_style('bootstrapcss');
wp_enqueue_style('bootstrapMinCss');
global $wpdb;
$type = $_POST["type"];
$context = array();
$context['siteUrl'] = get_site_url();
$insert_tospur_house_array = array(
'name' => $_POST['housename'],
'house_number' =>$_POST['house_number'],
'total_price' =>$_POST['total_price'],
'average_price' => $_POST['average_price'],
'buildproperty_id'=>$_POST['buildproperty_id'],
'covered_area' =>$_POST['covered_area'],
'floor' =>$_POST['floor'],
'faceto'=>$_POST['faceto'],
'decoration' => $_POST['decoration'],
'age'=>$_POST['age'],
'flat'=>$_POST['flat'],
'suite'=>$_POST["suite"],
'overview' => $_POST['overview'],
'city_id' => $_POST['baseCity'],
'district_id' => $_POST['baseAreaId'],
'plate_id' => $_POST["basePlateId"],
'address' => $_POST['address'],
'community_name'=>$_POST['community_name'],
'traffic' => $_POST['traffic'],
'periphery' => $_POST['periphery'],
'status' =>$_POST['status'],
'owner_name'=>$_POST['owner_name'],
'owner_phone'=>$_POST['owner_phone'],
"location" => $_POST["location"],
);
if($type==2){
$wpdb->query("START TRANSACTION");
if(isset($_POST['houseId'])){
$result = SecHandHouse::data_update($_POST['houseId'],$insert_tospur_house_array);
if($result != 201){
$wpdb->query("ROLLBACK");
print_r( $result);;
echo "二手房房源修改失败";
}else{
$wpdb->query("COMMIT");
echo "二手房房源修改成功";
}
}else {
$result = SecHandHouse::secHouseData_insert($insert_tospur_house_array);
if ($result != 200) {
$wpdb->query("ROLLBACK");
print_r( $result);;
echo "二手房房源新增失败";
} else {
$wpdb->query("COMMIT");
echo "二手房房源新增成功";
}
}
exit;
}else if(isset($_GET['edit'])){
$context['houseId'] = $_GET['id'];
$context = array_merge($context,SearchDao::getDetailInfo($_GET['id']));
$context["district"] = SearchDao::searchCity($context['result']->city_id);
$context["plate"] = SearchDao::searchCity($context['result']->city_id,$context['result']->district_id);
$context["mark"] = SearchDao::searchHouseTag($_GET['id']);
$context["featureOld"] = SearchDao::searchFeatureByHouse($_GET['id']);
}
$context['role'] = SecHandHouse::getCurrentRole();
$context["city"] = SearchDao::searchCity();
$context["buildProperty"] = SearchDao::searchBuildProperty();
$context["room"] = SearchDao::searchRoom();
$context["photoType"] = SearchDao::searchPhotoType();
$context["status"] = searchDao::searchStatusType(2);
$context["feature"] = searchDao::searchFeature();
Timber::render("secHandHouse.html",$context);
}
public static function secHouseData_insert($params)
{
global $wpdb;
//房源与类型以及面积信息
$data = $_POST["data"];
$params['user_id'] = get_current_user_id();
$params['creattime'] = date("Y-m-d H:i:s");
$params['house_type'] = 1;
//获取新房信息,存入tospur_house表
$res = $wpdb->get_results('SELECT * FROM tospur_house WHERE address="' .$params['address'] . '" and owner_name="' .$params['owner_name'] . '" and owner_phone="'.$params['owner_phone'].'" and house_type=1', OBJECT);
if(!$res){
$houseId = InsertDao::insert_tospur_house($params);
InsertDao::addMainImage($houseId,$data);
InsertDao::addRecommend($houseId,$data);
InsertDao::addRecConsultant($houseId,$data);
if(isset($_POST['mark'])&&$_POST['mark']!=""){
InsertDao::addHouseTag($_POST['mark'],$houseId);
}
InsertDao::addHouseFeature($houseId,$data);
}else{
return 507;
}
return 200;
}
public static function data_update($houseId,$params){
global $wpdb;
$data = $_POST["data"];
$res = $wpdb->update(Config::TOSPUR_HOUSE_TABLE,$params,array("id" => $houseId));
$result = 201;
InsertDao::addMainImage($houseId,$data);
$exists_photo_ids = array();
if(isset($_POST['exists_photo'])){
foreach($_POST['exists_photo'] as $id => $item){
$wpdb->update(Config::TOSPUR_IMAGE_TABLE,array(
"image_type" => $item['type'],
),array("id" => $id));
$exists_photo_ids[] = $id;
}
}
$old_exists_photo_ids = explode(",",$_POST['exists_photo_ids']);
$delete_photo_ids = array();
foreach(array_diff($old_exists_photo_ids,$exists_photo_ids) as $key => $id){
$delete_photo_ids[] = $id;
}
$delete_photo_ids = implode(",",$delete_photo_ids);
$wpdb->query("delete from ".Config::A_HOUSE_IMAGE_TABLE." where house_id = {$houseId} and image_id in ({$delete_photo_ids});");
$wpdb->delete(Config::A_HOUSE_RECOMMEND_TABLE,array("house_id" => $houseId));
InsertDao::addRecommend($houseId,$data);
$wpdb->delete(Config::A_HOUSE_USER_TABLE,array("house_id" => $houseId));
InsertDao::addRecConsultant($houseId,$data);
$wpdb->query(
$wpdb->prepare(
"DELETE FROM a_house_tag
WHERE tag_id in(select tag_id from (select tag_id,tt.type from a_house_tag as aht
left JOIN tospur_tag tt on aht.tag_id = tt.id) as a
where house_id = %d and a.type = 1);", $houseId)
);
InsertDao::addHouseFeature($houseId,$data);
if(isset($_POST['mark'])&&$_POST['mark']!="") {
InsertDao::addHouseTag($_POST['mark'],$houseId);
}
return $result;
}
}
<?php
require_once(PLUGIN_DIR . 'Dao/SearchDao.php');
require_once(PLUGIN_DIR . 'Dao/InsertDao.php');
require_once(PLUGIN_DIR . 'Tools/Image.php');
class SecHandHouse extends Tospur_House{
//二手房信息
public static function secHandHouse_html(){
wp_enqueue_script('bootstrapjs');
wp_enqueue_script('publicjs');
wp_enqueue_script('validate');
wp_enqueue_style('bootstrapMinCss');
global $wpdb;
$type = $_POST["type"];
$context = array();
$context['siteUrl'] = get_site_url();
$insert_tospur_house_array = array(
'name' => $_POST['housename'],
'house_number' =>$_POST['house_number'],
'total_price' =>$_POST['total_price'],
'average_price' => $_POST['average_price'],
'buildproperty_id'=>$_POST['buildproperty_id'],
'covered_area' =>$_POST['covered_area'],
'floor' =>$_POST['floor'],
'faceto'=>$_POST['faceto'],
'decoration' => $_POST['decoration'],
'age'=>$_POST['age'],
'flat'=>$_POST['flat'],
'suite'=>$_POST["suite"],
'overview' => $_POST['overview'],
'city_id' => $_POST['baseCity'],
'district_id' => $_POST['baseAreaId'],
'plate_id' => $_POST["basePlateId"],
'address' => $_POST['address'],
'community_name'=>$_POST['community_name'],
'traffic' => $_POST['traffic'],
'periphery' => $_POST['periphery'],
'owner_name'=>$_POST['owner_name'],
'owner_phone'=>$_POST['owner_phone'],
"location" => $_POST["location"],
"totalFloor"=>$_POST["totalFloor"],
"useArea"=>$_POST["useArea"],
"street"=>$_POST["street"],
"propertyProof"=>$_POST["propertyProof"],
"roomNum"=>$_POST["roomNum"],
"livingRoom"=>$_POST["livingRoom"],
"bathRoom"=>$_POST["bathRoom"],
"kitchen"=>$_POST["kitchen"],
"balcony"=>$_POST["balcony"],
"propertyRight"=>$_POST["propertyRight"],
"structure"=>$_POST["structure"],
"key"=>$_POST["key"],
"matching_facilities"=>$_POST["matching_facilities"],
"garage"=>$_POST["garage"]
);
if($type==2){
$wpdb->query("START TRANSACTION");
if(isset($_POST['houseId'])){
$insert_tospur_house_array['status'] = 0;
$result = SecHandHouse::data_update($_POST['houseId'],$insert_tospur_house_array);
if($result != 201){
$wpdb->query("ROLLBACK");
print_r( $result);;
echo "二手房房源修改失败";
}else{
$wpdb->query("COMMIT");
echo "二手房房源修改成功";
}
}else {
$insert_tospur_house_array['status'] = $_POST['status'];
$result = SecHandHouse::secHouseData_insert($insert_tospur_house_array);
if ($result != 200) {
$wpdb->query("ROLLBACK");
print_r( $result);;
echo "二手房房源新增失败";
} else {
$wpdb->query("COMMIT");
echo "二手房房源新增成功";
}
}
exit;
}else if(isset($_GET['edit'])){
$context['houseId'] = $_GET['id'];
$context = array_merge($context,SearchDao::getDetailInfo($_GET['id']));
$context["district"] = SearchDao::searchCity($context['result']->city_id);
$context["plate"] = SearchDao::searchCity($context['result']->city_id,$context['result']->district_id);
$context["mark"] = SearchDao::searchHouseTag($_GET['id']);
$context['featureOld'] = SearchDao::searchFeatureOld($_GET['id']);
$context["searchStatus"] = SearchDao::searchStatus($_GET['id'],2);
}
$context['role'] = SecHandHouse::getCurrentRole();
$context["city"] = SearchDao::searchCity();
$context["buildProperty"] = SearchDao::searchBuildProperty();
$context["room"] = SearchDao::searchRoom();
$context["photoType"] = SearchDao::searchPhotoType();
$context["status"] = searchDao::searchStatusType(2);
$context["feature"] = searchDao::searchFeature();
for($i = 1981; $i<= 2020; $i++){
$context["age"][]=$i;
}
Timber::render("secHandHouse.html",$context);
}
public static function secHouseData_insert($params)
{
global $wpdb;
//房源与类型以及面积信息
$data = $_POST["data"];
$params['user_id'] = get_current_user_id();
$params['creattime'] = date("Y-m-d H:i:s");
$params['house_type'] = 1;
//获取新房信息,存入tospur_house表
$res = $wpdb->get_results('SELECT * FROM tospur_house WHERE address="' .$params['address'] . '" and owner_name="' .$params['owner_name'] . '" and owner_phone="'.$params['owner_phone'].'" and house_type=1', OBJECT);
if(!$res){
$houseId = InsertDao::insert_tospur_house($params);
InsertDao::addMainImage($houseId,$data);
InsertDao::addRecommend($houseId,$data);
InsertDao::addRecConsultant($houseId,$data);
if(isset($_POST['mark'])&&$_POST['mark']!=""){
InsertDao::addHouseTag($_POST['mark'],$houseId);
}
InsertDao::addHouseFeature($houseId,$data);
}else{
return 507;
}
return 200;
}
public static function data_update($houseId,$params){
global $wpdb;
$data = $_POST["data"];
$res = $wpdb->update(Config::TOSPUR_HOUSE_TABLE,$params,array("id" => $houseId));
$result = 201;
InsertDao::addMainImage($houseId,$data);
$exists_photo_ids = array();
if(isset($_POST['exists_photo'])){
foreach($_POST['exists_photo'] as $id => $item){
$wpdb->update(Config::TOSPUR_IMAGE_TABLE,array(
"image_type" => $item['type'],
),array("id" => $id));
$exists_photo_ids[] = $id;
}
}
$old_exists_photo_ids = explode(",",$_POST['exists_photo_ids']);
$delete_photo_ids = array();
foreach(array_diff($old_exists_photo_ids,$exists_photo_ids) as $key => $id){
$delete_photo_ids[] = $id;
}
$delete_photo_ids = implode(",",$delete_photo_ids);
$wpdb->query("delete from ".Config::A_HOUSE_IMAGE_TABLE." where house_id = {$houseId} and image_id in ({$delete_photo_ids});");
$wpdb->delete(Config::A_HOUSE_RECOMMEND_TABLE,array("house_id" => $houseId));
InsertDao::addRecommend($houseId,$data);
$wpdb->delete(Config::A_HOUSE_USER_TABLE,array("house_id" => $houseId));
InsertDao::addRecConsultant($houseId,$data);
$wpdb->query(
$wpdb->prepare(
"DELETE FROM a_house_tag
WHERE tag_id in(select tag_id from (select tag_id,tt.type from a_house_tag as aht
left JOIN tospur_tag tt on aht.tag_id = tt.id) as a
where house_id = %d and a.type = 1);", $houseId)
);
InsertDao::addHouseFeature($houseId,$data);
if(isset($_POST['mark'])&&$_POST['mark']!="") {
InsertDao::addHouseTag($_POST['mark'],$houseId);
}
return $result;
}
}
<h2>添加特色</h2>
<label for="feature">特色:</label>
<input id="feature" type="text">
<input type="submit" id="submit" class="button">
<script>
var admin_url = '{{ admin_url }}';
(function ($) {
$(document).ready(function () {
$('#submit').click(function () {
var name = $('#feature').val();
if (name.trim() != '') {
$.ajax({
type: 'POST',
url: '{{ url }}/wp-admin/admin-ajax.php/',
data: 'action=add_feature&name=' + name,
success: function (data) {
switch (data.code) {
case 2000:
window.location.href = admin_url + 'admin.php?page=feature_list';
break;
case 2001:
alert('不能重复添加特色');
break;
default:
break;
}
}
});
} else {
alert('请输入特色');
}
});
});
})(jQuery);
</script>
\ No newline at end of file
......@@ -2,7 +2,24 @@
<label for="feature">特色:</label>
<input id="feature" type="text">
<input type="submit" id="submit" class="button">
<h2>特色列表</h2>
<table class="table">
<thead>
</thead>
<tbody>
{% for item in result %}
{% if loop.index0%4 == 0%}
<tr>
{% endif %}
<td>{{ item.name }}</td>
{% if loop.index0%4 == 3%}
</tr>
{% endif %}
{% endfor %}
</tbody>
</table>
<script>
var admin_url = '{{ admin_url }}';
(function ($) {
$(document).ready(function () {
$('#submit').click(function () {
......@@ -13,10 +30,15 @@
url: '{{ url }}/wp-admin/admin-ajax.php/',
data: 'action=add_feature&name=' + name,
success: function (data) {
if (data) {
alert('添加成功');
} else {
alert('添加失败');
switch (data.code) {
case 2000:
window.location.href = admin_url + 'admin.php?page=add_feature';
break;
case 2001:
alert('不能重复添加特色');
break;
default:
break;
}
}
});
......
<link rel="stylesheet" type="text/css" href="{{ view }}/css/bootstrap.min.css">
<h2>特色列表</h2>
<table class="table">
<thead>
<tr>
<th style="">
<div class="th-inner">ID</div>
<div class="fht-cell"></div>
</th>
<th style="">
<div class="th-inner">名称</div>
<div class="fht-cell"></div>
</th>
</tr>
</thead>
<tbody>
{% for item in result %}
<tr>
<td>{{ item.id }}</td>
<td>{{ item.name }}</td>
</tr>
{% endfor %}
</tbody>
</table>
\ No newline at end of file
(function($){
function searchConsultant(consulCityId,consultantName){
$.ajax({
type: "GET",
url: "/tospur/wp-admin/admin-ajax.php",
data: "action=searchConsultant&consulCityId="+consulCityId+"&consultantName="+consultantName,
success:function(json){
for(var i = 0; i <=json.length-1; i++){
var name = json[i]["consultantName"];
var imgUrl = json[i]["imageUrl"];
var img = $("<img>").attr({"src":imgUrl,"height":100,"width":100,"style":"margin-right:50px"});
var li = $("<li>").attr("id",json[i]["id"]).append(img).append(name).addClass("consultantImg");
$("#consultantList").append(li);
}
}
});
}
})(jQuery);
\ No newline at end of file
<!DOCTYPE HTML>
<html>
<head>
{% set title = houseId?"修改新房房源":"添加新房房源" %}
<meta charset="utf-8">
<title>{{title}}</title>
</head>
<body>
<h2 class="title">{{title}}</h2>
<form action="" method="POST" enctype="multipart/form-data" id="newHouse">
<div class="row">
<div class="col-md-11">
<div class="row">
<div class="col-md-8">
<table class="form-table">
<tbody>
<tr>
<th><label for="housename">楼盘名</label></th>
<td> <input name="housename" id="housename" type="text" value="{{result.name}}" class="form-control" style="width: 150px;"></td>
</tr>
<tr>
<th><label for="mark">标签:</label></th>
<td> <input name="mark" id="mark" type="text" value="{{mark}}" class="form-control"></td>
</tr>
<tr>
<th><label for="community_name">小区名</label></th>
<td> <input name="community_name" id="community_name" type="text" value="{{result.community_name}}" style="width: 150px;" class="form-control" ></td>
</tr>
<tr>
<th><label for="address">地址</label></th>
<td> <input name="address" type="text" value="{{result.address}}" class="form-control"></td>
</tr>
<tr>
<th><label for="average_price">均价</label></th>
<td> <input name="average_price" id="average_price" type="text" value="{{result.average_price}}" class="form-control" style="width: 90px;"></td>
</tr>
<tr>
<th><label for="latest_news">最新动态</label></th>
<td><textarea name="latest_news" rows="4" cols="40" class="form-control" style="width: 400px;">{{result.latest_news}}</textarea></td>
</tr>
</tbody>
</table>
</div>
</div>
<h2 class="title">位置及周边</h2>
<div class="row">
<div class="col-md-8">
<table class="form-table">
<tbody>
<tr>
<th><label for="from">所属地区</label></th>
<td>
<select id="baseCity" name="baseCity">
<option value="-1"> 城市</option>
{% for item in city %}
<option {{ item.id == result.city_id?"selected":"" }} value="{{ item.id }}">{{ item.value }}</option>
{% endfor %}
</select>
<select id="baseAreaId" name="baseAreaId">
<option value = "-1">区域</option>
{% if district %}
{% for item in district %}
<option {{ item.id == result.district_id?"selected":"" }} value="{{ item.id }}">{{ item.value }}</option>
{% endfor %}
{% endif %}
</select>
<select id="basePlateId" name="basePlateId">
<option value = "-1">板块</option>
{% if district %}
{% for item in plate %}
<option {{ item.id == result.plate_id?"selected":"" }} value="{{ item.id }}">{{ item.value }}</option>
{% endfor %}
{% endif %}
</select>
</td>
</tr>
<tr>
<th><label for="location">地域坐标</label></th>
<td> <input name="location" id="location" type="text" value="{{result.location}}" class="form-control"></td>
</tr>
<tr>
<th><label for="traffic">交通线路</label></th>
<td> <input name="traffic" type="text" value="{{result.traffic}}" class="form-control" style="width: 300px;"></td>
</tr>
<tr>
<th><label for="periphery">周边配套</label></th>
<td> <input name="periphery" type="text" value="{{result.periphery}}" class="form-control" style="width: 300px;"></td>
</tr>
</tbody>
</table>
</div>
</div>
<h2 class="title">基本信息</h2>
<div class="row">
<div class="col-md-8">
<table class="form-table">
<tbody>
<tr>
<th><label for="developers">建筑类型</label></th>
<td>
<select id="baseRoom" name="baseRoom">
{% for item in room %}
<option {{ item.id == result.room_id?"selected":"" }} value="{{ item.id }}">{{ item.value }}</option>
{% endfor %}
</select>
</td>
</tr>
<tr>
<th><label for="developers">开发商</label></th>
<td> <input name="developers" type="text" value="{{result.developer}}" class="form-control" style="width: 150px;"></td>
</tr>
<tr>
<th><label for="check_in_time">入住时间</label></th>
<td> <input name="check_in_time" id="checkin" type="text" value="{{result.check_in_time}}" class="form-control" style="width: 150px;"></td>
</tr>
<tr>
<th><label for="property_age">产权年限</label></th>
<td> <input name="property_age" type="text" value="{{result.property_age}}" class="form-control" style="width: 90px;"></td>
</tr>
<tr>
<th><label for="decoration">装修状况</label></th>
<td> <input name="decoration" type="text" value="{{result.decoration}}" class="form-control"style="width: 90px;"></td>
</tr>
<tr>
<th><label for="covered_area">建筑面积</label></th>
<td> <input name="covered_area" type="text" value="{{result.covered_area}}" class="form-control" style="width: 90px;"></td>
</tr>
<tr>
<th><label for="volume_rate">容积率</label></th>
<td> <input name="volume_rate" type="text" value="{{result.volume_rate}}" class="form-control" style="width: 50px;"></td>
</tr>
<tr>
<th><label for="greening_rate">绿化率</label></th>
<td> <input name="greening_rate" type="text" value="{{result.greening_rate}}" class="form-control" style="width: 50px;"></td>
</tr>
<tr>
<th><label for="households">规划户数</label></th>
<td> <input name="households" type="text" value="{{result.households}}" class="form-control" style="width: 50px;"></td>
</tr>
<tr>
<th><label for="parking_spaces">车位数</label></th>
<td> <input name="parking_spaces" type="text" value="{{result.parking_spaces}}" class="form-control" style="width: 50px;"></td>
</tr>
<tr>
<th><label for="property_management">物业公司</label></th>
<td> <input name="property_management" type="text" value="{{result.property_management}}" class="form-control" style="width: 150px;"></td>
</tr>
<tr>
<th><label for="property_money">物业费</label></th>
<td> <input name="property_money" type="text" value="{{result.property_money}}" class="form-control" style="width: 50px;"></td>
</tr>
<tr>
<th><label for="overview">楼盘概述</label></th>
<td> <textarea name="overview" rows="4" cols="40" class="form-control" style="width: 400px;">{{result.overview}}</textarea></td>
</tr>
</tbody>
</table>
</div>
</div>
<h2 class="title">关联信息</h2>
<div class="row">
<div class="col-md-12">
<table class="form-table">
<tbody>
<tr>
<th><label for="mainHouse">主力户型</label></th>
<td>
<div id="preview">
{% set exists_ids = "" %}
{% for item in mainImage %}
{% if exists_ids != "" %}
{% set exists_ids = exists_ids~"," %}
{% endif %}
{% set exists_ids = exists_ids~item.id %}
<div>
<img src="{{siteUrl}}{{item.path}}" heghit="100" width="100"><br />
<select name="exists[{{item.id}}][buildProperty]">
{% for i in buildProperty %}
<option {{ i.id == item.buildproperty_id?"selected":"" }} value="{{i.id}}">{{i.value}}</option>
{% endfor %}
</select>
<input type="text" placeholder="面积" name="exists[{{item.id}}][housearea]" class="form-control" value="{{item.area}}">
<input type="button" value="取消" class="cancel existsCancel">
</div>
{% endfor %}
<input type="hidden" name="exists_ids" value="{{exists_ids}}" >
<input type="file" name="files[0]" property="0" class = "files"multiple class="browser button button-hero">
<P></P>
</div>
</td>
</tr>
<tr>
<th><label>房源相册</label></th>
<td>
<div id="picList">
{% set exists_photo_ids = "" %}
{% for item in images %}
{% if exists_photo_ids != "" %}
{% set exists_photo_ids = exists_photo_ids~"," %}
{% endif %}
{% set exists_photo_ids = exists_photo_ids~item.image_id %}
<p>
<input type="radio" name="frontCover" value="{{item.image_id}}" {{ result.frontCover_id == item.image_id?"checked":"" }} />
<select name="exists_photo[{{ item.image_id }}][type]">
{% for i in photoType %}
<option {{ i.id == item.image_type?"selected":"" }} value="{{ i.id }}">{{ i.value }}</option>
{% endfor %}
</select>
<img src="{{siteUrl}}{{item.path}}" heghit="100" width="100">
<input type="button" value="取消" class="cancel existsCancel">
</p>
{% endfor %}
<input type="hidden" name="exists_photo_ids" value="{{exists_photo_ids}}" >
</div><br />
<button type="button" id="housePicture" class="button action" data-toggle="modal">
新增
</button>
</td>
</tr>
<tr>
<th><label for="traffic">推荐房源</label></th>
<td>
<div id="houseImg">
{% for item in recommends %}
<p>
<img src="{{siteUrl}}{{item.path}}" height="100" width="100">
<input type="button" value="删除" class="imgCancel existsCancel">
<input type="hidden" name="data[recommend][]" value="{{item.id}}">
</p>
{% endfor %}
</div><br />
<button type="button" class="button action" data-toggle="modal" data-target="#myModal" id="recHouseBt">
添加房源
</button>
</td>
</tr>
<tr>
<th><label for="periphery">置业顾问</label></th>
<td>
<div id="consultantImg">
{% for item in consultant %}
<p>
<span>{{item.name}}</span>
<input type="button" value="删除" class="consultantCancel existsCancel">
<input type="hidden" name="data[recConsultant][]" value="{{item.id}}">
</p>
{% endfor %}
</div><br />
<button type="button" class="button action" data-toggle="modal" data-target="#myConsultant" id="recConsultantBt">
选择置业顾问
</button>
</td>
</tr>
{% if role == 'administrator' %}
<tr>
<th><label for="from">状态</label></th>
<td>
<select id="status" name="status">
{% for item in status %}
<option value={{item.id}}>{{item.value}}</option>
{% endfor %}
</select>
</td>
</tr>
{% endif %}
</tbody>
</table>
</div>
</div>
<input type="text" name="type" value="1" hidden="hidden">
{% if houseId %}
<input type="text" name="houseId" value="{{houseId}}" hidden="hidden">
{% endif %}
</div>
<div class = "col-md-1">
<input type="submit" id="submit" class="button action" style="position: fixed;">
</div>
</div>
</form>
<!-- Modal -->
<!-- 新增房源弹出层 -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-body" style="height: 300px;overflow: auto;">
<select id="cityId">
</select>
<select id="areaId">
<option value = "-1">区域</option>
</select>
<select id="plateId">
<option value = "-1">板块</option>
</select>
<select id="price">
<option value = "-1">价格</option>
</select>
<select id="buildProperty">
<option value = "-1">房型</option>
{% for item in buildProperty %}
<option value="{{ item.id }}">{{ item.value }}</option>
{% endfor %}
</select>
<select id="room">
<option value = "-1">类型</option>
{% for item in room %}
<option value="{{ item.id }}">{{ item.value }}</option>
{% endfor %}
</select>
<select id="acreage">
<option value = "-1">面积</option>
</select>
<input type="text" placeholder="请出入楼盘名/地段名搜索" id="searchtext">
<button type="button" class="button action" id="search">搜索</button>
<ul id="houseList">
</ul>
</div>
</div>
</div>
</div>
<!-- 置业顾问弹出层 -->
<div class="modal fade" id="myConsultant" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-body" style="height: 300px;overflow: auto;">
<select id="consultCity">
</select>
<input type="text" placeholder="请出入置业顾问姓名搜索" id="consultantName" class="form-control">
<button type="button" class="button action" id="searchConsult">搜索</button>
<ul id="consultantList">
</ul>
</div>
</div>
</div>
</div>
<script>
(function($){
$(document).ready(function(){
var titleFlag = 0;
//主力房源中选择图片file的下标
var i = 0;
//入住时间选择
$("#checkin").datepicker({
dateFormat: "yy-mm-dd"
});
//主力房源选择文件
$("form").on("change",".files",function(){
readURL(this,1);
$(this).hide();
});
//主力房源中图片的删除功能
$("form").on("click",".cancel",function(){
$buttonid = $(this).attr("property");
$("[property = "+$buttonid+"]").remove();
$("form input[type='file']:last-child").show();
});
//基本信息的联动AJAX
$("#baseCity").change(function(){
var cityId = $("#baseCity").val();
var baserArea = $("#baseAreaId");
$('#baseAreaId').find('option:not(:first-child)').remove();
$('#basePlateId').find('option:not(:first-child)').remove();
//城市联动区域
$.ajax({
type: "GET",
url: "/tospur/wp-admin/admin-ajax.php",
data: "action=serachCity&cityId="+cityId,
success:function(json){
addOption(json,baserArea);
}
});
});
//区域联动板块
$("#baseAreaId").change(function(){
var basePlate = $("#basePlateId");
var areaId = $("#baseAreaId").val();
var cityId = $("#baseCity").val();
$('#basePlateId').find('option:not(:first-child)').remove();
$.ajax({
type: "GET",
url: "/tospur/wp-admin/admin-ajax.php",
data: "action=serachCity&cityId="+cityId+"&districtId="+areaId,
success:function(json){
addOption(json,basePlate);
}
});
});
//根据上方选择的城市,选择推荐房源的默认城市
$("#recHouseBt").click(function(){
$('#cityId').find('option').remove();
$('#areaId').find('option:not(:first-child)').remove();
$('#plateId').find('option:not(:first-child)').remove();
$('#price').find('option:not(:first-child)').remove();
$('#acreage').find('option:not(:first-child)').remove();
$("#houseList").find("li").remove();
var acreage =$("#acreage");
var price = $("#price");
var cityId = $("#baseCity").val();
var cityName = $("#baseCity").find("option:selected").text();
var option = $("<option>").attr("value",cityId).append(cityName);
$("#cityId").append(option);
if(cityId != -1){
var area = $("#areaId");
$.ajax({
type: "GET",
url: "/tospur/wp-admin/admin-ajax.php",
data: "action=serachCity&cityId="+cityId,
success:function(json){
addOption(json,area);
}
});
//城市联动房子面积
$.ajax({
type: "GET",
url: "/tospur/wp-admin/admin-ajax.php",
data: "action=searchArea&cityId="+cityId,
success:function(json){
addOption(json,acreage);
}
});
//城市联动房子价格
$.ajax({
type: "GET",
url: "/tospur/wp-admin/admin-ajax.php",
data: "action=searchUnitPriceRange&cityId="+cityId,
success:function(json){
addOption(json,price);
}
});
addList(0);
}
});
//区域联动板块
$("#areaId").change(function(){
var areaId = $("#areaId").val();
var cityId = $("#cityId").val();
var plate = $("#plateId");
$("#houseList").find("li").remove();
$('#plateId').find('option:not(:first-child)').remove();
$.ajax({
type: "GET",
url: "/tospur/wp-admin/admin-ajax.php",
data: "action=serachCity&cityId="+cityId+"&districtId="+areaId,
success:function(json){
addOption(json,plate);
}
});
});
//推荐房源下显示图片信息以及房名
$("#areaId,#plateId,#buildProperty,#room,#acreage,#price").change(function(){
addList(0);
});
//添加房源中搜索框的搜索
$("#search").click(function(){
$searchtext = $("#searchtext").val();
$("#houseList").find("li").remove();
$.ajax({
type: "post",
url: "/tospur/wp-admin/admin-ajax.php",
data: "action=searchHouse&searchText="+$searchtext,
success:function(json){
var result = json.result;
for(var i = 0; i < result.length; i++){
var name = result[i]["name"];
var id = result[i]['id'];
var imgUrl = json.images[id];
var img = $("<img>").attr({"src":imgUrl,"height":100,"width":100});
var li = $("<li>").addClass("addImg").append(img).append(name);
$("#houseList").append(li);
}
}
});
})
//根据上方选择的城市,选择推荐置业顾问的默认城市
$("#recConsultantBt").click(function(){
$('#consultCity').find('option').remove();
$("#consultantList").find("li").remove();
var consulCityId = $("#baseCity").val();
var consultantName =$("#consultantName").val();
var cityName = $("#baseCity").find("option:selected").text();
var option = $("<option>").attr("value",consulCityId).append(cityName);
$("#consultCity").append(option);
$.ajax({
type: "GET",
url: "/tospur/wp-admin/admin-ajax.php",
data: "action=searchConsultant&consulCityId="+consulCityId+"&consultantName="+consultantName,
success:function(json){
for(var i = 0; i <=json.length-1; i++){
var name = json[i]["consultantName"];
var imgUrl = json[i]["imageUrl"];
var img = $("<img>").attr({"src":imgUrl,"height":100,"width":100});
var li = $("<li>").attr("id",json[i]["id"]).append(img).append(name).addClass("consultantImg");
$("#consultantList").append(li);
}
}
});
});
//添加置业顾问弹出层中搜索框的搜索内容
$("#searchConsult").click(function(){
var consulCityId = $("#consultCity").val();
var consultantName =$("#consultantName").val();
$("#consultantList").find("li").remove();
$.ajax({
type: "GET",
url: "/tospur/wp-admin/admin-ajax.php",
data: "action=searchConsultant&consulCityId="+consulCityId+"&consultantName="+consultantName,
success:function(json){
for(var i = 0; i <=json.length-1; i++){
var name = json[i]["consultantName"];
var imgUrl = json[i]["imageUrl"];
var img = $("<img>").attr({"src":imgUrl,"height":100,"width":100});
var li = $("<li>").append(img).append(name).addClass("consultantImg");
$("#consultantList").append(li);
}
}
});
})
//点击添加房源中显示的列表,在界面中显示
$("#houseList").on("click",".addImg",function(){
var recommendHouse = $("<input>").attr({"type":"hidden","name":"data[recommend][]","value": $(this).attr("id")});
var url = $(this).find("img").attr("src");
var img = $("<img>").attr({"src":url,"height":100,"width":100});
var cancel = $("<input>").attr({"type":"button","value":"删除"}).addClass("button action imgCancel");
var p = $("<p>").append(img).append(cancel).append(recommendHouse);
$("#houseImg").append(p);
controlCommand();
});
//添加置业顾问
$("#consultantList").on("click",".consultantImg",function(){
var recommendConsultant = $("<input>").attr({"type":"hidden","name":"data[recConsultant][]","value": $(this).attr("id")});
var cancel = $("<input>").attr({"type":"button","value":"删除"}).addClass("button action consultantCancel");
var font = $("<font>").append( $(this).text());
var p = $("<p>").append(font).append(cancel).append(recommendConsultant);
$("#consultantImg").append(p);
});
//新增房源相册
$("#housePicture").click(function(){
var checkBox = $("<input>").attr({"type":"radio","name":"frontCover","value":i});
var picDelet = $("<input>").attr({"type":"button","value":"删除"}).addClass("button action picDelet");
var file = $("<input>").attr({"type":"file","name":"files["+i+"]"}).addClass("picFiles");
var select = $("<select>").attr("name","data["+i+"][type]");
var checkTd = $("<th>").append(checkBox);
var picDeletTd = $("<td>").append(picDelet);
var selectTd = $("<th>").append(select);
var fileTd = $("<th>").append(file);
{% for item in photoType %}
select.append($("<option>").attr("value",{{item.id}}).append('{{item.value}}'));
{% endfor%}
var p = $("<p>").append(checkTd).append(selectTd).append(fileTd).append(picDeletTd);
var fontA = $("<font>").append("设为封面");
var fontB = $("<font>").append("类型");
var fontC = $("<font>").append("相册");
var tdA = $("<th>").append(fontA);
var tdB = $("<th>").append(fontB);
var tdC = $("<th>").append(fontC);
var titleP = $("<p>").append(tdA).append(tdB).append(tdC);
$("#picList").append(p);
if( titleFlag== 0){
$("#picList").before(titleP);
titleFlag = 1
}
i++
});
//房源相册
$("#picList").on("change",".picFiles",function(){
readURL(this,2);
$(this).hide();
});
//删除房源相册、推荐房源、推荐置业顾问
$("#houseImg,#consultantImg,#picList").on("click",".imgCancel,.consultantCancel,.picDelet",function(){
$(this).parents("p").remove();
});
$("#preview,#picList,#houseImg,#consultantImg").on("click",".existsCancel",function(){
$(this).parent().remove();
});
$('#newHouse').validate({
onkeyup: false,
onfocusout: false,
rules: {
housename:'required',
mark:'required',
community_name:'required',
address:'required',
average_price:'required',
latest_news:'required'
},
messages: {
housename:'请输入楼盘名称',
mark:'请输入标签',
community_name:'请输入小区名称',
address:'请输入地址',
average_price:'请输入均价',
latest_news:'请输入最新动态'
},
errorLabelContainer: "#notice",
errorElement: 'span',
submitHandler: function (form) {
form.submit();
}
});
//file上传之前,显示图片的方法
function readURL(input,type) {
if(type == 1){
if (input.files && input.files[0]){
var reader = new FileReader();
reader.onload = function (e) {
var img = $("<img>").attr({"id":"target","src":e.target.result,"heghit":100,"width":100});
var button = $("<input>").attr({"type":"button","value":"取消","property":+i,"id":+i}).addClass("button action cancel");
var type = $("<input>").attr({"type":"hidden","name":"data["+i+"][type]","value":4,"property":+i});
var file = $("<input>").attr({"type":"file","name":"files["+(i+1)+"]","property":+(i+1)}).addClass("files");
var select = $("<select>").attr({"name":"data["+i+"][buildProperty]"});
{% for item in buildProperty %}{{item.id}}
select.append($("<option>").attr("value",{{item.id}}).append('{{item.value}}'));
{% endfor%}
var areatext = $("<input>").attr({"type":"text","placeholder":"面积","name":"data["+i+"][housearea]"}).addClass("form-control");
var div = $("<div>").append(select).append(areatext).append(button).append(type);
var span = $("<span>").attr({"property":+i}).append(img).append(div);
$("form").find("#preview > p").before(file);
$("#preview > p").append(span);
i++;
}
}
}else{
if (input.files && input.files[0]){
var reader = new FileReader();
reader.onload = function (e){
var img = $("<img>").attr({"src":e.target.result,"heghit":100,"width":100});
$(input).before(img);
}
}
}
reader.readAsDataURL(input.files[0]);
}
function addOption(json,select){
var selectId = select.attr("id");
for(var i = 0; i <=json.length-1; i++){
var id = json[i]["id"];
var value = json[i]["value"];
if(selectId == "acreage" || selectId == "price"){
id = value;
}
var Option = $("<option>").attr({"value": id}).append(value);
select.append(Option);
}
}
function controlCommand(){
var num = $("#houseImg > p").length;
if(num>3){
alert("最多只能推荐3个房源");
$("#houseImg").find("p:last-child").remove();
}
}
function getUrlParmas(){
var href = location.search.substr(1,location.search.length-1);
var params = href.split("&");
var map = {};
for(item in params){
var key = params[item].split("=")[0] || "";
var value = params[item].split("=")[1] || "";
map[key] = value;
}
return map;
}
function addList($houseType){
$("#houseList").find("li").remove();
var cityId = $("#baseCity").val();
var buildPropertyId = $("#buildProperty").val();
var room = $("#room").val();
var areaId = $("#areaId").val();
var cityId = $("#cityId").val();
var plateId = $("#plateId").val();
var acreage = $("#acreage").val();
var price = $("#price").val();
$.ajax({
type: "post",
url: "/tospur/wp-admin/admin-ajax.php",
data: "action=searchHouse&cityId="+cityId+"&districtId="+areaId+"&plateId="+plateId+"&buildPropertyId="+buildPropertyId+"&roomId="+room+"&acreage="+acreage+"&totalPrice="+price+"&houseType="+$houseType,
success:function(json){
var result = json.result;
var urlParams = getUrlParmas();
for(var i = 0; i <result.length; i++){
var name = result[i]["name"];
var id = result[i]['id'];
var imgUrl = result[i]['path'];
var img = $("<img>").attr({"src":imgUrl,"height":100,"width":100});
var li = $("<li>").attr("id",id).addClass("addImg").append(img).append(name);
if(urlParams["id"]){
if(urlParams["id"]!=id){
$("#houseList").append(li);
}
}else{
$("#houseList").append(li);
}
}
}
});
}
});
})(jQuery);
</script>
</body>
<!DOCTYPE HTML>
<html>
<head>
{% set title = houseId?"修改新房房源":"添加新房房源" %}
<meta charset="utf-8">
<title>{{title}}</title>
</head>
<body>
<h2 class="title">{{title}}</h2>
<form action="" method="POST" enctype="multipart/form-data" id="newHouse">
<div class="row">
<div class="col-md-11">
<div class="row">
<div class="col-md-4">
<label for="housename">楼盘名:</label>
<input name="housename" id="housename" type="text" value="{{result.name}}" class="form-control" >
</div>
<div class="col-md-4">
<label for="mark">标签:</label>
<input name="mark" id="mark" type="text" value="{{mark}}" class="form-control">
</div>
<div class="col-md-4">
<label for="community_name">小区名:</label>
<input name="community_name" id="community_name" type="text" value="{{result.community_name}}" class="form-control" >
</div>
</div><br>
<div class="row">
<div class="col-md-8">
<label for="address">地址:</label>
<input name="address" type="text" value="{{result.address}}" class="form-control">
</div>
<div class="col-md-4">
<label for="average_price">均价:</label>
<p>
<input name="average_price" id="average_price" type="text" value="{{result.average_price}}" class="form-control" style="width:80%;display: inline-block">
</p>
</div>
</div><br>
<div class="row">
<div class="col-md-8">
<label for="latest_news">最新动态:</label>
<textarea name="latest_news" rows="4" cols="40" class="form-control" >{{result.latest_news}}</textarea>
</div>
</div><br>
<h2 class="title">位置及周边</h2>
<div class="row">
<div class="col-md-4">
<label for="from">所属地区:</label>
<div class="row">
<div class="col-md-3">
<select id="baseCity" name="baseCity" class="required">
<option value="-1"> 城市</option>
{% for item in city %}
<option {{ item.id == result.city_id?"selected":"" }} value="{{ item.id }}">{{ item.value }}</option>
{% endfor %}
</select>
</div>
<div class="col-md-3">
<select id="baseAreaId" name="baseAreaId">
<option value = "-1">区域</option>
{% if district %}
{% for item in district %}
<option {{ item.id == result.district_id?"selected":"" }} value="{{ item.id }}">{{ item.value }}</option>
{% endfor %}
{% endif %}
</select>
</div>
<div class="col-md-3">
<select id="basePlateId" name="basePlateId">
<option value = "-1">板块</option>
{% if district %}
{% for item in plate %}
<option {{ item.id == result.plate_id?"selected":"" }} value="{{ item.id }}">{{ item.value }}</option>
{% endfor %}
{% endif %}
</select>
</div>
</div>
</div>
<div class="col-md-4">
<th><label for="location">地域坐标:</label>
<td> <input name="location" id="location" type="text" value="{{result.location}}" class="form-control">
</div>
<div class="col-md-4">
<label for="traffic">交通线路:</label>
<input name="traffic" type="text" value="{{result.traffic}}" class="form-control">
</div>
</div><br>
<div class="row">
<div class="col-md-4">
<label for="periphery">周边配套:</label>
<input name="periphery" type="text" value="{{result.periphery}}" class="form-control">
</div>
</div><br>
<h2 class="title">基本信息</h2>
<div class="row">
<div class="col-md-4">
<div class="row">
<div class="col-md-4">
<label for="developers">建筑类型:</label>
<select id="baseRoom" name="baseRoom">
{% for item in room %}
<option {{ item.id == result.room_id?"selected":"" }} value="{{ item.id }}">{{ item.value }}</option>
{% endfor %}
</select>
</div>
</div>
</div>
<div class="col-md-4">
<label for="developers">开发商:</label>
<input name="developers" type="text" value="{{result.developer}}" class="form-control" >
</div>
<div class="col-md-4">
<label for="check_in_time">入住时间:</label>
<input name="check_in_time" id="checkin" type="text" value="{{result.check_in_time}}" class="form-control" >
</div>
</div><br>
<div class="row">
<div class="col-md-4">
<label for="property_age">产权年限:</label>
<input name="property_age" type="text" value="{{result.property_age}}" class="form-control" >
</div>
<div class="col-md-4">
<label for="decoration">装修状况:</label></th>
<input name="decoration" type="text" value="{{result.decoration}}" class="form-control">
</div>
<div class="col-md-4">
<label for="covered_area">建筑面积:</label></th>
<div class="row">
<div class="col-md-9">
<input name="covered_area" type="text" value="{{result.covered_area}}" class="form-control" >
</div>
<div class="col-md-3">
<font>平方米</font>
</div>
</div>
</div>
</div><br>
<div class="row">
<div class="col-md-4">
<label for="volume_rate">容积率:</label>
<input name="volume_rate" type="text" value="{{result.volume_rate}}" class="form-control">
</div>
<div class="col-md-4">
<label for="greening_rate">绿化率:</label>
<input name="greening_rate" type="text" value="{{result.greening_rate}}" class="form-control" >
</div>
<div class="col-md-4">
<label for="households">规划户数:</label>
<input name="households" type="text" value="{{result.households}}" class="form-control" >
</div>
</div><br>
<div class="row">
<div class="col-md-4">
<label for="parking_spaces">车位数:</label>
<input name="parking_spaces" type="text" value="{{result.parking_spaces}}" class="form-control" >
</div>
<div class="col-md-4">
<label for="property_management">物业公司:</label></th>
<input name="property_management" type="text" value="{{result.property_management}}" class="form-control" >
</div>
<div class="col-md-4">
<label for="property_money">物业费:</label>
<input name="property_money" type="text" value="{{result.property_money}}" class="form-control">
</div>
</div><br>
<div class="row">
<div class="col-md-6">
<label for="overview">楼盘概述:</label>
<textarea name="overview" rows="4" cols="40" class="form-control">{{result.overview}}</textarea>
</div>
</div><br>
<h2 class="title">关联信息</h2>
<table class="form-table">
<tbody>
<tr>
<th><label for="mainHouse">主力户型</label></th>
<td>
<div id="preview">
{% set exists_ids = "" %}
{% for item in mainImage %}
{% if exists_ids != "" %}
{% set exists_ids = exists_ids~"," %}
{% endif %}
{% set exists_ids = exists_ids~item.id %}
<div>
<img src="{{siteUrl}}{{item.path}}" height="90" width="140" style="margin-right: 50px;margin-top:10px">
<select name="exists[{{item.id}}][buildProperty]" style="margin-right: 50px">
{% for i in buildProperty %}
<option {{ i.id == item.buildproperty_id?"selected":"" }} value="{{i.id}}">{{i.value}}</option>
{% endfor %}
</select>
<input type="text" placeholder="面积" name="exists[{{item.id}}][housearea]" class="form-control" value="{{item.area}}" style="width: 100px;display:inline-block; margin-right: 50px">
<input type="button" value="取消" class="button action cancel existsCancel" style="margin-top: 30px">
</div>
{% endfor %}
<p></p>
<input type="hidden" name="exists_ids" value="{{exists_ids}}" >
<input type="file" name="files[0]" property="0" class = "files"multiple class="browser button button-hero">
</div>
</td>
</tr>
<tr>
<th><label>房源相册</label></th>
<td>
{% if houseId %}
<div class="row">
<div class="col-md-3">
<font>类型</font>
</div>
<div class="col-md-3">
<font>相册</font>
</div>
<div class="col-md-3">
<font>设为封面</font>
</div>
</div>
{% endif %}
<div id="picList">
{% set exists_photo_ids = "" %}
{% for item in images %}
{% if exists_photo_ids != "" %}
{% set exists_photo_ids = exists_photo_ids~"," %}
{% endif %}
{% set exists_photo_ids = exists_photo_ids~item.image_id %}
<div class="row">
<div class="col-md-3">
<select name="exists_photo[{{ item.image_id }}][type]" style="margin-right: 50px">
{% for i in photoType %}
<option {{ i.id == item.image_type?"selected":"" }} value="{{ i.id }}">{{ i.value }}</option>
{% endfor %}
</select>
</div>
<div class="col-md-3">
<img src="{{siteUrl}}{{item.path}}" height="90" width="140" style="margin-right: 50px">
</div>
<div class="col-md-3">
<input type="radio" name="frontCover" style="margin-right: 50px" value="{{item.image_id}}" {{ result.frontCover_id == item.image_id?"checked":"" }} />
</div>
<div class="col-md-2">
<input type="button" value="删除" class="button action cancel existsCancel">
</div>
</div>
{% endfor %}
<input type="hidden" name="exists_photo_ids" value="{{exists_photo_ids}}" >
</div>
<button type="button" id="housePicture" class="button action" data-toggle="modal" style="margin-top: 10px">
新增
</button>
</td>
</tr>
<tr>
<th><label for="traffic">推荐房源</label></th>
<td>
<div id="houseImg">
{% for item in recommends %}
<p>
<img src="{{siteUrl}}{{item.path}}" height="90" width="140" style="margin-right: 50px">
<input type="button" value="删除" class="button action imgCancel existsCancel">
<input type="hidden" name="data[recommend][]" value="{{item.id}}">
</p>
{% endfor %}
</div><br />
<button type="button" class="button action" data-toggle="modal" data-target="#myModal" id="recHouseBt">
添加房源
</button>
</td>
</tr>
<tr>
<th><label for="periphery">置业顾问</label></th>
<td>
<div id="consultantImg">
{% for item in consultant %}
<p>
<img src="{{item.imageUrl}}" height="90" width="140" style="margin-right: 50px">
<span style="margin-right: 50px">{{item.name}}</span>
<input type="button" value="删除" class="button action consultantCancel existsCancel">
<input type="hidden" name="data[recConsultant][]" value="{{item.id}}">
</p>
{% endfor %}
</div><br />
<button type="button" class="button action" data-toggle="modal" data-target="#myConsultant" id="recConsultantBt">
选择置业顾问
</button>
</td>
</tr>
</tbody>
</table>
<input type="text" name="type" value="1" hidden="hidden">
{% if houseId %}
<input type="text" name="houseId" value="{{houseId}}" hidden="hidden">
{% endif %}
</div>
<div class = "col-md-1">
<input type="submit" id="submit" class="button action" style="position: fixed;">
{% if role == 'administrator' %}
<div class="row" style="position: fixed;top:60px;">
<select id="status" name="status">
{% for item in status %}
<option {{ item.id == searchStatus.id?"selected":"" }} value={{item.id}}>{{item.value}}</option>
{% endfor %}
</select>
</div>
{% endif %}
</div>
</div>
</form>
<!-- Modal -->
<!-- 新增房源弹出层 -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-body" style="height: 300px;overflow: auto;">
<select id="cityId">
</select>
<select id="areaId">
<option value = "-1">区域</option>
</select>
<select id="plateId">
<option value = "-1">板块</option>
</select>
<select id="price">
<option value = "-1">价格</option>
</select>
<select id="buildProperty">
<option value = "-1">房型</option>
{% for item in buildProperty %}
<option value="{{ item.id }}">{{ item.value }}</option>
{% endfor %}
</select>
<select id="room">
<option value = "-1">类型</option>
{% for item in room %}
<option value="{{ item.id }}">{{ item.value }}</option>
{% endfor %}
</select>
<select id="acreage">
<option value = "-1">面积</option>
</select>
<input type="text" placeholder="请出入楼盘名/地段名搜索" id="searchtext">
<button type="button" class="button action" id="search">搜索</button>
<ul id="houseList">
</ul>
</div>
</div>
</div>
</div>
<!-- 置业顾问弹出层 -->
<div class="modal fade" id="myConsultant" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-body" style="height: 300px;overflow: auto;">
<select id="consultCity">
</select>
<input type="text" placeholder="请出入置业顾问姓名搜索" id="consultantName" class="form-control">
<button type="button" class="button action" id="searchConsult">搜索</button>
<ul id="consultantList">
</ul>
</div>
</div>
</div>
</div>
<script>
(function($){
$(document).ready(function(){
var titleFlag = 0;
//主力房源中选择图片file的下标
var i = 0;
//入住时间选择
$("#checkin").datepicker({
dateFormat: "yy-mm-dd"
});
//主力房源选择文件
$("form").on("change",".files",function(){
readURL(this,1);
$(this).hide();
});
//主力房源中图片的删除功能
$("form").on("click",".cancel",function(){
$buttonid = $(this).attr("property");
$("[property = "+$buttonid+"]").remove();
$("form input[type='file']:last-child").show();
});
//基本信息的联动AJAX
$("#baseCity").change(function(){
var cityId = $("#baseCity").val();
var baserArea = $("#baseAreaId");
$('#baseAreaId').find('option:not(:first-child)').remove();
$('#basePlateId').find('option:not(:first-child)').remove();
//城市联动区域
$.ajax({
type: "GET",
url: "/tospur/wp-admin/admin-ajax.php",
data: "action=serachCity&cityId="+cityId,
success:function(json){
addOption(json,baserArea);
}
});
});
//区域联动板块
$("#baseAreaId").change(function(){
var basePlate = $("#basePlateId");
var areaId = $("#baseAreaId").val();
var cityId = $("#baseCity").val();
$('#basePlateId').find('option:not(:first-child)').remove();
$.ajax({
type: "GET",
url: "/tospur/wp-admin/admin-ajax.php",
data: "action=serachCity&cityId="+cityId+"&districtId="+areaId,
success:function(json){
addOption(json,basePlate);
}
});
});
//根据上方选择的城市,选择推荐房源的默认城市
$("#recHouseBt").click(function(){
$('#cityId').find('option').remove();
$('#areaId').find('option:not(:first-child)').remove();
$('#plateId').find('option:not(:first-child)').remove();
$('#price').find('option:not(:first-child)').remove();
$('#acreage').find('option:not(:first-child)').remove();
$("#houseList").find("li").remove();
var acreage =$("#acreage");
var price = $("#price");
var cityId = $("#baseCity").val();
var cityName = $("#baseCity").find("option:selected").text();
var option = $("<option>").attr("value",cityId).append(cityName);
$("#cityId").append(option);
if(cityId != -1){
var area = $("#areaId");
$.ajax({
type: "GET",
url: "/tospur/wp-admin/admin-ajax.php",
data: "action=serachCity&cityId="+cityId,
success:function(json){
addOption(json,area);
}
});
//城市联动房子面积
$.ajax({
type: "GET",
url: "/tospur/wp-admin/admin-ajax.php",
data: "action=searchArea&cityId="+cityId,
success:function(json){
addOption(json,acreage);
}
});
//城市联动房子价格
$.ajax({
type: "GET",
url: "/tospur/wp-admin/admin-ajax.php",
data: "action=searchUnitPriceRange&cityId="+cityId,
success:function(json){
addOption(json,price);
}
});
addList(0);
}
});
//区域联动板块
$("#areaId").change(function(){
var areaId = $("#areaId").val();
var cityId = $("#cityId").val();
var plate = $("#plateId");
$("#houseList").find("li").remove();
$('#plateId').find('option:not(:first-child)').remove();
$.ajax({
type: "GET",
url: "/tospur/wp-admin/admin-ajax.php",
data: "action=serachCity&cityId="+cityId+"&districtId="+areaId,
success:function(json){
addOption(json,plate);
}
});
});
//推荐房源下显示图片信息以及房名
$("#areaId,#plateId,#buildProperty,#room,#acreage,#price").change(function(){
addList(0);
});
//添加房源中搜索框的搜索
$("#search").click(function(){
$searchtext = $("#searchtext").val();
$("#houseList").find("li").remove();
$.ajax({
type: "post",
url: "/tospur/wp-admin/admin-ajax.php",
data: "action=searchHouse&searchText="+$searchtext,
success:function(json){
var result = json.result;
for(var i = 0; i < result.length; i++){
var name = result[i]["name"];
var id = result[i]['id'];
var imgUrl = json.images[id];
var img = $("<img>").attr({"src":imgUrl,"height":90,"width":140});
var li = $("<li>").addClass("addImg").append(img).append(name);
$("#houseList").append(li);
}
}
});
})
//根据上方选择的城市,选择推荐置业顾问的默认城市
$("#recConsultantBt").click(function(){
$('#consultCity').find('option').remove();
$("#consultantList").find("li").remove();
var consulCityId = $("#baseCity").val();
var consultantName =$("#consultantName").val();
var cityName = $("#baseCity").find("option:selected").text();
var option = $("<option>").attr("value",consulCityId).append(cityName);
$("#consultCity").append(option);
$.ajax({
type: "GET",
url: "/tospur/wp-admin/admin-ajax.php",
data: "action=searchConsultant&consulCityId="+consulCityId+"&consultantName="+consultantName,
success:function(json){
for(var i = 0; i <=json.length-1; i++){
var name = json[i]["consultantName"];
var imgUrl = json[i]["imageUrl"];
var img = $("<img>").attr({"src":imgUrl,"height":90,"width":140,"style":"margin-right:50px"});
var li = $("<li>").attr("id",json[i]["id"]).append(img).append(name).addClass("consultantImg");
$("#consultantList").append(li);
}
}
});
});
//添加置业顾问弹出层中搜索框的搜索内容
$("#searchConsult").click(function(){
var consulCityId = $("#consultCity").val();
var consultantName =$("#consultantName").val();
$("#consultantList").find("li").remove();
$.ajax({
type: "GET",
url: "/tospur/wp-admin/admin-ajax.php",
data: "action=searchConsultant&consulCityId="+consulCityId+"&consultantName="+consultantName,
success:function(json){
for(var i = 0; i <=json.length-1; i++){
var name = json[i]["consultantName"];
var imgUrl = json[i]["imageUrl"];
var img = $("<img>").attr({"src":imgUrl,"height":90,"width":140});
var li = $("<li>").attr("id",json[i]["id"]).append(img).append(name).addClass("consultantImg");
$("#consultantList").append(li);
}
}
});
})
//点击添加房源中显示的列表,在界面中显示
$("#houseList").on("click",".addImg",function(){
var recommendHouse = $("<input>").attr({"type":"hidden","name":"data[recommend][]","value": $(this).attr("id")});
var url = $(this).find("img").attr("src");
var img = $("<img>").attr({"src":url,"height":90,"width":140,"style":"margin-right:50px"});
var cancel = $("<input>").attr({"type":"button","value":"删除"}).addClass("button action imgCancel");
var p = $("<p>").append(img).append(cancel).append(recommendHouse);
$("#houseImg").append(p);
controlCommand();
});
//添加置业顾问
$("#consultantList").on("click",".consultantImg",function(){
var url = $(this).find("img").attr("src");
var img = $("<img>").attr({"src":url,"height":90,"width":140,"style":"margin-right:55px"});
var recommendConsultant = $("<input>").attr({"type":"hidden","name":"data[recConsultant][]","value": $(this).attr("id")});
var cancel = $("<input>").attr({"type":"button","value":"删除"}).addClass("button action consultantCancel");
var font = $("<font>").attr("style","margin-right:50px").append( $(this).text());
var p = $("<p>").append(img).append(font).append(cancel).append(recommendConsultant);
$("#consultantImg").append(p);
});
//新增房源相册
$("#housePicture").click(function(){
var radio = $("<input>").attr({"type":"radio","name":"frontCover","value":i,});
var picDelet = $("<input>").attr({"type":"button","value":"删除"}).addClass("button action existsCancel");
var file = $("<input>").attr({"type":"file","name":"files["+i+"]"}).addClass("picFiles");
var select = $("<select>").attr({"name":"data["+i+"][type]"});
var dicRadio = $("<div>").append(radio).addClass("col-md-3");
var dicPicDelet = $("<div>").append(picDelet).addClass("col-md-2");
var dicFile = $("<div>").append(file).addClass("col-md-3");
var dicSelect = $("<div>").append(select).addClass("col-md-3");
var div = $("<div>").append(dicSelect).append(dicFile).append(dicRadio).append(dicPicDelet).addClass("row");
{% for item in photoType %}
select.append($("<option>").attr("value",{{item.id}}).append('{{item.value}}'));
{% endfor%}
var fontA = $("<div>").append("<font>").append("设为封面").addClass("col-md-3");
var fontB = $("<div>").append("<font>").append("类型").addClass("col-md-3");
var fontC = $("<div>").append("<font>").append("相册").addClass("col-md-3");
var titleP = $("<div>").append(fontB).append(fontC).append(fontA).addClass("row");
$("#picList").append(div);
var url = getUrlParmas();
if(!url.id){
if( titleFlag== 0){
$("#picList").before(titleP);
titleFlag = 1
}
}
i++
});
//房源相册
$("#picList").on("change",".picFiles",function(){
readURL(this,2);
$(this).hide();
});
//删除房源相册、推荐房源、推荐置业顾问
$("#houseImg,#consultantImg").on("click",".imgCancel,.consultantCancel,.picDelet",function(){
$(this).parents("p").remove();
});
$("#preview,#houseImg,#consultantImg").on("click",".existsCancel",function(){
$(this).parent().remove();
});
$("#picList").on("click",".existsCancel",function(){
$(this).parent().parent().remove();
});
$('#newHouse').validate({
onkeyup: false,
onfocusout: false,
errorClass: "my-error-class",
rules: {
housename:'required',
mark:'required',
community_name:'required',
address:'required',
average_price:'required',
latest_news:'required',
baseCity:{
selectcheck: true
},
baseAreaId:{
selectcheck: true
},
basePlateId:{
selectcheck: true
}
},
messages: {
housename:'请输入楼盘名称',
mark:'请输入标签',
community_name:'请输入小区名称',
address:'请输入地址',
average_price:'请输入均价',
latest_news:'请输入最新动态'
},
errorLabelContainer: "#notice",
errorElement: 'div',
submitHandler: function (form) {
if($("#preview div").length == 0 ){
alert("请选择主力户型");
}else if($("#consultantImg > p").length == 0){
alert("请选择置业顾问");
} else{
form.submit();
}
}
});
jQuery.validator.addMethod('selectcheck', function (value) {
return (value != '-1');
},"请选择城市区域");
//file上传之前,显示图片的方法
function readURL(input,type) {
if(type == 1){
if (input.files && input.files[0]){
var reader = new FileReader();
reader.onload = function (e) {
var img = $("<img>").attr({"id":"target","src":e.target.result,"height":90,"width":140,"style":"margin-right:50px;margin-top:10px"});
var button = $("<input>").attr({"type":"button","value":"取消","property":+i,"id":+i}).addClass("button action cancel");
var type = $("<input>").attr({"type":"hidden","name":"data["+i+"][type]","value":4,"property":+i});
var mainHousePic = $("<input>").attr({"type":"hidden","name":"data["+i+"][mainHouse]","value":0,"property":+i});
var file = $("<input>").attr({"type":"file","name":"files["+(i+1)+"]","property":+(i+1)}).addClass("files");
var select = $("<select>").attr({"name":"data["+i+"][buildProperty]","style":"margin-right:50px"});
{% for item in buildProperty %}{{item.id}}
select.append($("<option>").attr("value",{{item.id}}).append('{{item.value}}'));
{% endfor%}
var areatext = $("<input>").attr({"type":"text","placeholder":"面积","name":"data["+i+"][housearea]","style":"width: 100px;display:inline-block;margin-right:50px"}).addClass("form-control");
var div = $("<div>").attr({"property":+i}).append(img).append(select).append(areatext).append(button).append(type).append(mainHousePic);
$("form").find("#preview > p").after(file);
$("#preview > p").append(div);
i++;
}
}
}else{
if (input.files && input.files[0]){
var reader = new FileReader();
reader.onload = function (e){
var img = $("<img>").attr({"src":e.target.result,"height":90,"width":140});
$(input).before(img);
}
}
}
reader.readAsDataURL(input.files[0]);
}
function addOption(json,select){
var selectId = select.attr("id");
for(var i = 0; i <=json.length-1; i++){
var id = json[i]["id"];
var value = json[i]["value"];
if(selectId == "acreage" || selectId == "price"){
id = value;
}
var Option = $("<option>").attr({"value": id}).append(value);
select.append(Option);
}
}
function controlCommand(){
var num = $("#houseImg > p").length;
if(num>3){
alert("最多只能推荐3个房源");
$("#houseImg").find("p:last-child").remove();
}
}
function getUrlParmas(){
var href = location.search.substr(1,location.search.length-1);
var params = href.split("&");
var map = {};
for(item in params){
var key = params[item].split("=")[0] || "";
var value = params[item].split("=")[1] || "";
map[key] = value;
}
return map;
}
function addList($houseType){
$("#houseList").find("li").remove();
var cityId = $("#baseCity").val();
var buildPropertyId = $("#buildProperty").val();
var room = $("#room").val();
var areaId = $("#areaId").val();
var cityId = $("#cityId").val();
var plateId = $("#plateId").val();
var acreage = $("#acreage").val();
var price = $("#price").val();
$.ajax({
type: "post",
url: "/tospur/wp-admin/admin-ajax.php",
data: "action=searchHouse&cityId="+cityId+"&districtId="+areaId+"&plateId="+plateId+"&buildPropertyId="+buildPropertyId+"&roomId="+room+"&acreage="+acreage+"&totalPrice="+price+"&houseType="+$houseType,
success:function(json){
var result = json.result;
var urlParams = getUrlParmas();
for(var i = 0; i <result.length; i++){
var name = result[i]["name"];
var id = result[i]['id'];
var imgUrl = result[i]['path'];
var img = $("<img>").attr({"src":imgUrl,"height":90,"width":140,"style":"margin-right:50px"});
var li = $("<li>").attr("id",id).addClass("addImg").append(img).append(name);
if(urlParams["id"]){
if(urlParams["id"]!=id){
$("#houseList").append(li);
}
}else{
$("#houseList").append(li);
}
}
}
});
}
});
})(jQuery);
</script>
</body>
</html>
\ No newline at end of file
<!DOCTYPE HTML>
<html>
<head>
{% set title = houseId?"修改租房房源":"添租新房房源" %}
<meta charset="utf-8">
<title>{{title}}</title>
</head>
<body>
<h2 class="title">{{title}}</h2>
<form action="" method="POST" enctype="multipart/form-data">
<table class="form-table">
<tbody>
<tr>
<th><label for="housename">房源名:</label></th>
<td> <input name="housename" id="housename" type="text" value="{{result.name}}" class="regular-text code" style="width: 150px;"></td>
</tr>
<tr>
<th><label for="mark">标签:</label></th>
<td> <input name="mark" id="mark" type="text" value="{{mark}}" class="regular-text code"></td>
</tr>
{% if not houseId %}
<tr>
<th><label for="owner_name">业主姓名</label></th>
<td> <input name="owner_name" id="owner_name" type="text" value="" class="regular-text code" style="width: 150px;"></td>
</tr>
<tr>
<th><label for="owner_phone">业主电话</label></th>
<td> <input name="owner_phone" id="owner_phone" type="text" value="" class="regular-text code" style="width: 150px;"></td>
</tr>
{% endif %}
<tr>
<th><label for="rent">租金</label></th>
<td> <input name="rent" id="rent" type="text" value="{{result.rent}}" class="regular-text code" style="width: 90px;"></td>
</tr>
</tbody>
</table>
<h2 class="title">基本信息</h2>
<table class="form-table">
<tbody>
<tr>
<th><label for="from">户型</label></th>
<td>
<select id="buildproperty_id" name="buildproperty_id">
<option value="-1"> 户型</option>
{% for item in buildProperty %}
<option {{ item.id == result.buildproperty_id?"selected":"" }} value="{{ item.id }}">{{ item.value }}</option>
{% endfor %}
</select>
</td>
</tr>
<tr>
<th><label for="covered_area">面积</label></th>
<td> <input name="covered_area" type="text" value="{{result.covered_area}}" class="regular-text code" style="width: 90px;"></td>
</tr>
<tr>
<th><label for="floor">楼层:</label></th>
<td> <input name="floor" type="text" value="{{result.floor}}" class="regular-text code" style="width: 90px;"></td>
</tr>
<tr>
<th><label for="faceto">朝向:</label></th>
<td> <input name="faceto" type="text" value="{{result.faceto}}" class="regular-text code" style="width: 70px;"></td>
</tr>
<tr>
<th><label for="decoration">装修状况</label></th>
<td> <input name="decoration" type="text" value="{{result.decoration}}" class="regular-text code" style="width: 70px;"></td>
</tr>
<tr>
<th><label for="age">建筑年代</label></th>
<td> <input name="age" type="text" value="{{result.age}}" class="regular-text code" style="width: 70px;"></td>
</tr>
<tr>
<th><label for="matching_facilities">配套设施</label></th>
<td> <input name="matching_facilities" type="text" value="{{result.matching_facilities}}" class="regular-text code"></td>
</tr>
<tr>
<th><label for="flat">楼号</label></th>
<td> <input name="flat" type="text" value="{{result.flat}}" class="regular-text code" style=" width: 50px;"></td>
</tr>
<tr>
<th><label for="suite"></label></th>
<td> <input name="suite" type="text" value="{{result.suite}}" class="regular-text code" style=" width: 50px;"></td>
</tr>
<tr>
<th><label for="overview">房源点评</label></th>
<td> <textarea name="overview" rows="4" cols="40" class="large-text code" style=" width: 400px;">{{result.overview}}</textarea></td>
</tr>
<tr>
<th><label for="from">所属地区</label></th>
<td>
<select id="baseCity" name="baseCity">
<option value="-1"> 城市</option>
{% for item in city %}
<option {{ item.id == result.city_id?"selected":"" }} value="{{ item.id }}">{{ item.value }}</option>
{% endfor %}
</select>
<select id="baseAreaId" name="baseAreaId">
<option value = -1">区域</option>
{% if district %}
{% for item in district %}
<option {{ item.id == result.district_id?"selected":"" }} value="{{ item.id }}">{{ item.value }}</option>
{% endfor %}
{% endif %}
</select>
<select id="basePlateId" name="basePlateId">
<option value = "-1">板块</option>
{% if district %}
{% for item in plate %}
<option {{ item.id == result.plate_id?"selected":"" }} value="{{ item.id }}">{{ item.value }}</option>
{% endfor %}
{% endif %}
</select>
</td>
</tr>
<tr>
<th><label for="location">地域坐标</label></th>
<td> <input name="location" id="location" type="text" value="{{result.location}}" class="regular-text code"></td>
</tr>
</tbody>
</table>
<h2 class="title">位置及周边</h2>
<table class="form-table">
<tbody>
<tr>
<th><label for="address">地址</label></th>
<td> <input name="address" type="text" value="{{result.address}}" class="regular-text code"></td>
</tr>
<tr>
<th><label for="address">小区名称</label></th>
<td> <input name="community_name" type="text" value="{{result.community_name}}" class="regular-text code" style="width: 150px;"></td>
</tr>
<tr>
<th><label for="traffic">交通线路</label></th>
<td> <input name="traffic" type="text" value="{{result.traffic}}" class="regular-text code" style="width: 300px;"></td>
</tr>
<tr>
<th><label for="periphery">周边配套</label></th>
<td> <input name="periphery" type="text" value="{{result.periphery}}" class="regular-text code" ></td>
</tr>
</tbody>
</table>
<h2 class="title">关联信息</h2>
<table class="form-table">
<tbody>
<tr>
<th><label>房源相册</label></th>
<td>
<div id="picList">
{% set exists_photo_ids = "" %}
{% for item in images %}
{% if exists_photo_ids != "" %}
{% set exists_photo_ids = exists_photo_ids~"," %}
{% endif %}
{% set exists_photo_ids = exists_photo_ids~item.image_id %}
<p>
<input type="radio" name="frontCover" value="{{item.image_id}}" {{ result.frontCover_id == item.image_id?"checked":"" }} />
<select name="exists_photo[{{ item.image_id }}][type]">
{% for i in photoType %}
<option {{ i.id == item.image_type?"selected":"" }} value="{{ i.id }}">{{ i.value }}</option>
{% endfor %}
</select>
<img src="{{siteUrl}}{{item.path}}" heghit="100" width="100">
<input type="button" value="取消" class="cancel existsCancel">
</p>
{% endfor %}
<input type="hidden" name="exists_photo_ids" value="{{exists_photo_ids}}" >
</div><br />
<button type="button" id="housePicture" class="button action" data-toggle="modal">
新增
</button>
</td>
</tr>
<tr>
<th><label for="recommend">推荐房源</label></th>
<td>
<div id="houseImg"></div><br />
<button type="button" class="button action" data-toggle="modal" data-target="#myModal" id="recHouseBt" >
添加房源
</button>
</td>
</tr>
<tr>
<th><label for="consultant">置业顾问</label></th>
<td>
<div id="consultantImg">
{% for item in consultant %}
<p>
<span>{{item.name}}</span>
<input type="button" value="删除" class="consultantCancel existsCancel">
<input type="hidden" name="data[recConsultant][]" value="{{item.id}}">
</p>
{% endfor %}
</div><br />
<button type="button" class="button action" data-toggle="modal" data-target="#myConsultant" id="recConsultantBt">
选择置业顾问
</button>
</td>
</tr>
{% if role == 'administrator' %}
<tr>
<th><label for="from">状态</label></th>
<td>
<select id="status" name="status">
{% for item in status %}
<option value={{item.id}}>{{item.value}}</option>
{% endfor %}
</select>
</td>
</tr>
{% endif %}
</tbody>
</table>
<input type="text" name="type" value="3" hidden="hidden">
{% if houseId %}
<input type="text" name="houseId" value="{{houseId}}" hidden="hidden">
{% endif %}
<input type="submit" id="submit" class="button action">
</form>
<!-- Modal -->
<!-- 新增房源弹出层 -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-body" style="height: 300px;overflow: auto;">
<select id="cityId">
</select>
<select id="areaId">
<option value = "-1">区域</option>
</select>
<select id="plateId">
<option value = "-1">板块</option>
</select>
<select id="price">
<option value = "-1">价格</option>
</select>
<select id="buildProperty">
<option value = "-1">房型</option>
{% for item in buildProperty %}
<option value="{{ item.id }}">{{ item.value }}</option>
{% endfor %}
</select>
<select id="room">
<option value = "-1">类型</option>
{% for item in room %}
<option value="{{ item.id }}">{{ item.value }}</option>
{% endfor %}
</select>
<select id="acreage">
<option value = "-1">面积</option>
</select>
<input type="text" placeholder="请出入楼盘名/地段名搜索" id="searchtext">
<button type="button" class="button action" id="search">搜索</button>
<ul id="houseList">
</ul>
</div>
</div>
</div>
</div>
<!-- 置业顾问弹出层 -->
<div class="modal fade" id="myConsultant" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-body" style="height: 300px;overflow: auto;">
<select id="consultCity">
<option value=""> 城市</option>
{% for item in city %}
<option value="{{ item.id }}">{{ item.value }}</option>
{% endfor %}
</select>
<input type="text" placeholder="请出入置业顾问姓名搜索" id="consultantName">
<button type="button" class="button action" id="searchConsult">搜索</button>
<ul id="consultantList">
</ul>
</div>
</div>
</div>
</div>
<script>
(function($){
$(document).ready(function(){
var titleFlag = 0;
//主力房源中选择图片file的下标
var i = 0;
//基本信息的联动AJAX
$("#baseCity").change(function(){
var cityId = $("#baseCity").val();
var baserArea = $("#baseAreaId");
$('#baseAreaId').find('option:not(:first-child)').remove();
$('#basePlateId').find('option:not(:first-child)').remove();
//城市联动区域
$.ajax({
type: "GET",
url: "/tospur/wp-admin/admin-ajax.php",
data: "action=serachCity&cityId="+cityId,
success:function(json){
addOption(json,baserArea);
}
});
});
//区域联动板块
$("#baseAreaId").change(function(){
var basePlate = $("#basePlateId");
var areaId = $("#baseAreaId").val();
var cityId = $("#baseCity").val();
$('#basePlateId').find('option:not(:first-child)').remove();
$.ajax({
type: "GET",
url: "/tospur/wp-admin/admin-ajax.php",
data: "action=serachCity&cityId="+cityId+"&districtId="+areaId,
success:function(json){
addOption(json,basePlate);
}
});
});
//根据上方选择的城市,选择推荐房源的默认城市
$("#recHouseBt").click(function(){
$('#cityId').find('option').remove();
$('#areaId').find('option:not(:first-child)').remove();
$('#plateId').find('option:not(:first-child)').remove();
$('#price').find('option:not(:first-child)').remove();
$('#acreage').find('option:not(:first-child)').remove();
$("#houseList").find("li").remove();
var acreage =$("#acreage");
var price = $("#price");
var cityId = $("#baseCity").val();
var cityName = $("#baseCity").find("option:selected").text();
var option = $("<option>").attr("value",cityId).append(cityName);
$("#cityId").append(option);
var area = $("#areaId");
if(cityId != -1){
$.ajax({
type: "GET",
url: "/tospur/wp-admin/admin-ajax.php",
data: "action=serachCity&cityId="+cityId,
success:function(json){
addOption(json,area);
}
});
//城市联动房子面积
$.ajax({
type: "GET",
url: "/tospur/wp-admin/admin-ajax.php",
data: "action=searchArea&cityId="+cityId,
success:function(json){
addOption(json,acreage);
}
});
//城市联动房子价格
$.ajax({
type: "GET",
url: "/tospur/wp-admin/admin-ajax.php",
data: "action=searchUnitPriceRange&cityId="+cityId,
success:function(json){
addOption(json,price);
}
});
addList(2);
}
});
//区域联动板块
$("#areaId").change(function(){
var areaId = $("#areaId").val();
var cityId = $("#cityId").val();
var plate = $("#plateId");
$("#houseList").find("li").remove();
$('#plateId').find('option:not(:first-child)').remove();
$.ajax({
type: "GET",
url: "/tospur/wp-admin/admin-ajax.php",
data: "action=serachCity&cityId="+cityId+"&districtId="+areaId,
success:function(json){
addOption(json,plate);
}
});
});
//推荐房源下显示图片信息以及房名
$("#areaId,#plateId,#buildProperty,#room,#acreage,#price").change(function(){
addList(2);
});
//添加房源中搜索框的搜索
$("#search").click(function(){
$searchtext = $("#searchtext").val();
$("#houseList").find("li").remove();
$.ajax({
type: "post",
url: "/tospur/wp-admin/admin-ajax.php",
data: "action=searchHouse&searchText="+$searchtext,
success:function(json){
var result = json.result;
for(var i = 0; i < result.length; i++){
var name = result[i]["name"];
var id = result[i]['id'];
var imgUrl = json.images[id];
var img = $("<img>").attr({"src":imgUrl,"height":100,"width":100});
var li = $("<li>").addClass("addImg").append(img).append(name);
$("#houseList").append(li);
}
}
});
})
//根据上方选择的城市,选择推荐置业顾问的默认城市
$("#recConsultantBt").click(function(){
$('#consultCity').find('option').remove();
$("#consultantList").find("li").remove();
var consulCityId = $("#baseCity").val();
var consultantName =$("#consultantName").val();
var cityName = $("#baseCity").find("option:selected").text();
var option = $("<option>").attr("value",consulCityId).append(cityName);
$("#consultCity").append(option);
$.ajax({
type: "GET",
url: "/tospur/wp-admin/admin-ajax.php",
data: "action=searchConsultant&consulCityId="+consulCityId+"&consultantName="+consultantName,
success:function(json){
for(var i = 0; i <=json.length-1; i++){
var name = json[i]["consultantName"];
var imgUrl = json[i]["imageUrl"];
var img = $("<img>").attr({"src":imgUrl,"height":100,"width":100});
var li = $("<li>").attr("id",json[i]["id"]).append(img).append(name).addClass("consultantImg");
$("#consultantList").append(li);
}
}
});
});
//添加置业顾问弹出层中搜索框的搜索内容
$("#searchConsult").click(function(){
var consulCityId = $("#consultCity").val();
var consultantName =$("#consultantName").val();
$("#consultantList").find("li").remove();
$.ajax({
type: "GET",
url: "/tospur/wp-admin/admin-ajax.php",
data: "action=searchConsultant&consulCityId="+consulCityId+"&consultantName="+consultantName,
success:function(json){
for(
var i = 0; i <=json.length-1; i++){
var name = json[i]["consultantName"];
var imgUrl = json[i]["imageUrl"];
var img = $("<img>").attr({"src":imgUrl,"height":100,"width":100});
var li = $("<li>").append(img).append(name).addClass("consultantImg");
$("#consultantList").append(li);
}
}
});
})
//点击添加房源中显示的列表,在界面中显示
$("#houseList").on("click",".addImg",function(){
var recommendHouse = $("<input>").attr({"type":"hidden","name":"data[recommend][]","value": $(this).attr("id")});
var url = $(this).find("img").attr("src");
var img = $("<img>").attr({"src":url,"height":100,"width":100});
var cancel = $("<input>").attr({"type":"button","value":"删除"}).addClass("imgCancel");
var p = $("<p>").append(img).append(cancel).append(recommendHouse);
$("#houseImg").append(p);
controlCommand("houseImg",3,0);
});
//添加置业顾问
$("#consultantList").on("click",".consultantImg",function(){
var recommendConsultant = $("<input>").attr({"type":"hidden","name":"data[recConsultant][]","value": $(this).attr("id")});
var cancel = $("<input>").attr({"type":"button","value":"删除"}).addClass("consultantCancel");
var font = $("<font>").append( $(this).text());
var p = $("<p>").append(font).append(cancel).append(recommendConsultant);
$("#consultantImg").append(p);
controlCommand("consultantImg",1,1);
});
//新增房源相册
$("#housePicture").click(function(){
var checkBox = $("<input>").attr({"type":"radio","name":"frontCover","value":i});
var picDelet = $("<input>").attr({"type":"button","value":"删除"}).addClass("button action picDelet");
var file = $("<input>").attr({"type":"file","name":"files["+i+"]"}).addClass("picFiles");
var select = $("<select>").attr("name","data["+i+"][type]");
var checkTd = $("<th>").append(checkBox);
var picDeletTd = $("<td>").append(picDelet);
var selectTd = $("<th>").append(select);
var fileTd = $("<th>").append(file);
{% for item in photoType %}
select.append($("<option>").attr("value",{{item.id}}).append('{{item.value}}'));
{% endfor%}
var p = $("<p>").append(checkTd).append(selectTd).append(fileTd).append(picDeletTd);
var fontA = $("<font>").append("设为封面");
var fontB = $("<font>").append("类型");
var fontC = $("<font>").append("相册");
var tdA = $("<th>").append(fontA);
var tdB = $("<th>").append(fontB);
var tdC = $("<th>").append(fontC);
var titleP = $("<p>").append(tdA).append(tdB).append(tdC);
$("#picList").append(p);
if( titleFlag== 0){
$("#picList").before(titleP);
titleFlag = 1
}
i++
});
//房源相册
$("#picList").on("change",".picFiles",function(){
readURL(this,2);
$(this).hide();
});
//删除房源相册、推荐房源、推荐置业顾问
$("#houseImg,#consultantImg,#picList").on("click",".imgCancel,.consultantCancel,.picDelet",function(){
$(this).parent("p").remove();
});
$("#picList,#houseImg,#consultantImg").on("click",".existsCancel",function(){
$(this).parent().remove();
});
$("#submit").click(function(){
if($("#housename").val()==""){
alert("请输入楼盘名");
return false;
}
});
//file上传之前,显示图片的方法
function readURL(input,type) {
if(type == 1){
if (input.files && input.files[0]){
var reader = new FileReader();
reader.onload = function (e) {
var img = $("<img>").attr({"id":"target","src":e.target.result,"heghit":100,"width":100});
var button = $("<input>").attr({"type":"button","value":"取消","property":+i,"id":+i}).addClass("cancel");
var type = $("<input>").attr({"type":"hidden","name":"data["+i+"][type]","value":0,"property":+i});
var file = $("<input>").attr({"type":"file","name":"files["+(i+1)+"]","property":+(i+1)}).addClass("files");
var select = $("<select>").attr({"name":"data["+i+"][buildProperty]"});
{% for item in buildProperty %}{{item.id}}
select.append($("<option>").attr("value",{{item.id}}).append('{{item.value}}'));
{% endfor%}
var areatext = $("<input>").attr({"type":"text","placeholder":"面积","name":"data["+i+"][housearea]"}).addClass("regular-text");
var div = $("<div>").append(select).append(areatext).append(button).append(type);
var span = $("<span>").attr({"property":+i}).append(img).append(div);
$("form").find("#preview > p").before(file);
$("#preview > p").append(span);
i++;
}
}
}else{
if (input.files && input.files[0]){
var reader = new FileReader();
reader.onload = function (e){
var img = $("<img>").attr({"src":e.target.result,"heghit":100,"width":100});
$(input).before(img);
}
}
}
reader.readAsDataURL(input.files[0]);
}
function addOption(json,select){
var selectId = select.attr("id");
for(var i = 0; i <=json.length-1; i++){
var id = json[i]["id"];
var value = json[i]["value"];
if(selectId == "acreage" || selectId == "price"){
id = value;
}
var Option = $("<option>").attr({"value": id}).append(value);
select.append(Option);
}
}
function controlCommand(id,number,type){
var num = $("#"+id+" > p").length;
if(num>number){
if(type==0){
alert("最多只能推荐3个房源");
}else if(type==1){
alert("您只能推荐一位置业顾问");
}
$("#"+id).find("p:last-child").remove();
}
}
function getUrlParmas(){
var href = location.search.substr(1,location.search.length-1);
var params = href.split("&");
var map = {};
for(item in params){
var key = params[item].split("=")[0] || "";
var value = params[item].split("=")[1] || "";
map[key] = value;
}
return map;
}
function addList($houseType){
$("#houseList").find("li").remove();
var cityId = $("#baseCity").val();
var buildPropertyId = $("#buildProperty").val();
var room = $("#room").val();
var areaId = $("#areaId").val();
var cityId = $("#cityId").val();
var plateId = $("#plateId").val();
var acreage = $("#acreage").val();
var price = $("#price").val();
$.ajax({
type: "post",
url: "/tospur/wp-admin/admin-ajax.php",
data: "action=searchHouse&cityId="+cityId+"&districtId="+areaId+"&plateId="+plateId+"&buildPropertyId="+buildPropertyId+"&roomId="+room+"&acreage="+acreage+"&totalPrice="+price+"&houseType="+$houseType,
success:function(json){
var result = json.result;
var urlParams = getUrlParmas();
for(var i = 0; i <result.length; i++){
var name = result[i]["name"];
var id = result[i]['id'];
var imgUrl = result[i]['path'];
var img = $("<img>").attr({"src":imgUrl,"height":100,"width":100});
var li = $("<li>").attr("id",id).addClass("addImg").append(img).append(name);
if(urlParams["id"]){
if(urlParams["id"]!=id){
$("#houseList").append(li);
}
}else{
$("#houseList").append(li);
}
}
}
});
}
});
})(jQuery);
</script>
</body>
<!DOCTYPE HTML>
<html>
<head>
{% set title = houseId?"修改租房房源":"添租新房房源" %}
<meta charset="utf-8">
<title>{{title}}</title>
</head>
<body>
<h2 class="title">{{title}}</h2>
<form action="" method="POST" enctype="multipart/form-data" id="rentHouse">
<div class="row">
<div class="col-md-11">
<div class="row">
<div class="col-md-4">
<label for="housename">房源名:</label>
<input name="housename" id="housename" type="text" value="{{result.name}}" class="form-control" >
</div>
<div class="col-md-4">
<label for="community_name">小区名称:</label>
<input name="community_name" type="text" value="{{result.community_name}}" class="form-control">
</div>
<div class="col-md-4">
<label for="rent">租金:</label>
<div class="row">
<p>
<input name="rent" id="rent" type="text" value="{{rent.value}}" class="form-control" style="width:80%;display: inline-block"> 元/月
</p>
</div>
</div>
</div><br>
<div class="row">
<div class="col-md-6">
<label for="mark">标签:</label>
<input name="mark" id="mark" type="text" value="{{mark}}" class="form-control">
</div>
</div><br>
<div class="row">
{% if not houseId %}
<div class="col-md-4">
<label for="owner_name">业主姓名:</label>
<input name="owner_name" id="owner_name" type="text" value="" class="form-control">
</div>
<div class="col-md-4">
<label for="owner_phone">业主电话:</label>
<input name="owner_phone" id="owner_phone" type="text" value="" class="form-control">
</div>
{% endif %}
</div><br>
<h2 class="title">基本信息</h2>
<div class="row">
<div class="col-md-12">
<label for="suite">门牌号码:</label></th>
<input name="suite" type="text" value="{{result.suite}}"style="width: 10%">
&nbsp;
<label for="floor">楼层:</label>
<input name="floor" type="text" value="{{result.floor}}" style="width: 5%">
&nbsp;
<label for="totalFloor">总层:</label>
<input type="text" name="totalFloor"value="{{result.totalFloor}}" style="width: 5%">
&nbsp;
<label for="faceto">朝向:</label>
<select name="faceto">
<option value="其他">其他</option>
<option value="东"></option>
<option value="南"></option>
<option value="西">西</option>
<option value="北"></option>
<option value="东西">东西</option>
<option value="南北">南北</option>
<option value="南南">南南</option>
<option value="东南">东南</option>
<option value="东北">东北</option>
<option value="西南">西南</option>
<option value="西北">西北</option>
</select>
&nbsp;
<label for="age">建筑年代:</label>
<!--<input name="age" type="text" value="{{result.age}}" class="form-control">-->
<select name="age">
<option>未知</option>
{% for item in age%}
<option {{ item == result.age?"selected":"" }}value="{{item}}">{{item}}</option>
{% endfor %}
</select>
&nbsp;
<label for="propertyRight">产权:</label>
<select name="propertyRight">
<option value="个人产权">个人产权</option>
<option value="单位产权">单位产权</option>
<option value="售后产权">售后产权</option>
<option value="家庭成员共有">家庭成员共有</option>
<option value="使用权">使用权</option>
<option value="小产权">小产权</option>
<option value="协议房">协议房</option>
<option value="私产">私产</option>
<option value="公产">公产</option>
<option value="合同发票">合同发票</option>
<option value="三联单">三联单</option>
<option value="其他">其他</option>
</select>
</div>
</div><br>
<div class="row">
<div class="col-md-12">
<label for="propertyProof">产证:</label>
<input type="text" name="propertyProof" value="{{result.propertyProof}}">
&nbsp;
<label for="decoration">装修状况:</label>
<select name="decoration">
<option value="毛坯">毛坯</option>
<option value="简单装修">简单装修</option>
<option value="中等装修">中等装修</option>
<option value="精装修">精装修</option>
<option value="豪华装修">豪华装修</option>
</select>
&nbsp;
<label for="useArea">使用面积:</label>
<input type="text" name="useArea" value="{{result.useArea}}" style="width: 10%;display: inline-block">平方米
&nbsp;
<label for="covered_area">建筑面积:</label>
<input name="covered_area" type="text" value="{{result.covered_area}}" style="width:10%;display: inline-block">平方米
&nbsp;
<input type="checkbox" id="keyCheck" {{ result.key?"checked":"" }}> <label for="key">钥匙:</label><input type="text" {% if not result.key %} disabled="true" {% endif %} id="key" name="key" value="{{result.key}}" style="width: 10%">
</div>
</div><br>
<div class="row">
<div class="col-md-12">
<input type="checkbox" id="garageCheck" {{ result.garage?"checked":"" }}> <label for="garage">车库:</label><input type="text" {% if not result.garage %}disabled="true"{% endif %} id="garage" name="garage" value="{{result.garage}}" style="width: 10%">
&nbsp;
<label for="street">街道:</label>
<input type="text" name="street" value="{{result.street}}">
&nbsp;
<label for="flat">楼号:</label>
<input name="flat" type="text" value="{{result.flat}}" style="width: 10%;">
&nbsp;
<label for="matching_facilities">设施:</label>
<input type="text" name="matching_facilities" value="{{result.matching_facilities}}">
&nbsp;
<label for="structure">结构:</label>
<select name="structure">
<option value="其他">其他</option>
<option value="框架">框架</option>
<option value="砖混">砖混</option>
<option value="剪力">剪力</option>
<option value="钢混">钢混</option>
<option value="木混">木混</option>
<option value="砖木">砖木</option>
</select>
</div>
</div><br>
<div class="row">
<div class="col-md-12">
<label for="from">户型:</label>
<select id="buildproperty_id" name="buildproperty_id">
{% for item in buildProperty %}
<option {{ item.id == result.buildproperty_id?"selected":"" }} value="{{ item.id }}">{{ item.value }}</option>
{% endfor %}
</select>
<label for="roomNum">室:</label>
<select name="roomNum">
<option value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
</select>
<label for="livingRoom">厅:</label>
<select name="livingRoom">
<option value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
</select>
<label for="bathRoom">卫:</label>
<select name="bathRoom">
<option value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
</select>
<label for="kitchen">厨:</label>
<select name="kitchen">
<option value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
</select>
<label for="balcony">阳台:</label>
<select name="balcony">
<option value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
</select>
</div>
</div><br>
<div class="row">
<div class="col-md-12">
<label for="overview">房源点评:</label>
<textarea name="overview" rows="4" cols="40" class="form-control" >{{result.overview}}</textarea>
</div>
</div><br>
<h2 class="title">位置及周边</h2>
<div class="row">
<div class="col-md-4">
<label for="from">所属地区:</label>
<div class="row">
<div class="col-md-3">
<select id="baseCity" name="baseCity" class="required">
<option value="-1"> 城市</option>
{% for item in city %}
<option {{ item.id == result.city_id?"selected":"" }} value="{{ item.id }}">{{ item.value }}</option>
{% endfor %}
</select>
</div>
<div class="col-md-3">
<select id="baseAreaId" name="baseAreaId">
<option value = "-1">区域</option>
{% if district %}
{% for item in district %}
<option {{ item.id == result.district_id?"selected":"" }} value="{{ item.id }}">{{ item.value }}</option>
{% endfor %}
{% endif %}
</select>
</div>
<div class="col-md-3">
<select id="basePlateId" name="basePlateId">
<option value = "-1">板块</option>
{% if district %}
{% for item in plate %}
<option {{ item.id == result.plate_id?"selected":"" }} value="{{ item.id }}">{{ item.value }}</option>
{% endfor %}
{% endif %}
</select>
</div>
</div>
</div>
<div class="col-md-4">
<label for="address">地址:</label>
<input name="address" type="text" value="{{result.address}}" class="form-control">
</div>
<div class="col-md-4">
<label for="traffic">交通线路:</label>
<input name="traffic" type="text" value="{{result.traffic}}" class="form-control">
</div>
</div><br>
<div class="row">
<div class="col-md-4">
<label for="periphery">周边配套:</label>
<input name="periphery" type="text" value="{{result.periphery}}" class="form-control">
</div>
<div class="col-md-4">
<label for="location">地域坐标:</label>
<input name="location" id="location" type="text" value="{{result.location}}" class="form-control">
</div>
</div><br>
<h2 class="title">关联信息</h2>
<table class="form-table">
<tbody>
<tr>
<th><label>房源相册:</label></th>
<td>
{% if houseId %}
<div class="row">
<div class="col-md-3">
<font>类型</font>
</div>
<div class="col-md-3">
<font>相册</font>
</div>
<div class="col-md-3">
<font>设为封面</font>
</div>
</div>
{% endif %}
<div id="picList">
{% set exists_photo_ids = "" %}
{% for item in images %}
{% if exists_photo_ids != "" %}
{% set exists_photo_ids = exists_photo_ids~"," %}
{% endif %}
{% set exists_photo_ids = exists_photo_ids~item.image_id %}
<div class="row">
<div class="col-md-3">
<select name="exists_photo[{{ item.image_id }}][type]" style="margin-right: 50px">
{% for i in photoType %}
<option {{ i.id == item.image_type?"selected":"" }} value="{{ i.id }}">{{ i.value }}</option>
{% endfor %}
</select>
</div>
<div class="col-md-3">
<img src="{{siteUrl}}{{item.path}}" height="90" width="140" style="margin-right: 50px">
</div>
<div class="col-md-3">
<input type="radio" name="frontCover" style="margin-right: 50px" value="{{item.image_id}}" {{ result.frontCover_id == item.image_id?"checked":"" }} />
</div>
<div class="col-md-2">
<input type="button" value="删除" class="button action cancel existsCancel">
</div>
</div>
{% endfor %}
<input type="hidden" name="exists_photo_ids" value="{{exists_photo_ids}}" >
</div>
<button type="button" id="housePicture" class="button action" data-toggle="modal" style="margin-top: 10px">
新增
</button>
</td>
</tr>
<tr>
<th><label for="traffic">推荐房源</label></th>
<td>
<div id="houseImg">
{% for item in recommends %}
<p>
<img src="{{siteUrl}}{{item.path}}" height="90" width="140" style="margin-right: 50px">
<input type="button" value="删除" class="button action imgCancel existsCancel">
<input type="hidden" name="data[recommend][]" value="{{item.id}}">
</p>
{% endfor %}
</div><br />
<button type="button" class="button action" data-toggle="modal" data-target="#myModal" id="recHouseBt">
添加房源
</button>
</td>
</tr>
<tr>
<th><label for="periphery">置业顾问</label></th>
<td>
<div id="consultantImg">
{% for item in consultant %}
<p>
<img src="{{item.imageUrl}}" height="100" width="100" style="margin-right: 50px">
<span style="margin-right: 50px">{{item.name}}</span>
<input type="button" value="删除" class="button action consultantCancel existsCancel">
<input type="hidden" name="data[recConsultant][]" value="{{item.id}}">
</p>
{% endfor %}
</div><br />
<button type="button" class="button action" data-toggle="modal" data-target="#myConsultant" id="recConsultantBt">
选择置业顾问
</button>
</td>
</tr>
</tbody>
</table>
<input type="text" name="type" value="3" hidden="hidden">
{% if houseId %}
<input type="text" name="houseId" value="{{houseId}}" hidden="hidden">
{% endif %}
</div>
<div class="col-md-1">
<input type="submit" id="submit" class="button action" style="position: fixed;">
{% if role == 'administrator' %}
<div class="row" style="position: fixed;top:50px;">
<select id="status" name="status">
{% for item in status %}
<option {{ item.id == searchStatus.id?"selected":"" }} value={{item.id}}>{{item.value}}</option>
{% endfor %}
</select>
</div>
{% endif %}
</div>
</div>
</form>
<!-- Modal -->
<!-- 新增房源弹出层 -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-body" style="height: 300px;overflow: auto;">
<select id="cityId">
</select>
<select id="areaId">
<option value = "-1">区域</option>
</select>
<select id="plateId">
<option value = "-1">板块</option>
</select>
<select id="price">
<option value = "-1">价格</option>
</select>
<select id="buildProperty">
<option value = "-1">房型</option>
{% for item in buildProperty %}
<option value="{{ item.id }}">{{ item.value }}</option>
{% endfor %}
</select>
<select id="room">
<option value = "-1">类型</option>
{% for item in room %}
<option value="{{ item.id }}">{{ item.value }}</option>
{% endfor %}
</select>
<select id="acreage">
<option value = "-1">面积</option>
</select>
<input type="text" placeholder="请出入楼盘名/地段名搜索" id="searchtext">
<button type="button" class="button action" id="search">搜索</button>
<ul id="houseList">
</ul>
</div>
</div>
</div>
</div>
<!-- 置业顾问弹出层 -->
<div class="modal fade" id="myConsultant" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-body" style="height: 300px;overflow: auto;">
<select id="consultCity">
<option value=""> 城市</option>
{% for item in city %}
<option value="{{ item.id }}">{{ item.value }}</option>
{% endfor %}
</select>
<input type="text" placeholder="请出入置业顾问姓名搜索" id="consultantName">
<button type="button" class="button action" id="searchConsult">搜索</button>
<ul id="consultantList">
</ul>
</div>
</div>
</div>
</div>
<script>
(function($){
$(document).ready(function(){
var titleFlag = 0;
//主力房源中选择图片file的下标
var i = 0;
//基本信息的联动AJAX
$("#baseCity").change(function(){
var cityId = $("#baseCity").val();
var baserArea = $("#baseAreaId");
$('#baseAreaId').find('option:not(:first-child)').remove();
$('#basePlateId').find('option:not(:first-child)').remove();
//城市联动区域
$.ajax({
type: "GET",
url: "/tospur/wp-admin/admin-ajax.php",
data: "action=serachCity&cityId="+cityId,
success:function(json){
addOption(json,baserArea);
}
});
});
//区域联动板块
$("#baseAreaId").change(function(){
var basePlate = $("#basePlateId");
var areaId = $("#baseAreaId").val();
var cityId = $("#baseCity").val();
$('#basePlateId').find('option:not(:first-child)').remove();
$.ajax({
type: "GET",
url: "/tospur/wp-admin/admin-ajax.php",
data: "action=serachCity&cityId="+cityId+"&districtId="+areaId,
success:function(json){
addOption(json,basePlate);
}
});
});
//根据上方选择的城市,选择推荐房源的默认城市
$("#recHouseBt").click(function(){
$('#cityId').find('option').remove();
$('#areaId').find('option:not(:first-child)').remove();
$('#plateId').find('option:not(:first-child)').remove();
$('#price').find('option:not(:first-child)').remove();
$('#acreage').find('option:not(:first-child)').remove();
$("#houseList").find("li").remove();
var acreage =$("#acreage");
var price = $("#price");
var cityId = $("#baseCity").val();
var cityName = $("#baseCity").find("option:selected").text();
var option = $("<option>").attr("value",cityId).append(cityName);
$("#cityId").append(option);
var area = $("#areaId");
if(cityId != -1){
$.ajax({
type: "GET",
url: "/tospur/wp-admin/admin-ajax.php",
data: "action=serachCity&cityId="+cityId,
success:function(json){
addOption(json,area);
}
});
//城市联动房子面积
$.ajax({
type: "GET",
url: "/tospur/wp-admin/admin-ajax.php",
data: "action=searchArea&cityId="+cityId,
success:function(json){
addOption(json,acreage);
}
});
//城市联动房子价格
$.ajax({
type: "GET",
url: "/tospur/wp-admin/admin-ajax.php",
data: "action=searchUnitPriceRange&cityId="+cityId,
success:function(json){
addOption(json,price);
}
});
addList(2);
}
});
//区域联动板块
$("#areaId").change(function(){
var areaId = $("#areaId").val();
var cityId = $("#cityId").val();
var plate = $("#plateId");
$("#houseList").find("li").remove();
$('#plateId').find('option:not(:first-child)').remove();
$.ajax({
type: "GET",
url: "/tospur/wp-admin/admin-ajax.php",
data: "action=serachCity&cityId="+cityId+"&districtId="+areaId,
success:function(json){
addOption(json,plate);
}
});
});
//推荐房源下显示图片信息以及房名
$("#areaId,#plateId,#buildProperty,#room,#acreage,#price").change(function(){
addList(2);
});
//添加房源中搜索框的搜索
$("#search").click(function(){
$searchtext = $("#searchtext").val();
$("#houseList").find("li").remove();
$.ajax({
type: "post",
url: "/tospur/wp-admin/admin-ajax.php",
data: "action=searchHouse&searchText="+$searchtext,
success:function(json){
var result = json.result;
for(var i = 0; i < result.length; i++){
var name = result[i]["name"];
var id = result[i]['id'];
var imgUrl = json.images[id];
var img = $("<img>").attr({"src":imgUrl,"height":90,"width":140,"style":"margin-right:50px"});
var li = $("<li>").addClass("addImg").append(img).append(name);
$("#houseList").append(li);
}
}
});
})
//根据上方选择的城市,选择推荐置业顾问的默认城市
$("#recConsultantBt").click(function(){
$('#consultCity').find('option').remove();
$("#consultantList").find("li").remove();
var consulCityId = $("#baseCity").val();
var consultantName =$("#consultantName").val();
var cityName = $("#baseCity").find("option:selected").text();
var option = $("<option>").attr("value",consulCityId).append(cityName);
$("#consultCity").append(option);
$.ajax({
type: "GET",
url: "/tospur/wp-admin/admin-ajax.php",
data: "action=searchConsultant&consulCityId="+consulCityId+"&consultantName="+consultantName,
success:function(json){
for(var i = 0; i <=json.length-1; i++){
var name = json[i]["consultantName"];
var imgUrl = json[i]["imageUrl"];
var img = $("<img>").attr({"src":imgUrl,"height":90,"width":140,"style":"margin-right:50px"});
var li = $("<li>").attr("id",json[i]["id"]).append(img).append(name).addClass("consultantImg");
$("#consultantList").append(li);
}
}
});
});
//添加置业顾问弹出层中搜索框的搜索内容
$("#searchConsult").click(function(){
var consulCityId = $("#consultCity").val();
var consultantName =$("#consultantName").val();
$("#consultantList").find("li").remove();
$.ajax({
type: "GET",
url: "/tospur/wp-admin/admin-ajax.php",
data: "action=searchConsultant&consulCityId="+consulCityId+"&consultantName="+consultantName,
success:function(json){
for(
var i = 0; i <=json.length-1; i++){
var name = json[i]["consultantName"];
var imgUrl = json[i]["imageUrl"];
var img = $("<img>").attr({"src":imgUrl,"height":100,"width":100,"style":"margin-right:50px"});
var li = $("<li>").attr("id",json[i]["id"]).append(img).append(name).addClass("consultantImg");
$("#consultantList").append(li);
}
}
});
})
//点击添加房源中显示的列表,在界面中显示
$("#houseList").on("click",".addImg",function(){
var recommendHouse = $("<input>").attr({"type":"hidden","name":"data[recommend][]","value": $(this).attr("id")});
var url = $(this).find("img").attr("src");
var img = $("<img>").attr({"src":url,"height":90,"width":140,"style":"margin-right:50px"});
var cancel = $("<input>").attr({"type":"button","value":"删除"}).addClass("button action imgCancel");
var p = $("<p>").append(img).append(cancel).append(recommendHouse);
$("#houseImg").append(p);
controlCommand("houseImg",3,0);
});
//添加置业顾问
$("#consultantList").on("click",".consultantImg",function(){
var url = $(this).find("img").attr("src");
var img = $("<img>").attr({"src":url,"height":100,"width":100,"style":"margin-right:50px"});
var recommendConsultant = $("<input>").attr({"type":"hidden","name":"data[recConsultant][]","value": $(this).attr("id")});
var cancel = $("<input>").attr({"type":"button","value":"删除"}).addClass("button action consultantCancel");
var font = $("<font>").attr("style","margin-right:50px").append( $(this).text());
var p = $("<p>").append(img).append(font).append(cancel).append(recommendConsultant);
$("#consultantImg").append(p);
controlCommand("consultantImg",1,1);
});
//新增房源相册
$("#housePicture").click(function(){
var radio = $("<input>").attr({"type":"radio","name":"frontCover","value":i,});
var picDelet = $("<input>").attr({"type":"button","value":"删除"}).addClass("button action existsCancel");
var file = $("<input>").attr({"type":"file","name":"files["+i+"]"}).addClass("picFiles");
var select = $("<select>").attr({"name":"data["+i+"][type]"});
var dicRadio = $("<div>").append(radio).addClass("col-md-3");
var dicPicDelet = $("<div>").append(picDelet).addClass("col-md-2");
var dicFile = $("<div>").append(file).addClass("col-md-3");
var dicSelect = $("<div>").append(select).addClass("col-md-3");
var div = $("<div>").append(dicSelect).append(dicFile).append(dicRadio).append(dicPicDelet).addClass("row");
{% for item in photoType %}
select.append($("<option>").attr("value",{{item.id}}).append('{{item.value}}'));
{% endfor%}
var p = $("<p>").append(div);
var fontA = $("<div>").append("<font>").append("设为封面").addClass("col-md-3");
var fontB = $("<div>").append("<font>").append("类型").addClass("col-md-3");
var fontC = $("<div>").append("<font>").append("相册").addClass("col-md-3");
var titleP = $("<div>").append(fontB).append(fontC).append(fontA).addClass("row");
$("#picList").append(p);
var url = getUrlParmas();
if(!url.id){
if( titleFlag== 0){
$("#picList").before(titleP);
titleFlag = 1
}
}
i++
});
//房源相册
$("#picList").on("change",".picFiles",function(){
readURL(this,2);
$(this).hide();
});
//删除房源相册、推荐房源、推荐置业顾问
$("#houseImg,#consultantImg").on("click",".imgCancel,.consultantCancel,.picDelet",function(){
$(this).parents("p").remove();
});
$("#houseImg,#consultantImg").on("click",".existsCancel",function(){
$(this).parent().remove();
});
$("#picList").on("click",".existsCancel",function(){
$(this).parent().parent().remove();
});
$("input[id='keyCheck']").change(function(){
textDisable("keyCheck","key");
});
$("input[id='garageCheck']").change(function(){
textDisable("garageCheck","garage");
});
$("form").find("select[name='faceto']").val("{{result.faceto}}");
$("form").find("select[name='age']").val("{{result.age}}");
$("form").find("select[name='propertyRight']").val("{{result.propertyRight}}");
$("form").find("select[name='decoration']").val("{{result.decoration}}");
$("form").find("select[name='source']").val("{{result.source}}");
$("form").find("select[name='structure']").val("{{result.structure}}");
$("form").find("select[name='roomNum']").val("{{result.roomNum}}");
$("form").find("select[name='livingRoom']").val("{{result.livingRoom}}");
$("form").find("select[name='bathRoom']").val("{{result.bathRoom}}");
$("form").find("select[name='kitchen']").val("{{result.kitchen}}");
$("form").find("select[name='balcony']").val("{{result.balcony}}");
$('#rentHouse').validate({
onkeyup: false,
onfocusout: false,
errorClass: "my-error-class",
rules: {
housename:'required',
mark:'required',
rent:'required',
owner_name:'required',
owner_phone:'required',
community_name:'required',
baseCity:{
selectcheck: true
},
baseAreaId:{
selectcheck: true
},
basePlateId:{
selectcheck: true
}
},
messages: {
housename:'请输入房源名称',
mark:'请输入标签',
owner_name:'请输入业主姓名',
owner_phone:'请输入业主电话',
rent:'请输入租金',
community_name:'请输入小区名称',
},
errorLabelContainer: "#notice",
errorElement: 'div',
submitHandler: function (form) {
if($("#consultantImg > p").length == 0 ){
alert("请选择置业顾问");
}else{
form.submit();
}
}
});
jQuery.validator.addMethod('selectcheck', function (value) {
return (value != '-1');
},"请选择城市区域");
function textDisable(checkId,textId){
if($('input[id="'+checkId+'"]:checked').length > 0){
$("#"+textId).removeAttr("disabled");
}else{
$("#"+textId).attr("disabled","true");
}
}
//file上传之前,显示图片的方法
function readURL(input,type) {
if(type == 1){
if (input.files && input.files[0]){
var reader = new FileReader();
reader.onload = function (e) {
var img = $("<img>").attr({"id":"target","src":e.target.result,"heghit":90,"width":140});
var button = $("<input>").attr({"type":"button","value":"取消","property":+i,"id":+i}).addClass("cancel");
var type = $("<input>").attr({"type":"hidden","name":"data["+i+"][type]","value":0,"property":+i});
var file = $("<input>").attr({"type":"file","name":"files["+(i+1)+"]","property":+(i+1)}).addClass("files");
var select = $("<select>").attr({"name":"data["+i+"][buildProperty]"});
{% for item in buildProperty %}{{item.id}}
select.append($("<option>").attr("value",{{item.id}}).append('{{item.value}}'));
{% endfor%}
var areatext = $("<input>").attr({"type":"text","placeholder":"面积","name":"data["+i+"][housearea]"}).addClass("regular-text");
var div = $("<div>").append(select).append(areatext).append(button).append(type);
var span = $("<span>").attr({"property":+i}).append(img).append(div);
$("form").find("#preview > p").before(file);
$("#preview > p").append(span);
i++;
}
}
}else{
if (input.files && input.files[0]){
var reader = new FileReader();
reader.onload = function (e){
var img = $("<img>").attr({"src":e.target.result,"heghit":90,"width":140});
$(input).before(img);
}
}
}
reader.readAsDataURL(input.files[0]);
}
function addOption(json,select){
var selectId = select.attr("id");
for(var i = 0; i <=json.length-1; i++){
var id = json[i]["id"];
var value = json[i]["value"];
if(selectId == "acreage" || selectId == "price"){
id = value;
}
var Option = $("<option>").attr({"value": id}).append(value);
select.append(Option);
}
}
function controlCommand(id,number,type){
var num = $("#"+id+" > p").length;
if(num>number){
if(type==0){
alert("最多只能推荐3个房源");
}else if(type==1){
alert("您只能推荐一位置业顾问");
}
$("#"+id).find("p:last-child").remove();
}
}
function getUrlParmas(){
var href = location.search.substr(1,location.search.length-1);
var params = href.split("&");
var map = {};
for(item in params){
var key = params[item].split("=")[0] || "";
var value = params[item].split("=")[1] || "";
map[key] = value;
}
return map;
}
function addList($houseType){
$("#houseList").find("li").remove();
var cityId = $("#baseCity").val();
var buildPropertyId = $("#buildProperty").val();
var room = $("#room").val();
var areaId = $("#areaId").val();
var cityId = $("#cityId").val();
var plateId = $("#plateId").val();
var acreage = $("#acreage").val();
var price = $("#price").val();
$.ajax({
type: "post",
url: "/tospur/wp-admin/admin-ajax.php",
data: "action=searchHouse&cityId="+cityId+"&districtId="+areaId+"&plateId="+plateId+"&buildPropertyId="+buildPropertyId+"&roomId="+room+"&acreage="+acreage+"&totalPrice="+price+"&houseType="+$houseType,
success:function(json){
var result = json.result;
var urlParams = getUrlParmas();
for(var i = 0; i <result.length; i++){
var name = result[i]["name"];
var id = result[i]['id'];
var imgUrl = result[i]['path'];
var img = $("<img>").attr({"src":imgUrl,"height":90,"width":140,"style":"margin-right:50px"});
var li = $("<li>").attr("id",id).addClass("addImg").append(img).append(name);
if(urlParams["id"]){
if(urlParams["id"]!=id){
$("#houseList").append(li);
}
}else{
$("#houseList").append(li);
}
}
}
});
}
});
})(jQuery);
</script>
</body>
</html>
\ No newline at end of file
<!DOCTYPE HTML>
<html>
<head>
{% set title = houseId?"修改二手房房源":"添加二手房房源" %}
<meta charset="utf-8">
<title>{{title}}</title>
</head>
<body>
<h2 class="title">{{title}}</h2>
<form action="" method="POST" enctype="multipart/form-data">
<div class="row">
<div class="col-md-11">
<div class="row">
<div class="col-md-8">
<table class="form-table">
<tbody>
<tr>
<th><label for="housename">房源名:</label></th>
<td> <input name="housename" id="housename" type="text" value="{{result.name}}" class="form-control" style="width: 150px;"></td>
</tr>
<tr>
<th><label for="address">小区名称</label></th>
<td> <input name="community_name" type="text" value="{{result.community_name}}" class="form-control" style="width: 150px;"></td>
</tr>
<tr>
<th><label for="mark">标签:</label></th>
<td> <input name="mark" id="mark" type="text" value="{{mark}}" class="form-control"></td>
</tr>
{% if not houseId %}
<tr>
<th><label for="owner_name">业主姓名</label></th>
<td> <input name="owner_name" id="owner_name" type="text" value="" class="form-control" style="width: 150px;"></td>
</tr>
<tr>
<th><label for="owner_phone">业主电话</label></th>
<td> <input name="owner_phone" id="owner_phone" type="text" value="" class="form-control" style="width: 150px;"></td>
</tr>
{% endif %}
<tr>
<th><label for="total_price">售价</label></th>
<td> <input name="total_price" id="total_price" type="text" value="{{result.total_price}}" class="form-control" style="width: 90px;"></td>
</tr>
<tr>
<th><label for="average_price">单价</label></th>
<td> <input name="average_price" id="average_price" type="text" value="{{result.average_price}}" class="form-control" style="width: 90px;"></td>
</tr>
</tbody>
</table>
</div>
</div>
<h2 class="title">基本信息</h2>
<div class="row">
<div class="col-md-8">
<table class="form-table">
<tbody>
<tr>
<th><label for="from">户型</label></th>
<td>
<select id="buildproperty_id" name="buildproperty_id">
{% for item in buildProperty %}
<option {{ item.id == result.buildproperty_id?"selected":"" }} value="{{ item.id }}">{{ item.value }}</option>
{% endfor %}
</select>
</td>
</tr>
<tr>
<th><label for="covered_area">面积</label></th>
<td> <input name="covered_area" type="text" value="{{result.covered_area}}" class="form-control" style="width: 90px;"></td>
</tr>
<tr>
<th><label for="floor">楼层:</label></th>
<td> <input name="floor" type="text" value="{{result.floor}}" class="form-control" style=" width: 70px;"></td>
</tr>
<tr>
<th><label for="faceto">朝向:</label></th>
<td> <input name="faceto" type="text" value="{{result.faceto}}" class="form-control" style=" width: 70px;"></td>
</tr>
<tr>
<th><label for="decoration">装修状况</label></th>
<td> <input name="decoration" type="text" value="{{result.decoration}}" class="form-control" style=" width: 70px;"></td>
</tr>
<tr>
<th><label for="age">建筑年代</label></th>
<td> <input name="age" type="text" value="{{result.age}}" class="form-control" style=" width: 70px;"></td>
</tr>
<tr>
<th><label for="flat">楼号</label></th>
<td> <input name="flat" type="text" value="{{result.flat}}" class="form-control" style=" width: 50px;"></td>
</tr>
<tr>
<th><label for="suite"></label></th>
<td> <input name="suite" type="text" value="{{result.suite}}" class="form-control" style=" width: 50px;"></td>
</tr>
<tr>
<th><label for="overview">房源点评</label></th>
<td> <textarea name="overview" rows="4" cols="40" class="form-control" style=" width: 400px;">{{result.overview}}</textarea></td>
</tr>
</tbody>
</table>
</div>
</div>
<h2 class="title">位置及周边</h2>
<div class="row">
<div class="col-md-8">
<table class="form-table">
<tbody>
<tr>
<th><label for="from">所属地区</label></th>
<td>
<select id="baseCity" name="baseCity">
<option value="-1"> 城市</option>
{% for item in city %}
<option {{ item.id == result.city_id?"selected":"" }} value="{{ item.id }}">{{ item.value }}</option>
{% endfor %}
</select>
<select id="baseAreaId" name="baseAreaId">
<option value = "-1">区域</option>
{% if district %}
{% for item in district %}
<option {{ item.id == result.district_id?"selected":"" }} value="{{ item.id }}">{{ item.value }}</option>
{% endfor %}
{% endif %}
</select>
<select id="basePlateId" name="basePlateId">
<option value = "-1">板块</option>
{% if district %}
{% for item in plate %}
<option {{ item.id == result.plate_id?"selected":"" }} value="{{ item.id }}">{{ item.value }}</option>
{% endfor %}
{% endif %}
</select>
</td>
</tr>
<tr>
<th><label for="location">地域坐标</label></th>
<td> <input name="location" id="location" type="text" value="{{result.location}}" class="form-control"></td>
</tr>
<tr>
<th><label for="address">地址</label></th>
<td> <input name="address" type="text" value="{{result.address}}" class="form-control"></td>
</tr>
<tr>
<th><label for="traffic">交通线路</label></th>
<td> <input name="traffic" type="text" value="{{result.traffic}}" class="form-control" style="width: 300px;"></td>
</tr>
<tr>
<th><label for="periphery">周边配套</label></th>
<td> <input name="periphery" type="text" value="{{result.periphery}}" class="form-control" style="width: 300px;"></td>
</tr>
</tbody>
</table>
</div>
</div>
<h2 class="title">关联信息</h2>
<div class="row">
<div class="col-md-12">
<table class="form-table">
<tbody>
<tr>
<th><label>房源相册</label></th>
<td>
<div id="picList">
{% set exists_photo_ids = "" %}
{% for item in images %}
{% if exists_photo_ids != "" %}
{% set exists_photo_ids = exists_photo_ids~"," %}
{% endif %}
{% set exists_photo_ids = exists_photo_ids~item.image_id %}
<p>
<input type="radio" name="frontCover" value="{{item.image_id}}" {{ result.frontCover_id == item.image_id?"checked":"" }} />
<select name="exists_photo[{{ item.image_id }}][type]">
{% for i in photoType %}
<option {{ i.id == item.image_type?"selected":"" }} value="{{ i.id }}">{{ i.value }}</option>
{% endfor %}
</select>
<img src="{{siteUrl}}{{item.path}}" heghit="100" width="100">
<input type="button" value="取消" class="cancel existsCancel">
</p>
{% endfor %}
<input type="hidden" name="exists_photo_ids" value="{{exists_photo_ids}}" >
</div><br />
<button type="button" id="housePicture" class="button action" data-toggle="modal">
新增
</button>
</td>
</tr>
<tr>
<th><label for="traffic">推荐房源</label></th>
<td>
<div id="houseImg">
{% for item in recommends %}
<p>
<img src="{{siteUrl}}{{item.path}}" height="100" width="100">
<input type="button" value="删除" class="imgCancel existsCancel">
<input type="hidden" name="data[recommend][]" value="{{item.id}}">
</p>
{% endfor %}
</div><br />
<button type="button" class="button action" data-toggle="modal" data-target="#myModal" id="recHouseBt">
添加房源
</button>
</td>
</tr>
<tr>
<th><label for="feature">房源特色</label></th>
<td>
<div id="feature">
{% for item in featureOld %}
<p>
<span>{{ item.name }}</span>
<input type="button" value="删除" class="featureCancel existsCancel">
<input type="hidden" name="data[houseFeature][]" value="{{item.tag_id}}">
</p>
{% endfor %}
</div><br/>
<button type="button" class="button action" data-toggle="modal" data-target="#houseFeature" id="featureBt">
添加特色
</button>
</td>
</tr>
<tr>
<th><label for="consultant">置业顾问</label></th>
<td>
<div id="consultantImg">
{% for item in consultant %}
<p>
<span>{{item.name}}</span>
<input type="button" value="删除" class="consultantCancel existsCancel">
<input type="hidden" name="data[recConsultant][]" value="{{item.id}}">
</p>
{% endfor %}
</div><br />
<button type="button" class="button action" data-toggle="modal" data-target="#myConsultant" id="recConsultantBt">
选择置业顾问
</button>
</td>
</tr>
{% if role == 'administrator' %}
<tr>
<th><label for="from">状态</label></th>
<td>
<select id="status" name="status">
{% for item in status %}
<option value={{item.id}}>{{item.value}}</option>
{% endfor %}
</select>
</td>
</tr>
{% endif %}
</tbody>
</table>
</div>
</div>
<input type="text" name="type" value="2" hidden="hidden">
{% if houseId %}
<input type="text" name="houseId" value="{{houseId}}" hidden="hidden">
{% endif %}
</div>
<div class="col-md-1">
<input type="submit" id="submit" class="button action">
</div>
</div>
</form>
<!-- Modal -->
<!-- 新增房源弹出层 -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-body" style="height: 300px;overflow: auto;">
<select id="cityId">
<option value="-1"> 城市</option>
{% for item in city %}
<option value="{{ item.id }}">{{ item.value }}</option>
{% endfor %}
</select>
<select id="areaId">
<option value = "-1">区域</option>
</select>
<select id="plateId">
<option value = "-1">板块</option>
</select>
<select id="price">
<option value = "-1">价格</option>
</select>
<select id="buildProperty">
<option value = "-1">房型</option>
{% for item in buildProperty %}
<option value="{{ item.id }}">{{ item.value }}</option>
{% endfor %}
</select>
<select id="room">
<option value = "-1">类型</option>
{% for item in room %}
<option value="{{ item.id }}">{{ item.value }}</option>
{% endfor %}
</select>
<select id="acreage">
<option value = "-1">面积</option>
</select>
<input type="text" placeholder="请出入楼盘名/地段名搜索" id="searchtext" class="form-control">
<button type="button" class="button action" id="search">搜索</button>
<ul id="houseList">
</ul>
</div>
</div>
</div>
</div>
<!-- 置业顾问弹出层 -->
<div class="modal fade" id="myConsultant" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-body" style="height: 300px;overflow: auto;">
<select id="consultCity">
<option value=""> 城市</option>
{% for item in city %}
<option value="{{ item.id }}">{{ item.value }}</option>
{% endfor %}
</select>
<input type="text" placeholder="请出入置业顾问姓名搜索" id="consultantName" class="form-control">
<button type="button" class="button action" id="searchConsult">搜索</button>
<ul id="consultantList">
</ul>
</div>
</div>
</div>
</div>
<!-- 房源特色出层 -->
<div class="modal fade" id="houseFeature" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<table class="form-table" id="featureTable">
<tbody>
<tr>
<th style="width: 45px"><label for="feature">特色:</label></th>
{% for item in feature %}
<td id="{{ item.id }}">{{ item.value }}</td>
{% endfor %}
</tr>
</tbody>
</table>
</div>
</div>
</div>
<script>
(function($){
$(document).ready(function(){
var titleFlag = 0;
//主力房源中选择图片file的下标
var i = 0;
//基本信息的联动AJAX
$("#baseCity").change(function(){
var cityId = $("#baseCity").val();
var baserArea = $("#baseAreaId");
$('#baseAreaId').find('option:not(:first-child)').remove();
$('#basePlateId').find('option:not(:first-child)').remove();
//城市联动区域
$.ajax({
type: "GET",
url: "/tospur/wp-admin/admin-ajax.php",
data: "action=serachCity&cityId="+cityId,
success:function(json){
addOption(json,baserArea);
}
});
});
//区域联动板块
$("#baseAreaId").change(function(){
var basePlate = $("#basePlateId");
var areaId = $("#baseAreaId").val();
var cityId = $("#baseCity").val();
$('#basePlateId').find('option:not(:first-child)').remove();
$.ajax({
type: "GET",
url: "/tospur/wp-admin/admin-ajax.php",
data: "action=serachCity&cityId="+cityId+"&districtId="+areaId,
success:function(json){
addOption(json,basePlate);
}
});
});
//根据上方选择的城市,选择推荐房源的默认城市
$("#recHouseBt").click(function(){
$('#cityId').find('option').remove();
$('#areaId').find('option:not(:first-child)').remove();
$('#plateId').find('option:not(:first-child)').remove();
$('#price').find('option:not(:first-child)').remove();
$('#acreage').find('option:not(:first-child)').remove();
$("#houseList").find("li").remove();
var acreage =$("#acreage");
var price = $("#price");
var area = $("#areaId");
var cityId = $("#baseCity").val();
var cityName = $("#baseCity").find("option:selected").text();
var option = $("<option>").attr("value",cityId).append(cityName);
$("#cityId").append(option);
if(cityId != -1){
$.ajax({
type: "GET",
url: "/tospur/wp-admin/admin-ajax.php",
data: "action=serachCity&cityId="+cityId,
success:function(json){
addOption(json,area);
}
});
//城市联动房子面积
$.ajax({
type: "GET",
url: "/tospur/wp-admin/admin-ajax.php",
data: "action=searchArea&cityId="+cityId,
success:function(json){
addOption(json,acreage);
}
});
//城市联动房子价格
$.ajax({
type: "GET",
url: "/tospur/wp-admin/admin-ajax.php",
data: "action=searchUnitPriceRange&cityId="+cityId,
success:function(json){
addOption(json,price);
}
});
addList(1)
}
});
//区域联动板块
$("#areaId").change(function(){
var areaId = $("#areaId").val();
var cityId = $("#cityId").val();
var plate = $("#plateId");
$("#houseList").find("li").remove();
$('#plateId').find('option:not(:first-child)').remove();
$.ajax({
type: "GET",
url: "/tospur/wp-admin/admin-ajax.php",
data: "action=serachCity&cityId="+cityId+"&districtId="+areaId,
success:function(json){
addOption(json,plate);
}
});
});
//推荐房源下显示图片信息以及房名
$("#areaId,#plateId,#buildProperty,#room,#acreage,#price").change(function(){
addList(1)
});
//添加房源中搜索框的搜索
$("#search").click(function(){
$searchtext = $("#searchtext").val();
$("#houseList").find("li").remove();
$.ajax({
type: "post",
url: "/tospur/wp-admin/admin-ajax.php",
data: "action=searchHouse&searchText="+$searchtext,
success:function(json){
var result = json.result;
for(var i = 0; i < result.length; i++){
var name = result[i]["name"];
var id = result[i]['id'];
var imgUrl = json.images[id];
var img = $("<img>").attr({"src":imgUrl,"height":100,"width":100});
var li = $("<li>").addClass("addImg").append(img).append(name);
$("#houseList").append(li);
}
}
});
})
//根据上方选择的城市,选择推荐置业顾问的默认城市
$("#recConsultantBt").click(function(){
$('#consultCity').find('option').remove();
$("#consultantList").find("li").remove();
var consulCityId = $("#baseCity").val();
var consultantName =$("#consultantName").val();
var cityName = $("#baseCity").find("option:selected").text();
var option = $("<option>").attr("value",consulCityId).append(cityName);
$("#consultCity").append(option);
$.ajax({
type: "GET",
url: "/tospur/wp-admin/admin-ajax.php",
data: "action=searchConsultant&consulCityId="+consulCityId+"&consultantName="+consultantName,
success:function(json){
for(var i = 0; i <=json.length-1; i++){
var name = json[i]["consultantName"];
var imgUrl = json[i]["imageUrl"];
var img = $("<img>").attr({"src":imgUrl,"height":100,"width":100});
var li = $("<li>").attr("id",json[i]["id"]).append(img).append(name).addClass("consultantImg");
$("#consultantList").append(li);
}
}
});
});
//添加置业顾问弹出层中搜索框的搜索内容
$("#searchConsult").click(function(){
var consulCityId = $("#consultCity").val();
var consultantName =$("#consultantName").val();
$("#consultantList").find("li").remove();
$.ajax({
type: "GET",
url: "/tospur/wp-admin/admin-ajax.php",
data: "action=searchConsultant&consulCityId="+consulCityId+"&consultantName="+consultantName,
success:function(json){
for(var i = 0; i <=json.length-1; i++){
var name = json[i]["consultantName"];
var imgUrl = json[i]["imageUrl"];
var img = $("<img>").attr({"src":imgUrl,"height":100,"width":100});
var li = $("<li>").append(img).append(name).addClass("consultantImg");
$("#consultantList").append(li);
}
}
});
})
//点击添加房源中显示的列表,在界面中显示
$("#houseList").on("click",".addImg",function(){
var recommendHouse = $("<input>").attr({"type":"hidden","name":"data[recommend][]","value": $(this).attr("id")});
var url = $(this).find("img").attr("src");
var img = $("<img>").attr({"src":url,"height":100,"width":100});
var cancel = $("<input>").attr({"type":"button","value":"删除"}).addClass("imgCancel");
var p = $("<p>").append(img).append(cancel).append(recommendHouse);
$("#houseImg").append(p);
controlCommand("houseImg",3,0);
});
//添加置业顾问
$("#consultantList").on("click",".consultantImg",function(){
var recommendConsultant = $("<input>").attr({"type":"hidden","name":"data[recConsultant][]","value": $(this).attr("id")});
var cancel = $("<input>").attr({"type":"button","value":"删除"}).addClass("consultantCancel");
var font = $("<font>").append( $(this).text());
var p = $("<p>").append(font).append(cancel).append(recommendConsultant);
$("#consultantImg").append(p);
controlCommand("consultantImg",1,1);
});
//新增房源相册
$("#housePicture").click(function(){
var checkBox = $("<input>").attr({"type":"radio","name":"frontCover","value":i});
var picDelet = $("<input>").attr({"type":"button","value":"删除"}).addClass("button action picDelet");
var file = $("<input>").attr({"type":"file","name":"files["+i+"]"}).addClass("picFiles");
var select = $("<select>").attr("name","data["+i+"][type]");
var checkTd = $("<th>").append(checkBox);
var picDeletTd = $("<td>").append(picDelet);
var selectTd = $("<th>").append(select);
var fileTd = $("<th>").append(file);
{% for item in photoType %}
select.append($("<option>").attr("value",{{item.id}}).append('{{item.value}}'));
{% endfor%}
var p = $("<p>").append(checkTd).append(selectTd).append(fileTd).append(picDeletTd);
var fontA = $("<font>").append("设为封面");
var fontB = $("<font>").append("类型");
var fontC = $("<font>").append("相册");
var tdA = $("<th>").append(fontA);
var tdB = $("<th>").append(fontB);
var tdC = $("<th>").append(fontC);
var titleP = $("<p>").append(tdA).append(tdB).append(tdC);
$("#picList").append(p);
if( titleFlag== 0){
$("#picList").before(titleP);
titleFlag = 1
}
i++
});
//显示选中的特色
$("#featureTable").find("tr > td").click(function(){
var houseFeature = $("<input>").attr({"type":"hidden","name":"data[houseFeature][]","value": $(this).attr("id")});
var cancel = $("<input>").attr({"type":"button","value":"删除"}).addClass("featureCancel");
var font = $("<font>").append( $(this).text());
var p =$("<p>").append(houseFeature).append(font).append(cancel);
$("#feature").append(p);
});
//房源相册
$("#picList").on("change",".picFiles",function(){
readURL(this,2);
$(this).hide();
});
//删除房源相册、推荐房源、推荐置业顾问
$("#houseImg,#consultantImg,#picList,#feature").on("click",".imgCancel,.consultantCancel,.picDelet,.featureCancel",function(){
$(this).parent("p").remove();
});
$("#picList,#houseImg,#consultantImg").on("click",".existsCancel",function(){
$(this).parent().remove();
});
$("#submit").click(function(){
if($("#housename").val()==""){
alert("请输入楼盘名");
return false;
}
});
//file上传之前,显示图片的方法
function readURL(input,type) {
if(type == 1){
if (input.files && input.files[0]){
var reader = new FileReader();
reader.onload = function (e) {
var img = $("<img>").attr({"id":"target","src":e.target.result,"heghit":100,"width":100});
var button = $("<input>").attr({"type":"button","value":"取消","property":+i,"id":+i}).addClass("cancel");
var type = $("<input>").attr({"type":"hidden","name":"data["+i+"][type]","value":0,"property":+i});
var file = $("<input>").attr({"type":"file","name":"files["+(i+1)+"]","property":+(i+1)}).addClass("files");
var select = $("<select>").attr({"name":"data["+i+"][buildProperty]"});
{% for item in buildProperty %}{{item.id}}
select.append($("<option>").attr("value",{{item.id}}).append('{{item.value}}'));
{% endfor%}
var areatext = $("<input>").attr({"type":"text","placeholder":"面积","name":"data["+i+"][housearea]"}).addClass("form-control");
var div = $("<div>").append(select).append(areatext).append(button).append(type);
var span = $("<span>").attr({"property":+i}).append(img).append(div);
$("form").find("#preview > p").before(file);
$("#preview > p").append(span);
i++;
}
}
}else{
if (input.files && input.files[0]){
var reader = new FileReader();
reader.onload = function (e){
var img = $("<img>").attr({"src":e.target.result,"heghit":100,"width":100});
$(input).before(img);
}
}
}
reader.readAsDataURL(input.files[0]);
}
function addOption(json,select){
var selectId = select.attr("id");
for(var i = 0; i <=json.length-1; i++){
var id = json[i]["id"];
var value = json[i]["value"];
if(selectId == "acreage" || selectId == "price"){
id = value;
}
var Option = $("<option>").attr({"value": id}).append(value);
select.append(Option);
}
}
function controlCommand(id,number,type){
var num = $("#"+id+" > p").length;
if(num>number){
if(type==0){
alert("最多只能推荐3个房源");
}else if(type==1){
alert("您只能推荐一位置业顾问");
}
$("#"+id).find("p:last-child").remove();
}
}
function getUrlParmas(){
var href = location.search.substr(1,location.search.length-1);
var params = href.split("&");
var map = {};
for(item in params){
var key = params[item].split("=")[0] || "";
var value = params[item].split("=")[1] || "";
map[key] = value;
}
return map;
}
function addList(houseType){
$("#houseList").find("li").remove();
var cityId = $("#baseCity").val();
var buildPropertyId = $("#buildProperty").val();
var room = $("#room").val();
var areaId = $("#areaId").val();
var cityId = $("#cityId").val();
var plateId = $("#plateId").val();
var acreage = $("#acreage").val();
var price = $("#price").val();
$.ajax({
type: "post",
url: "/tospur/wp-admin/admin-ajax.php",
data: "action=searchHouse&cityId="+cityId+"&districtId="+areaId+"&plateId="+plateId+"&buildPropertyId="+buildPropertyId+"&roomId="+room+"&acreage="+acreage+"&totalPrice="+price+"&houseType="+houseType,
success:function(json){
var result = json.result;
var urlParams = getUrlParmas();
for(var i = 0; i <result.length; i++){
var name = result[i]["name"];
var id = result[i]['id'];
var imgUrl = result[i]['path'];
var img = $("<img>").attr({"src":imgUrl,"height":100,"width":100});
var li = $("<li>").attr("id",id).addClass("addImg").append(img).append(name);
if(urlParams["id"]){
if(urlParams["id"]!=id){
$("#houseList").append(li);
}
}else{
$("#houseList").append(li);
}
}
}
});
}
});
})(jQuery);
</script>
</body>
<!DOCTYPE HTML>
<html>
<head>
{% set title = houseId?"修改二手房房源":"添加二手房房源" %}
<meta charset="utf-8">
<title>{{title}}</title>
</head>
<body>
<h2 class="title">{{title}}</h2>
<form action="" method="POST" enctype="multipart/form-data" id="secHouse">
<div class="row">
<div class="col-md-11">
<div class="row">
<div class="col-md-3">
<label for="housename">房源名:</label>
<input name="housename" id="housename" type="text" value="{{result.name}}" class="form-control" >
</div>
<div class="col-md-3">
<label for="address">小区名称:</label>
<input name="community_name" type="text" value="{{result.community_name}}" class="form-control">
</div>
<div class="col-md-3">
<label for="total_price">售价:</label>
<div class="row">
<p>
<input name="total_price" id="total_price" type="text" value="{{result.total_price}}" class="form-control" style="width:80%;display: inline-block"> 万元
</p>
</div>
</div>
<div class="col-md-3">
<label for="average_price">单价:</label>
<p>
<input name="average_price" id="average_price" type="text" value="{{result.average_price}}" class="form-control" style="width:80%;display: inline-block">
</p>
</div>
</div><br>
<div class="row">
<div class="col-md-6">
<label for="mark">标签:</label>
<input name="mark" id="mark" type="text" value="{{mark}}" class="form-control">
</div>
</div><br>
<div class="row">
{% if not houseId %}
<div class="col-md-4">
<label for="owner_name">业主姓名:</label>
<input name="owner_name" id="owner_name" type="text" value="" class="form-control">
</div>
<div class="col-md-4">
<label for="owner_phone">业主电话:</label>
<input name="owner_phone" id="owner_phone" type="text" value="" class="form-control">
</div>
{% endif %}
</div><br>
<h2 class="title">基本信息</h2>
<div class="row">
<div class="col-md-12">
<label for="suite">门牌号码:</label></th>
<input name="suite" type="text" value="{{result.suite}}"style="width: 10%">
&nbsp;
<label for="floor">楼层:</label>
<input name="floor" type="text" value="{{result.floor}}" style="width: 5%">
&nbsp;
<label for="totalFloor">总层:</label>
<input type="text" name="totalFloor"value="{{result.totalFloor}}" style="width: 5%">
&nbsp;
<label for="faceto">朝向:</label>
<select name="faceto">
<option value="其他">其他</option>
<option value="东"></option>
<option value="南"></option>
<option value="西">西</option>
<option value="北"></option>
<option value="东西">东西</option>
<option value="南北">南北</option>
<option value="南南">南南</option>
<option value="东南">东南</option>
<option value="东北">东北</option>
<option value="西南">西南</option>
<option value="西北">西北</option>
</select>
&nbsp;
<label for="age">建筑年代:</label>
<!--<input name="age" type="text" value="{{result.age}}" class="form-control">-->
<select name="age">
<option>未知</option>
{% for item in age%}
<option {{ item == result.age?"selected":"" }}value="{{item}}">{{item}}</option>
{% endfor %}
</select>
&nbsp;
<label for="propertyRight">产权:</label>
<select name="propertyRight">
<option value="个人产权">个人产权</option>
<option value="单位产权">单位产权</option>
<option value="售后产权">售后产权</option>
<option value="家庭成员共有">家庭成员共有</option>
<option value="使用权">使用权</option>
<option value="小产权">小产权</option>
<option value="协议房">协议房</option>
<option value="私产">私产</option>
<option value="公产">公产</option>
<option value="合同发票">合同发票</option>
<option value="三联单">三联单</option>
<option value="其他">其他</option>
</select>
</div>
</div><br>
<div class="row">
<div class="col-md-12">
<label for="propertyProof">产证:</label>
<input type="text" name="propertyProof" value="{{result.propertyProof}}">
&nbsp;
<label for="decoration">装修状况:</label>
<select name="decoration">
<option value="毛坯">毛坯</option>
<option value="简单装修">简单装修</option>
<option value="中等装修">中等装修</option>
<option value="精装修">精装修</option>
<option value="豪华装修">豪华装修</option>
</select>
&nbsp;
<label for="useArea">使用面积:</label>
<input type="text" name="useArea" value="{{result.useArea}}" style="width: 10%;display: inline-block">平方米
&nbsp;
<label for="covered_area">建筑面积:</label>
<input name="covered_area" type="text" value="{{result.covered_area}}" style="width:10%;display: inline-block">平方米
&nbsp;
<input type="checkbox" id="keyCheck" {{ result.key?"checked":"" }}> <label for="key">钥匙:</label><input type="text" {% if not result.key %} disabled="true" {% endif %} id="key" name="key" value="{{result.key}}" style="width: 10%">
</div>
</div><br>
<div class="row">
<div class="col-md-12">
<input type="checkbox" id="garageCheck" {{ result.garage?"checked":"" }}> <label for="garage">车库:</label><input type="text" {% if not result.garage %}disabled="true"{% endif %} id="garage" name="garage" value="{{result.garage}}" style="width: 10%">
&nbsp;
<label for="street">街道:</label>
<input type="text" name="street" value="{{result.street}}">
&nbsp;
<label for="flat">楼号:</label>
<input name="flat" type="text" value="{{result.flat}}" style="width: 10%;">
&nbsp;
<label for="matching_facilities">设施:</label>
<input type="text" name="matching_facilities" value="{{result.matching_facilities}}">
&nbsp;
<label for="structure">结构:</label>
<select name="structure">
<option value="其他">其他</option>
<option value="框架">框架</option>
<option value="砖混">砖混</option>
<option value="剪力">剪力</option>
<option value="钢混">钢混</option>
<option value="木混">木混</option>
<option value="砖木">砖木</option>
</select>
</div>
</div><br>
<div class="row">
<div class="col-md-12">
<label for="from">户型:</label>
<select id="buildproperty_id" name="buildproperty_id">
{% for item in buildProperty %}
<option {{ item.id == result.buildproperty_id?"selected":"" }} value="{{ item.id }}">{{ item.value }}</option>
{% endfor %}
</select>
<label for="roomNum">室:</label>
<select name="roomNum">
<option value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
</select>
<label for="livingRoom">厅:</label>
<select name="livingRoom">
<option value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
</select>
<label for="bathRoom">卫:</label>
<select name="bathRoom">
<option value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
</select>
<label for="kitchen">厨:</label>
<select name="kitchen">
<option value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
</select>
<label for="balcony">阳台:</label>
<select name="balcony">
<option value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
</select>
</div>
</div><br>
<div class="row">
<div class="col-md-12">
<label for="overview">房源点评:</label>
<textarea name="overview" rows="4" cols="40" class="form-control" >{{result.overview}}</textarea>
</div>
</div><br>
<h2 class="title">位置及周边</h2>
<div class="row">
<div class="col-md-4">
<label for="from">所属地区:</label>
<div class="row">
<div class="col-md-3">
<select id="baseCity" name="baseCity" class="required">
<option value="-1"> 城市</option>
{% for item in city %}
<option {{ item.id == result.city_id?"selected":"" }} value="{{ item.id }}">{{ item.value }}</option>
{% endfor %}
</select>
</div>
<div class="col-md-3">
<select id="baseAreaId" name="baseAreaId">
<option value = "-1">区域</option>
{% if district %}
{% for item in district %}
<option {{ item.id == result.district_id?"selected":"" }} value="{{ item.id }}">{{ item.value }}</option>
{% endfor %}
{% endif %}
</select>
</div>
<div class="col-md-3">
<select id="basePlateId" name="basePlateId">
<option value = "-1">板块</option>
{% if district %}
{% for item in plate %}
<option {{ item.id == result.plate_id?"selected":"" }} value="{{ item.id }}">{{ item.value }}</option>
{% endfor %}
{% endif %}
</select>
</div>
</div>
</div>
<div class="col-md-4">
<label for="address">地址:</label>
<input name="address" type="text" value="{{result.address}}" class="form-control">
</div>
<div class="col-md-4">
<label for="traffic">交通线路:</label>
<input name="traffic" type="text" value="{{result.traffic}}" class="form-control">
</div>
</div><br>
<div class="row">
<div class="col-md-4">
<label for="periphery">周边配套:</label>
<input name="periphery" type="text" value="{{result.periphery}}" class="form-control">
</div>
<div class="col-md-4">
<label for="location">地域坐标:</label>
<input name="location" id="location" type="text" value="{{result.location}}" class="form-control">
</div>
</div><br>
<h2 class="title">关联信息</h2>
<table class="form-table">
<tbody>
<tr>
<th><label>房源相册:</label></th>
<td>
{% if houseId %}
<div class="row">
<div class="col-md-3">
<font>类型</font>
</div>
<div class="col-md-3">
<font>相册</font>
</div>
<div class="col-md-3">
<font>设为封面</font>
</div>
</div>
{% endif %}
<div id="picList">
{% set exists_photo_ids = "" %}
{% for item in images %}
{% if exists_photo_ids != "" %}
{% set exists_photo_ids = exists_photo_ids~"," %}
{% endif %}
{% set exists_photo_ids = exists_photo_ids~item.image_id %}
<div class="row">
<div class="col-md-3">
<select name="exists_photo[{{ item.image_id }}][type]" style="margin-right: 50px">
{% for i in photoType %}
<option {{ i.id == item.image_type?"selected":"" }} value="{{ i.id }}">{{ i.value }}</option>
{% endfor %}
</select>
</div>
<div class="col-md-3">
<img src="{{siteUrl}}{{item.path}}" height="90" width="140" style="margin-right: 50px">
</div>
<div class="col-md-3">
<input type="radio" name="frontCover" style="margin-right: 50px" value="{{item.image_id}}" {{ result.frontCover_id == item.image_id?"checked":"" }} />
</div>
<div class="col-md-2">
<input type="button" value="删除" class="button action cancel existsCancel">
</div>
</div>
{% endfor %}
<input type="hidden" name="exists_photo_ids" value="{{exists_photo_ids}}" >
</div>
<button type="button" id="housePicture" class="button action" data-toggle="modal" style="margin-top: 10px">
新增
</button>
</td>
</tr>
<tr>
<th><label for="traffic">推荐房源</label></th>
<td>
<div id="houseImg">
{% for item in recommends %}
<p>
<img src="{{siteUrl}}{{item.path}}" height="90" width="140" style="margin-right: 50px">
<input type="button" value="删除" class="button action imgCancel existsCancel">
<input type="hidden" name="data[recommend][]" value="{{item.id}}">
</p>
{% endfor %}
</div><br />
<button type="button" class="button action" data-toggle="modal" data-target="#myModal" id="recHouseBt">
添加房源
</button>
</td>
</tr>
<tr>
<th><label for="feature">房源特色</label></th>
<td>
<div id="feature">
{% for item in featureOld %}
<p>
<span style="margin-right:50px">{{ item.name }}</span>
<input type="button" value="删除" class="button action featureCancel existsCancel">
<input type="hidden" name="data[houseFeature][]" value="{{item.tag_id}}">
</p>
{% endfor %}
</div><br/>
<button type="button" class="button action" data-toggle="modal" data-target="#houseFeature" id="featureBt">
添加特色
</button>
</td>
</tr>
<tr>
<th><label for="periphery">置业顾问</label></th>
<td>
<div id="consultantImg">
{% for item in consultant %}
<p>
<img src="{{item.imageUrl}}" height="100" width="100" style="margin-right: 50px">
<span style="margin-right: 50px">{{item.name}}</span>
<input type="button" value="删除" class="button action consultantCancel existsCancel">
<input type="hidden" name="data[recConsultant][]" value="{{item.id}}">
</p>
{% endfor %}
</div><br />
<button type="button" class="button action" data-toggle="modal" data-target="#myConsultant" id="recConsultantBt">
选择置业顾问
</button>
</td>
</tr>
</tbody>
</table>
<div>
</div>
<input type="text" name="type" value="2" hidden="hidden">
{% if houseId %}
<input type="text" name="houseId" value="{{houseId}}" hidden="hidden">
{% endif %}
</div>
<div class="col-md-1">
<input type="submit" id="submit" class="button action" style="position: fixed;">
{% if role == 'administrator' %}
<div class="row" style="position: fixed;top:50px;">
<select id="status" name="status">
{% for item in status %}
<option {{ item.id == searchStatus.id?"selected":"" }} value={{item.id}}>{{item.value}}</option>
{% endfor %}
</select>
</div>
{% endif %}
</div>
</div>
</form>
<!-- Modal -->
<!-- 新增房源弹出层 -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-body" style="height: 300px;overflow: auto;">
<select id="cityId">
<option value="-1"> 城市</option>
{% for item in city %}
<option value="{{ item.id }}">{{ item.value }}</option>
{% endfor %}
</select>
<select id="areaId">
<option value = "-1">区域</option>
</select>
<select id="plateId">
<option value = "-1">板块</option>
</select>
<select id="price">
<option value = "-1">价格</option>
</select>
<select id="buildProperty">
<option value = "-1">房型</option>
{% for item in buildProperty %}
<option value="{{ item.id }}">{{ item.value }}</option>
{% endfor %}
</select>
<select id="room">
<option value = "-1">类型</option>
{% for item in room %}
<option value="{{ item.id }}">{{ item.value }}</option>
{% endfor %}
</select>
<select id="acreage">
<option value = "-1">面积</option>
</select>
<input type="text" placeholder="请出入楼盘名/地段名搜索" id="searchtext" class="form-control">
<button type="button" class="button action" id="search">搜索</button>
<ul id="houseList">
</ul>
</div>
</div>
</div>
</div>
<!-- 置业顾问弹出层 -->
<div class="modal fade" id="myConsultant" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-body" style="height: 300px;overflow: auto;">
<select id="consultCity">
<option value=""> 城市</option>
{% for item in city %}
<option value="{{ item.id }}">{{ item.value }}</option>
{% endfor %}
</select>
<input type="text" placeholder="请出入置业顾问姓名搜索" id="consultantName" class="form-control">
<button type="button" class="button action" id="searchConsult">搜索</button>
<ul id="consultantList">
</ul>
</div>
</div>
</div>
</div>
<!-- 房源特色出层 -->
<div class="modal fade" id="houseFeature" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div id="featureTable">
<div class="row">
<div class="col-md-2">
<label for="feature">特色:</label>
</div>
<div class="col-md-10" id="featureList">
{% for item in feature %}
<div id="{{ item.id }}">{{ item.value }}</div>
{% endfor %}
</div>
</div>
</div>
</div>
</div>
</div>
<script>
(function($){
$(document).ready(function(){
var titleFlag = 0;
//主力房源中选择图片file的下标
var i = 0;
//基本信息的联动AJAX
$("#baseCity").change(function(){
var cityId = $("#baseCity").val();
var baserArea = $("#baseAreaId");
$('#baseAreaId').find('option:not(:first-child)').remove();
$('#basePlateId').find('option:not(:first-child)').remove();
//城市联动区域
$.ajax({
type: "GET",
url: "/tospur/wp-admin/admin-ajax.php",
data: "action=serachCity&cityId="+cityId,
success:function(json){
addOption(json,baserArea);
}
});
});
//区域联动板块
$("#baseAreaId").change(function(){
var basePlate = $("#basePlateId");
var areaId = $("#baseAreaId").val();
var cityId = $("#baseCity").val();
$('#basePlateId').find('option:not(:first-child)').remove();
$.ajax({
type: "GET",
url: "/tospur/wp-admin/admin-ajax.php",
data: "action=serachCity&cityId="+cityId+"&districtId="+areaId,
success:function(json){
addOption(json,basePlate);
}
});
});
//根据上方选择的城市,选择推荐房源的默认城市
$("#recHouseBt").click(function(){
$('#cityId').find('option').remove();
$('#areaId').find('option:not(:first-child)').remove();
$('#plateId').find('option:not(:first-child)').remove();
$('#price').find('option:not(:first-child)').remove();
$('#acreage').find('option:not(:first-child)').remove();
$("#houseList").find("li").remove();
var acreage =$("#acreage");
var price = $("#price");
var area = $("#areaId");
var cityId = $("#baseCity").val();
var cityName = $("#baseCity").find("option:selected").text();
var option = $("<option>").attr("value",cityId).append(cityName);
$("#cityId").append(option);
if(cityId != -1){
$.ajax({
type: "GET",
url: "/tospur/wp-admin/admin-ajax.php",
data: "action=serachCity&cityId="+cityId,
success:function(json){
addOption(json,area);
}
});
//城市联动房子面积
$.ajax({
type: "GET",
url: "/tospur/wp-admin/admin-ajax.php",
data: "action=searchArea&cityId="+cityId,
success:function(json){
addOption(json,acreage);
}
});
//城市联动房子价格
$.ajax({
type: "GET",
url: "/tospur/wp-admin/admin-ajax.php",
data: "action=searchUnitPriceRange&cityId="+cityId,
success:function(json){
addOption(json,price);
}
});
addList(1)
}
});
//区域联动板块
$("#areaId").change(function(){
var areaId = $("#areaId").val();
var cityId = $("#cityId").val();
var plate = $("#plateId");
$("#houseList").find("li").remove();
$('#plateId').find('option:not(:first-child)').remove();
$.ajax({
type: "GET",
url: "/tospur/wp-admin/admin-ajax.php",
data: "action=serachCity&cityId="+cityId+"&districtId="+areaId,
success:function(json){
addOption(json,plate);
}
});
});
//推荐房源下显示图片信息以及房名
$("#areaId,#plateId,#buildProperty,#room,#acreage,#price").change(function(){
addList(1)
});
//添加房源中搜索框的搜索
$("#search").click(function(){
$searchtext = $("#searchtext").val();
$("#houseList").find("li").remove();
$.ajax({
type: "post",
url: "/tospur/wp-admin/admin-ajax.php",
data: "action=searchHouse&searchText="+$searchtext,
success:function(json){
var result = json.result;
for(var i = 0; i < result.length; i++){
var name = result[i]["name"];
var id = result[i]['id'];
var imgUrl = json.images[id];
var img = $("<img>").attr({"src":imgUrl,"height":90,"width":140,"style":"margin-right:50px"});
var li = $("<li>").addClass("addImg").append(img).append(name);
$("#houseList").append(li);
}
}
});
})
//根据上方选择的城市,选择推荐置业顾问的默认城市
$("#recConsultantBt").click(function(){
$('#consultCity').find('option').remove();
$("#consultantList").find("li").remove();
var consulCityId = $("#baseCity").val();
var consultantName =$("#consultantName").val();
var cityName = $("#baseCity").find("option:selected").text();
var option = $("<option>").attr("value",consulCityId).append(cityName);
$("#consultCity").append(option);
$.ajax({
type: "GET",
url: "/tospur/wp-admin/admin-ajax.php",
data: "action=searchConsultant&consulCityId="+consulCityId+"&consultantName="+consultantName,
success:function(json){
for(var i = 0; i <=json.length-1; i++){
var name = json[i]["consultantName"];
var imgUrl = json[i]["imageUrl"];
var img = $("<img>").attr({"src":imgUrl,"height":90,"width":140,"style":"margin-right:50px"});
var li = $("<li>").attr("id",json[i]["id"]).append(img).append(name).addClass("consultantImg");
$("#consultantList").append(li);
}
}
});
});
//添加置业顾问弹出层中搜索框的搜索内容
$("#searchConsult").click(function(){
var consulCityId = $("#consultCity").val();
var consultantName =$("#consultantName").val();
$("#consultantList").find("li").remove();
$.ajax({
type: "GET",
url: "/tospur/wp-admin/admin-ajax.php",
data: "action=searchConsultant&consulCityId="+consulCityId+"&consultantName="+consultantName,
success:function(json){
for(var i = 0; i <=json.length-1; i++){
var name = json[i]["consultantName"];
var imgUrl = json[i]["imageUrl"];
var img = $("<img>").attr({"src":imgUrl,"height":100,"width":100,"style":"margin-right:50px"});
var li = $("<li>").attr("id",json[i]["id"]).append(img).append(name).addClass("consultantImg");
$("#consultantList").append(li);
}
}
});
})
//点击添加房源中显示的列表,在界面中显示
$("#houseList").on("click",".addImg",function(){
var recommendHouse = $("<input>").attr({"type":"hidden","name":"data[recommend][]","value": $(this).attr("id")});
var url = $(this).find("img").attr("src");
var img = $("<img>").attr({"src":url,"height":90,"width":140,"style":"margin-right:50px"});
var cancel = $("<input>").attr({"type":"button","value":"删除"}).addClass("button action imgCancel");
var p = $("<p>").append(img).append(cancel).append(recommendHouse);
$("#houseImg").append(p);
controlCommand("houseImg",3,0);
});
//添加置业顾问
$("#consultantList").on("click",".consultantImg",function(){
var url = $(this).find("img").attr("src");
var img = $("<img>").attr({"src":url,"height":100,"width":100,"style":"margin-right:50px"});
var recommendConsultant = $("<input>").attr({"type":"hidden","name":"data[recConsultant][]","value": $(this).attr("id")});
var cancel = $("<input>").attr({"type":"button","value":"删除"}).addClass("button action consultantCancel");
var font = $("<font>").attr("style","margin-right:50px").append( $(this).text());
var p = $("<p>").append(img).append(font).append(cancel).append(recommendConsultant);
$("#consultantImg").append(p);
controlCommand("consultantImg",1,1);
});
//新增房源相册
$("#housePicture").click(function(){
var radio = $("<input>").attr({"type":"radio","name":"frontCover","value":i,});
var picDelet = $("<input>").attr({"type":"button","value":"删除"}).addClass("button action existsCancel");
var file = $("<input>").attr({"type":"file","name":"files["+i+"]"}).addClass("picFiles");
var select = $("<select>").attr({"name":"data["+i+"][type]"});
var dicRadio = $("<div>").append(radio).addClass("col-md-3");
var dicPicDelet = $("<div>").append(picDelet).addClass("col-md-2");
var dicFile = $("<div>").append(file).addClass("col-md-3");
var dicSelect = $("<div>").append(select).addClass("col-md-3");
var div = $("<div>").append(dicSelect).append(dicFile).append(dicRadio).append(dicPicDelet).addClass("row");
{% for item in photoType %}
select.append($("<option>").attr("value",{{item.id}}).append('{{item.value}}'));
{% endfor%}
var p = $("<p>").append(div);
var fontA = $("<div>").append("<font>").append("设为封面").addClass("col-md-3");
var fontB = $("<div>").append("<font>").append("类型").addClass("col-md-3");
var fontC = $("<div>").append("<font>").append("相册").addClass("col-md-3");
var titleP = $("<div>").append(fontB).append(fontC).append(fontA).addClass("row");
$("#picList").append(p);
var url = getUrlParmas();
if(!url.id){
if( titleFlag== 0){
$("#picList").before(titleP);
titleFlag = 1
}
}
i++
});
//显示选中的特色
$("#featureTable").find("#featureList > div").click(function(){
var houseFeature = $("<input>").attr({"type":"hidden","name":"data[houseFeature][]","value": $(this).attr("id")});
var cancel = $("<input>").attr({"type":"button","value":"删除"}).addClass("button action featureCancel");
var font = $("<font>").attr("style","margin-right:50px").append( $(this).text());
var p =$("<p>").append(houseFeature).append(font).append(cancel);
$("#feature").append(p);
});
//房源相册
$("#picList").on("change",".picFiles",function(){
readURL(this,2);
$(this).hide();
});
//删除房源相册、推荐房源、推荐置业顾问
$("#houseImg,#consultantImg,#feature").on("click",".imgCancel,.consultantCancel,.picDelet,.featureCancel",function(){
$(this).parents("p").remove();
});
$("#houseImg,#consultantImg").on("click",".existsCancel",function(){
$(this).parent().remove();
});
$("#picList").on("click",".existsCancel",function(){
$(this).parent().parent().remove();
});
$("input[id='keyCheck']").change(function(){
textDisable("keyCheck","key");
});
$("input[id='garageCheck']").change(function(){
textDisable("garageCheck","garage");
});
$('#secHouse').validate({
onkeyup: false,
onfocusout: false,
errorClass: "my-error-class",
rules: {
housename:'required',
mark:'required',
owner_name:'required',
owner_phone:'required',
total_price:'required',
community_name:'required',
average_price:'required',
latest_news:'required',
baseCity:{
selectcheck: true
},
baseAreaId:{
selectcheck: true
},
basePlateId:{
selectcheck: true
}
},
messages: {
housename:'请输入房源名称',
mark:'请输入标签',
owner_name:'请输入业主姓名',
owner_phone:'请输入业主电话',
total_price:'请输入售价',
community_name:'请输入小区名称',
average_price:'请输入单价'
},
errorLabelContainer: "#notice",
errorElement: 'div',
submitHandler: function (form) {
if ($("#feature > p").length == 0){
alert("请选择房源特色");
}else if($("#consultantImg > p").length == 0 ){
alert("请选择置业顾问");
}else{
form.submit();
}
}
});
jQuery.validator.addMethod('selectcheck', function (value) {
return (value != '-1');
},"请选择城市区域");
$("form").find("select[name='faceto']").val("{{result.faceto}}");
$("form").find("select[name='age']").val("{{result.age}}");
$("form").find("select[name='propertyRight']").val("{{result.propertyRight}}");
$("form").find("select[name='decoration']").val("{{result.decoration}}");
$("form").find("select[name='source']").val("{{result.source}}");
$("form").find("select[name='structure']").val("{{result.structure}}");
$("form").find("select[name='roomNum']").val("{{result.roomNum}}");
$("form").find("select[name='livingRoom']").val("{{result.livingRoom}}");
$("form").find("select[name='bathRoom']").val("{{result.bathRoom}}");
$("form").find("select[name='kitchen']").val("{{result.kitchen}}");
$("form").find("select[name='balcony']").val("{{result.balcony}}");
function textDisable(checkId,textId){
if($('input[id="'+checkId+'"]:checked').length > 0){
$("#"+textId).removeAttr("disabled");
}else{
$("#"+textId).attr("disabled","true");
}
}
//file上传之前,显示图片的方法
function readURL(input,type) {
if(type == 1){
if (input.files && input.files[0]){
var reader = new FileReader();
reader.onload = function (e) {
var img = $("<img>").attr({"id":"target","src":e.target.result,"heghit":140,"width":90,"style":"margin-right:50px;margin-top:10px"});
var button = $("<input>").attr({"type":"button","value":"取消","property":+i,"id":+i}).addClass("button action cancel");
var type = $("<input>").attr({"type":"hidden","name":"data["+i+"][type]","value":4,"property":+i});
var mainHousePic = $("<input>").attr({"type":"hidden","name":"data["+i+"][mainHouse]","value":0,"property":+i});
var file = $("<input>").attr({"type":"file","name":"files["+(i+1)+"]","property":+(i+1)}).addClass("files");
var select = $("<select>").attr({"name":"data["+i+"][buildProperty]","style":"margin-right:50px"});
{% for item in buildProperty %}{{item.id}}
select.append($("<option>").attr("value",{{item.id}}).append('{{item.value}}'));
{% endfor%}
var areatext = $("<input>").attr({"type":"text","placeholder":"面积","name":"data["+i+"][housearea]","style":"width: 100px;display:inline-block;margin-right:50px"}).addClass("form-control");
var div = $("<div>").attr({"property":+i}).append(img).append(select).append(areatext).append(button).append(type).append(mainHousePic).addClass("row");
$("form").find("#preview > p").after(file);
$("#preview > p").append(div);
i++;
}
}
}else{
if (input.files && input.files[0]){
var reader = new FileReader();
reader.onload = function (e){
var img = $("<img>").attr({"src":e.target.result,"heghit":90,"width":140});
$(input).before(img);
}
}
}
reader.readAsDataURL(input.files[0]);
}
function addOption(json,select){
var selectId = select.attr("id");
for(var i = 0; i <=json.length-1; i++){
var id = json[i]["id"];
var value = json[i]["value"];
if(selectId == "acreage" || selectId == "price"){
id = value;
}
var Option = $("<option>").attr({"value": id}).append(value);
select.append(Option);
}
}
function controlCommand(id,number,type){
var num = $("#"+id+" > p").length;
if(num>number){
if(type==0){
alert("最多只能推荐3个房源");
}else if(type==1){
alert("您只能推荐一位置业顾问");
}
$("#"+id).find("p:last-child").remove();
}
}
function getUrlParmas(){
var href = location.search.substr(1,location.search.length-1);
var params = href.split("&");
var map = {};
for(item in params){
var key = params[item].split("=")[0] || "";
var value = params[item].split("=")[1] || "";
map[key] = value;
}
return map;
}
function addList(houseType){
$("#houseList").find("li").remove();
var cityId = $("#baseCity").val();
var buildPropertyId = $("#buildProperty").val();
var room = $("#room").val();
var areaId = $("#areaId").val();
var cityId = $("#cityId").val();
var plateId = $("#plateId").val();
var acreage = $("#acreage").val();
var price = $("#price").val();
$.ajax({
type: "post",
url: "/tospur/wp-admin/admin-ajax.php",
data: "action=searchHouse&cityId="+cityId+"&districtId="+areaId+"&plateId="+plateId+"&buildPropertyId="+buildPropertyId+"&roomId="+room+"&acreage="+acreage+"&totalPrice="+price+"&houseType="+houseType,
success:function(json){
var result = json.result;
var urlParams = getUrlParmas();
for(var i = 0; i <result.length; i++){
var name = result[i]["name"];
var id = result[i]['id'];
var imgUrl = result[i]['path'];
var img = $("<img>").attr({"src":imgUrl,"height":90,"width":140,"style":"margin-right:50px"});
var li = $("<li>").attr("id",id).addClass("addImg").append(img).append(name);
if(urlParams["id"]){
if(urlParams["id"]!=id){
$("#houseList").append(li);
}
}else{
$("#houseList").append(li);
}
}
}
});
}
});
})(jQuery);
</script>
</body>
</html>
\ No newline at end of file
......@@ -23,6 +23,7 @@ class Config {
const TOSPUR_TAG_TABLE = 'tospur_tag';
const TOSPUR_VIEW_HOUSE_TABLE = 'tospur_view_house';
const TOSPUR_VERIFY_TABLE = 'tospur_verify';
const TOSPUR_SALE_TABLE = 'tospur_sale';
const WP_USERS_TABLE = 'wp_users';
......
......@@ -115,7 +115,7 @@ class InsertDao{
}
//房源类型、面积与图片关联表
if($data[$key]["type"] == "0"){
if($data[$key]["mainHouse"] == "0"){
$houseTypeArea = array(
'house_id' => $houseId,
"buildproperty_id" => $data["$key"]["buildProperty"],
......
......@@ -387,6 +387,7 @@ class SearchDao
LEFT JOIN ".Config::TOSPUR_IMAGE_TABLE." ti on ti.id = ada.image_id
where ada.house_id = %d";
$mainImage = $wpdb->get_results($wpdb->prepare($mainImagesSql,$hid));
foreach($mainImage as $key => $value){
$value->path = Image::getImage($value->path,'big');
}
......@@ -461,4 +462,28 @@ class SearchDao
return $results;
}
public static function searchFeatureOld($hid){
global $wpdb;
$featureSql ="select tag_id,name from a_house_tag aht
LEFT JOIN (select id as tid,name ,type from tospur_tag) tt on aht.tag_id = tt.tid where aht.house_id = %d and type = 1";
$feature = $wpdb->get_results($wpdb->prepare($featureSql,$hid));
return $feature;
}
public static function searchStatus($hid,$statusType){
global $wpdb;
$statusSql = "select status_id as id from tospur_house th
left join(select status_type,status_id,status_name from tospur_status) ts on th.status = ts.status_id where th.id=".$hid." and status_type=".$statusType;
$status = $wpdb->get_row($statusSql);
return $status;
}
public static function searchRent($hid){
global $wpdb;
$rentSql = "select rent as value from tospur_house where id = %d";
$results = $wpdb->get_row($wpdb->prepare($rentSql,$hid));
return $results;
}
}
\ No newline at end of file
<?php
require_once(PLUGIN_DIR . 'Config.php');
class TospurDao
{
//insert 预约看房
public static function insert_view_house($house_id, $user_id, $date, $index, $time, $consultant_id)
{
$insert_view_house_array = array(
'house_id' => $house_id,
'user_id' => $user_id,
'date' => $date,
'time_index' => $index,
'time' => $time,
'consultant_id' => $consultant_id,
'handle' => 0
);
global $wpdb;
$result = $wpdb->insert(Config::TOSPUR_VIEW_HOUSE_TABLE, $insert_view_house_array);
return $result;
}
public static function update_view_house($id)
{
global $wpdb;
$result = $wpdb->update(Config::TOSPUR_VIEW_HOUSE_TABLE, array(
'handle' => 1,
'handle_date' => current_time('Y-m-d H:i:s')
), array(
'id' => $id
));
return $result;
}
public static function update_view_house_consultant($house_id, $consultant_id)
{
global $wpdb;
$result = $wpdb->update(Config::TOSPUR_VIEW_HOUSE_TABLE, array(
'consultant_id' => $consultant_id
), array(
'id' => $house_id
));
return $result;
}
//search 预约看房 user_id
public static function search_view_house_by_user_id($user_id)
{
global $wpdb;
$sql = 'select v.house_id,v.date,v.time,v.consultant_id,v.handle,h.name from ' . Config::TOSPUR_VIEW_HOUSE_TABLE . ' v ' .
'left join ' . Config::TOSPUR_HOUSE_TABLE . ' h on v.house_id = h.id ' .
'where v.user_id = ' . $user_id . ' order by v.date desc';
return $wpdb->get_results($sql);
}
//search 预约看房 consultant_id
public static function search_view_house_by_consultant_id($consultant_id)
{
global $wpdb;
$sql = 'select v.id,v.house_id,v.date,v.time,v.user_id,v.handle,h.name from ' . Config::TOSPUR_VIEW_HOUSE_TABLE . ' v ' .
'left join ' . Config::TOSPUR_HOUSE_TABLE . ' h on v.house_id = h.id ' .
'where v.consultant_id = ' . $consultant_id . ' order by v.date desc';
return $wpdb->get_results($sql);
}
//insert 置业顾问评分
public static function insert_consultant_score($consultant_id, $user_id, $score, $valid = 1)
{
$insert_consultant_score_array = array(
'consultant_id' => $consultant_id,
'user_id' => $user_id,
'score' => $score,
'valid' => $valid
);
global $wpdb;
$result = $wpdb->insert(Config::TOSPUR_CONSULTANT_SCORE_TABLE, $insert_consultant_score_array);
return $result;
}
public static function search_score_type($user_id, $consultant_id)
{
global $wpdb;
$sql = 'select type from (SELECT user_id,consultant_id,handle_date,1 as type FROM ' . Config::TOSPUR_VIEW_HOUSE_TABLE .
' where handle = 1 and user_id = ' . $user_id . ' and consultant_id = ' . $consultant_id . ' UNION' .
' SELECT user_id,consultant_id,handle_date,2 as type FROM ' . Config::TOSPUR_SALE_TABLE .
' where handle = 1 and user_id = ' . $user_id . ' and consultant_id = ' . $consultant_id . ') as u' .
' order by handle_date desc limit 1';
return $wpdb->get_var($sql);
}
//search 置业顾问信息
public static function search_consultant_info($consultant_id)
{
global $wpdb;
$sql = 'select c.*,u.display_name,s.average_score from ' . Config::TOSPUR_CONSULTANT . ' c ' .
'left join ' . Config::WP_USERS_TABLE . ' u on c.id = u.ID ' .
'left join (select consultant_id,sum(score)/count(score) as average_score from ' . Config::TOSPUR_CONSULTANT_SCORE_TABLE . ' group by consultant_id) s ' .
'on c.id = s.consultant_id where c.id = ' . $consultant_id;
return $wpdb->get_row($sql);
}
public static function update_consultant_score($score_id, $valid)
{
global $wpdb;
$result = $wpdb->update(Config::TOSPUR_CONSULTANT_SCORE_TABLE, array(
'valid' => $valid
), array(
'id' => $score_id
));
return $result;
}
public static function search_tospur_verify($phone, $code)
{
global $wpdb;
$sql = 'select code from ' . Config::TOSPUR_VERIFY_TABLE . ' where phone = ' . $phone . ' and status = 0 ' .
'and create_time > NOW() - INTERVAL 30 MINUTE ' .
'order by create_time desc limit 1';
return $wpdb->get_var($sql);
}
public static function insert_tospur_verify($phone, $code)
{
$insert_tospur_verify_array = array(
'phone' => $phone,
'code' => $code,
'create_time' => current_time('Y-m-d H:i:s'),
'status' => 0
);
global $wpdb;
$result = $wpdb->insert(Config::TOSPUR_VERIFY_TABLE, $insert_tospur_verify_array);
return $result;
}
public static function update_tospur_verify($phone)
{
global $wpdb;
$wpdb->update(Config::TOSPUR_VERIFY_TABLE, array(
'status' => 1
), array(
'phone' => $phone
));
}
public static function search_consultant_by_city($city_id, $index)
{
global $wpdb;
$consultant_sql = 'select c.*,u.display_name,s.average_score from ' . Config::TOSPUR_CONSULTANT . ' c ' .
'left join ' . Config::WP_USERS_TABLE . ' u on c.id = u.ID ' .
'left join (select consultant_id,sum(score)/count(score) as average_score from ' . Config::TOSPUR_CONSULTANT_SCORE_TABLE . ' where valid=1 group by consultant_id) s on c.id = s.consultant_id ' .
'where cityid = ' . $city_id . ' LIMIT ' . $index . ',20;';
return $wpdb->get_results($consultant_sql);
}
public static function insert_tospur_sale($post)
{
$post['submission_date'] = current_time('Y-m-d H:i:s');
unset($post['action']);
global $wpdb;
$result = $wpdb->insert(Config::TOSPUR_SALE_TABLE, $post);
return $result;
}
}
?>
\ No newline at end of file
......@@ -121,7 +121,7 @@ class consultantScoreList extends WP_List_Table
{
global $wpdb;
$per_page = 5;
$per_page = 10;
$columns = $this->get_columns();
$hidden = array();
$sortable = $this->get_sortable_columns();
......
......@@ -13,9 +13,10 @@ add_action('init', 'tospur_init');
function tospur_init()
{
require_once(PLUGIN_DIR . 'Config.php');
require_once(PLUGIN_DIR . 'Tools/TCSync.php');
require_once(PLUGIN_DIR . 'Tools/TCSync.php');
require_once(PLUGIN_DIR . 'Tools/Image.php');
require_once(PLUGIN_DIR . 'Dao/SearchDao.php');
require_once(PLUGIN_DIR . 'Dao/TospurDao.php');
require_once(PLUGIN_DIR . 'Admin/House.php');
require_once(PLUGIN_DIR . 'Admin/newHouseList.php');
require_once(PLUGIN_DIR . 'Admin/secHandHouse.php');
......@@ -71,6 +72,8 @@ function tospur_register_script_style(){
wp_register_script('jquery-ui',plugins_url('Admin/views', __FILE__)."/js/jquery-ui.js");
wp_register_script('validate',plugins_url('Admin/views', __FILE__)."/js/jquery.validate.js");
wp_register_script('bootstrapjs',plugins_url('Admin/views', __FILE__)."/js/bootstrap.min.js");
wp_register_script('publicjs',plugins_url('Admin/views', __FILE__)."/js/public.js");
wp_register_style('jquery-ui_css', plugins_url('Admin/views', __FILE__)."/css/jquery-ui.css");
wp_register_style('bootstrapcss', plugins_url('Admin/views', __FILE__)."/css/bootstrap.css");
wp_register_style('bootstrapMinCss', plugins_url('Admin/views', __FILE__)."/css/bootstrap.min.css");
......@@ -111,7 +114,7 @@ function valid_consultant_score()
$score_id = $_POST['id'];
$valid = $_POST['valid'];
if (isset($score_id) && isset($valid)) {
$result = dao::update_consultant_score($score_id, $valid);
$result = TospurDao::update_consultant_score($score_id, $valid);
$array = array();
if ($result) {
$array['code'] = 2000;
......@@ -126,7 +129,7 @@ function update_consultant()
$house_id = $_POST['id'];
$consultant_id = $_POST['consultant_id'];
if (isset($consultant_id) && isset($house_id)) {
$result = dao::update_view_house_consultant($house_id, $consultant_id);
$result = TospurDao::update_view_house_consultant($house_id, $consultant_id);
$array = array();
if ($result) {
$array['code'] = 2000;
......@@ -144,7 +147,6 @@ function reset_menu()
add_submenu_page('newHouseList', '添加新房', '添加新房', 'moderate_comments', 'newHouse', 'House::init_view');
add_menu_page('secHandHouseList','二手房列表', 'moderate_comments', 'secHandHouseList', 'function_secHandHouseList', 'dashicons-menu', 7);
add_submenu_page('secHandHouseList', '添加二手房', '添加二手房', 'moderate_comments', 'secHandHouse', 'SecHandHouse::secHandHouse_html');
add_submenu_page('secHandHouseList', '特色列表', '特色列表', 'moderate_comments', 'feature_list', 'feature::feature_list_html');
add_submenu_page('secHandHouseList', '添加特色', '添加特色', 'moderate_comments', 'add_feature', 'feature::add_feature_html');
add_menu_page('rentHouseList','租房列表', 'moderate_comments', 'rentHouseList', 'function_rentHouseList', 'dashicons-menu', 8);
add_submenu_page('rentHouseList', '添加租房', '添加租房', 'moderate_comments', 'rentHouse', 'RentHouse::rentHouse_html');
......
......@@ -85,7 +85,7 @@ class viewHouseList extends WP_List_Table
{
global $wpdb;
$per_page = 5;
$per_page = 10;
$columns = $this->get_columns();
$hidden = array();
//$sortable = $this->get_sortable_columns();
......
......@@ -7,7 +7,6 @@ $current_user = wp_get_current_user();
$user_id = $current_user->ID;
if ($user_id != 0) {
$context['user_id'] = $user_id;
$current_user = wp_get_current_user();
$consultant_id = isset($_GET['consultant_id'])?$_GET['consultant_id']:$current_user->ID;
$context['consultant_id'] = $consultant_id;
$context['consultant'] = get_consultant_info($consultant_id);
......
......@@ -442,13 +442,14 @@ a:hover {
height: 45px;
background-color: #f9f9f9;
}
.footer .btn {
width: 94%;
display: block;
.footer .btn-group {
border-spacing: 10px 5px;
}
.footer .btn-group .btn {
color: #ffffff;
font-weight: bold;
margin: 5px auto;
padding: 1px;
margin: 0;
padding: 2px 12px 0;
background-color: #008cd7;
border-top-left-radius: 4px;
border-top-right-radius: 4px;
......@@ -461,28 +462,40 @@ a:hover {
box-shadow: 0 2px 0 0 #117bb9;
-webkit-box-shadow: 0 2px 0 0 #117bb9;
}
.footer .btn:active {
.footer .btn-group .btn:active {
background-color: #117bb9;
}
.footer .btn:focus {
.footer .btn-group .btn:focus {
outline: 0;
}
.footer .btn.btn-wechat span {
.footer .btn-group .btn.btn-phone span {
width: 30px;
height: 30px;
background: url("../img/white_wechat_icon.png") no-repeat;
background: url("../img/white_phone_icon.png") no-repeat;
background-size: cover;
-webkit-background-size: cover;
display: inline-block;
vertical-align: middle;
margin-right: 6px;
}
.footer .btn.btn-phone span {
.footer .btn-group .btn.btn-wechat span {
width: 30px;
height: 30px;
background: url("../img/white_phone_icon.png") no-repeat;
background: url("../img/white_wechat_icon.png") no-repeat;
background-size: cover;
-webkit-background-size: cover;
display: inline-block;
vertical-align: middle;
margin-right: 6px;
}
.footer .btn-group .btn:first-child:not(:last-child):not(.dropdown-toggle) {
border-top-right-radius: 4px;
border-bottom-right-radius: 4px;
-webkit-border-top-right-radius: 4px;
-webkit-border-bottom-right-radius: 4px;
}
.footer .btn-group .btn:last-child:not(:first-child) {
border-top-left-radius: 4px;
border-bottom-left-radius: 4px;
-webkit-border-top-left-radius: 4px;
-webkit-border-bottom-left-radius: 4px;
}
......@@ -577,6 +577,12 @@ body {
.detail_row.recommend .recommendCont {
margin: 0 -10px;
}
.detail_row.recommend .recommendCont ul {
font-size: 14px;
}
.detail_row.recommend .recommendCont ul .address span:nth-child(1) {
font-size: 16px;
}
.detail_row .peopleCont li {
width: 100%;
height: 60px;
......
......@@ -573,3 +573,12 @@ a:hover {
font-weight: bold;
display: block;
}
.footer a span {
width: 30px;
height: 30px;
background: url("../img/blue_phone_icon.png") no-repeat;
background-size: cover;
-webkit-background-size: cover;
display: inline-block;
vertical-align: middle;
}
.tab {
width: 100%;
height: 40px;
margin-bottom: 0;
border-bottom: 1px solid #008cd7;
}
.tab li .btn {
color: #000000;
font-size: 18px;
font-weight: bold;
position: static;
}
.tab li .btn:after {
content: "";
width: 88%;
height: 4px;
position: absolute;
bottom: 0;
left: 0;
right: 0;
margin: 0 auto;
}
.tab li .btn:active {
box-shadow: none;
-webkit-box-shadow: none;
}
.tab li.active .btn:after {
background-color: #008cd7;
}
.row {
width: 100%;
height: 121px;
margin: 0;
padding: 15px 0;
border-bottom: 1px solid #b7b7b7;
}
.row p {
width: 140px;
height: 100%;
float: left;
padding: 0 10px;
margin-bottom: 0;
overflow: hidden;
}
.row p img {
height: 100%;
border-top-left-radius: 6px;
border-top-right-radius: 6px;
border-bottom-left-radius: 6px;
border-bottom-right-radius: 6px;
-webkit-border-top-left-radius: 6px;
-webkit-border-top-right-radius: 6px;
-webkit-border-bottom-left-radius: 6px;
-webkit-border-bottom-right-radius: 6px;
}
.row ul {
height: 100%;
padding-right: 10px;
margin-bottom: 0;
overflow: hidden;
zoom: 1;
position: relative;
color: #5a5a5a;
font-size: 15px;
}
.row ul li {
height: 18px;
line-height: 18px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.row ul li span {
margin-right: 15px;
}
.row ul li span:last-child {
margin-right: 0;
}
.row ul li.address {
height: 22px;
line-height: 22px;
margin-top: 2px;
}
.row ul li.address span:nth-child(1) {
color: #000000;
font-size: 19px;
font-weight: bold;
}
.row ul li:last-child {
position: absolute;
left: 0;
right: 10px;
bottom: 0;
font-size: 0;
}
.row ul li:last-child .label {
color: #ff0000;
padding: 1px 4px;
font-size: 9px;
border: 1px solid #acacac;
margin: 0 5px 0 0;
vertical-align: middle;
border-top-left-radius: 3px;
border-top-right-radius: 3px;
border-bottom-left-radius: 3px;
border-bottom-right-radius: 3px;
-webkit-border-top-left-radius: 3px;
-webkit-border-top-right-radius: 3px;
-webkit-border-bottom-left-radius: 3px;
-webkit-border-bottom-right-radius: 3px;
}
.row ul li:last-child span {
color: #000000;
font-size: 15px;
}
.row ul li:last-child span em {
font-style: normal;
}
.row ul li:last-child span em:nth-child(1) {
color: #ff0000;
font-size: 19px;
font-weight: bold;
}
.row ul li:last-child span em:nth-child(2) {
font-size: 7px;
vertical-align: top;
}
.row ul li.multiLine_omit {
color: #000000;
font-weight: bold;
height: 36px;
margin-top: 0;
-webkit-line-clamp: 2;
display: -webkit-box;
-webkit-box-orient: vertical;
white-space: normal;
}
.row:active {
background-color: #e9e9e9;
}
.modal .modal-dialog {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
margin: auto;
width: 280px;
height: 130px;
}
.modal .modal-dialog .modal-content {
color: #000000;
font-size: 16px;
border: 0;
border-top-left-radius: 8px;
border-top-right-radius: 8px;
border-bottom-left-radius: 8px;
border-bottom-right-radius: 8px;
-webkit-border-top-left-radius: 8px;
-webkit-border-top-right-radius: 8px;
-webkit-border-bottom-left-radius: 8px;
-webkit-border-bottom-right-radius: 8px;
box-shadow: none;
-webkit-box-shadow: none;
}
.modal .modal-dialog .modal-content h4 {
font-size: 19px;
font-weight: bold;
margin: 0 20px;
padding-top: 15px;
}
.modal .modal-dialog .modal-content p {
margin: 12px 20px 14px;
}
.modal .modal-dialog .modal-content p:nth-of-type(2) {
margin: 0;
font-size: 0;
}
.modal .modal-dialog .modal-content p:nth-of-type(2) .btn {
width: 50%;
}
.modal .modal-dialog .modal-content p:nth-of-type(2) .btn:nth-child(2) {
border-left-color: #cfd0d0;
}
.modal .modal-dialog .modal-content .btn {
border-top-color: #cfd0d0;
background-color: transparent;
font-weight: bold;
border-top-left-radius: 0;
border-top-right-radius: 0;
border-bottom-left-radius: 0;
border-bottom-right-radius: 0;
-webkit-border-top-left-radius: 0;
-webkit-border-top-right-radius: 0;
-webkit-border-bottom-left-radius: 0;
-webkit-border-bottom-right-radius: 0;
}
.modal .modal-dialog .modal-content .btn:active {
background-color: #e9e9e9;
border-bottom-left-radius: 8px;
border-bottom-right-radius: 8px;
-webkit-border-bottom-left-radius: 8px;
-webkit-border-bottom-right-radius: 8px;
box-shadow: none;
-webkit-box-shadow: none;
}
.modal .modal-dialog .modal-content .btn:focus {
outline: 0;
}
.loading {
position: fixed;
top: 0;
bottom: 0;
left: 0;
right: 0;
z-index: 1040;
background-color: rgba(0, 0, 0, 0.5);
}
.loading ul {
position: fixed;
top: 0;
bottom: 0;
left: 0;
right: 0;
margin: auto;
width: 40px;
height: 40px;
}
.loading ul li {
position: absolute;
width: 100%;
height: 100%;
}
.loading ul li:nth-child(1) p:nth-child(2) {
animation-delay: -0.9s;
-webkit-animation-delay: -0.9s;
}
.loading ul li:nth-child(1) p:nth-child(3) {
animation-delay: -0.6s;
-webkit-animation-delay: -0.6s;
}
.loading ul li:nth-child(1) p:nth-child(4) {
animation-delay: -0.3s;
-webkit-animation-delay: -0.3s;
}
.loading ul li:nth-child(2) {
transform: rotateZ(45deg);
-webkit-transform: rotateZ(45deg);
}
.loading ul li:nth-child(2) p:nth-child(1) {
animation-delay: -1.1s;
-webkit-animation-delay: -1.1s;
}
.loading ul li:nth-child(2) p:nth-child(2) {
animation-delay: -0.8s;
-webkit-animation-delay: -0.8s;
}
.loading ul li:nth-child(2) p:nth-child(3) {
animation-delay: -0.5s;
-webkit-animation-delay: -0.5s;
}
.loading ul li:nth-child(2) p:nth-child(4) {
animation-delay: -0.2s;
-webkit-animation-delay: -0.2s;
}
.loading ul li:nth-child(3) {
transform: rotateZ(90deg);
-webkit-transform: rotateZ(90deg);
}
.loading ul li:nth-child(3) p:nth-child(1) {
animation-delay: -1s;
-webkit-animation-delay: -1s;
}
.loading ul li:nth-child(3) p:nth-child(2) {
animation-delay: -0.7s;
-webkit-animation-delay: -0.7s;
}
.loading ul li:nth-child(3) p:nth-child(3) {
animation-delay: -0.4s;
-webkit-animation-delay: -0.4s;
}
.loading ul li:nth-child(3) p:nth-child(4) {
animation-delay: -0.1s;
-webkit-animation-delay: -0.1s;
}
.loading ul li p {
width: 10px;
height: 10px;
margin-bottom: 0;
border-top-left-radius: 50%;
border-top-right-radius: 50%;
border-bottom-left-radius: 50%;
border-bottom-right-radius: 50%;
-webkit-border-top-left-radius: 50%;
-webkit-border-top-right-radius: 50%;
-webkit-border-bottom-left-radius: 50%;
-webkit-border-bottom-right-radius: 50%;
position: absolute;
background-color: #ffffff;
animation: bouncedelay 1.2s infinite ease-in-out both;
-webkit-animation: bouncedelay 1.2s infinite ease-in-out both;
}
.loading ul li p:nth-child(1) {
top: 0;
left: 0;
}
.loading ul li p:nth-child(2) {
top: 0;
right: 0;
}
.loading ul li p:nth-child(3) {
bottom: 0;
right: 0;
}
.loading ul li p:nth-child(4) {
bottom: 0;
left: 0;
}
@keyframes bouncedelay {
0%,
80%,
100% {
transform: scale(0);
-webkit-transform: scale(0);
}
40% {
transform: scale(1);
-webkit-transform: scale(1);
}
}
@-webkit-keyframes bouncedelay {
0%,
80%,
100% {
transform: scale(0);
-webkit-transform: scale(0);
}
40% {
transform: scale(1);
-webkit-transform: scale(1);
}
}
html,
body {
width: 100%;
height: 100%;
}
body {
user-select: none;
-webkit-user-select: none;
tap-highlight-color: rgba(0, 0, 0, 0);
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
color: #707070;
background-color: #f9f9f9;
}
a:hover {
text-decoration: none;
}
.container-fluid {
width: 100%;
height: 100%;
background: url("../img/formBg.jpg") no-repeat;
background-size: 100% 100%;
-webkit-background-size: 100% 100%;
background-attachment: fixed;
overflow: auto;
padding: 0 25px;
}
.container-fluid form {
width: 400px;
margin: 0 auto;
}
.container-fluid form h2 {
margin: 100px 0;
color: #ffffff;
font-weight: bold;
width: 100%;
height: 34px;
background: url("../img/logo.png") no-repeat;
background-size: 150px 34px;
-webkit-background-size: 150px 34px;
background-position: center;
}
.container-fluid form .has-feedback {
margin-bottom: 0;
background-color: #ffffff;
border: 1px solid #cfd0d0;
}
.container-fluid form .has-feedback .form-control {
height: 60px;
color: #7d7d7d;
border: 0;
box-shadow: none;
-webkit-box-shadow: none;
border-top-left-radius: 0;
border-top-right-radius: 0;
border-bottom-left-radius: 0;
border-bottom-right-radius: 0;
-webkit-border-top-left-radius: 0;
-webkit-border-top-right-radius: 0;
-webkit-border-bottom-left-radius: 0;
-webkit-border-bottom-right-radius: 0;
-webkit-appearance: none;
}
.container-fluid form .has-feedback .form-control::-webkit-input-placeholder {
color: #7d7d7d;
}
.container-fluid form .has-feedback:first-of-type {
margin-bottom: -1px;
border-top-left-radius: 4px;
border-top-right-radius: 4px;
-webkit-border-top-left-radius: 4px;
-webkit-border-top-right-radius: 4px;
}
.container-fluid form .has-feedback:first-of-type .form-control {
border-top-left-radius: 3px;
border-top-right-radius: 3px;
-webkit-border-top-left-radius: 3px;
-webkit-border-top-right-radius: 3px;
}
.container-fluid form .has-feedback:last-of-type {
margin-top: -1px;
border-bottom-left-radius: 4px;
border-bottom-right-radius: 4px;
-webkit-border-bottom-left-radius: 4px;
-webkit-border-bottom-right-radius: 4px;
}
.container-fluid form .has-feedback:last-of-type .form-control {
border-bottom-left-radius: 3px;
border-bottom-right-radius: 3px;
-webkit-border-bottom-left-radius: 3px;
-webkit-border-bottom-right-radius: 3px;
}
.container-fluid form .has-feedback.username .form-control-feedback {
width: 30px;
height: 30px;
background: url("../img/gray_username_icon.png") no-repeat;
background-size: cover;
-webkit-background-size: cover;
top: 15px;
right: 15px;
}
.container-fluid form .has-feedback.password .form-control-feedback {
width: 30px;
height: 30px;
background: url("../img/gray_password_icon.png") no-repeat;
background-size: cover;
-webkit-background-size: cover;
top: 15px;
right: 15px;
}
.container-fluid form .has-feedback.code .form-control {
width: 60%;
}
.container-fluid form .has-feedback.code .form-control-feedback {
top: 6px;
right: 4px;
width: 35%;
height: 46px;
line-height: 46px;
color: #ffffff;
font-size: 16px;
background-color: #0bacd3;
box-shadow: 0 2px 0 0 #088aa9;
-webkit-box-shadow: 0 2px 0 0 #088aa9;
border-top-left-radius: 4px;
border-top-right-radius: 4px;
border-bottom-left-radius: 4px;
border-bottom-right-radius: 4px;
-webkit-border-top-left-radius: 4px;
-webkit-border-top-right-radius: 4px;
-webkit-border-bottom-left-radius: 4px;
-webkit-border-bottom-right-radius: 4px;
pointer-events: auto;
}
.container-fluid form .has-feedback.code .form-control-feedback:active {
background-color: #088aa9;
}
.container-fluid form .btn {
color: #ffffff;
font-weight: bold;
margin: 100px 0 0;
padding: 8px;
background-color: #008cd7;
border-top-left-radius: 4px;
border-top-right-radius: 4px;
border-bottom-left-radius: 4px;
border-bottom-right-radius: 4px;
-webkit-border-top-left-radius: 4px;
-webkit-border-top-right-radius: 4px;
-webkit-border-bottom-left-radius: 4px;
-webkit-border-bottom-right-radius: 4px;
box-shadow: 0 2px 0 0 #117bb9;
-webkit-box-shadow: 0 2px 0 0 #117bb9;
}
.container-fluid form .btn:active {
background-color: #117bb9;
}
.container-fluid form .btn:focus {
outline: 0;
}
.container-fluid form .btn.btn-register {
margin-top: 20%;
}
.container-fluid form a {
display: block;
color: #ffffff;
font-size: 16px;
}
.container-fluid form a span {
width: 30px;
height: 1px;
display: inline-block;
vertical-align: middle;
margin: 0 5px;
background-color: rgba(255, 255, 255, 0.4);
}
.container-fluid form a:active {
color: #636363;
}
.container-fluid form a:active span {
background-color: #636363;
}
.container-fluid form a.link-register {
margin-top: 30%;
padding-bottom: 25px;
}
......@@ -356,31 +356,41 @@ body {
a:hover {
text-decoration: none;
}
.main {
#wrapper {
position: absolute;
z-index: 1;
top: 40px;
bottom: 0;
left: 0;
width: 100%;
padding-bottom: 5%;
overflow: hidden;
}
#wrapper #scroller {
padding-bottom: 15px;
}
.main ul li {
#wrapper #scroller ul li {
margin: 0 15px;
padding: 13px 0;
height: 60px;
line-height: 60px;
border-bottom: 1px solid #b7b7b7;
color: #7d7d7d;
font-size: 18px;
overflow: hidden;
}
.main ul li label {
#wrapper #scroller ul li label {
margin-bottom: 0;
padding: 5px 0 0 4px;
padding: 0 0 0 4px;
}
.main ul li p {
#wrapper #scroller ul li p {
margin-bottom: 0;
padding: 0;
height: 100%;
}
.main ul li p .form-control {
#wrapper #scroller ul li p .form-control {
color: #7d7d7d;
font-size: 18px;
background-color: transparent;
border-color: transparent;
border: 0;
display: inline-block;
box-shadow: none;
-webkit-box-shadow: none;
......@@ -394,29 +404,34 @@ a:hover {
-webkit-border-bottom-right-radius: 0;
-webkit-appearance: none;
}
.main ul li p .form-control::-webkit-input-placeholder {
#wrapper #scroller ul li p .form-control::-webkit-input-placeholder {
color: #7d7d7d;
}
.main ul li p .form-control::-webkit-outer-spin-button,
.main ul li p .form-control::-webkit-inner-spin-button {
#wrapper #scroller ul li p .form-control::-webkit-outer-spin-button,
#wrapper #scroller ul li p .form-control::-webkit-inner-spin-button {
-webkit-appearance: none !important;
margin: 0;
}
.main ul li p .form-control.width-sm {
width: 45px;
#wrapper #scroller ul li p .form-control.width-sm {
width: 36px;
padding: 6px;
}
.main ul li p textarea.form-control {
#wrapper #scroller ul li p textarea.form-control {
resize: none;
background-color: #ffffff;
border-color: #e9e9e9;
border: 1px solid #e9e9e9;
}
.main ul li:last-child {
border-bottom: 0;
#wrapper #scroller ul li p em {
font-size: 9px;
position: relative;
top: -6px;
font-style: normal;
}
.main ul li:last-child label {
margin-bottom: 18px;
#wrapper #scroller ul li:last-child {
height: auto;
border-bottom: 0;
}
.main .btn {
#wrapper #scroller .btn {
width: 86%;
display: block;
color: #ffffff;
......@@ -435,9 +450,9 @@ a:hover {
box-shadow: 0 2px 0 0 #117bb9;
-webkit-box-shadow: 0 2px 0 0 #117bb9;
}
.main .btn:active {
#wrapper #scroller .btn:active {
background-color: #117bb9;
}
.main .btn:focus {
#wrapper #scroller .btn:focus {
outline: 0;
}
......@@ -14,10 +14,10 @@ if ($_POST) {
} else if (!$password) {
$context['error'] = '请输入新密码';
} else {
$search_code = dao::search_tospur_verify($phone, $code);
$search_code = TospurDao::search_tospur_verify($phone, $code);
if ($code == $search_code) {
wp_set_password($password, $user->data->ID);
dao::update_tospur_verify($phone);
TospurDao::update_tospur_verify($phone);
$context['error'] = '成功修改密码';
} else {
$context['error'] = '验证码错误';
......
<?php
require_once(dirname(__FILE__) . '/dao.php');
require_once('const.php');
require_once(dirname(__FILE__) . '/../../plugins/tospur/Dao/TospurDao.php');
require_once(dirname(__FILE__) . '/../../plugins/tospur/Dao/SearchDao.php');
require_once(dirname(__FILE__) . '/../../plugins/tospur/Tools/Image.php');
......@@ -35,9 +36,6 @@ function page_template($template)
case 'consultant_list':
$page = $theme . '/consultant_list.php';
break;
case 'score':
$page = $theme . '/score.php';
break;
case 'comment':
$page = $theme . '/comment.php';
break;
......@@ -53,6 +51,12 @@ function page_template($template)
case 'loan_calculator':
$page = $theme . '/loan_calculator.php';
break;
case 'manager':
$page = $theme . '/manager.php';
break;
case 'sale':
$page = $theme . '/sale.php';
break;
}
return $page;
} else {
......@@ -85,7 +89,7 @@ function send_code()
$array['code'] = 2002;
} else {
$code = generate_code();
$insert_result = dao::insert_tospur_verify($phone, strtolower($code));
$insert_result = TospurDao::insert_tospur_verify($phone, strtolower($code));
$response = wp_remote_post('http://218.1.67.130:8988/api/NanTongWechat/MobileSendMessage' .
'?mobilePhone=' . $phone . '&VerificationCode=' . $code
);
......@@ -114,7 +118,7 @@ function view_house()
$date = $_POST['date'];
}
$time = (9 + $index) . ':00-' . (10 + $index) . ':00';
$result = dao::insert_view_house($_POST['house_id'], $_POST['user_id'], $date, $index, $time, $_POST['consultant_id']);
$result = TospurDao::insert_view_house($_POST['house_id'], $_POST['user_id'], $date, $index, $time, $_POST['consultant_id']);
$array = array();
if ($result) {
$array['code'] = 2000;
......@@ -131,7 +135,7 @@ function handle_view_house()
{
$id = $_POST['id'];
if (isset($id)) {
$result = dao::update_view_house($id);
$result = TospurDao::update_view_house($id);
$array = array();
if ($result) {
$array['code'] = 2000;
......@@ -147,12 +151,18 @@ add_action('wp_ajax_add_score', 'add_consultant_score');
function add_consultant_score()
{
if (isset($_POST['score'])) {
$result = dao::insert_consultant_score($_POST['consultant_id'], $_POST['user_id'], $_POST['score']);
$type = TospurDao::search_score_type($_POST['user_id'], $_POST['consultant_id']);
$result = null;
if ($type) {
$result = TospurDao::insert_consultant_score($_POST['consultant_id'], $_POST['user_id'], $_POST['score']);
}
$array = array();
if ($result) {
if ($type && $result) {
$array['code'] = 2000;
} else {
} else if(!$type){
$array['code'] = 2001;
} else if(!$result){
$array['code'] = 2002;
}
wp_send_json($array);
}
......@@ -161,14 +171,14 @@ function add_consultant_score()
//置业顾问信息
function get_consultant_info($consultant_id)
{
return dao::search_consultant_info($consultant_id);
return TospurDao::search_consultant_info($consultant_id);
}
add_action('wp_ajax_get_consultant', 'get_consultant');
function get_consultant()
{
if (isset($_POST['city_id']) && isset($_POST['index'])) {
$result = dao::search_consultant_by_city($_POST['city_id'], $_POST['index']);
$result = TospurDao::search_consultant_by_city($_POST['city_id'], $_POST['index']);
$array = array();
if ($result) {
$array['code'] = 2000;
......@@ -224,7 +234,7 @@ function add_collect($house_id)
add_filter('login_redirect', 'new_login_redirect', 10, 3);
function new_login_redirect($redirect_to, $request, $user)
{
if ($user - ID > 0) {
if ($user->ID > 0) {
$role = $user->roles[0];
if ($role == 'administrator' || $role == 'editor') {
return admin_url('admin.php?page=newHouseList');
......@@ -236,4 +246,44 @@ function new_login_redirect($redirect_to, $request, $user)
}
}
add_action('wp_logout', 'auto_redirect_after_logout');
function auto_redirect_after_logout()
{
header('Location: ' . home_url('/?page=manager'));
exit;
}
add_filter('login_url', 'my_login_page', 10, 2);
function my_login_page($login_url, $redirect)
{
return home_url('/?page=manager&redirect_to=' . $redirect);
}
function user_redirect($user)
{
$url = null;
if ($user->ID > 0) {
$role = $user->roles[0];
if ($role == 'administrator' || $role == 'editor') {
$url = admin_url('admin.php?page=newHouseList');
} else {
$url = site_url();
}
header('Location:' . $url);
}
}
add_action('wp_ajax_submit_sale', 'submit_sale');
function submit_sale()
{
$array = array('code' => 2001);
if ($_POST) {
$result = TospurDao::insert_tospur_sale($_POST);
if ($result) {
$array['code'] = 2000;
}
}
wp_send_json($array);
}
?>
\ No newline at end of file
<?php
require_once(dirname(__FILE__) . '/dao.php');
$context = array();
$context['theme'] = get_template_directory_uri();
$context['url'] = home_url();
......@@ -12,10 +11,10 @@ if ($current_user_id != 0) {
$result = null;
switch ($role) {
case 'subscriber':
$result = dao::search_view_house_by_user_id($current_user_id);
$result = TospurDao::search_view_house_by_user_id($current_user_id);
break;
case 'editor':
$result = dao::search_view_house_by_consultant_id($current_user_id);
$result = TospurDao::search_view_house_by_consultant_id($current_user_id);
break;
}
if ($result) {
......
<?php
$context = array();
$context['theme'] = get_template_directory_uri();
if (is_user_logged_in()) {
$user = wp_get_current_user();
user_redirect($user);
} else {
if ($_POST) {
$phone = $_POST['phone'];
$password = $_POST['password'];
if (!$phone) {
$context['error'] = '请输入用户名';
} else if (!$password) {
$context['error'] = '请输入密码';
} else {
if (strlen($phone) != 11 && $phone != 'admin') {
$response = wp_remote_post('http://218.1.67.130:8988/api/NanTongWechat/LoginWechat' .
'?userName=' . $phone . '&password=' . $password
);
$body = json_decode($response['body']);
$data = $body->data;
if ($data) {
$password = $data->WorkNoAndId;
}
}
$creds['user_login'] = $phone;
$creds['user_password'] = $password;
$creds['remember'] = true;
$user = wp_signon($creds, false);
if (!is_wp_error($user)) {
user_redirect($user);
} else if ($user->get_error_code() == 'invalid_username') {
$context['error'] = '此帐号尚未注册';
} else if ($user->get_error_code() == 'incorrect_password') {
$context['error'] = '您输入的密码有误';
}
}
}
Timber::render('manager.html', $context);
}
?>
\ No newline at end of file
<?php
require_once('const.php');
$context = array();
$context['theme'] = get_template_directory_uri();
......
......@@ -15,11 +15,11 @@ if ($_POST) {
} else if (!$password) {
$context['error'] = '请输入密码';
} else {
$search_code = dao::search_tospur_verify($phone, $code);
$search_code = TospurDao::search_tospur_verify($phone, $code);
if ($code == $search_code) {
$result = wp_create_user($phone, $password);
if (is_integer($result)) {
dao::update_tospur_verify($phone);
TospurDao::update_tospur_verify($phone);
$creds['user_login'] = $phone;
$creds['user_password'] = $password;
$creds['remember'] = true;
......
<?php
$context = array();
$context['theme'] = get_template_directory_uri();
$context['url'] = home_url();
$current_user = wp_get_current_user();
$user_id = $current_user->ID;
if ($user_id != 0) {
$context['user_id'] = $user_id;
$context['consultant_id'] = $_GET['consultant_id'];
}
Timber::render('score.html', $context);
?>
\ No newline at end of file
......@@ -6,14 +6,6 @@ $context['url'] = home_url();
$current_user = wp_get_current_user();
$user_id = $current_user->ID;
if ($user_id != 0) {
$date = current_time('Y-m-d');
$datetime = new DateTime($cureent_time . '+1 day');
$date = $datetime->format('Y-m-d');
$context['data'] = array(
'jt' => $date,
'mt' => new DateTime($date . '+1 day'),
'ht' => $date
);
$context['user_id'] = $user_id;
$context['house_id'] = $_GET['house_id'];
$context['consultant_id'] = $_GET['consultant_id'];
......@@ -23,5 +15,4 @@ if ($user_id != 0) {
exit;
}
?>
\ No newline at end of file
......@@ -2,7 +2,7 @@
<html>
<head lang="en">
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0"/>
<meta name="viewport" content="width=360, user-scalable=0"/>
<meta name="apple-mobile-web-app-capable" content="yes"/>
<meta name="apple-mobile-web-app-status-bar-style" content="black"/>
<title>信息反馈</title>
......
......@@ -32,9 +32,6 @@
</div>
<p>同策房屋</p>
</li>
<li class="col-xs-3">
<a class="btn btn-block" data-toggle="modal" data-target="#scoreDiv">评分</a>
</li>
</ul>
<h4>诚信宣言</h4>
<div id="people_wrapper">
......@@ -63,9 +60,14 @@
</div>
</div>
<footer class="footer navbar-fixed-bottom">
<a href="tel:{{ consultant_mobile }}" class="btn btn-phone">
<span></span>电话联系
</a>
<div class="btn-group btn-group-justified">
<a href="tel:{{ consultant_mobile }}" class="btn btn-phone">
<span></span>电话联系
</a>
<a data-toggle="modal" data-target="#scoreDiv" class="btn btn-phone">
评分
</a>
</div>
</footer>
<div class="loading" id="loading" style="display: none;">
<ul class="list-unstyled">
......@@ -184,10 +186,18 @@
url: '{{ url }}/wp-admin/admin-ajax.php/',
data: 'action=add_score&user_id={{user_id}}&consultant_id={{consultant_id}}&score='+$("#score").val(),
success: function (data) {
if (data.code == 2000) {
alert('评分成功');
}else{
alert('您已经提交过评分了');
switch (data.code){
case 2000:
alert('评分成功');
break;
case 2001:
alert('未和置业顾问接触过,不能评分');
break;
case 2002:
alert('您已经提交过评分了');
break;
default:
break;
}
},
complete:function(){
......
......@@ -274,10 +274,10 @@
{% else %}
<a href="tel:{{item.mobile}}" class="btn btn-xs btn-phone">
{% endif %}
<span></span>电话联系
<span></span>电话
</a>
<a href="{{siteUrl}}?page=view&house_id={{hid}}&consultant_id={{item.id}}" class="btn btn-xs btn-booking">
<span></span>一键预约
<span></span>预约
</a>
</ol>
</li>
......
......@@ -62,6 +62,9 @@
notice.html('<span>{{ error }}</span>');
myModal.modal('show');
{% endif %}
document.addEventListener('touchmove', function(e){
e.preventDefault();
});
});
</script>
</head>
......
......@@ -45,6 +45,9 @@
notice.html('<span>{{ error }}</span>');
myModal.modal('show');
{% endif %}
document.addEventListener('touchmove', function(e){
e.preventDefault();
});
});
</script>
</head>
......
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<meta name="viewport" content="width=360, user-scalable=0"/>
<meta name="apple-mobile-web-app-capable" content="yes"/>
<meta name="apple-mobile-web-app-status-bar-style" content="black"/>
<title>登录</title>
<link rel="stylesheet" type="text/css" href="{{ theme }}/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="{{ theme }}/css/manager.css">
<script src="{{ theme }}/js/jquery.min.js"></script>
<script src="{{ theme }}/js/jquery.validate.js"></script>
<script src="{{ theme }}/js/bootstrap.min.js"></script>
<script>
$(document).ready(function () {
var notice = $('#notice');
var myModal = $('#myModal');
$('#loginForm').validate({
onkeyup: false,
onfocusout: false,
rules: {
phone: 'required',
password: 'required'
},
messages: {
phone: '请输入用户名',
password: '请输入密码'
},
errorLabelContainer: "#notice",
errorElement: 'span',
invalidHandler: function () {
myModal.modal('show');
},
submitHandler: function (form) {
form.submit();
}
});
notice.bind('DOMNodeInserted',function(){
$(this).children(':not(:first)').remove();
});
myModal.on('hide.bs.modal',function(){
notice.children().remove();
});
{% if(error) %}
notice.html('<span>{{ error }}</span>');
myModal.modal('show');
{% endif %}
});
</script>
</head>
<body>
<div class="container-fluid text-center">
<form id="loginForm" method="post">
<h2></h2>
<p class="has-feedback username">
<label for="phone" class="sr-only">用户名</label>
<input type="tel" name="phone" id="phone" class="form-control input-lg" placeholder="账号">
<span class="form-control-feedback"></span>
</p>
<p class="has-feedback password">
<label for="password" class="sr-only">密码</label>
<input type="password" name="password" id="password" class="form-control input-lg" placeholder="密码">
<span class="form-control-feedback"></span>
</p>
<input type="submit" id="login_submit" value="登录" class="btn btn-lg btn-block">
</form>
</div>
<div class="modal fade" id="myModal">
<div class="modal-dialog">
<div class="modal-content text-center">
<h4>提示</h4>
<p id="notice"></p>
<button type="button" class="btn btn-lg btn-block" data-dismiss="modal">确认</button>
</div>
</div>
</div>
</body>
</html>
\ No newline at end of file
......@@ -62,6 +62,9 @@
notice.html('<span>{{ error }}</span>');
myModal.modal('show');
{% endif %}
document.addEventListener('touchmove', function(e){
e.preventDefault();
});
});
</script>
</head>
......
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<meta name="viewport" content="width=360, user-scalable=0"/>
<meta name="apple-mobile-web-app-capable" content="yes"/>
<meta name="apple-mobile-web-app-status-bar-style" content="black"/>
<title></title>
<style></style>
<link rel="stylesheet" href="{{ theme }}/css/bootstrap.min.css">
<link rel="stylesheet" href="{{ theme }}/css/star-rating.min.css">
<script src="{{ theme }}/js/jquery.min.js"></script>
<script src="{{ theme }}/js/star-rating.min.js"></script>
<script>
$(document).ready(function () {
var score = 0;
$('#score').rating({
min: 0,
max: 5,
step: 0.5,
size: 'xs',
showClear: false,
showCaption: false,
hoverEnabled: false,
starCaptions: function (data) {
console.log(data);
score = data;
$(this).val(score);
}
});
var scoreForm = $('#scoreForm');
scoreForm.submit(function () {
if (score > 0) {
$.ajax({
type: 'POST',
url: '{{ url }}/wp-admin/admin-ajax.php/',
data: 'action=add_score&' + scoreForm.serialize(),
success: function (data) {
if (data.code == 2000) {
alert('评分成功');
}else{
alert('不能重复评分');
}
}
});
} else {
alert('请选择评分');
}
return false;
});
});
</script>
</head>
<body>
<form id="scoreForm" method="post">
<br>
<label for="score">评分</label>
<input type="hidden" id="score" name="score" value="0">
<input type="hidden" name="user_id" value="{{ user_id }}">
<input type="hidden" name="consultant_id" value="{{ consultant_id }}">
<br>
<p class="submit">
<input type="submit" id="score_submit" value="提交">
</p>
</form>
</body>
</html>
\ No newline at end of file
......@@ -59,6 +59,9 @@
}
return false;
});
document.addEventListener('touchmove', function(e){
e.preventDefault();
});
});
</script>
</head>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment