var $url="/cms/settings/settingsSite",data=utils.init({siteId:utils.getQueryInt("siteId"),siteUrl:null,pageType:null,form:null,styles:null,files:[]}),methods={runFormLayerImageUploadText:function(t,i,e){this.insertText(t,i,e)},runFormLayerImageUploadEditor:function(t,i){this.insertEditor(t,i)},runMaterialLayerImageSelect:function(t,i,e){this.insertText(t,i,e)},runFormLayerFileUpload:function(t,i,e){this.insertText(t,i,e)},runMaterialLayerFileSelect:function(t,i,e){this.insertText(t,i,e)},runFormLayerVideoUpload:function(t,i,e){this.insertText(t,i,e)},runMaterialLayerVideoSelect:function(t,i,e){this.insertText(t,i,e)},runEditorLayerImage:function(t,i){this.insertEditor(t,i)},insertText:function(t,i,e){var n=this.form[utils.getCountName(t)];n&&n<i&&(this.form[utils.getCountName(t)]=i),this.form[utils.getExtendName(t,i)]=e,this.form=_.assign({},this.form)},insertEditor:function(t,i){t||(t="Body"),i&&utils.getEditor(t).execCommand("insertHTML",i)},apiGet:function(){var t=this;utils.loading(this,!0),$api.get($url,{params:{siteId:this.siteId}}).then(function(i){var e=i.data;t.siteUrl=e.siteUrl,t.styles=e.styles,t.form=e.entity,t.loadEditor(e)}).catch(function(t){utils.error(t)}).then(function(){utils.loading(t,!1)})},btnSiteStylesClick:function(){location.href=utils.getCmsUrl("settingsStyleSite",{siteId:this.siteId,returnUrl:location.href})},loadEditor:function(t){var i=this;setTimeout(function(){for(var t=0;t<i.styles.length;t++){var e=i.styles[t];if("TextEditor"===e.inputType){var n=utils.getEditor(e.attributeName);n.attributeName=e.attributeName,n.ready(function(){this.addListener("contentChange",function(){i.form[this.attributeName]=this.getContent()})})}}},100)},btnExtendAddClick:function(t){var i=this.form[utils.getCountName(t.attributeName)]+1;this.form[utils.getCountName(t.attributeName)]=i,this.form[utils.getExtendName(t.attributeName,i)]="",this.form=_.assign({},this.form)},btnExtendRemoveClick:function(t){var i=this.form[utils.getCountName(t.attributeName)];this.form[utils.getCountName(t.attributeName)]=i-1,this.form[utils.getExtendName(t.attributeName,i)]="",this.form=_.assign({},this.form)},btnExtendPreviewClick:function(t,i){for(var e=this.form[utils.getCountName(t)],n=[],s=0;s<=e;s++){var r=this.form[utils.getExtendName(t,s)];r=utils.getUrl(this.siteUrl,r),n.push({src:r})}layer.photos({photos:{start:i,data:n},anim:5})},btnLayerClick:function(t){var i={siteId:this.siteId,attributeName:t.attributeName};t.no&&(i.no=t.no);var e={title:t.title,url:utils.getCommonUrl(t.name,i)};t.full||(e.width=t.width?t.width:700,e.height=t.height?t.height:500),utils.openLayer(e)},apiSubmit:function(){var t=this;utils.loading(this,!0),$api.post($url,_.assign({siteId:this.siteId},this.form)).then(function(t){t.data;utils.success("站点设置保存成功！")}).catch(function(t){utils.error(t)}).then(function(){utils.loading(t,!1)})},btnSubmitClick:function(){var t=this;this.$refs.form.validate(function(i){i&&t.apiSubmit()})}},$vue=new Vue({el:"#main",data:data,methods:methods,created:function(){this.apiGet()}});