Commit 9af48fab by felix

每日一更

parent 5a0a2ded
...@@ -66,6 +66,7 @@ class House { ...@@ -66,6 +66,7 @@ class House {
$houseid = $wpdb->insert_id; $houseid = $wpdb->insert_id;
} }
//主力房源的图片与房子信息关联插入数据库 //主力房源的图片与房子信息关联插入数据库
if(isset($uploadedfile["name"])){
foreach($uploadedfile["name"] as $key=> $value) { foreach($uploadedfile["name"] as $key=> $value) {
$uploadParam = array( $uploadParam = array(
"name" => $uploadedfile["name"][$key], "name" => $uploadedfile["name"][$key],
...@@ -128,7 +129,9 @@ class House { ...@@ -128,7 +129,9 @@ class House {
} }
} }
} }
}
if(isset($data["recommend"])){
//插入推荐房源id与添加新房id到关联表a_house_recommend //插入推荐房源id与添加新房id到关联表a_house_recommend
foreach($data["recommend"] as $value){ foreach($data["recommend"] as $value){
$a_house_recommendArray = array( $a_house_recommendArray = array(
...@@ -140,6 +143,9 @@ class House { ...@@ -140,6 +143,9 @@ class House {
return 504; return 504;
} }
} }
}
if($data["recConsultant"]){
//插入推荐置业顾问user_id与新房id到关联表a_house_recommend //插入推荐置业顾问user_id与新房id到关联表a_house_recommend
foreach($data["recConsultant"] as $val){ foreach($data["recConsultant"] as $val){
$a_house_userArray = array( $a_house_userArray = array(
...@@ -153,4 +159,5 @@ class House { ...@@ -153,4 +159,5 @@ class House {
} }
} }
} }
}
} }
\ No newline at end of file
...@@ -377,7 +377,7 @@ ...@@ -377,7 +377,7 @@
var file = $("<input>").attr({"type":"file","name":"files["+i+"]"}).addClass("picFiles"); var file = $("<input>").attr({"type":"file","name":"files["+i+"]"}).addClass("picFiles");
var select = $("<select>").attr("name","data["+i+"][type]"); var select = $("<select>").attr("name","data["+i+"][type]");
{% for item in photoType %} {% for item in photoType %}
select.append($("<option>").attr("value",{{item.id}}).append('{{item.photoType}}')); select.append($("<option>").attr("value",{{item.id}}).append('{{item.value}}'));
{% endfor%} {% endfor%}
var p = $("<p>").append(select).append(file).append(picDelet); var p = $("<p>").append(select).append(file).append(picDelet);
$("#picList").append(p); $("#picList").append(p);
...@@ -413,7 +413,7 @@ ...@@ -413,7 +413,7 @@
var type = $("<input>").attr({"type":"hidden","name":"data["+i+"][type]","value":0,"property":+i}); 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 file = $("<input>").attr({"type":"file","name":"files["+(i+1)+"]","property":+(i+1)}).addClass("files");
var select = $("<select>").attr({"name":"data["+i+"][buildProperty]"}); var select = $("<select>").attr({"name":"data["+i+"][buildProperty]"});
{% for item in buildProperty %} {% for item in buildProperty %}{{item.id}}
select.append($("<option>").attr("value",{{item.id}}).append('{{item.value}}')); select.append($("<option>").attr("value",{{item.id}}).append('{{item.value}}'));
{% endfor%} {% endfor%}
var areatext = $("<input>").attr({"type":"text","placeholder":"面积","name":"data["+i+"][housearea]"}).addClass("regular-text"); var areatext = $("<input>").attr({"type":"text","placeholder":"面积","name":"data["+i+"][housearea]"}).addClass("regular-text");
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
class Config { class Config {
//table name //table name
const A_DISTRICT_AREA_TABLE = 'a_district_area';
const DIC_CITY_TABLE = 'dic_city'; const DIC_CITY_TABLE = 'dic_city';
const DIC_ROOM_TABLE = 'dic_room'; const DIC_ROOM_TABLE = 'dic_room';
const DIC_BUILDPROPERTY_TABLE = 'dic_buildproperty'; const DIC_BUILDPROPERTY_TABLE = 'dic_buildproperty';
...@@ -12,6 +13,7 @@ class Config { ...@@ -12,6 +13,7 @@ class Config {
const TOSPUR_ORGANIZATION_TABLE = 'tospur_organization'; const TOSPUR_ORGANIZATION_TABLE = 'tospur_organization';
const TOSPUR_CONSULTANT = 'tospur_consultant'; const TOSPUR_CONSULTANT = 'tospur_consultant';
const TOSPUR_HOUSE_TABLE = 'tospur_house'; const TOSPUR_HOUSE_TABLE = 'tospur_house';
const TOSPUR_IMAGE_TABLE = 'tospur_image';
//sync url //sync url
......
<?php <?php
define('tospur_view_house_table', 'tospur_view_house');
class dao class dao
{ {
//insert 预约看房 //insert 预约看房
...@@ -15,14 +17,14 @@ class dao ...@@ -15,14 +17,14 @@ class dao
'handle' => 0 'handle' => 0
); );
global $wpdb; global $wpdb;
$result = $wpdb->insert('view_house', $insert_view_house_array); $result = $wpdb->insert(tospur_view_house_table, $insert_view_house_array);
return $result; return $result;
} }
public static function update_view_house($id) public static function update_view_house($id)
{ {
global $wpdb; global $wpdb;
$result = $wpdb->update('view_house', array( $result = $wpdb->update(tospur_view_house_table, array(
'handle' => 1, 'handle' => 1,
'handle_date' => current_time('Y-m-d H:i:s') 'handle_date' => current_time('Y-m-d H:i:s')
), array( ), array(
...@@ -34,7 +36,7 @@ class dao ...@@ -34,7 +36,7 @@ class dao
public static function update_view_house_consultant($house_id, $consultant_id) public static function update_view_house_consultant($house_id, $consultant_id)
{ {
global $wpdb; global $wpdb;
$result = $wpdb->update('view_house', array( $result = $wpdb->update(tospur_view_house_table, array(
'consultant_id' => $consultant_id 'consultant_id' => $consultant_id
), array( ), array(
'id' => $house_id 'id' => $house_id
...@@ -46,7 +48,7 @@ class dao ...@@ -46,7 +48,7 @@ class dao
public static function search_view_house_by_user_id($user_id) public static function search_view_house_by_user_id($user_id)
{ {
global $wpdb; global $wpdb;
$sql = "select v.house_id,v.date,v.time,v.consultant_id,v.handle from view_house v where user_id = " . $user_id . " order by v.date desc"; $sql = "select v.house_id,v.date,v.time,v.consultant_id,v.handle from " . tospur_view_house_table . " v where user_id = " . $user_id . " order by v.date desc";
return $wpdb->get_results($sql); return $wpdb->get_results($sql);
} }
...@@ -54,7 +56,7 @@ class dao ...@@ -54,7 +56,7 @@ class dao
public static function search_view_house_by_consultant_id($consultant_id) public static function search_view_house_by_consultant_id($consultant_id)
{ {
global $wpdb; global $wpdb;
$sql = "select v.id,v.house_id,v.user_id,v.date,v.time,v.handle from view_house v where consultant_id = " . $consultant_id . " order by v.date desc"; $sql = "select v.id,v.house_id,v.user_id,v.date,v.time,v.handle from " . tospur_view_house_table . " v where consultant_id = " . $consultant_id . " order by v.date desc";
return $wpdb->get_results($sql); return $wpdb->get_results($sql);
} }
...@@ -122,6 +124,34 @@ class dao ...@@ -122,6 +124,34 @@ class dao
'phone' => $phone '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 tospur_consultant c ' .
'left join wp_users u on c.id = u.ID ' .
'left join (select consultant_id,sum(score)/count(score) as average_score from tospur_consultant_score 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 search_house_image($house_ids)
{
$sql = 'select ahi.house_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 ' . $house_ids . ' group by house_id';
global $wpdb;
return $wpdb->get_results($sql);
}
public static function search_house_tag($house_ids)
{
$sql = 'select aht.house_id,tt.name from a_house_tag aht' .
' left join tospur_tag tt on aht.tag_id = tt.id' .
' where house_id in ' . $house_ids;
global $wpdb;
return $wpdb->get_results($sql);
}
} }
?> ?>
\ No newline at end of file
...@@ -2,12 +2,46 @@ ...@@ -2,12 +2,46 @@
require_once(WP_PLUGIN_DIR."/tospur/Config.php"); require_once(WP_PLUGIN_DIR."/tospur/Config.php");
$context = array(); $context = array();
$context['theme'] = get_template_directory_uri(); $context['theme'] = get_template_directory_uri();
$context['siteUrl'] = get_site_url();
if(isset($_GET['hid'])){ if(isset($_GET['hid'])){
$hid = $_GET['hid']; $hid = $_GET['hid'];
$context['hid'] = $hid;
$sql = "select * from ".Config::TOSPUR_HOUSE_TABLE." where id = %d"; $sql = "select * from ".Config::TOSPUR_HOUSE_TABLE." where id = %d";
$result = $wpdb->get_row($wpdb->prepare($sql,$hid)); $result = $wpdb->get_row($wpdb->prepare($sql,$hid));
$context['result'] = $result; $context['result'] = $result;
$context['cityName'] = SearchDao::getCityNameWithId($result->city_id);
$mainImagesSql = "SELECT db.literal as type,ada.house_area as area,ti.path FROM ".Config::A_DISTRICT_AREA_TABLE." ada
LEFT JOIN ".Config::DIC_BUILDPROPERTY_TABLE." db on db.value = ada.buildproperty_id
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));
$context['mainImage'] = $mainImage;
$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));
$context['recommends'] = $recommends;
$consultantSql = 'select id,name,mobile,imageUrl,s.average_score from tospur_consultant c
LEFT JOIN (select consultant_id,sum(score)/count(score) as average_score
from tospur_consultant_score
where valid=1 group by consultant_id) s on c.id = s.consultant_id
where id in(select user_id from a_house_user where user_type = 1 and house_id = %d);';
$consultant = $wpdb->get_results($wpdb->prepare($consultantSql,$hid));
$context['consultant'] = $consultant;
$imagesSql = 'select * from tospur_image ti
LEFT JOIN a_house_image ahi on ti.id = ahi.image_id
WHERE ahi.house_id = %d order by image_type;';
$images = $wpdb->get_results($wpdb->prepare($imagesSql,$hid));
$context['images'] = $images;
Timber::render('detail.html', $context); Timber::render('detail.html', $context);
}else{ }else{
Timber::render('error.html', $context); Timber::render('error.html', $context);
......
...@@ -35,6 +35,9 @@ function page_template($template) ...@@ -35,6 +35,9 @@ function page_template($template)
case 'detail': case 'detail':
$page = $theme . '/detail.php'; $page = $theme . '/detail.php';
break; break;
case 'map':
$page = $theme . '/map.php';
break;
default: default:
$page = $template; $page = $template;
break; break;
...@@ -97,6 +100,7 @@ function view_house() ...@@ -97,6 +100,7 @@ function view_house()
} }
$time = (9 + $index) . ':00-' . (10 + $index) . ':00'; $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 = dao::insert_view_house($_POST['house_id'], $_POST['user_id'], $date, $index, $time, $_POST['consultant_id']);
print_r($result);
$array = array(); $array = array();
if ($result) { if ($result) {
$array['code'] = 2000; $array['code'] = 2000;
...@@ -146,4 +150,23 @@ function get_consultant_score($consultant_id) ...@@ -146,4 +150,23 @@ function get_consultant_score($consultant_id)
return dao::search_consultant_score($consultant_id); return dao::search_consultant_score($consultant_id);
} }
add_action('wp_ajax_add_collect', 'add_collect');
function add_collect($house_id){
$insert_a_house_user_array = array(
'user_id' => get_current_user_id(),
'house_id' => $_POST["hid"],
'user_type' => 0
);
global $wpdb;
$result = $wpdb->insert('a_house_user', $insert_a_house_user_array);
$array = array();
if ($result) {
$array['code'] = 2000;
} else {
$array['code'] = 2001;
}
wp_send_json($array);
}
?> ?>
\ No newline at end of file
wp-content/themes/tospur/img/star.png

5.61 KB | W: | H:

wp-content/themes/tospur/img/star.png

7.18 KB | W: | H:

wp-content/themes/tospur/img/star.png
wp-content/themes/tospur/img/star.png
wp-content/themes/tospur/img/star.png
wp-content/themes/tospur/img/star.png
  • 2-up
  • Swipe
  • Onion skin
<?php
require_once(WP_PLUGIN_DIR."/tospur/Config.php");
$context = array();
$context['theme'] = get_template_directory_uri();
$context['siteUrl'] = get_site_url();
$context['address'] = $_GET['a'];
$context['city'] = $_GET['c'];
$context['point'] = $_GET['p'];
$context['houseName'] = $_GET['hn'];
Timber::render('map.html', $context);
?>
\ No newline at end of file
...@@ -6,7 +6,8 @@ $context['url'] = home_url(); ...@@ -6,7 +6,8 @@ $context['url'] = home_url();
$current_user = wp_get_current_user(); $current_user = wp_get_current_user();
$user_id = $current_user->ID; $user_id = $current_user->ID;
if ($user_id == 0) { if ($user_id == 0) {
wp_redirect(get_site_url()."?page=login");
exit;
}else{ }else{
$date = current_time('Y-m-d'); $date = current_time('Y-m-d');
$datetime = new DateTime($cureent_time . '+1 day'); $datetime = new DateTime($cureent_time . '+1 day');
...@@ -19,8 +20,8 @@ if ($user_id == 0) { ...@@ -19,8 +20,8 @@ if ($user_id == 0) {
$context['user_id'] = $user_id; $context['user_id'] = $user_id;
$context['house_id'] = $_GET['house_id']; $context['house_id'] = $_GET['house_id'];
$context['consultant_id'] = $_GET['consultant_id']; $context['consultant_id'] = $_GET['consultant_id'];
Timber::render('view.html', $context);
} }
Timber::render('view.html', $context);
?> ?>
\ No newline at end of file
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no"/>
<style type="text/css">
body, html, #allmap {
width: 100%;
height: 100%;
overflow: hidden;
margin: 0;
font-family: "微软雅黑";
}
.hn {
margin: 10px 0 5px 0
}
</style>
<script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=DhzdodNVxoDSiBzRfZod4FG8"></script>
<title>地图</title>
</head>
<body>
<div id="allmap"></div>
</body>
</html>
<script type="text/javascript">
//map.html?a=南通市城山家园&hn=城山家园</br>同普路1220号&c=南通市&p=120.890824,31.971025
// 创建Map实例
var map = new BMap.Map("allmap");
var url_address = '{{address}}';
var url_city = '{{city}}';
var url_point = '{{point}}';
var url_houseName = "<a class='hn'>{{houseName}}</a>";
if (url_point) {
var pointLng = url_point.split(',')[0];
var pointLat = url_point.split(',')[1];
fromPoint(pointLng,pointLat);
} else if (!!url_address) {
fromAddress();
}
function fromAddress() {
// 创建地址解析器实例
var myGeo = new BMap.Geocoder();
// 将地址解析结果显示在地图上,并调整地图视野
myGeo.getPoint(url_address, function (point) {
if (point) {
map.centerAndZoom(point, 18);
map.addOverlay(new BMap.Marker(point));
showinfo(point);
} else {
alert("您选择地址没有解析到结果!");
}
},url_city);
}
function fromPoint(lng,lat) {
var point = new BMap.Point(lng, lat);
map.centerAndZoom(point, 18);
map.addOverlay(new BMap.Marker(point));
showinfo(point);
}
function showinfo(point) {
var opts = {
width: 0, // 信息窗口宽度
height: 0, // 信息窗口高度
//title: "楼盘名称", // 信息窗口标题
enableCloseOnClick: false, //
offset: new BMap.Size(10, -20) //信息窗位置偏移值
}
var infoWindow = new BMap.InfoWindow(url_houseName, opts); // 创建信息窗口对象
map.openInfoWindow(infoWindow, point); //开启信息窗口
}
function getUrlParam(name) {
var reg= new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
var r = window.location.search.substr(1).match(reg);
if (r != null) return decodeURI(r[2]);
return null;
}
</script>
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