107 lines
3.5 KiB
JavaScript
107 lines
3.5 KiB
JavaScript
var a = getApp();
|
|
|
|
Page({
|
|
data: {
|
|
token: a.globalData.token,
|
|
sourceUrl: a.baseUrls.sourceUrl,
|
|
areaList: [],
|
|
areaAll: [],
|
|
index: 0,
|
|
areaSelected: "",
|
|
page: {
|
|
rows: 10,
|
|
page: 1,
|
|
areaCode: ""
|
|
},
|
|
keywords: "",
|
|
communityList: [],
|
|
haveMore: !0
|
|
},
|
|
enterCommunity: function(e) {
|
|
var t = {
|
|
communityId: e.currentTarget.dataset.communityId,
|
|
communityName: e.currentTarget.dataset.communityName
|
|
};
|
|
a.globalData.currentCommunity = t, wx.setStorage({
|
|
data: e.currentTarget.dataset.communityName,
|
|
key: "curCommunityName"
|
|
}), wx.setStorage({
|
|
data: e.currentTarget.dataset.communityId,
|
|
key: "curCommunityId"
|
|
}), wx.setStorage({
|
|
data: e.currentTarget.dataset.location,
|
|
key: "locationCode"
|
|
}), wx.reLaunch({
|
|
url: "../index/index"
|
|
});
|
|
},
|
|
getArea: function() {
|
|
var t = this;
|
|
a.restAjax.get(a.restAjax.path(a.apis.getArea, [ a.baseUrls.serviceUrl, "110889" ]), {}, {
|
|
headers: {
|
|
token: a.globalData.token
|
|
}
|
|
}, function(a, o) {
|
|
for (var n = [], r = 0; r < o.length; r++) n.push(o[r].areaName);
|
|
t.setData(e({
|
|
areaList: n,
|
|
areaAll: o,
|
|
areaSelected: o[0].areaCode
|
|
}, "page.areaCode", o[0].areaCode)), t.getCommunity();
|
|
}, function(e, a) {
|
|
console.log(a);
|
|
});
|
|
},
|
|
bindPickerChange: function(a) {
|
|
var t;
|
|
this.setData((t = {
|
|
index: a.detail.value,
|
|
areaSelected: this.data.areaAll[a.detail.value].areaCode
|
|
}, e(t, "page.areaCode", this.data.areaAll[a.detail.value].areaCode), e(t, "page.page", 1),
|
|
e(t, "haveMore", !0), t)), this.getCommunity();
|
|
},
|
|
getCommunity: function() {
|
|
var t = this, o = t.data.page;
|
|
t.data.keywords && (o.keywords = t.data.keywords), a.restAjax.get(a.restAjax.path(a.apis.getCommunityListPage, [ a.baseUrls.communityUrl ]), o, {
|
|
headers: {
|
|
token: a.globalData.token
|
|
}
|
|
}, function(a, o) {
|
|
if (1 == t.data.page.page) t.setData({
|
|
communityList: o.rows
|
|
}); else if (o.rows.length > 0) {
|
|
for (var n = t.data.communityList, r = 0; r < o.rows.length; r++) n.push(o.rows[r]);
|
|
t.setData({
|
|
communityList: n
|
|
});
|
|
} else t.setData(e({}, "page.page", t.data.page.page - 1));
|
|
o.rows.length < 10 && t.setData({
|
|
haveMore: !1
|
|
});
|
|
}, function(e, a) {
|
|
console.log(a);
|
|
});
|
|
},
|
|
loadMore: function() {
|
|
this.setData(e({}, "page.page", this.data.page.page + 1)), this.getCommunity();
|
|
},
|
|
selectCommunity: function(e) {
|
|
var t = {
|
|
communityId: e.currentTarget.dataset.item.communityId,
|
|
communityName: e.currentTarget.dataset.item.communityName
|
|
};
|
|
a.globalData.currentCommunity = t, wx.reLaunch({
|
|
url: "../index/index"
|
|
});
|
|
},
|
|
onLoad: function(e) {
|
|
this.getArea();
|
|
},
|
|
onReady: function() {},
|
|
onShow: function() {},
|
|
onHide: function() {},
|
|
onUnload: function() {},
|
|
onPullDownRefresh: function() {},
|
|
onReachBottom: function() {},
|
|
onShareAppMessage: function() {}
|
|
}); |