var e = getApp(); Page({ data: { token: e.globalData.token, sourceUrl: e.baseUrls.sourceUrl, neighborCircleId: "", circleDetail: {}, serviceUrl: e.baseUrls.serviceUrl, baseImgUrl: e.baseUrls.baseImgUrl, userIcon: "", userName: "", reply: "", goodCount: 0, isClickedGood: "no", isGetFocus: !1, placeholder: "写评论", replyTo: "", replyUserName: "", isLoading: !1 }, getCircleDetai: function() { var t = this; e.restAjax.get(e.restAjax.path(e.apis.getCircleDetail, [ e.baseUrls.requestUrl, t.data.neighborCircleId ]), {}, { headers: { token: t.data.token } }, function(e, a) { a.photo && (a.photo = a.photo.split(",")), t.setData({ circleDetail: a }); }, function(e, t) { console.log(t); }); }, doReplyCircle: function() { var t = this; if (!t.data.isLoading) { var a = { content: t.data.reply, headPortrait: t.data.userIcon, neighborCircleId: t.data.neighborCircleId, userName: t.data.userName }; t.setData({ isLoading: !0 }), e.restAjax.post(e.restAjax.path(e.apis.submitCircleReply, [ e.baseUrls.requestUrl ]), a, { headers: { token: t.data.token } }, function(e, a) { "200" == e && (t.setData({ isLoading: !1 }), wx.showToast({ title: "回复成功!", icon: "success" }), t.getReplyList(), t.setData({ reply: "", replyTo: "", replyUserName: "", placeholder: "讨论一下" })); }, function(e, a) { console.log(a), t.setData({ isLoading: !1 }); }); } }, getReplyList: function() { var t = this; e.restAjax.get(e.restAjax.path(e.apis.getCircleReplyList, [ e.baseUrls.requestUrl ]), { neighborCircleId: t.data.neighborCircleId }, { headers: { token: t.data.token } }, function(e, a) { t.setData({ replyList: a }); }, function(e, t) { console.log(t); }); }, clickGood: function() { var t = this, a = { headPortrait: t.data.userIcon, userName: t.data.userName, neighborCircleId: t.data.neighborCircleId }; e.restAjax.post(e.restAjax.path(e.apis.circleClickGood, [ e.baseUrls.requestUrl ]), a, { headers: { token: t.data.token } }, function(e, a) { "200" == e && (t.getGoodCount(), t.getIsClicked()), console.log(a); }, function(e, t) { console.log(t); }); }, getGoodCount: function() { var t = this; e.restAjax.get(e.restAjax.path(e.apis.getCircleGoodCount, [ e.baseUrls.requestUrl ]), { neighborCircleId: t.data.neighborCircleId }, { headers: { token: t.data.token } }, function(e, a) { t.setData({ goodCount: a.data }), console.log(a); }, function(e, t) { console.log(t); }); }, getIsClicked: function() { var t = this; e.restAjax.get(e.restAjax.path(e.apis.circleIsClicked, [ e.baseUrls.requestUrl, t.data.neighborCircleId ]), {}, { headers: { token: t.data.token } }, function(e, a) { t.setData({ isClickedGood: a }), console.log(a); }, function(e, t) { console.log(t); }); }, toggleGood: function() { "yes" == this.data.isClickedGood ? this.cancelGood() : this.clickGood(); }, cancelGood: function() { var t = this; e.restAjax.delete(e.restAjax.path(e.apis.cancelGood, [ e.baseUrls.requestUrl, t.data.neighborCircleId ]), {}, { headers: { token: t.data.token } }, function(e, a) { "200" == e && (t.getIsClicked(), t.getGoodCount()), console.log(a); }, function(e, t) { console.log(t); }); }, getFocus: function(e) { var t = e.currentTarget.dataset.user, a = e.currentTarget.dataset.id, o = e.currentTarget.dataset.name; console.log(a), this.setData({ isGetFocus: !0, placeholder: "回复" + t + ":", replyTo: a, replyUserName: o }); }, inputBlur: function() { this.data.reply || this.setData({ placeholder: "讨论一下", isGetFocus: !1 }); }, doReply: function() { this.data.replyTo ? this.doReplyReply() : this.doReplyCircle(); }, doReplyReply: function() { var t = this; if (!t.data.isLoading) { var a = { content: t.data.reply, headPortrait: t.data.userIcon, userName: t.data.userName, neighborCircleId: t.data.neighborCircleId, replyCommentId: t.data.replyTo, replyNeighborCircleCommentId: t.data.replyTo, replyUserName: t.data.replyUserName }; t.setData({ isLoading: !0 }), e.restAjax.post(e.restAjax.path(e.apis.submitCircleReply, [ e.baseUrls.requestUrl ]), a, { headers: { token: t.data.token } }, function(e, a) { "200" == e && (t.setData({ isLoading: !1 }), wx.showToast({ title: "评论成功!", icon: "success" }), t.getReplyList(), t.setData({ reply: "", replyTo: "", replyUserName: "", placeholder: "讨论一下" })); }, function(e, a) { console.log(a), t.setData({ isLoading: !1 }); }); } }, viewImg: function(e) { for (var t = this.data.serviceUrl + this.data.baseImgUrl + e.currentTarget.dataset.id, a = [], o = 0; o < this.data.circleDetail.photo.length; o++) { var r = this.data.serviceUrl + this.data.baseImgUrl + this.data.circleDetail.photo[o]; a.push(r); } wx.previewImage({ current: t, urls: a }); }, onLoad: function(t) { this.setData({ neighborCircleId: t.neighborCircleId, userIcon: wx.getStorageSync("userIcon"), userName: wx.getStorageSync("name"), token: e.globalData.token }), this.getCircleDetai(), this.getReplyList(), this.getGoodCount(), this.getIsClicked(); }, onReady: function() {}, onShow: function() {}, onHide: function() {}, onUnload: function() {}, onPullDownRefresh: function() {}, onReachBottom: function() {}, onShareAppMessage: function() {} });