Commit 9af48fab by felix

每日一更

parent 5a0a2ded
......@@ -66,6 +66,7 @@ class House {
$houseid = $wpdb->insert_id;
}
//主力房源的图片与房子信息关联插入数据库
if(isset($uploadedfile["name"])){
foreach($uploadedfile["name"] as $key=> $value) {
$uploadParam = array(
"name" => $uploadedfile["name"][$key],
......@@ -128,7 +129,9 @@ class House {
}
}
}
}
if(isset($data["recommend"])){
//插入推荐房源id与添加新房id到关联表a_house_recommend
foreach($data["recommend"] as $value){
$a_house_recommendArray = array(
......@@ -140,6 +143,9 @@ class House {
return 504;
}
}
}
if($data["recConsultant"]){
//插入推荐置业顾问user_id与新房id到关联表a_house_recommend
foreach($data["recConsultant"] as $val){
$a_house_userArray = array(
......@@ -153,4 +159,5 @@ class House {
}
}
}
}
}
\ No newline at end of file
......@@ -377,7 +377,7 @@
var file = $("<input>").attr({"type":"file","name":"files["+i+"]"}).addClass("picFiles");
var select = $("<select>").attr("name","data["+i+"][type]");
{% 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%}
var p = $("<p>").append(select).append(file).append(picDelet);
$("#picList").append(p);
......@@ -413,7 +413,7 @@
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 %}
{% 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");
......
......@@ -2,6 +2,7 @@
class Config {
//table name
const A_DISTRICT_AREA_TABLE = 'a_district_area';
const DIC_CITY_TABLE = 'dic_city';
const DIC_ROOM_TABLE = 'dic_room';
const DIC_BUILDPROPERTY_TABLE = 'dic_buildproperty';
......@@ -12,6 +13,7 @@ class Config {
const TOSPUR_ORGANIZATION_TABLE = 'tospur_organization';
const TOSPUR_CONSULTANT = 'tospur_consultant';
const TOSPUR_HOUSE_TABLE = 'tospur_house';
const TOSPUR_IMAGE_TABLE = 'tospur_image';
//sync url
......
<?php
define('tospur_view_house_table', 'tospur_view_house');
class dao
{
//insert 预约看房
......@@ -15,14 +17,14 @@ class dao
'handle' => 0
);
global $wpdb;
$result = $wpdb->insert('view_house', $insert_view_house_array);
$result = $wpdb->insert(tospur_view_house_table, $insert_view_house_array);
return $result;
}
public static function update_view_house($id)
{
global $wpdb;
$result = $wpdb->update('view_house', array(
$result = $wpdb->update(tospur_view_house_table, array(
'handle' => 1,
'handle_date' => current_time('Y-m-d H:i:s')
), array(
......@@ -34,7 +36,7 @@ class dao
public static function update_view_house_consultant($house_id, $consultant_id)
{
global $wpdb;
$result = $wpdb->update('view_house', array(
$result = $wpdb->update(tospur_view_house_table, array(
'consultant_id' => $consultant_id
), array(
'id' => $house_id
......@@ -46,7 +48,7 @@ class dao
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 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);
}
......@@ -54,7 +56,7 @@ class dao
public static function search_view_house_by_consultant_id($consultant_id)
{
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);
}
......@@ -122,6 +124,34 @@ class dao
'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 @@
require_once(WP_PLUGIN_DIR."/tospur/Config.php");
$context = array();
$context['theme'] = get_template_directory_uri();
$context['siteUrl'] = get_site_url();
if(isset($_GET['hid'])){
$hid = $_GET['hid'];
$context['hid'] = $hid;
$sql = "select * from ".Config::TOSPUR_HOUSE_TABLE." where id = %d";
$result = $wpdb->get_row($wpdb->prepare($sql,$hid));
$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);
}else{
Timber::render('error.html', $context);
......
......@@ -35,6 +35,9 @@ function page_template($template)
case 'detail':
$page = $theme . '/detail.php';
break;
case 'map':
$page = $theme . '/map.php';
break;
default:
$page = $template;
break;
......@@ -97,6 +100,7 @@ function view_house()
}
$time = (9 + $index) . ':00-' . (10 + $index) . ':00';
$result = dao::insert_view_house($_POST['house_id'], $_POST['user_id'], $date, $index, $time, $_POST['consultant_id']);
print_r($result);
$array = array();
if ($result) {
$array['code'] = 2000;
......@@ -146,4 +150,23 @@ function get_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();
$current_user = wp_get_current_user();
$user_id = $current_user->ID;
if ($user_id == 0) {
wp_redirect(get_site_url()."?page=login");
exit;
}else{
$date = current_time('Y-m-d');
$datetime = new DateTime($cureent_time . '+1 day');
......@@ -19,8 +20,8 @@ if ($user_id == 0) {
$context['user_id'] = $user_id;
$context['house_id'] = $_GET['house_id'];
$context['consultant_id'] = $_GET['consultant_id'];
Timber::render('view.html', $context);
}
Timber::render('view.html', $context);
?>
\ No newline at end of file
......@@ -10,9 +10,12 @@
<!--CSS-->
<link rel="stylesheet" type="text/css" href="{{ theme }}/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="{{ theme }}/css/detail.css">
<link rel="stylesheet" type="text/css" href="{{ theme }}/css/star-rating.min.css">
<script type="text/javascript" src="{{ theme }}/js/iscroll.js"></script>
<script type="text/javascript" src="{{ theme }}/js/swipe.js"></script>
<script type="text/javascript" src="{{ theme }}/js/jquery.min.js"></script>
<script type="text/javascript" src="{{ theme }}/js/jquery.mobile.custom.min.js"></script>
<script type="text/javascript" src="{{ theme }}/js/star-rating.min.js"></script>
<script type="text/javascript" src="{{ theme }}/js/bootstrap.min.js"></script>
<script type="text/javascript">
var myScroll;
......@@ -36,6 +39,12 @@
preventDefault: false,
click: true
});
},false);
$(document).ready(function(){
$("#slider").bind("tap",function(){
$("#carousel_wrapper").parent().show();
carouselScroll = new IScroll('#carousel_wrapper', {
bounce: false,
scrollX: true,
......@@ -49,7 +58,37 @@
$("#carousel_indicator li").removeClass("carousel_active");
$("#carousel_indicator li").eq(this.currentPage.pageX).addClass("carousel_active");
});
},false);
var carousel = $("#carousel_wrapper");
var carouselWidth = carousel.width();
carousel.find("#carousel_scroller ul li").css({"width":carouselWidth});
carousel.find("#carousel_indicator li").removeClass("carousel_active");
carousel.find("#carousel_indicator li:first").addClass("carousel_active");
return false;
});
$("#carousel_wrapper").parent().bind("click",function(){
$(this).hide();
return false;
});
$(".collect").bind("tap",function(){
$.ajax({
type: 'POST',
url: '{{ siteUrl }}/wp-admin/admin-ajax.php/',
data: 'action=add_collect&hid={{hid}}',
success: function (data) {
if (data.code == 2000) {
alert('收藏成功');
} else {
alert('收藏失败');
}
}
});
});
$(".map").bind("tap",function(){
location.href = "{{ siteUrl }}/?page=map&a={{result.address}}&c={{cityName}}&hn={{result.community_name}}<br>{{result.address}}&p={{result.location}}";
});
});
</script>
</head>
<body>
......@@ -62,25 +101,17 @@
<div class="addWrap">
<div id="slider" class="swipe">
<div class="swipe-wrap">
{% for item in images %}
<div>
<img src="{{ theme }}/img/img1.jpg">
</div>
<div>
<img src="{{ theme }}/img/img1.jpg">
</div>
<div>
<img src="{{ theme }}/img/img1.jpg">
</div>
<div>
<img src="{{ theme }}/img/img1.jpg">
<img src="{{siteUrl}}{{item.path}}">
</div>
{% endfor %}
</div>
</div>
<ul id="indicator" class="list-inline text-center">
<li class="active"></li>
<li></li>
<li></li>
<li></li>
{% for i in 1..images|length %}
<li {% if loop.index0 == 0 %}class="active"{% endif %}></li>
{% endfor %}
</ul>
</div>
<!-- /图片滚动 -->
......@@ -118,41 +149,13 @@
<div id="wrapper">
<div id="scroller">
<ul class="list-inline text-nowrap">
{% for item in mainImage %}
<li>
<p><img src="{{ theme }}/img/img1.jpg"></p>
<p>一居</p>
<p>60平米以下</p>
</li>
<li>
<p><img src="{{ theme }}/img/img1.jpg"></p>
<p>一居</p>
<p>60平米以下</p>
</li>
<li>
<p><img src="{{ theme }}/img/img1.jpg"></p>
<p>一居</p>
<p>60平米以下</p>
</li>
<li>
<p><img src="{{ theme }}/img/img1.jpg"></p>
<p>一居</p>
<p>60平米以下</p>
</li>
<li>
<p><img src="{{ theme }}/img/img1.jpg"></p>
<p>一居</p>
<p>60平米以下</p>
</li>
<li>
<p><img src="{{ theme }}/img/img1.jpg"></p>
<p>一居</p>
<p>60平米以下</p>
</li>
<li>
<p><img src="{{ theme }}/img/img1.jpg"></p>
<p>一居</p>
<p>60平米以下</p>
<p><img src="{{siteUrl}}{{ item.path }}"></p>
<p>{{item.type}}</p>
<p>{{item.area}}平</p>
</li>
{% endfor %}
</ul>
</div>
</div>
......@@ -171,75 +174,74 @@
<div class="detail_row">
<a class="collapsed" data-toggle="collapse" href="#collapseExample"><p class="detail_title">基本信息<i class="iconfont pull-right"></i></p></a>
<ul class="list-unstyled collapse infoCont" id="collapseExample">
<li>开发商:<span>上海韩汇置业有限公司</span></li>
<li>建筑类型:</li>
<li>装修状况:</li>
<li>容积率:</li>
<li>规划户数:</li>
<li>物业公司:</li>
<li>入住时间:<span>2015-12-31</span></li>
<li>产权年限:</li>
<li>建筑面积:</li>
<li>绿化率:</li>
<li>车位数:</li>
<li>物业费:</li>
<li>开发商:<span>{{result.developer}}</span></li>
<li>建筑类型:{{result.periphery}}</li>
<li>装修状况:{{result.decoration}}</li>
<li>容积率:{{result.volume_rate}}</li>
<li>规划户数:{{result.households}}</li>
<li>物业公司:{{result.property_management}}</li>
<li>入住时间:<span>{{result.check_in_time}}</span></li>
<li>产权年限:{{result.property_age}}</li>
<li>建筑面积:{{result.covered_area}}</li>
<li>绿化率:{{result.greening_rate}}</li>
<li>车位数:{{result.parking_spaces}}</li>
<li>物业费:{{result.property_money}}</li>
</ul>
</div>
<div class="detail_row">
<p class="detail_title">楼盘概述</p>
<p>开发商对于楼盘的描述...</p>
<p>{{result.overview}}</p>
</div>
<div class="detail_row">
<p class="detail_title pull-left">推荐房源</p>
<ul class="list-unstyled recommendCont">
<li class="col-xs-3"><p style="background-image:url({{ theme }}/img/img1.jpg);"></p></li>
<li class="col-xs-3"><p style="background-image:url({{ theme }}/img/img1.jpg);"></p></li>
<li class="col-xs-3"><p style="background-image:url({{ theme }}/img/img1.jpg);"></p></li>
{% 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>
{% endfor %}
</ul>
</div>
<div class="detail_row">
<div class="detail_row" id="consultantDiv">
<p class="detail_title">置业顾问</p>
<ul class="list-unstyled peopleCont">
{% for item in consultant %}
<li>
<ol class="col-xs-2 text-center">
{% if item.imageUrl %}
<img src="{{ item.imageUrl }}">
{% else %}
<img src="{{ theme }}/img/head.png">
{% endif %}
</ol>
<ol class="col-xs-4">
<p>邓绿</p>
<p><img src="{{ theme }}/img/star.png" width="100px"></p>
</ol>
<ol class="col-xs-6">
<button type="button" class="btn btn-xs btn-phone">
<span></span>电话联系
</button>
<button type="button" class="btn btn-xs btn-booking">
<span></span>一键预约
</button>
</ol>
</li>
<li>
<ol class="col-xs-2 text-center">
<img src="img/head.png">
</ol>
<ol class="col-xs-4">
<p>邓绿</p>
<p><img src="{{ theme }}/img/star.png" width="100px"></p>
<p>{{item.name}}</p>
<p>
<div class="star-rating rating-xs rating-disabled" style="font-size:12px;">
<div class="rating-container rating-gly-star" data-content="">
<div class="rating-stars" data-content="" style="width: {{item.average_score*2*10}}%;"></div>
</div>
</div>
</p>
</ol>
<ol class="col-xs-6">
<button type="button" class="btn btn-xs btn-phone">
{% if not item.mobile %}
<a class="btn btn-xs btn-phone" disabled="disabled">
{% else %}
<a href="tel:{{item.mobile}}" class="btn btn-xs btn-phone">
{% endif %}
<span></span>电话联系
</button>
<button type="button" class="btn btn-xs btn-booking">
</a>
<a href="{{siteUrl}}?page=view&house_id={{hid}}&consultant_id={{item.id}}" class="btn btn-xs btn-booking">
<span></span>一键预约
</button>
</a>
</ol>
</li>
{% endfor %}
</ul>
</div>
<footer class="footer navbar-fixed-bottom">
<button type="button" class="btn">置业顾问</button>
<button type="button" class="btn">预约看房</button>
<a href="#consultantDiv" class="btn">置业顾问</a>
<a href="{{siteUrl}}?page=view&house_id={{hid}}" class="btn">预约看房</a>
<!-- 二手房详细 -->
<!-- <ul class="list-inline text-right">
<li class="text-center phone">
......@@ -258,33 +260,19 @@
<div id="carousel_wrapper">
<div id="carousel_scroller">
<ul class="list-inline text-nowrap">
{% for item in images %}
<li>
<p>
<span><img src="{{ theme }}/img/img1.jpg"></span>
</p>
</li>
<li>
<p>
<span><img src="{{ theme }}/img/img1.jpg"></span>
</p>
</li>
<li>
<p>
<span><img src="{{ theme }}/img/img1.jpg"></span>
</p>
</li>
<li>
<p>
<span><img src="{{ theme }}/img/img1.jpg"></span>
<span><img src="{{siteUrl}}{{item.path}}"></span>
</p>
</li>
{% endfor %}
</ul>
</div>
<ul id="carousel_indicator" class="list-inline text-center indicators">
<li class="carousel_active"></li>
<li></li>
<li></li>
{% for i in 1..images|length %}
<li></li>
{% endfor %}
</ul>
</div>
</div>
......
<!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