Commit 31937177 by shz

修改table名字 完成置业顾问列表功能

parent 361cd587
<?php
class TCSync {
const user_url = 'http://218.1.67.130:8988/api/NanTongWechat/GetPropertyConsultant?cityId=1';
public static function user_sync(){
$response = wp_remote_post( TCSync::user_url );
$res = array(
'code' => 200,
'msg' => "success"
);
//判断请求是否成功
if( is_wp_error( $response ) || wp_remote_retrieve_response_code( $response ) !== 200 ){
$res['code'] = 500;
$res['msg'] = "get user info error";
}else{
set_time_limit(0) ;
//获取请求内容
$result = wp_remote_retrieve_body( $response );
$result = json_decode($result,true);
foreach($result['data'] as $item){
if(username_exists($item['WorkNum'])){
$user = get_user_by( "login", $item['WorkNum'] );
$userdata = array(
'ID' => $user->data->ID,
'display_name' => $item['Name']
);
$user_id = wp_update_user( $userdata ) ;
}else{
$userdata = array(
'user_login' => $item['WorkNum'],
'user_pass' => $item['WorkNumAndID'], // When creating an user, `user_pass` is expected.
'role' => 'editor',
'wp_user_level' => 7,
'display_name' => $item['Name']
);
$user_id = wp_insert_user( $userdata ) ;
}
if(is_numeric($user_id) && !is_null($item['ImageUrl'])){
update_user_meta( $user_id, "tc_image", $item['ImageUrl'] );
}
}
}
return $res;
}
}
\ No newline at end of file
<?php
$house_id = $_GET['id'];
$house_sql = 'SELECT v.id, h.name, u.user_login as phone, v.date, v.time, v.consultant_id as consultant_id, v.handle, v.handle_date FROM view_house v '
$house_sql = 'SELECT v.id, h.name, u.user_login as phone, v.date, v.time, v.consultant_id as consultant_id, v.handle, v.handle_date FROM tospur_view_house v '
. 'left join tospur_house h on v.house_id = h.id '
. 'left join wp_users u on v.user_id = u.id '
. 'where v.id = ' . $house_id;
......
......@@ -141,7 +141,7 @@ class viewHouseList extends WP_List_Table
$this->process_bulk_action();
$sql = 'SELECT v.id, h.name, u.user_login as phone, v.date, v.time, c.display_name as consultant, v.handle, v.handle_date FROM view_house v '
$sql = 'SELECT v.id, h.name, u.user_login as phone, v.date, v.time, c.display_name as consultant, v.handle, v.handle_date FROM tospur_view_house v '
. 'left join tospur_house h on v.house_id = h.id '
. 'left join wp_users u on v.user_id = u.id '
. 'left join wp_users c on v.consultant_id = c.id '
......
<?php
$context = array();
$context['theme'] = get_template_directory_uri();
$context['url'] = home_url();
Timber::render('comment.html', $context);
?>
\ No newline at end of file
......@@ -10,7 +10,7 @@ if ($user_id != 0) {
$context['user_id'] = $user_id;
$consultant_id = $_GET['consultant_id'];
$context['consultant_id'] = $consultant_id;
$context['consultant_name'] = get_user_by('id', $consultant_id)->user_nicename;
$context['consultant_name'] = get_user_by('id', $consultant_id)->display_name;
$context['consultant_score'] = get_consultant_score($consultant_id);
$context['consultant_score_url'] = $const_score_page . '&consultant_id=' . $consultant_id;
}
......
<?php
$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;
}
$context['city_id'] = $city_id;
Timber::render('consultant_list.html', $context);
?>
\ No newline at end of file
@font-face {
font-family: 'iconfont';
src: url('http://at.alicdn.com/t/font_1439179733_4587424.eot');
src: url('http://at.alicdn.com/t/font_1439179733_4587424.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */ url('http://at.alicdn.com/t/font_1439179733_4587424.woff') format('woff'), /* chrome、firefox */ url('http://at.alicdn.com/t/font_1439179733_4587424.ttf') format('truetype'), /* chrome、firefox、opera、Safari, Android, iOS 4.2+*/ url('http://at.alicdn.com/t/font_1439179733_4587424.svg#iconfont') format('svg');
/* IE9*/
/* iOS 4.1- */
}
.iconfont {
font-family: "iconfont" !important;
font-size: 16px;
font-style: normal;
-webkit-font-smoothing: antialiased;
-webkit-text-stroke-width: 0.2px;
-moz-osx-font-smoothing: grayscale;
}
.tab {
width: 100%;
height: 40px;
margin-bottom: 0;
border-bottom: 1px solid #008cd7;
}
.tab li a {
color: #000000;
font-size: 18px;
font-weight: bold;
}
.tab li a:after {
content: "";
width: 88%;
height: 4px;
position: absolute;
bottom: -1px;
left: 0;
right: 0;
margin: 0 auto;
}
.tab li a:active {
box-shadow: none;
-webkit-box-shadow: none;
}
.tab li.active a:after {
background-color: #008cd7;
}
.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;
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 {
font-size: 16px;
margin: 12px 20px 14px;
}
.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 {
box-shadow: none;
-webkit-box-shadow: none;
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;
}
.modal .modal-dialog .modal-content .btn:focus {
outline: 0;
}
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;
}
.jumbotron {
padding: 15px 20px 8px;
margin-bottom: 0;
border-bottom: 1px solid #7d7d7d;
background-color: transparent;
}
.jumbotron ul {
overflow: hidden;
}
.jumbotron ul li {
padding-left: 5px;
}
.jumbotron ul li img {
width: 90px;
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;
}
.jumbotron ul li p {
margin-bottom: 2px;
color: #626262;
font-size: 18px;
}
.jumbotron ul li p:nth-child(1) {
color: #000000;
font-size: 22px;
font-weight: bold;
}
.jumbotron h4 {
color: #000000;
font-size: 16px;
font-weight: bold;
margin-bottom: 5px;
}
.jumbotron #people_wrapper {
width: 100%;
height: 88px;
line-height: 22px;
position: relative;
overflow: hidden;
}
#wrapper {
position: absolute;
z-index: 1;
top: 275px;
bottom: 0;
left: 0;
width: 100%;
overflow: hidden;
}
#wrapper #scroller {
padding-bottom: 45px;
}
#wrapper #scroller .row {
width: 100%;
height: 121px;
margin: 0;
padding: 15px 0;
border-bottom: 1px solid #b7b7b7;
}
#wrapper #scroller .row p {
width: 140px;
height: 100%;
float: left;
padding: 0 10px;
margin-bottom: 0;
overflow: hidden;
}
#wrapper #scroller .row p img {
height: 100%;
border-top-left-radius: 5px;
border-top-right-radius: 5px;
border-bottom-left-radius: 5px;
border-bottom-right-radius: 5px;
-webkit-border-top-left-radius: 5px;
-webkit-border-top-right-radius: 5px;
-webkit-border-bottom-left-radius: 5px;
-webkit-border-bottom-right-radius: 5px;
}
#wrapper #scroller .row ul {
height: 100%;
padding-right: 10px;
margin-bottom: 0;
overflow: hidden;
zoom: 1;
position: relative;
color: #5a5a5a;
font-size: 15px;
}
#wrapper #scroller .row ul li {
line-height: 18px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
#wrapper #scroller .row ul li:first-child {
margin-top: 5px;
}
#wrapper #scroller .row ul li:first-child .address {
color: #000000;
font-size: 21px;
font-weight: bold;
}
#wrapper #scroller .row ul li:last-child {
position: absolute;
left: 0;
right: 10px;
bottom: 0;
}
#wrapper #scroller .row ul li:last-child .label {
color: #ff0000;
font-size: 9px;
padding: 0 4px 1px;
border: 1px solid #acacac;
vertical-align: bottom;
}
#wrapper #scroller .row ul li:last-child span {
color: #000000;
}
#wrapper #scroller .row ul li:last-child span em {
font-style: normal;
}
#wrapper #scroller .row ul li:last-child span em:nth-child(1) {
color: #ff0000;
font-size: 21px;
font-weight: bold;
}
#wrapper #scroller .row ul li:last-child span em:nth-child(2) {
font-size: 7px;
vertical-align: top;
}
#wrapper #scroller .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;
}
.footer {
width: 100%;
height: 45px;
background-color: rgba(0, 0, 0, 0.5);
}
.footer .btn {
width: 45%;
margin: 5px 2%;
padding: 1px;
color: #ffffff;
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;
}
.footer .btn.btn-wechat span {
width: 30px;
height: 30px;
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.btn-phone span {
width: 30px;
height: 30px;
background: url("../img/white_phone_icon.png") no-repeat;
background-size: cover;
-webkit-background-size: cover;
display: inline-block;
vertical-align: middle;
}
......@@ -14,6 +14,34 @@
-webkit-text-stroke-width: 0.2px;
-moz-osx-font-smoothing: grayscale;
}
.tab {
width: 100%;
height: 40px;
margin-bottom: 0;
border-bottom: 1px solid #008cd7;
}
.tab li a {
color: #000000;
font-size: 18px;
font-weight: bold;
}
.tab li a:after {
content: "";
width: 88%;
height: 4px;
position: absolute;
bottom: -1px;
left: 0;
right: 0;
margin: 0 auto;
}
.tab li a:active {
box-shadow: none;
-webkit-box-shadow: none;
}
.tab li.active a:after {
background-color: #008cd7;
}
.modal .modal-dialog {
position: absolute;
top: 0;
......@@ -86,6 +114,9 @@ body {
color: #707070;
background-color: #f9f9f9;
}
a:hover {
text-decoration: none;
}
body {
height: auto;
padding-bottom: 45px;
......@@ -166,6 +197,17 @@ body {
position: relative;
border-bottom: 1px solid #b7b7b7;
}
.detail_row a .iconfont {
color: #b7b7b7;
font-size: 12px;
font-weight: normal;
}
.detail_row a .iconfont:after {
content: "\e602";
}
.detail_row a.collapsed .iconfont:after {
content: "\e601";
}
.detail_row p {
margin-bottom: 0;
}
......@@ -177,6 +219,7 @@ body {
}
.detail_row .detail_title {
color: #000000;
font-size: 16px;
font-weight: bold;
margin-bottom: 5px;
}
......@@ -224,7 +267,7 @@ body {
.detail_row #wrapper {
width: 100%;
height: auto;
margin-top: 8px;
margin-top: 10px;
overflow: hidden;
}
.detail_row #wrapper #scroller {
......@@ -276,16 +319,18 @@ body {
-webkit-background-size: cover;
display: inline-block;
}
.detail_row .infoCont li {
margin-bottom: 2px;
}
.detail_row .infoCont li span {
color: #000000;
}
.detail_row .recommendCont {
margin-top: 5px;
overflow: hidden;
zoom: 1;
}
.detail_row .recommendCont li {
margin: 5px 0 0 15px;
margin: 10px 0 0 15px;
}
.detail_row .recommendCont li p {
width: 100%;
......@@ -458,6 +503,7 @@ body {
font-size: 0;
}
.modal #carousel_wrapper #carousel_scroller ul li {
width: 360px;
height: 100%;
padding: 0;
overflow: hidden;
......
......@@ -14,6 +14,34 @@
-webkit-text-stroke-width: 0.2px;
-moz-osx-font-smoothing: grayscale;
}
.tab {
width: 100%;
height: 40px;
margin-bottom: 0;
border-bottom: 1px solid #008cd7;
}
.tab li a {
color: #000000;
font-size: 18px;
font-weight: bold;
}
.tab li a:after {
content: "";
width: 88%;
height: 4px;
position: absolute;
bottom: -1px;
left: 0;
right: 0;
margin: 0 auto;
}
.tab li a:active {
box-shadow: none;
-webkit-box-shadow: none;
}
.tab li.active a:after {
background-color: #008cd7;
}
.modal .modal-dialog {
position: absolute;
top: 0;
......@@ -86,12 +114,17 @@ body {
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 h2 {
......@@ -227,5 +260,6 @@ body {
text-decoration: none;
}
.container-fluid form a.link-register {
margin-top: 100px;
margin-top: 30%;
padding-bottom: 25px;
}
......@@ -14,6 +14,34 @@
-webkit-text-stroke-width: 0.2px;
-moz-osx-font-smoothing: grayscale;
}
.tab {
width: 100%;
height: 40px;
margin-bottom: 0;
border-bottom: 1px solid #008cd7;
}
.tab li a {
color: #000000;
font-size: 18px;
font-weight: bold;
}
.tab li a:after {
content: "";
width: 88%;
height: 4px;
position: absolute;
bottom: -1px;
left: 0;
right: 0;
margin: 0 auto;
}
.tab li a:active {
box-shadow: none;
-webkit-box-shadow: none;
}
.tab li.active a:after {
background-color: #008cd7;
}
.modal .modal-dialog {
position: absolute;
top: 0;
......@@ -86,6 +114,9 @@ body {
color: #707070;
background-color: #f9f9f9;
}
a:hover {
text-decoration: none;
}
.search {
width: 100%;
height: 54px;
......@@ -98,8 +129,13 @@ body {
}
.search .btn-group .btn {
color: #ffffff;
font-size: 17px;
font-weight: bold;
}
.search .btn-group .btn:active {
box-shadow: none;
-webkit-box-shadow: none;
}
.search .btn-group .btn .iconfont {
color: #ffffff;
font-size: 12px;
......@@ -108,6 +144,8 @@ body {
}
.search .btn-group .btn .iconfont:after {
content: "\e601";
position: relative;
top: -2px;
}
.search .btn-group.open .btn .iconfont:after {
content: "\e602";
......@@ -136,9 +174,6 @@ body {
display: block;
border-bottom: 1px solid;
}
.search .btn-group .dropdown-menu a:hover {
text-decoration: none;
}
.search .btn-group .dropdown-menu a.active {
color: #008cd7;
}
......@@ -204,8 +239,13 @@ body {
}
.btn-group-justified .btn-group .btn {
color: #000000;
font-size: 15px;
font-weight: bold;
}
.btn-group-justified .btn-group .btn:active {
box-shadow: none;
-webkit-box-shadow: none;
}
.btn-group-justified .btn-group .btn .iconfont {
color: #b7b7b7;
font-size: 12px;
......@@ -214,6 +254,8 @@ body {
}
.btn-group-justified .btn-group .btn .iconfont:after {
content: "\e601";
position: relative;
top: -2px;
}
.btn-group-justified .btn-group.open .btn .iconfont:after {
content: "\e602";
......@@ -242,9 +284,6 @@ body {
display: block;
border-bottom: 1px solid;
}
.btn-group-justified .btn-group .dropdown-menu a:hover {
text-decoration: none;
}
.btn-group-justified .btn-group .dropdown-menu a.active {
color: #008cd7;
}
......@@ -285,13 +324,14 @@ body {
#wrapper #scroller {
padding-bottom: 45px;
}
#wrapper #scroller div {
#wrapper #scroller .row {
width: 100%;
height: 121px;
margin: 0;
padding: 15px 0;
border-bottom: 1px solid #b7b7b7;
}
#wrapper #scroller div p {
#wrapper #scroller .row p {
width: 140px;
height: 100%;
float: left;
......@@ -299,7 +339,7 @@ body {
margin-bottom: 0;
overflow: hidden;
}
#wrapper #scroller div p img {
#wrapper #scroller .row p img {
height: 100%;
border-top-left-radius: 5px;
border-top-right-radius: 5px;
......@@ -310,7 +350,7 @@ body {
-webkit-border-bottom-left-radius: 5px;
-webkit-border-bottom-right-radius: 5px;
}
#wrapper #scroller div ul {
#wrapper #scroller .row ul {
height: 100%;
padding-right: 10px;
margin-bottom: 0;
......@@ -318,55 +358,60 @@ body {
zoom: 1;
position: relative;
color: #5a5a5a;
font-size: 15px;
}
#wrapper #scroller div ul li {
#wrapper #scroller .row ul li {
line-height: 18px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
#wrapper #scroller div ul li.multiLine_omit {
color: #000000;
font-weight: bold;
height: 36px;
-webkit-line-clamp: 2;
display: -webkit-box;
-webkit-box-orient: vertical;
white-space: normal;
#wrapper #scroller .row ul li:first-child {
margin-top: 5px;
}
#wrapper #scroller div ul li .address {
#wrapper #scroller .row ul li:first-child .address {
color: #000000;
font-size: 22px;
font-size: 21px;
font-weight: bold;
}
#wrapper #scroller div ul li:last-child {
#wrapper #scroller .row ul li:last-child {
position: absolute;
left: 0;
right: 10px;
bottom: 0;
}
#wrapper #scroller div ul li:last-child .label {
#wrapper #scroller .row ul li:last-child .label {
color: #ff0000;
font-size: 9px;
padding: 0 3px;
padding: 0 4px 1px;
border: 1px solid #acacac;
vertical-align: bottom;
}
#wrapper #scroller div ul li:last-child span {
#wrapper #scroller .row ul li:last-child span {
color: #000000;
}
#wrapper #scroller div ul li:last-child span em {
#wrapper #scroller .row ul li:last-child span em {
font-style: normal;
}
#wrapper #scroller div ul li:last-child span em:nth-child(1) {
#wrapper #scroller .row ul li:last-child span em:nth-child(1) {
color: #ff0000;
font-size: 22px;
font-size: 21px;
font-weight: bold;
}
#wrapper #scroller div ul li:last-child span em:nth-child(2) {
#wrapper #scroller .row ul li:last-child span em:nth-child(2) {
font-size: 7px;
vertical-align: top;
}
#wrapper #scroller .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;
}
.footer {
width: 100%;
height: 45px;
......
<?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,16 @@ 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);
}
}
?>
\ No newline at end of file
......@@ -7,6 +7,7 @@ function page_template($template)
{
$theme = get_stylesheet_directory();
$page = null;
if (isset($_GET['page'])) {
switch ($_GET['page']) {
case 'login':
$page = $theme . '/login.php';
......@@ -29,14 +30,20 @@ function page_template($template)
case 'consultant_info':
$page = $theme . '/consultant_info.php';
break;
case 'consultant_list':
$page = $theme . '/consultant_list.php';
break;
case 'score':
$page = $theme . '/score.php';
break;
default:
$page = $template;
case 'comment':
$page = $theme . '/comment.php';
break;
}
return $page;
} else {
return $template;
}
}
function generate_code()
......@@ -143,4 +150,20 @@ function get_consultant_score($consultant_id)
return dao::search_consultant_score($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']);
$array = array();
if ($result) {
$array['code'] = 2000;
$array['result'] = $result;
} else {
$array['code'] = 2001;
}
wp_send_json($array);
}
}
?>
\ No newline at end of file
<?php
?>
\ No newline at end of file
<!DOCTYPE html>
<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="apple-mobile-web-app-capable" content="yes"/>
<meta name="apple-mobile-web-app-status-bar-style" content="black"/>
<title></title>
<style></style>
<script src="{{ theme }}/js/jquery.min.js"></script>
<script>
$(document).ready(function () {
$('#submit').click(function () {
var content = $('#content').val();
if (content.trim() == '') {
alert('请输入评论内容!');
}
$.ajax({
type: 'POST',
url: '{{ url }}/wp-admin/admin-ajax.php/',
data: 'action=submit_comment',
success: function (data) {
}
});
});
});
</script>
</head>
<body>
</body>
</html>
\ No newline at end of file
<!DOCTYPE html>
<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="apple-mobile-web-app-capable" content="yes"/>
<meta name="apple-mobile-web-app-status-bar-style" content="black"/>
<title></title>
<style>
html, body {
width: 100%;
height: 100%;
}
#wrapper {
position: absolute;
z-index: 1;
top: 0;
bottom: 0;
left: 0;
width: 100%;
background: #fff;
overflow: hidden;
}
#scroller {
position: absolute;
width: 100%;
}
#pullUp {
height: 40px;
position: absolute;
bottom: -40px;
}
.star-rating {
display: inline-block;
}
</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 src="{{ theme }}/js/iscroll.js"></script>
</head>
<body>
<div id="wrapper">
<div id="scroller">
<label for="city"></label>
<select id="city">
{% for item in city %}
<option value="{{ item.id }}"
{% if(item.id==city_id) %}selected="selected"{% endif %}>{{ item.value }}</option>
{% endfor %}
</select>
<a href="{{ url }}/?page=consultant_list&city_id={{ city_id }}" id="change">切换</a>
<div id="pullUp">
<span>上拉刷新</span>
</div>
</div>
</div>
<div id="template" style="display: none">
<p data-attr="name"></p>
<div style="height: 42px;">
<span>星级:</span><input type="hidden" value="" data-attr="score">
</div>
<span data-attr="mobile"></span>
<p><a href="" data-attr="url">&gt;</a></p>
</div>
<script>
var index = 0;
var myScroll;
var template;
var consultant_info_url = '{{ url }}/?page=consultant_info';
$(document).ready(function () {
var i = 0;
$('#city').on('change', function () {
var city_id = $(this).find('option:selected').val();
$('#change').attr('href', '{{ url }}/?page=consultant_list&city_id=' + city_id);
});
var pullUpFlag = false;
myScroll = new IScroll('#wrapper');
myScroll.on("scrollStart", function () {
console.log(this.maxScrollY);
console.log(this.y);
if (this.maxScrollY >= this.y) {
pullUpFlag = true;
}
});
myScroll.on("scrollEnd", function () {
if (pullUpFlag) {
pullUpFlag = false;
ajax_get_consultant();
}
});
template = $('#template').html();
ajax_get_consultant();
});
function ajax_get_consultant() {
$.ajax({
type: 'POST',
url: '{{ url }}/wp-admin/admin-ajax.php/',
data: 'action=get_consultant&city_id={{ city_id }}&index=' + index,
success: function (data) {
if (data.code == 2000) {
$.each(data.result, function (index, value) {
var div = $('<div>');
div.append(template);
div.find('[data-attr=name]').text(value.display_name);
div.find('[data-attr=score]').val(value.average_score);
div.find('[data-attr=mobile]').text('电话联系:' + value.mobile);
div.find('[data-attr=url]').attr('href', consultant_info_url + '&consultant_id=' + value.id);
$('#pullUp').before(div);
});
$('input[data-attr=score]').rating({
size: 'xs',
showClear: false,
showCaption: false,
hoverEnabled: false,
readonly: true
});
index += 20;
myScroll.refresh();
} else {
}
}
});
}
</script>
</body>
</html>
\ No newline at end of file
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