city_card/pages/community/join/select.js

92 lines
2.8 KiB
JavaScript
Raw Normal View History

2023-07-15 14:25:28 +08:00
var e = getApp();
Page({
data: {
token: e.globalData.token,
areaList: [ "请选择地区" ],
areaIndex: 0,
areaAll: [],
areaSelected: "",
officeList: [ "请选择办事处" ],
officeIndex: 0,
officeAll: [],
officeSelected: "",
committeeList: []
},
joinCommunity: function(e) {
var t = e.currentTarget.dataset.item;
wx.navigateTo({
url: "./joinDetail?communityId=" + t.communityId + "&communityName=" + t.communityName + "&locationCode=" + t.locationCode
});
},
getAreaList: function() {
var t = this;
e.restAjax.get(e.restAjax.path(e.apis.getArea, [ e.baseUrls.serviceUrl, "110889" ]), {}, {
headers: {
token: e.globalData.token
}
}, function(e, a) {
for (var i = t.data.areaList, o = 0; o < a.length; o++) i.push(a[o].areaName);
t.setData({
areaList: i,
areaAll: a
});
}, function(e, t) {
console.log(t);
});
},
bindAreaPickerChange: function(e) {
this.setData({
areaIndex: e.detail.value,
areaSelected: this.data.areaAll[e.detail.value - 1].areaId
}), this.getOfficeList();
},
getOfficeList: function(t) {
var a = this;
e.restAjax.get(e.restAjax.path(e.apis.getArea, [ e.baseUrls.serviceUrl, a.data.areaSelected ]), {}, {
headers: {
token: e.globalData.token
}
}, function(e, t) {
for (var i = a.data.officeList, o = 0; o < t.length; o++) i.push(t[o].areaName);
a.setData({
officeList: i,
officeAll: t
});
}, function(e, t) {
console.log(t);
});
},
bindOfficePickerChange: function(e) {
this.setData({
officeIndex: e.detail.value,
officeSelected: this.data.officeAll[e.detail.value - 1].areaId
}), this.getCommunityList();
},
getCommunityList: function() {
var t = this;
e.restAjax.get(e.restAjax.path(e.apis.getCommunityList, [ e.baseUrls.communityUrl ]), {
parentCode: t.data.officeSelected
}, {
headers: {
token: e.globalData.token
}
}, function(e, a) {
t.setData({
committeeList: a
});
}, function(e, t) {
console.log(t);
});
},
onLoad: function(e) {
this.getAreaList();
},
onReady: function() {},
onShow: function() {},
onHide: function() {},
onUnload: function() {},
onPullDownRefresh: function() {},
onReachBottom: function() {},
onShareAppMessage: function() {}
});