164 lines
4.4 KiB
JavaScript
164 lines
4.4 KiB
JavaScript
var a = getApp();
|
|
|
|
Page({
|
|
data: {
|
|
token: a.globalData.token,
|
|
sourceUrl: a.baseUrls.sourceUrl,
|
|
areaList: [],
|
|
areaIndex: 0,
|
|
areaAll: [],
|
|
areaSelected: "",
|
|
areaName: "",
|
|
communityList: [],
|
|
myCommunityList: [],
|
|
page: {
|
|
rows: 10,
|
|
page: 1,
|
|
areaCode: ""
|
|
}
|
|
},
|
|
getAreaList: function () {
|
|
var t = this;
|
|
a.restAjax.get(a.restAjax.path(a.apis.getArea, [a.baseUrls.serviceUrl, "110889"]), {}, {
|
|
headers: {
|
|
token: a.globalData.token
|
|
}
|
|
}, function (a, r) {
|
|
for (var n = t.data.areaList, o = 0; o < r.length; o++) {
|
|
n.push(r[o].areaName)
|
|
}
|
|
t.setData({
|
|
areaList: n,
|
|
areaAll: r,
|
|
areaSelected: r[0].areaCode,
|
|
areaName: r[0].areaName,
|
|
"page.areaCode": r[0].areaCode
|
|
});
|
|
t.getCommunity();
|
|
}, function (e, a) {
|
|
console.log(a);
|
|
});
|
|
},
|
|
getCommunity: function () {
|
|
var t = this, r = t.data.page;
|
|
t.data.keywords && (r.keywords = t.data.keywords), a.restAjax.get(a.restAjax.path(a.apis.getCommunityListPage, [a.baseUrls.communityUrl]), r, {
|
|
headers: {
|
|
token: a.globalData.token
|
|
}
|
|
}, function (a, r) {
|
|
if (1 == t.data.page.page) t.setData({
|
|
communityList: r.rows
|
|
}); else if (r.rows.length > 0) {
|
|
for (var n = t.data.communityList, o = 0; o < r.rows.length; o++) n.push(r.rows[o]);
|
|
t.setData({
|
|
communityList: n
|
|
});
|
|
} else t.setData(e({}, "page.page", t.data.page.page - 1));
|
|
r.rows.length < 10 && t.setData({
|
|
haveMore: !1
|
|
});
|
|
}, function (e, a) {
|
|
console.log(a);
|
|
});
|
|
},
|
|
bindAreaPickerChange: function (a) {
|
|
var _self = this;
|
|
_self.setData({
|
|
areaIndex: a.detail.value,
|
|
areaSelected: _self.data.areaAll[a.detail.value].areaCode,
|
|
"page.areaCode": _self.data.areaAll[a.detail.value].areaCode,
|
|
"page.page": 1,
|
|
"haveMore": !0
|
|
})
|
|
_self.getCommunity();
|
|
},
|
|
getMyCommunity: function () {
|
|
var e = this;
|
|
a.restAjax.get(a.restAjax.path(a.apis.mycommunity, [a.baseUrls.requestUrl]), {}, {
|
|
headers: {
|
|
token: a.globalData.token
|
|
}
|
|
}, function (a, t) {
|
|
e.setData({
|
|
myCommunityList: t
|
|
});
|
|
}, function (e, a) {
|
|
console.log(a);
|
|
});
|
|
},
|
|
otherCommunity: function () {
|
|
wx.navigateTo({
|
|
url: "./selectCommunity"
|
|
});
|
|
},
|
|
selectCommunity: function (e) {
|
|
var t = {
|
|
communityId: e.currentTarget.dataset.item.communityId,
|
|
communityName: e.currentTarget.dataset.item.communityName
|
|
};
|
|
a.globalData.currentCommunity = t, wx.setStorage({
|
|
data: e.currentTarget.dataset.item.communityName,
|
|
key: "curCommunityName"
|
|
}), wx.setStorage({
|
|
data: e.currentTarget.dataset.item.communityId,
|
|
key: "curCommunityId"
|
|
}), wx.setStorage({
|
|
data: e.currentTarget.dataset.item.locationCode,
|
|
key: "areaCode"
|
|
}), wx.setStorage({
|
|
data: parseInt(e.currentTarget.dataset.item.areaLevel),
|
|
key: "areaLevel"
|
|
}), wx.reLaunch({
|
|
url: "../index/index"
|
|
});
|
|
},
|
|
selectMyCommunity: function (e) {
|
|
var t = {
|
|
communityId: e.currentTarget.dataset.item.communityId,
|
|
communityName: e.currentTarget.dataset.item.communityName
|
|
};
|
|
a.globalData.currentCommunity = t, wx.setStorage({
|
|
data: e.currentTarget.dataset.item.communityName,
|
|
key: "curCommunityName"
|
|
}), wx.setStorage({
|
|
data: e.currentTarget.dataset.item.communityId,
|
|
key: "curCommunityId"
|
|
}), wx.setStorage({
|
|
data: e.currentTarget.dataset.item.areaCode,
|
|
key: "areaCode"
|
|
}), wx.setStorage({
|
|
data: "4",
|
|
key: "areaLevel"
|
|
}), wx.reLaunch({
|
|
url: "../index/index"
|
|
});
|
|
},
|
|
loadMore: function () {
|
|
this.setData({
|
|
"page.page": this.data.page.page + 1
|
|
});
|
|
this.getCommunity();
|
|
},
|
|
enterCurrentArea: function () {
|
|
wx.setStorage({
|
|
data: this.data.areaAll[this.data.areaIndex].areaName,
|
|
key: "curCommunityName"
|
|
}), wx.setStorage({
|
|
data: this.data.areaAll[this.data.areaIndex].areaId,
|
|
key: "curCommunityId"
|
|
}), wx.setStorage({
|
|
data: this.data.page.areaCode,
|
|
key: "areaCode"
|
|
}), wx.setStorage({
|
|
data: parseInt(this.data.areaAll[this.data.areaIndex].areaLevel),
|
|
key: "areaLevel"
|
|
}), wx.reLaunch({
|
|
url: "../index/index"
|
|
});
|
|
},
|
|
onLoad: function (e) {
|
|
this.getAreaList();
|
|
this.getMyCommunity();
|
|
},
|
|
|
|
}); |