var $url="/wx/replyMessage",$urlUpload="/wx/replyMessage/actions/upload",data=utils.init({siteId:utils.getQueryInt("siteId"),activeName:utils.getQueryString("activeName"),success:!1,errorMessage:null,form:{id:0,materialType:"Text",materialId:0,text:""},items:null,image:null,audio:null,video:null,editEditor:null}),methods={runLayerMessage:function(i){this.form.materialId=0,i&&(this.form.materialId=i.id,this.items=i.items)},runLayerImage:function(i){this.form.materialId=0,i&&(this.form.materialId=i.id,this.image=i)},runLayerAudio:function(i){this.form.materialId=0,i&&(this.form.materialId=i.id,this.audio=i)},runLayerVideo:function(i){this.form.materialId=0,i&&(this.form.materialId=i.id,this.video=i)},apiGet:function(){var i=this;utils.loading(this,!0),$api.get($url,{params:{siteId:this.siteId,activeName:this.activeName}}).then(function(t){var e=t.data;i.success=e.success,i.errorMessage=e.errorMessage,e.message&&(i.form=e.message,i.items=e.message.items,i.image=e.message.image,i.audio=e.message.audio,i.video=e.message.video)}).catch(function(i){utils.error(i)}).then(function(){utils.loading(i,!1)})},apiSubmit:function(){var i=this;utils.loading(this,!0),$api.post($url,{siteId:this.siteId,activeName:this.activeName,materialType:this.form.materialType,materialId:this.form.materialId,text:this.form.text}).then(function(t){var e=t.data;i.form.id=e.value,utils.success("自动回复消息保存成功！")}).catch(function(i){utils.error(i)}).then(function(){utils.loading(i,!1)})},apiDelete:function(){var i=this;utils.loading(this,!0),$api.delete($url,{data:{siteId:this.siteId,activeName:this.activeName}}).then(function(t){t.data;i.form={id:0,materialType:"Text",materialId:0,text:""},i.items=null,i.image=null,i.audio=null,i.video=null,i.editEditor.txt.html("")}).catch(function(i){utils.error(i)}).then(function(){utils.loading(i,!1)})},btnTabClick:function(i){this.form.materialType=i.name,"Message"===i.name?this.runLayerMessage(this.message):"Image"===i.name?this.runLayerImage(this.image):"Audio"===i.name?this.runLayerAudio(this.audio):"Video"===i.name&&this.runLayerVideo(this.video)},btnSelectClick:function(){utils.openLayer({title:"选择素材",url:utils.getWxUrl("layer"+this.form.materialType,{siteId:this.siteId})})},getUploadUrl:function(){return $apiUrl+$urlUpload+"?siteId="+this.siteId+"&materialType="+this.form.materialType},uploadProgress:function(){utils.loading(this,!0)},uploadSuccess:function(i){"Image"===this.form.materialType?(this.form.materialId=i.image.id,this.image=i.image):"Audio"===this.form.materialType?(this.form.materialId=i.audio.id,this.audio=i.audio):"Video"===this.form.materialType&&(this.form.materialId=i.video.id,this.video=i.video),utils.loading(this,!1)},uploadError:function(i){utils.loading(this,!1);var t=JSON.parse(i.form);utils.error(t.form)},btnRemoveClick:function(){this.form.materialId=0},btnSubmitClick:function(){var i=!1;"Text"===this.form.materialType?this.form.text&&this.form.text.length>0?i=!0:utils.error("请输入需要回复的消息!"):this.form.materialId>0?i=!0:utils.error("请选择或上传需要回复的消息!"),i&&this.apiSubmit()},btnDeleteClick:function(){var i=this;utils.alertDelete({title:"删除回复",text:"删除后，关注该公众号的用户将不再接收该回复，确定删除？",callback:function(){i.apiDelete()}})}},$vue=new Vue({el:"#main",data:data,methods:methods,created:function(){this.apiGet()}});