Commit 48e530a6 by shz

tospur

parent 7754a36b
<link rel="stylesheet" type="text/css" href="{{ view }}/css/bootstrap.min.css">
<style>
.sale_detail ul {
margin-top: 30px;
}
.sale_detail ul li {
margin: 20px 0;
}
.sale_detail ul li span:nth-of-type(1) {
font-weight: bold;
font-size: 14px;
display: inline-block;
width: 100px;
}
.sale_detail ul li span:nth-of-type(2) {
font-size: 14px;
display: inline-block;
width: 400px;
}
</style>
<script>
(function ($) {
$(document).ready(function () {
$('#handle').click(function () {
var consultant_id = $('#consultant').find('option:selected').val();
alert(consultant_id);
});
});
})(jQuery);
</script>
{% if house_type == 1 %}
{% set unit = '万元' %}
{% set price = '售价' %}
{% elseif house_type == 2 %}
{% set unit = '元/月' %}
{% set price = '租金' %}
{% endif %}
<div class="sale_detail">
<h2>房东服务详细</h2>
<ul>
<li>
<span>城市:</span>
<span>{{ detail_result.cityName }}</span>
</li>
<li>
<span>小区名称:</span>
<span>{{ detail_result.community_name }}</span>
</li>
<li>
<span>户型:</span>
<span>{{ detail_result.bedroom }}室{{ detail_result.hall }}厅{{ detail_result.kitchen }}厨{{ detail_result.bathroom }}卫</span>
</li>
<li>
<span>面积:</span>
<span>{{ detail_result.covered_area }}m²</span>
</li>
<li>
<span>楼层:</span>
<span>第{{ detail_result.floor }}层(共{{ detail_result.total_floor }}层)</span>
</li>
<li>
<span>期望{{ price }}:</span>
<span>{{ detail_result.price }}{{ unit }}</span>
</li>
<li>
<span>房源描述:</span>
<span>{{ detail_result.description }}</span>
</li>
<li>
<span>置业顾问:</span>
<span>
<select id="consultant">
{% for consultant in consultant_result %}
<option value="{{ consultant.id }}"{% if(house_result.consultant_id == consultant.id) %} selected="selected"{% endif %}>{{ consultant.display_name }}</option>
{% endfor %}
</select>
<label for="consultant"></label>
</span>
</li>
</ul>
</div>
<button id="handle">提交处理</button>
\ 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';
......
......@@ -78,6 +78,17 @@ class TospurDao
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)
{
......@@ -141,6 +152,15 @@ class TospurDao
'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
......@@ -27,6 +27,7 @@ function tospur_init()
require_once(PLUGIN_DIR . 'Admin/introduction.php');
require_once('consultant_score.php');
require_once('view_house.php');
require_once('tospur_sale.php');
add_action('admin_menu', 'reset_menu');
tospur_register_script_style();
tospur_ajax_set();
......
<?php
if (!class_exists('WP_List_Table')) {
require_once(ABSPATH . 'wp-admin/includes/class-wp-list-table.php');
}
class tospurSaleList extends WP_List_Table
{
function __construct()
{
global $status, $page;
//Set parent defaults
parent::__construct(array(
'singular' => 'sale', //singular name of the listed records
'plural' => 'sales', //plural name of the listed records
'ajax' => false //does this table support ajax?
));
}
function column_default($item, $column_name)
{
switch ($column_name) {
case 'community_name':
return '<a href="' . admin_url('admin.php?page=' . $_GET['page'] . '&id=' . $item['id']) . '">' . $item[$column_name] . '</a>';
case 'consultant':
$consultant = $item[$column_name] ? $item[$column_name] : '未分配';
return $consultant;
case 'handle':
$handle = ($item[$column_name] == 1) ? '已处理' : '未处理';
return $handle;
default:
return $item[$column_name];
}
}
function get_columns()
{
$columns = array(
'cityName' => '城市',
'community_name' => '小区名',
'apartment' => '户型',
'covered_area' => '面积',
'floor' => '楼层',
'faceto' => '朝向',
'price' => '期望售价',
'description' => '房源描述',
'phone' => '手机号',
'submission_date' => '提交时间',
'consultant' => '置业顾问',
'handle' => '处理状态',
'handle_date' => '处理时间'
);
return $columns;
}
function get_sortable_columns()
{
$sortable_columns = array();
return $sortable_columns;
}
function extra_tablenav($which)
{
if ($which == 'top') {
?>
<div>
<label for="cityDropDown"></label>
<select name="cityId" id="cityDropDown" style="vertical-align: initial;">
<?php
$cityId = (int)$_GET['cityId'];
$city = SearchDao::searchCity();
?>
<option value="-1"<?php if ($cityId == -1) {
echo ' selected="selected"';
} ?>>城市
</option>
<?php
foreach ($city as $item) {
if ($item->id == $cityId) {
$selected = ' selected="selected"';
} else {
$selected = null;
}
echo '<option value="' . $item->id . '"' . $selected . '>' . $item->value . '</option>';
}
?>
</select>
<span>
<label for="search"></label>
<input type="search" id="search" name="s" value="<?php echo $_GET['s']; ?>" placeholder="请输入关键字搜索"
style="height: 28px;">
<input type="submit" id="search-submit" class="button" value="搜索">
</span>
</div>
<?php
}
}
function prepare_items()
{
global $wpdb;
$per_page = 10;
$columns = $this->get_columns();
$hidden = array();
$sortable = $this->get_sortable_columns();
$this->_column_headers = array($columns, $hidden, $sortable);
$house_type = $_GET['page'];
if ($house_type == 'tospur_sale_secondhand') {
$house_type = 1;
} else if ($house_type == 'tospur_sale_rent') {
$house_type = 2;
}
$sql = "SELECT ts.*,dc.cityName,u.display_name FROM tospur_sale ts" .
" left join (SELECT cityId,cityName FROM dic_city group by cityId) dc on ts.cityId = dc.cityId" .
" left join wp_users u on u.ID = ts.consultant_id" .
" where ts.house_type = " . $house_type;
$cityId = (int)$_GET['cityId'];
if ($cityId > 0) {
$sql .= " and ts.cityId = " . $cityId;
}
$s = $_GET['s'];
if ($s) {
$sql .= " and (ts.community_name like '%" . $s . "%' or ts.phone like '%" . $s . "%' or ts.faceto like '%" . $s . "%')";
}
$result = $wpdb->get_results($sql);
$data = array();
foreach ($result as $key => $value) {
$unit = ($value->house_type == 1) ? '万元' : '元/月';
$data[$key] = array(
'id' => $value->id,
'cityName' => $value->cityName,
'community_name' => $value->community_name,
'apartment' => $value->bedroom . '室' . $value->hall . '厅' . $value->kitchen . '厨' . $value->bathroom . '卫',
'covered_area' => $value->covered_area . 'm²',
'floor' => '第' . $value->floor . '层(共' . $value->total_floor . '层)',
'faceto' => $value->faceto,
'price' => $value->price . $unit,
'description' => $value->description,
'phone' => $value->phone,
'submission_date' => $value->submission_date,
'consultant' => $value->display_name,
'handle' => $value->handle,
'handle_date' => $value->handle_date
);
}
function usort_reorder($a, $b)
{
$orderby = (!empty($_REQUEST['orderby'])) ? $_REQUEST['orderby'] : 'handle';
$order = (!empty($_REQUEST['order'])) ? $_REQUEST['order'] : 'asc';
$result = strcmp($a[$orderby], $b[$orderby]);
return ($order === 'asc') ? $result : -$result;
}
usort($data, 'usort_reorder');
$current_page = $this->get_pagenum();
$total_items = count($data);
$data = array_slice($data, (($current_page - 1) * $per_page), $per_page);
$this->items = $data;
$this->set_pagination_args(array(
'total_items' => $total_items,
'per_page' => $per_page,
'total_pages' => ceil($total_items / $per_page)
));
}
}
function add_tospur_sale_menu()
{
add_menu_page('房东服务', '房东服务', 'activate_plugins', 'tospur_sale_secondhand', 'tospur_sale_page', 'dashicons-menu', 28);
add_submenu_page('tospur_sale_secondhand', '出售', '出售', 'activate_plugins', 'tospur_sale_secondhand', 'tospur_sale_page');
add_submenu_page('tospur_sale_secondhand', '出租', '出租', 'activate_plugins', 'tospur_sale_rent', 'tospur_sale_page');
}
add_action('admin_menu', 'add_tospur_sale_menu');
function tospur_sale_page()
{
if ($_GET['id']) {
require_once('tospur_sale_detail.php');
} else {
$tospurSaleList = new tospurSaleList();
$tospurSaleList->prepare_items();
$house_type = $_GET['page'];
$title = null;
if ($house_type == 'tospur_sale_secondhand') {
$title = '房东服务列表—出售';
} else if ($house_type == 'tospur_sale_rent') {
$title = '房东服务列表—出租';
}
?>
<div class="wrap">
<h2><?php echo $title; ?></h2>
<form method="get">
<input type="hidden" name="page" value="<?php echo $_REQUEST['page']; ?>"/>
<?php $tospurSaleList->display(); ?>
</form>
</div>
<style>
</style>
<script>
(function ($) {
var cityId = -1;
$(document).ready(function () {
var cityDropDown = $('#cityDropDown');
cityId = Number(cityDropDown.find('option:selected').val());
cityDropDown.change(function () {
cityId = Number($(this).val());
window.location.href = '<?php
echo admin_url('admin.php?page='.$_GET['page'].'&paged=1');
?>' + '&cityId=' + cityId;
});
$('#search-submit').click(function () {
var s = $('#search').val();
if (!s) {
alert('请输入关键字搜索');
} else {
window.location.href = '<?php
echo admin_url('admin.php?page='.$_GET['page'].'&paged=1');
?>' + '&cityId=' + cityId + '&s=' + s;
}
return false;
});
});
})(jQuery);
</script>
<?php
}
}
?>
\ No newline at end of file
<?php
$house_id = $_GET['id'];
$page = $_GET['page'];
if ($page == 'tospur_sale_secondhand') {
$house_type = 1;
} else if ($page == 'tospur_sale_rent') {
$house_type = 2;
}
$detail_sql = "SELECT ts.*,dc.cityName,u.display_name FROM tospur_sale ts" .
" left join (SELECT cityId,cityName FROM dic_city group by cityId) dc on ts.cityId = dc.cityId" .
" left join wp_users u on u.ID = ts.consultant_id" .
" where ts.house_type = " . $house_type . " and ts.id = " . $house_id;
$consultant_sql = 'SELECT u.id,u.display_name FROM wp_users u '
. 'left join wp_usermeta m on u.id=m.user_id where meta_key="wp_user_level" and meta_value=7;';
global $wpdb;
$context['detail_result'] = $wpdb->get_row($detail_sql);
$context['consultant_result'] = $wpdb->get_results($consultant_sql);
$context['url'] = home_url();
$context['id'] = $house_id;
$context['house_type'] = $house_type;
$context['view'] = plugins_url() . '/tospur/Admin/views';
Timber::render('Admin/views/sale_detail.html', $context);
?>
\ No newline at end of file
......@@ -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);
......
......@@ -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;
}
<?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');
......@@ -150,12 +151,18 @@ add_action('wp_ajax_add_score', 'add_consultant_score');
function add_consultant_score()
{
if (isset($_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);
}
......@@ -266,4 +273,17 @@ function user_redirect($user)
}
}
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
......@@ -1571,7 +1571,11 @@ IScroll.prototype = {
this._key(e);
break;
case 'click':
if ( !e._constructed ) {
if (!e._constructed) {
if (!e._constructed && target.type != "submit") {
e.preventDefault();
e.stopPropagation();
}
e.preventDefault();
e.stopPropagation();
}
......
......@@ -7,9 +7,13 @@ $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'];
$context['phone'] = $current_user->data->user_login;
$city = SearchDao::searchCity();
$context['city'] = $city;
Timber::render('sale.html', $context);
}else{
wp_redirect($const_login_page);
exit;
}
Timber::render('score.html', $context);
?>
\ No newline at end of file
......@@ -184,10 +184,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) {
switch (data.code){
case 2000:
alert('评分成功');
}else{
break;
case 2001:
alert('未和置业顾问接触过,不能评分');
break;
case 2002:
alert('您已经提交过评分了');
break;
default:
break;
}
},
complete:function(){
......@@ -230,7 +238,7 @@
ajax_get_house('{{ url }}', loading, searchData, tabPane);
}, 200);
}
})
});
});
</script>
</body>
......
......@@ -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>
......
......@@ -45,6 +45,9 @@
notice.html('<span>{{ error }}</span>');
myModal.modal('show');
{% endif %}
document.addEventListener('touchmove', function(e){
e.preventDefault();
});
});
</script>
</head>
......
......@@ -62,6 +62,9 @@
notice.html('<span>{{ error }}</span>');
myModal.modal('show');
{% endif %}
document.addEventListener('touchmove', function(e){
e.preventDefault();
});
});
</script>
</head>
......
......@@ -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