var $url="/wx/chat",$urlStar="/wx/chat/actions/star",data=utils.init({success:!1,errorMessage:null,count:null,chats:null,users:null,form:{siteId:utils.getQueryInt("siteId"),star:!1,keyword:null,page:1,perPage:20}}),methods={apiGet:function(t){this.form.page=t;var e=this;utils.loading(this,!0),$api.get($url,{params:this.form}).then(function(t){var s=t.data;e.success=s.success,e.errorMessage=s.errorMessage,e.count=s.count,e.chats=s.chats,e.users=s.users}).catch(function(t){utils.error(t)}).then(function(){utils.loading(e,!1)})},apiStar:function(t){var e=this;utils.loading(this,!0),$api.post($urlStar,{siteId:this.form.siteId,chatId:t.id,star:!t.isStar}).then(function(e){e.data;utils.success(t.isStar?"取消收藏成功！":"收藏成功！"),t.isStar=!t.isStar}).catch(function(t){utils.error(t)}).then(function(){utils.loading(e,!1)})},getUser:function(t){return this.users.find(function(e){return e.openId===t.openId})||{}},getUserAvatarUrl:function(t){return this.getUser(t).headImgUrl},getUserTitle:function(t){var e=this.getUser(t);return e.remark?e.remark+"("+e.nickname+")":e.nickname},btnSearchClick(){this.apiGet(1)},btnPageClick:function(t){this.apiGet(t)},btnStarClick:function(t){this.apiStar(t)},btnReplyClick:function(t){utils.addTab("回复消息",utils.getWxUrl("chatSend",{siteId:this.form.siteId,openId:t.openId}))}},$vue=new Vue({el:"#main",data:data,methods:methods,created:function(){this.apiGet(1)}});