@@ -1587,7 +1594,7 @@ function init(){
})
$("#region").picker({
toolbarTemplate: '
',
cols: [
@@ -1598,7 +1605,7 @@ function init(){
]
});
regionChange();
-
+
if(response.data.data.dtos.length==0){
$("#nearAddress").css("display",none);
$("#nearDistricts").css("display",none);
@@ -1619,11 +1626,9 @@ function init(){
})
.catch(function (error) {
- alert(error)
console.log(error);
});
-
//资讯列表
axios.get(BASE_PATH+"/rest/news/list", {
params: {
@@ -1632,88 +1637,198 @@ function init(){
}
})
.then(function (response) {
- var html = '';
- for(var i in response.data.data.list){
- if(response.data.data.list[i].type=="专题"){
- html += '
'+
- '

'+
- '
'+
- ''+
- ''+
- '
';
- }
- /*if(response.data.data.list[i].type=="房源"){
- html += '
'+
- '

'+
- '
'+
- ''+
- '
'+
- ''+
- '
';
- }*/
- if(response.data.data.list[i].type=="活动"){
- html += '
'+
- '

'+
- '
'+
- ''+
- ''+
- '
';
- }
- /*if(response.data.data.list[i].type=="城市"){
-
-

-
-
-
-
-
- }*/
- if(response.data.data.list[i].type=="新闻"){
- html += '
';
- }
- if(response.data.data.list[i].type=="投票"){
- html += '
'+
- '同意'+
- '
'+
- '
反对'+
- '
V.S';
- }
- }
- $("#todayDate").append(html);
+ dataObj = response.data.data.list;
+ lastIndex = 0;
+ addItems(itemsPerLoad, 0)
+ if(dataObj.length>5){
+ $(".infinite-scroll-preloader").show();
+ }else{
+ $(".infinite-scroll-preloader").hide();
+ }
+ lastIndex = $('.cardInfo').length;
})
.catch(function (error) {
console.log(error);
});
-
}
+$("#region").click(function(e){
+ $(document).click(function(e){
+ alert($("#region").val());
+ var region_copy = $("#region_copy").val();
+ var value = $(".picker-selected").text();
+ if(region_copy != value && value!="" && value!=null){
+ alert($("#region").val());
+ changeRegion();
+ }
+ })
+})
+
+$("#regionStatusButton").click(function(e){
+ var region_copy = $("#region_copy").val();
+ var value = $(".picker-selected").text();
+ alert($("#region").val());
+ if(region_copy != value && value!="" && value!=null){
+ alert($("#region").val());
+ changeRegion();
+ }
+})
+
+
+function changeRegion(){
+ axios.get(BASE_PATH+"/houseApi/home", {
+ params: {
+ city: $("#input_city").text(),
+ region:$("#region").val(),
+ lat:0,
+ lng:0
+ }
+ })
+ .then(function (response) {
+ new Vue({
+ el: '#baseInfo',
+ data: {
+ region: response.data.data.region,
+ topMonth:response.data.data.topMonth,
+ momAvgPrice: response.data.data.momAvgPrice,
+ momRate: response.data.data.momRate
+ }
+ })
+ $("#region_copy").val(response.data.data.region);
+ })
+ .catch(function (error) {
+ console.log(error);
+ });
+}
+/* 页面底部无限加载事件 */
+$.init();
+var loading = false;
+// 最多可加载的条目
+var maxItems = 60;
+// 每次加载添加多少条目
+var itemsPerLoad = 5;
+var dataObj = {};
+function addItems(number, lastIndex) {
+ // 生成新条目的HTML
+ if(dataObj.length == 0) {
+ // 加载完毕,则注销无限加载事件,以防不必要的加载
+ $.detachInfiniteScroll($('.infinite-scroll'));
+ // 删除加载提示符
+ $('.infinite-scroll-preloader').remove();
+ $('.infinite-scroll-bottom .list-container ul ').html("
");
+ return;
+ }
+ var html = '';
+ for(var i in dataObj){
+ if(i>=lastIndex){
+ if((dataObj.length
'+
+ '
'+
+ ''+
+ ''+
+ ''+
+ ' ';
+ }
+ }
+ }
+ }
+ if(dataObj.length<=(lastIndex + number)){
+ $(".infinite-scroll-preloader").hide();
+ }
+ // 添加新条目
+ if(lastIndex == 0){
+ $("#newsList").html(html);
+ }else{
+ $('#newsList').append(html);
+ }
+ }
+
+// 上次加载的序号
+
+var lastIndex = 5;
+
+// 注册'infinite'事件处理函数
+$(document).on('infinite', '.infinite-scroll-bottom',function() {
+ // 如果正在加载,则退出
+ if (loading) return;
+ // 设置flag
+ loading = true;
+
+ // 模拟1s的加载过程
+ setTimeout(function() {
+ // 重置加载flag
+ loading = false;
+ // 添加新条目
+ addItems(itemsPerLoad, lastIndex);
+ // 更新最后加载的序号
+ lastIndex = $('.cardInfo').length;
+ }, 500);
+});
+
function regionChange(){
var text = $("#region").val();
var length = $("#region").val().length;