159 lines
5.3 KiB
JavaScript
159 lines
5.3 KiB
JavaScript
|
var e = require("../../@babel/runtime/helpers/defineProperty"), 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(e({
|
||
|
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 t;
|
||
|
this.setData((t = {
|
||
|
areaIndex: 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();
|
||
|
},
|
||
|
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(e({}, "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();
|
||
|
},
|
||
|
onReady: function() {},
|
||
|
onShow: function() {},
|
||
|
onHide: function() {},
|
||
|
onUnload: function() {},
|
||
|
onPullDownRefresh: function() {},
|
||
|
onReachBottom: function() {},
|
||
|
onShareAppMessage: function() {}
|
||
|
});
|