Commit b6aca874 by felix

每日一更

parent cc413842
......@@ -168,11 +168,4 @@ class House extends Tospur_House{
return 200;
}
public static function getCurrentRole(){
$current_user = wp_get_current_user();
if ( !($current_user instanceof WP_User) )
return;
$roles = $current_user->roles;
return $roles[0];
}
}
\ No newline at end of file
......@@ -192,7 +192,7 @@ class rentHouseList extends WP_List_Table
);
$sql = "select * from tospur_house th
left join(select user_id as aus_id,house_id from a_house_user) ahu on th.id = ahu.house_id
left join(select user_id as aus_id,house_id from a_house_user where user_type = 1) ahu on th.id = ahu.house_id
left join(select id as consul_id,name as consul_name from tospur_consultant) tc on ahu.aus_id = tc.consul_id
left join(select value,literal from dic_buildproperty) db on th.buildproperty_id = db.value
where 1=1 and house_type=2";
......
......@@ -68,6 +68,7 @@ class SecHandHouse extends Tospur_House{
$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();
......@@ -75,6 +76,7 @@ class SecHandHouse extends Tospur_House{
$context["room"] = SearchDao::searchRoom();
$context["photoType"] = SearchDao::searchPhotoType();
$context["status"] = searchDao::searchStatusType(2);
$context["feature"] = searchDao::searchFeature();
Timber::render("secHandHouse.html",$context);
}
......@@ -98,7 +100,12 @@ class SecHandHouse extends Tospur_House{
InsertDao::addRecConsultant($houseId,$data);
InsertDao::addHouseTag($_POST['mark'],$houseId);
if(isset($_POST['mark'])&&$_POST['mark']!=""){
InsertDao::addHouseTag($_POST['mark'],$houseId);
}
InsertDao::addHouseFeature($houseId,$data);
}else{
return 507;
......@@ -137,7 +144,19 @@ class SecHandHouse extends Tospur_House{
$wpdb->delete(Config::A_HOUSE_USER_TABLE,array("house_id" => $houseId));
InsertDao::addRecConsultant($houseId,$data);
// $wpdb->delete(Config::A_HOUSE_TAG_TABLE,array("house_id" => $houseId));
$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;
}
......
......@@ -181,7 +181,7 @@ class secHandHouseList extends WP_List_Table
//$data = $this->example_data;
$sql = "select * from tospur_house th
left join(select user_id as aus_id,house_id from a_house_user) ahu on th.id = ahu.house_id
left join(select user_id as aus_id,house_id from a_house_user where user_type = 1) ahu on th.id = ahu.house_id
left join(select id as consul_id,name as consul_name from tospur_consultant) tc on ahu.aus_id = tc.consul_id
left join(select value,literal from dic_buildproperty) db on th.buildproperty_id = db.value
where 1=1 and house_type=1";
......
......@@ -34,13 +34,13 @@
<th><label for="from">所属地区</label></th>
<td>
<select id="baseCity" name="baseCity">
<option value=""> 城市</option>
<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 = "">区域</option>
<option value = "-1">区域</option>
{% if district %}
{% for item in district %}
<option {{ item.id == result.district_id?"selected":"" }} value="{{ item.id }}">{{ item.value }}</option>
......@@ -48,7 +48,7 @@
{% endif %}
</select>
<select id="basePlateId" name="basePlateId">
<option value = "">板块</option>
<option value = "-1">板块</option>
{% if district %}
{% for item in plate %}
<option {{ item.id == result.plate_id?"selected":"" }} value="{{ item.id }}">{{ item.value }}</option>
......@@ -386,51 +386,37 @@
var cityName = $("#baseCity").find("option:selected").text();
var option = $("<option>").attr("value",cityId).append(cityName);
$("#cityId").append(option);
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);
}
});
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: "post",
url: "/tospur/wp-admin/admin-ajax.php",
data: "action=searchHouse&cityId="+cityId+"&houseType=0",
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>").attr("id",id).addClass("addImg").append(img).append(name);
$("#houseList").append(li);
//城市联动房子面积
$.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);
}
});
//区域联动板块
......@@ -452,30 +438,7 @@
//推荐房源下显示图片信息以及房名
$("#areaId,#plateId,#buildProperty,#room,#acreage,#price").change(function(){
$("#houseList").find("li").remove();
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=0",
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>").attr("id",id).addClass("addImg").append(img).append(name);
$("#houseList").append(li);
}
}
});
addList(0);
});
//添加房源中搜索框的搜索
......@@ -590,7 +553,9 @@
$("#houseImg,#consultantImg,#picList").on("click",".imgCancel,.consultantCancel,.picDelet",function(){
$(this).parent("p").remove();
});
$("#preview,#picList,#houseImg,#consultantImg").on("click",".existsCancel",function(){
$(this).parent().remove();
});
$("#submit").click(function(){
if($("#housename").val()==""){
......@@ -653,9 +618,54 @@
}
}
$("#preview,#picList,#houseImg,#consultantImg").on("click",".existsCancel",function(){
$(this).parent().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);
......
......@@ -89,13 +89,13 @@
<th><label for="from">所属地区</label></th>
<td>
<select id="baseCity" name="baseCity">
<option value=""> 城市</option>
<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 = "">区域</option>
<option value = -1">区域</option>
{% if district %}
{% for item in district %}
<option {{ item.id == result.district_id?"selected":"" }} value="{{ item.id }}">{{ item.value }}</option>
......@@ -103,7 +103,7 @@
{% endif %}
</select>
<select id="basePlateId" name="basePlateId">
<option value = "">板块</option>
<option value = "-1">板块</option>
{% if district %}
{% for item in plate %}
<option {{ item.id == result.plate_id?"selected":"" }} value="{{ item.id }}">{{ item.value }}</option>
......@@ -336,50 +336,36 @@
var option = $("<option>").attr("value",cityId).append(cityName);
$("#cityId").append(option);
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);
}
});
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: "post",
url: "/tospur/wp-admin/admin-ajax.php",
data: "action=searchHouse&cityId="+cityId+"&houseType=2",
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>").attr("id",id).addClass("addImg").append(img).append(name);
$("#houseList").append(li);
//城市联动房子面积
$.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);
}
});
......@@ -402,37 +388,7 @@
//推荐房源下显示图片信息以及房名
$("#areaId,#plateId,#buildProperty,#room,#acreage,#price").change(function(){
$("#houseList").find("li").remove();
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=2",
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 = json.images[id];
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);
}
}
}
});
addList(2);
});
//添加房源中搜索框的搜索
......@@ -547,6 +503,9 @@
$("#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()==""){
......@@ -624,9 +583,42 @@
}
return map;
}
$("#picList,#houseImg,#consultantImg").on("click",".existsCancel",function(){
$(this).parent().remove();
});
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);
......
......@@ -179,6 +179,23 @@ class InsertDao{
}
}
}
public static function addHouseFeature($houseId,$data){
global $wpdb;
if($data["houseFeature"]){
foreach($data["houseFeature"] as $val){
$a_house_feature = array(
"house_id" => $houseId,
"tag_id" =>$val
);
$a_house_featureRes = $wpdb->insert(Config::A_HOUSE_TAG_TABLE,$a_house_feature);
if(!$a_house_featureRes){
return 506;
}
}
}
}
public static function addHouseTag($tags, $house_id)
{
......@@ -212,11 +229,12 @@ class InsertDao{
}
}
//删除该房源的标签关联后,添加新的标签关联
$wpdb->delete(
'a_house_tag',
array(
'house_id' => $house_id
)
$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 = 0);", $house_id)
);
foreach ($tags_ids as $value) {
$wpdb->insert(
......
......@@ -168,7 +168,7 @@ class SearchDao
'index' => $_POST['index']
)
);
$array = SearchDao::get_house_image_and_tags($house_result);
$array = SearchDao::get_house_list($house_result);
wp_send_json($array);
}
......@@ -182,7 +182,7 @@ class SearchDao
if ($array['houseType'] == 0) {
$addSql = " left join (select buildproperty_id,house_area,image_id,house_id as bph_id from a_district_area) ada on th.id = ada.bph_id".
" left join (select value as bp_value,literal as bp_literal from dic_buildproperty) dbp on ada.buildproperty_id = dbp.bp_value";
$orderbySql = " group by ada.bph_id order by th.creattime DESC";
$orderbySql = " group by th.id order by th.creattime DESC";
}else if ($array['houseType'] == 1) {
$addSql = " left join (select value as bp_value,literal as bp_literal from dic_buildproperty) dbp on th.buildproperty_id = dbp.bp_value";
if ($array['feature'] > -1) {
......@@ -194,10 +194,13 @@ class SearchDao
$addSql = " left join (select value as bp_value,literal as bp_literal from dic_buildproperty) dbp on th.buildproperty_id = dbp.bp_value";
$orderbySql = " order by th.creattime DESC";
}
$sql = "select * from tospur_house th".
$sql = "select *,(SELECT GROUP_CONCAT(left(tt.name,3)) from a_house_tag aht".
" LEFT JOIN tospur_tag tt on tt.id = aht.tag_id".
" where aht.house_id = th.id) as tags from tospur_house th".
$addSql.
" left join dic_city dc on th.plate_id = dc.plateId".
" left join (select id as rid,value as r_value,literal from dic_room) dr on th.room_id = dr.r_value".
" left join (select id as image_id,path from tospur_image) ti on ti.image_id = th.frontCover_id".
" where 1=1";
if ($array['cityId'] > -1) {
$params[] = $array['cityId'];
......@@ -297,59 +300,24 @@ class SearchDao
return $result;
}
public static function get_house_image_and_tags($house_result)
{
$array = array();
if ($house_result) {
$array['code'] = 2000;
$house_ids = array();
foreach ($house_result as $key => $value) {
$house_id = $value->id;
$house_ids[] = $house_id;
}
$tag_result = SearchDao::search_house_tag($house_ids);
//标签
if ($tag_result) {
foreach ($tag_result as $key => $value) {
$array['tags'][$value->house_id][] = $value->name;
}
}
//图片
$image_result = SearchDao::search_house_image($house_ids);
if ($image_result) {
foreach ($image_result as $key => $value) {
$array['images'][$value->house_id] = home_url() . Image::getImage($value->path,'small');
}
}
$array['result'] = $house_result;
} else {
$array['code'] = 2001;
}
return $array;
}
public static function search_house_image($house_ids)
{
$string = '(' . implode(',', array_map('intval', $house_ids)) . ')';
$sql = 'select * from (select ahi.house_id,ti.path,ti.image_type,case ti.image_type ' .
'when 1 then 1 ' .
'when 5 then 1 ' .
'ELSE 2 ' .
'end as type from ' . Config::A_HOUSE_IMAGE_TABLE . ' ahi ' .
'left join ' . Config::TOSPUR_IMAGE_TABLE . ' ti on ahi.image_id = ti.id ' .
'where house_id in ' . $string . ' order by type) as image group by house_id;';
global $wpdb;
return $wpdb->get_results($sql);
}
public static function search_house_tag($house_ids)
public static function get_house_list($house_result)
{
$string = '(' . implode(',', array_map('intval', $house_ids)) . ')';
$sql = 'select aht.house_id,tt.name from ' . Config::A_HOUSE_TAG_TABLE . ' aht' .
' left join ' . Config::TOSPUR_TAG_TABLE . ' tt on aht.tag_id = tt.id' .
' where house_id in ' . $string . ' and tt.type = 0;';
global $wpdb;
return $wpdb->get_results($sql);
$array = array();
if ($house_result) {
$array['code'] = 2000;
$house_ids = array();
foreach ($house_result as $key => $value) {
$house_id = $value->id;
$house_ids[] = $house_id;
if($value->path){
$value->path = home_url() . Image::getImage($value->path,'small');
}
}
$array['result'] = $house_result;
} else {
$array['code'] = 2001;
}
return $array;
}
public static function searchFeature()
......@@ -400,22 +368,26 @@ class SearchDao
where ada.house_id = %d";
$mainImage = $wpdb->get_results($wpdb->prepare($mainImagesSql,$hid));
foreach($mainImage as $key => $value){
$value->path = Image::getImage($value->path,'small');
$value->path = Image::getImage($value->path,'big');
}
$context['mainImage'] = $mainImage;
$recommendSql = "select th.id,th.name,th.average_price,th.latest_news,th.address,ti.path,dr.literal,(SELECT GROUP_CONCAT(left(tt.name,3)) from a_house_tag aht
LEFT JOIN tospur_tag tt on tt.id = aht.tag_id
where aht.house_id = th.id) as tags from tospur_house th
LEFT JOIN tospur_image ti on th.frontCover_id = ti.id
LEFT JOIN dic_room dr on dr.value = th.room_id
where th.id in(select recommend_id from a_house_recommend where house_id = %d);";
}else{
$recommendSql = "select th.id,th.name,th.community_name,ti.path,dr.value,th.rent,th.decoration,th.covered_area,th.total_price,(SELECT GROUP_CONCAT(left(tt.name,3)) from a_house_tag aht
LEFT JOIN tospur_tag tt on tt.id = aht.tag_id
where aht.house_id = th.id) as tags from tospur_house th
LEFT JOIN dic_room dr on dr.id = th.room_id
LEFT JOIN tospur_image ti on th.frontCover_id = ti.id
where th.id in(select recommend_id from a_house_recommend where house_id = %d);";
}
$recommendSql = "select ahi.house_id as id,ti.path from a_house_image ahi
left join tospur_image ti on ahi.image_id = ti.id
where ti.image_type in (1,5) and house_id
in (select recommend_id from a_house_recommend where house_id = %d) group by house_id";
$recommends = $wpdb->get_results($wpdb->prepare($recommendSql,$hid));
if(count($recommends) == 0){
$recommendSql = "select ahi.house_id as id,ti.path from a_house_image ahi
left join tospur_image ti on ahi.image_id = ti.id
where house_id in (select recommend_id from a_house_recommend where house_id = %d) group by house_id";
$recommends = $wpdb->get_results($wpdb->prepare($recommendSql,$hid));
}
foreach($recommends as $key => $value){
$value->path = Image::getImage($value->path,'small');
}
......
<?php
require_once('const.php');
$context = array();
$context['theme'] = get_template_directory_uri();
$context['url'] = home_url();
......@@ -15,8 +14,12 @@ if ($user_id != 0) {
$context['consultant_mobile'] = $_GET['mobile'];
$context['consultant_score_url'] = $const_score_page . '&consultant_id=' . $consultant_id;
$context['default_head'] = get_avatar_url(1);
Timber::render('consultant_info.html', $context);
}else{
wp_redirect($const_login_page);
exit;
}
Timber::render('consultant_info.html', $context);
?>
\ No newline at end of file
......@@ -4,21 +4,27 @@ $context = array();
$context['theme'] = get_template_directory_uri();
$context['url'] = home_url();
require_once(WP_PLUGIN_DIR . "/tospur/Dao/SearchDao.php");
$city = SearchDao::searchCity();
$context['city'] = $city;
$city_id = $_GET['city_id'];
if (!isset($city_id)) {
$city_id = $city[0]->id;
}
foreach ($city as $value) {
if ($value->id == $city_id) {
$context['city_name'] = $value->value;
$current_user = wp_get_current_user();
$user_id = $current_user->ID;
if ($user_id != 0) {
require_once(WP_PLUGIN_DIR . "/tospur/Dao/SearchDao.php");
$city = SearchDao::searchCity();
$context['city'] = $city;
$city_id = $_GET['city_id'];
if (!isset($city_id)) {
$city_id = $city[0]->id;
}
}
$context['city_id'] = $city_id;
$context['default_head'] = get_avatar_url(1);
Timber::render('consultant_list.html', $context);
foreach ($city as $value) {
if ($value->id == $city_id) {
$context['city_name'] = $value->value;
}
}
$context['city_id'] = $city_id;
$context['default_head'] = get_avatar_url(1);
Timber::render('consultant_list.html', $context);
}else{
wp_redirect($const_login_page);
exit;
}
?>
\ No newline at end of file
......@@ -399,7 +399,7 @@ body {
position: relative;
}
.addWrap .swipe .swipe-wrap div img {
max-width: 100%;
width: 100%;
}
.addWrap ul {
position: absolute;
......@@ -424,7 +424,7 @@ body {
opacity: 0.7;
}
.addWrap ul li.active {
background-color: #ffffff;
background-color: #898989;
}
.detail_row {
width: 100%;
......@@ -745,7 +745,7 @@ body {
.footer ul li:nth-child(3) .btn.btn-wechat span:nth-child(1) {
width: 30px;
height: 30px;
background: url("../img/white_wechat_icon.png") no-repeat;
background: url("../img/white_bespeak_icon.png") no-repeat;
background-size: cover;
-webkit-background-size: cover;
margin: 0 auto;
......@@ -758,7 +758,6 @@ body {
height: 100%;
position: relative;
overflow: hidden;
background-color: #000000;
}
.modal #carousel_wrapper #carousel_scroller {
height: 100%;
......@@ -777,20 +776,6 @@ body {
padding: 0;
overflow: hidden;
}
.modal #carousel_wrapper #carousel_scroller ul li p {
margin-bottom: 0;
width: 100%;
height: 100%;
display: table;
}
.modal #carousel_wrapper #carousel_scroller ul li p span {
display: table-cell;
vertical-align: middle;
text-align: center;
}
.modal #carousel_wrapper #carousel_scroller ul li p span img {
max-width: 100%;
}
.modal #carousel_wrapper .indicators {
position: absolute;
bottom: 0;
......@@ -816,3 +801,20 @@ body {
.modal #carousel_wrapper .indicators li.carousel_active {
opacity: 1;
}
.modal p {
margin-bottom: 0;
width: 100%;
height: 100%;
display: table;
}
.modal p span {
display: table-cell;
vertical-align: middle;
text-align: center;
}
.modal p span img {
max-width: 100%;
}
.modal-backdrop.in {
opacity: 1;
}
......@@ -565,8 +565,11 @@ a:hover {
width: 100%;
height: 45px;
line-height: 45px;
background-color: rgba(255, 255, 255, 0.9);
}
.footer a {
color: #7d7d7d;
font-size: 20px;
font-weight: bold;
background-color: rgba(255, 255, 255, 0.9);
display: block;
}
......@@ -356,7 +356,19 @@ body {
a:hover {
text-decoration: none;
}
.tab-content .tab-pane ul li {
#tabWrapper {
position: absolute;
z-index: 1;
top: 40px;
bottom: 0;
left: 0;
width: 100%;
overflow: hidden;
}
#tabWrapper #tabScroller {
padding-bottom: 15px;
}
#tabWrapper #tabScroller .tab-pane ul li {
width: 100%;
height: 60px;
line-height: 60px;
......@@ -364,10 +376,10 @@ a:hover {
color: #898989;
font-size: 18px;
}
.tab-content .tab-pane ul li:nth-child(odd) {
#tabWrapper #tabScroller .tab-pane ul li:nth-child(odd) {
background-color: #ffffff;
}
.tab-content .tab-pane ul li.arrow {
#tabWrapper #tabScroller .tab-pane ul li.arrow {
width: 100%;
height: 60px;
background: url("../img/gray_leftarrow_icon.png") no-repeat;
......@@ -375,17 +387,17 @@ a:hover {
-webkit-background-size: 30px 30px;
background-position: 95% center;
}
.tab-content .tab-pane ul li label {
#tabWrapper #tabScroller .tab-pane ul li label {
color: #000000;
margin-bottom: 0;
padding: 0 0 0 10px;
}
.tab-content .tab-pane ul li p {
#tabWrapper #tabScroller .tab-pane ul li p {
margin-bottom: 0;
padding: 0;
height: 100%;
}
.tab-content .tab-pane ul li p .form-control {
#tabWrapper #tabScroller .tab-pane ul li p .form-control {
color: #898989;
font-size: 18px;
background-color: transparent;
......@@ -395,11 +407,16 @@ a:hover {
-webkit-box-shadow: none;
-webkit-appearance: none;
}
.tab-content .tab-pane > p {
#tabWrapper #tabScroller .tab-pane ul li p .form-control::-webkit-outer-spin-button,
#tabWrapper #tabScroller .tab-pane ul li p .form-control::-webkit-inner-spin-button {
-webkit-appearance: none !important;
margin: 0;
}
#tabWrapper #tabScroller .tab-pane > p {
padding-right: 15px;
color: #898989;
}
.tab-content .tab-pane .btn {
#tabWrapper #tabScroller .tab-pane .btn {
width: 86%;
display: block;
color: #ffffff;
......@@ -418,12 +435,12 @@ a:hover {
box-shadow: 0 2px 0 0 #117bb9;
-webkit-box-shadow: 0 2px 0 0 #117bb9;
}
.tab-content .tab-pane .btn:active {
#tabWrapper #tabScroller .tab-pane .btn:active {
background-color: #117bb9;
}
.tab-content .tab-pane .btn:focus {
#tabWrapper #tabScroller .tab-pane .btn:focus {
outline: 0;
}
.tab-content .tab-pane:last-child .btn {
#tabWrapper #tabScroller .tab-pane:last-child .btn {
margin-top: 5%;
}
......@@ -397,6 +397,11 @@ a:hover {
.main 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 {
-webkit-appearance: none !important;
margin: 0;
}
.main ul li p .form-control.width-sm {
width: 45px;
}
......
......@@ -109,10 +109,6 @@ function ajax_get_house(url, loading, ajax_data, context) {
$.each(data.result, function (index, value) {
var houseType = value.house_type;
var template = $('#template_' + houseType).html();
if (data.tags)
var data_tags = data.tags[value.id];
if (data.images)
var data_images = data.images[value.id];
var div = $('<div class="row">');
div.append(template);
div.find('[data-attr=name]').text(value.name);
......@@ -121,7 +117,12 @@ function ajax_get_house(url, loading, ajax_data, context) {
div.find('[data-attr=type]').text(value.literal);
div.find('[data-attr=address]').text(value.address);
div.find('[data-attr=latest_news]').text(value.latest_news);
div.find('[data-attr=price]').html('<em>' + (value.average_price / 10000).toFixed(2) + '万</em>/m<em>2</em>');
var price = value.average_price;
if (price.length > 4) {
price = (price / 10000).toFixed(2) + '万';
}
div.find('[data-attr=price]').html('<em>' + rent + '</em>/月');
div.find('[data-attr=price]').html('<em>' + price + '</em>/m<em>2</em>');
} else if (houseType == 1) {
div.find('[data-attr=community]').text(value.community_name);
div.find('[data-attr=apartment]').text(value.bp_literal);
......@@ -134,16 +135,20 @@ function ajax_get_house(url, loading, ajax_data, context) {
div.find('[data-attr=decoration]').text(value.decoration);
var rent = value.rent;
if (rent.length > 4) {
rent = rent / 10000 + '万';
rent = (rent / 10000).toFixed(2) + '万';
}
div.find('[data-attr=price]').html('<em>' + rent + '</em>/月');
}
var image = div.find('[data-attr=image]');
if (data_images) {
image.attr('src', data_images);
if (value.path){
image.attr('src', value.path);
}else{
image.attr('src', url + '/wp-content/themes/tospur/img/img.jpg');
}
if (data_tags) {
$.each(data_tags, function (k, v) {
if (value.tags) {
var tagsArray = value.tags.split(',');
console.log(tagsArray);
$.each(tagsArray, function (k, v) {
if (k < 3) {
tags.prepend('<span class="label">' + v + '</span>');
}
......
......@@ -23,8 +23,11 @@ if ($current_user_id != 0) {
} else {
$context['result'] = null;
}
}
Timber::render('list.html', $context);
Timber::render('list.html', $context);
}else{
wp_redirect($const_login_page);
exit;
}
?>
\ No newline at end of file
......@@ -8,6 +8,9 @@ $current_user = wp_get_current_user();
$user_id = $current_user->ID;
if ($user_id != 0) {
$context['user_id'] = $user_id;
}else{
wp_redirect($const_login_page);
exit;
}
Timber::render('myHouse.html', $context);
......
......@@ -19,7 +19,7 @@ if ($user_id != 0) {
$context['consultant_id'] = $_GET['consultant_id'];
Timber::render('view.html', $context);
}else{
wp_redirect(home_url()."?page=login");
wp_redirect($const_login_page);
exit;
}
......
......@@ -44,7 +44,7 @@
$(document).ready(function(){
$("#slider").bind("tap",function(){
$("#carousel_wrapper").parent().show();
$("#carouselModal").modal('show');
var carousel = $("#carousel_wrapper");
var carouselWidth = carousel.width();
......@@ -66,8 +66,8 @@
});
return false;
});
$("#carousel_wrapper").parent().bind("click",function(){
$(this).hide();
$("#carouselModal,#photoModal").bind("click",function(){
$(this).modal('hide');
return false;
});
......@@ -93,13 +93,22 @@
$(".map").bind("tap",function(){
location.href = "{{ siteUrl }}/?page=map&a={{result.address}}&c={{cityName}}&hn={{result.community_name}}<br>{{result.address}}&p={{result.location}}";
});
$(".recommendCont").on("tap",".row",function(){
window.location.href = '{{ siteUrl }}/?page=detail&hid=' + $(this).attr("data-id");
});
$("#scroller").on("tap","*[data-image-url]",function(){
$("#photoModal").find("img").eq(0).attr("src",$(this).attr("data-image-url"));
$("#photoModal").modal("show");
return false;
});
});
</script>
</head>
<body>
<p class="collect">
</p>
<p class="collect"></p>
<!-- 图片滚动 -->
<div class="addWrap">
......@@ -129,9 +138,9 @@
{% if result.average_price>=10000 %}
{{(result.average_price/10000)|round(2, 'floor')}}万
{% else %}
{{result.average_price}}
{{result.average_price}}
{% endif %}
</em>/m<em>2</em></span>
</em>m<em>2</em></span>
</li>
<li class="col-xs-5">
<button type="button" class="btn btn-xs" id="calculator">房贷计算器</button>
......@@ -148,10 +157,10 @@
<div id="scroller">
<ul class="list-inline text-nowrap">
{% for item in mainImage %}
<li>
<li data-image-url="{{siteUrl}}{{ item.path }}">
<p><img src="{{siteUrl}}{{ item.path }}"></p>
<p>{{item.type}}</p>
<p>{{item.area}}/m<em>2</em></p>
<p>{{item.area}}m<em>2</em></p>
</li>
{% endfor %}
</ul>
......@@ -197,19 +206,43 @@
{{result.overview}}
</p>
</div>
<div class="detail_row">
<p class="detail_title pull-left">推荐房源</p>
<div class="detail_row recommend">
<p class="detail_title">推荐房源</p>
<div class="recommendCont">
</div>
</div>
<ul class="list-unstyled recommendCont">
<div class="detail_row recommend">
<p class="detail_title">推荐房源</p>
<div class="recommendCont">
{% for item in recommends %}
<a href="{{siteUrl}}?page=detail&hid={{item.id}}"><li class="col-xs-3"><p style="background-image:url({{siteUrl}}{{ item.path }});"></p></li></a>
<div data-id="{{item.id}}" class="row">
<p>
{% if item.path %}
<img src="{{siteUrl}}{{item.path}}">
{% else %}
<img src="{{siteUrl}}/wp-content/themes/tospur/img/img.jpg">
{% endif %}
</p>
<ul class="list-unstyled">
<li class="address">
<span>{{item.name}}</span>
<span class="pull-right">{{item.literal}}</span>
</li>
<li>{{item.address}}</li>
<li>{{item.latest_news}}</li>
<li>
{% for tag in item.tags|split(',') %}
<span class="label">{{tag}}</span>
{% endfor %}
<span class="pull-right">
<em>
{% if item.average_price>=10000 %}
{{(item.average_price/10000)|round(2, 'floor')}}万
{% else %}
{{item.average_price}}元
{% endif %}
</em>/m<em>2</em>
</span>
</li>
</ul>
</div>
{% endfor %}
</ul>
</div>
</div>
<div class="detail_row" id="consultantDiv">
<p class="detail_title">置业顾问</p>
......@@ -267,7 +300,7 @@
<!-- 二手房详细 -->
</footer>
<div class="modal">
<div class="modal" id="carouselModal">
<div id="carousel_wrapper">
<div id="carousel_scroller">
<ul class="list-inline text-nowrap">
......@@ -287,6 +320,10 @@
</ul>
</div>
</div>
<div class="modal" id="photoModal">
<p>
<span><img></span>
</p>
</div>
</body>
</html>
\ No newline at end of file
......@@ -43,7 +43,7 @@
$(document).ready(function(){
$("#slider").bind("tap",function(){
$("#carousel_wrapper").parent().show();
$("#carouselModal").modal("show");
var carousel = $("#carousel_wrapper");
var carouselWidth = carousel.width();
carousel.find("#carousel_scroller ul li").css({"width":carouselWidth});
......@@ -65,8 +65,8 @@
});
return false;
});
$("#carousel_wrapper").parent().bind("click",function(){
$(this).hide();
$("#carouselModal").bind("click",function(){
$("#carouselModal").modal("hide");
return false;
});
......@@ -96,13 +96,17 @@
$(".col-xs-2").bind("tap",function(){
location.href = "{{siteUrl}}?page=consultant_info&consultant_id={{ consultant[0].id }}";
});
$(".recommendCont").on("tap",".row",function(){
window.location.href = '{{ siteUrl }}/?page=detail&hid=' + $(this).attr("data-id");
});
});
</script>
</head>
<body>
<p class="collect">
<i class="iconfont">&#xe604;</i>
<i class="iconfont"></i>
</p>
<!-- 图片滚动 -->
......@@ -138,19 +142,27 @@
<!-- 二手房详细 -->
<ul class="list-unstyled">
<li class="col-xs-7">房源编号:{{result.house_number}}</li>
<li class="col-xs-5">
<button type="button" class="btn btn-xs" id="calculator">房贷计算器</button>
</li>
<li class="col-xs-7 price">
售价:<span><em>{{(result.total_price/10000)|round(2, 'floor')}}万</em></span>
</li>
<li class="col-xs-5">单价:
{% if result.average_price>=10000 %}
{{(result.average_price/10000)|round(2, 'floor')}}万
{% else %}
{{result.average_price}}元
{% endif %}
</li>
{% if result.house_type == 1%}
<li class="col-xs-5">
<button type="button" class="btn btn-xs" id="calculator">房贷计算器</button>
</li>
<li class="col-xs-7 price">
售价:<span><em>{{(result.total_price/10000)|round(2, 'floor')}}万</em></span>
</li>
<li class="col-xs-5">单价:
{% if result.average_price>=10000 %}
{{(result.average_price/10000)|round(2, 'floor')}}万
{% else %}
{{result.average_price}}
{% endif %}
</li>
{% else %}
<li class="col-xs-5">
</li>
<li class="col-xs-7 price">
租金:<span><em>{{result.rent}}/月</em></span>
</li>
{% endif %}
</ul>
<!-- 二手房详细 -->
</div>
......@@ -168,27 +180,75 @@
</ul>
</div>
<div class="detail_row">
<p class="detail_title">房源点评</p>
<p>{{result.overview}}</p>
<a class="collapsed" data-toggle="collapse" href="#collapseSummary" aria-expanded="false">
<p class="detail_title">房源点评<span class="pull-right"></span></p>
</a>
<p class="collapse" id="collapseSummary" style="min-height: 60px; display: block; overflow: hidden; height: 0px;" aria-expanded="false">
{{result.overview}}
</p>
</div>
<div class="detail_row">
<p class="detail_title">位置及周边</p>
<ul class="list-unstyled">
<a class="collapsed" data-toggle="collapse" href="#collapseAddress">
<p class="detail_title">位置及周边<span class="pull-right"></span></p>
</a>
<ul class="list-unstyled collapse" id="collapseAddress" style="min-height:60px;display:block;overflow:hidden;height:0;">
<li>地址:{{result.address}}</li>
<li>交通线路:{{result.traffic}}</li>
<li>周边配套:{{result.periphery}}</li>
</ul>
<p class="map">
<span></span>
</p>
<p class="map"></p>
</div>
<div class="detail_row">
<p class="detail_title pull-left">推荐房源</p>
<ul class="list-unstyled recommendCont">
<div class="detail_row recommend">
<p class="detail_title">推荐房源</p>
<div class="recommendCont">
{% for item in recommends %}
<a href="{{siteUrl}}?page=detail&hid={{item.id}}"><li class="col-xs-3"><p style="background-image:url({{siteUrl}}{{ item.path }});"></p></li></a>
<div data-id="{{item.id}}" class="row">
<p>
{% if item.path %}
<img src="{{siteUrl}}{{item.path}}">
{% else %}
<img src="{{siteUrl}}/wp-content/themes/tospur/img/img.jpg">
{% endif %}
</p>
<ul class="list-unstyled">
<li class="multiLine_omit">
{{item.name}}
</li>
<li>{{item.community_name}}</li>
<li>
<span>{{item.value}}</span>
{% if result.house_type == 2 %}
<span>{{item.decoration}}</span>
{% endif %}
<span>{{item.covered_area}}平米</span>
</li>
<li>
{% for tag in item.tags|split(',') %}
{% if loop.index <=3 %}
<span class="label">{{tag}}</span>
{% endif %}
{% endfor %}
<span class="pull-right">
{% if result.house_type == 1 %}
<em>
{{(item.total_price/10000)|round(2, 'floor')}}万
</em>
{% elseif result.house_type == 2 %}
<em>
{% if item.rent>=10000 %}
{{(item.rent/10000)|round(2, 'floor')}}万
{% else %}
{{item.rent}}
{% endif %}
/月
</em>
{% endif %}
</span>
</li>
</ul>
</div>
{% endfor %}
</ul>
</div>
</div>
{% if consultant[0] %}
<footer class="footer navbar-fixed-bottom">
......@@ -218,17 +278,17 @@
<span>电话联系</span>
</a>
{% endif %}
<!--<a href="#" class="btn btn-wechat">
<a href="{{siteUrl}}?page=view&house_id={{hid}}&consultant_id={{consultant[0].id}}" class="btn btn-wechat">
<span></span>
<span>微信联系</span>
</a>-->
<span>一键预约</span>
</a>
</li>
</ul>
<!-- 二手房详细 -->
</footer>
{% endif %}
<div class="modal">
<div class="modal" id="carouselModal">
<div id="carousel_wrapper">
<div id="carousel_scroller">
<ul class="list-inline text-nowrap">
......
......@@ -6,7 +6,7 @@
<meta name="apple-mobile-web-app-capable" content="yes"/>
<meta name="apple-mobile-web-app-status-bar-style" content="black"/>
<meta name="format-detection" content="telephone=no"/>
<title>列表</title>
<title>{% if houseType == 0%}新房列表{% elseif houseType == 1 %}二手房列表{% elseif houseType == 2 %}租房列表{% endif %}</title>
<link rel="stylesheet" type="text/css" href="{{ theme }}/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="{{ theme }}/css/list.css">
<script type="text/javascript" src="{{ theme }}/js/iscroll.js"></script>
......@@ -29,8 +29,10 @@
</div>
</div>
<div class="has-feedback pull-right">
<input type="text" class="form-control" placeholder="输入楼盘名/地段名搜索" id="searchText">
<span class="glyphicon glyphicon-search form-control-feedback" id="searchBtn"></span>
<form id="searchForm" method="post">
<input type="text" class="form-control" placeholder="输入楼盘名/地段名搜索" id="searchText">
<span class="glyphicon glyphicon-search form-control-feedback" id="searchBtn"></span>
</form>
</div>
</div>
......@@ -309,7 +311,6 @@
other.children(":first").addClass('active');
}
$.each(other_item,function(i,item){
console.log(searchData[id]+"=="+item[roomAndAcreageKey]);
var active = searchData[id]==item[roomAndAcreageKey]?' class="active"':'';
other.append('<a data-id="'+item[roomAndAcreageKey]+'"'+active+'>'+item.value+'</a>');
});
......@@ -330,13 +331,20 @@
}
});
$('#searchBtn').bind('tap',function(){
searchData.index = 0;
searchData.searchText = $('#searchText').val();
scroller.html('');
ajax_get_house('{{ url }}', loading, searchData, scroller);
searchNameAndAddress();
});
$('#searchForm').submit(function(){
searchNameAndAddress();
return false;
});
ajax_get_house('{{ url }}', loading, searchData, scroller);
});
function searchNameAndAddress(){
searchData.index = 0;
searchData.searchText = $('#searchText').val();
scroller.html('');
ajax_get_house('{{ url }}', loading, searchData, scroller);
}
var searchData = {
action: 'search_house',
cityId: {{ cityId }},
......
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