var e = getApp(); Page({ data: { token: e.globalData.token, sourceUrl: e.baseUrls.sourceUrl, array: [], index: 0, communityList: [], communitySelected: "", areaCode: "", page: { page: 1, rows: 5, communityId: "" }, helpList: [], circleList: [], serviceUrl: e.baseUrls.serviceUrl, baseImgUrl: e.baseUrls.baseImgUrl, tab: "1", isShowMenu: !1 }, checkHelpMore: function() { "1" == this.data.tab ? wx.navigateTo({ url: "./help/helpList?communityId=" + this.data.communitySelected }) : wx.navigateTo({ url: "./circle/circleList" }); }, checkHelpDetail: function(t) { var e = t.currentTarget.dataset.id; wx.navigateTo({ url: "./help/helpDetail?neighborId=" + e }); }, bindPickerChange: function(e) { var a; this.setData((a = { index: e.detail.value, communitySelected: this.data.communityList[e.detail.value].communityId }, t(a, "page.communityId", this.data.communityList[e.detail.value].communityId), t(a, "areaCode", this.data.communityList[e.detail.value].areaCode), a)), wx.setStorage({ data: e.detail.value, key: "communityIndex" }), "1" == this.data.tab ? this.getHelpList() : this.getCircleList(); }, newHelp: function() { wx.navigateTo({ url: "./help/new?communityId=" + this.data.communitySelected + "&areaCode=" + this.data.areaCode }); }, newCircle: function() { wx.navigateTo({ url: "./circle/new?communityId=" + this.data.communitySelected + "&areaCode=" + this.data.areaCode }); }, getHelpList: function() { var t = this; e.restAjax.get(e.restAjax.path(e.apis.getHelpList, [ e.baseUrls.requestUrl ]), t.data.page, { headers: { token: t.data.token } }, function(e, a) { for (var n = 0; n < a.rows.length; n++) a.rows[n].photo && (a.rows[n].photo = a.rows[n].photo.split(",")); t.setData({ helpList: a.rows }); }, function(t, e) { console.log(e); }); }, getCircleList: function() { var t = this; e.restAjax.get(e.restAjax.path(e.apis.getCircleList, [ e.baseUrls.requestUrl ]), t.data.page, { headers: { token: t.data.token } }, function(e, a) { for (var n = 0; n < a.rows.length; n++) a.rows[n].photo && (a.rows[n].photo = a.rows[n].photo.split(",")); t.setData({ helpList: a.rows }); }, function(t, e) { console.log(e); }); }, checkCircleDetail: function(t) { var e = t.currentTarget.dataset.id; wx.navigateTo({ url: "./circle/circleDetail?neighborCircleId=" + e }); }, getMyCommunity: function() { var a = this; e.restAjax.get(e.restAjax.path(e.apis.mycommunity, [ e.baseUrls.requestUrl ]), {}, { headers: { token: a.data.token } }, function(e, n) { if (n.length > 0) { for (var i, o = [], s = 0; s < n.length; s++) o.push(n[s].communityName); a.setData((i = { communityList: n, array: o, communitySelected: wx.getStorageSync("communityIndex") ? n[wx.getStorageSync("communityIndex")].communityId : n[0].communityId }, t(i, "page.communityId", wx.getStorageSync("communityIndex") ? n[wx.getStorageSync("communityIndex")].communityId : n[0].communityId), t(i, "areaCode", wx.getStorageSync("communityIndex") ? n[wx.getStorageSync("communityIndex")].areaCode : n[0].areaCode), i)), "1" == a.data.tab ? a.getHelpList() : a.getCircleList(); } else wx.showToast({ title: "请先在首页加入您的社区", icon: "none" }), setTimeout(function() { wx.switchTab({ url: "../index/index" }); }, 1500); }, function(t, e) { console.log(e); }); }, newContent: function() { "1" == this.data.tab ? this.newHelp() : this.newCircle(); }, changeTab: function(e) { var a = e.currentTarget.dataset.tab; a != this.data.tab && ("1" == a ? (this.setData(t({ tab: a }, "page.page", 1)), this.getHelpList()) : (this.setData(t({ tab: a }, "page.page", 1)), this.getCircleList())); }, onLoad: function(t) { this.setData({ token: e.globalData.token }); }, onReady: function() {}, onShow: function() { this.getMyCommunity(), this.getMenuIsShow(); }, getMenuIsShow: function() { var t = this; e.restAjax.get(e.restAjax.path(e.apis.getBtnIsShow, [ e.baseUrls.requestUrl, "neighbor" ]), null, { headers: { token: e.globalData.token } }, function(e, a) { null != a && null != a ? t.setData({ isShowMenu: 1 == a.isShow }) : t.setData({ isShowMenu: !1 }); }, function(e, a) { t.setData({ isShowMenu: !1 }); }); }, onHide: function() {}, onUnload: function() {}, onPullDownRefresh: function() {}, onReachBottom: function() {}, onShareAppMessage: function() {} });