var $url="/settings/sitesAdd",data=utils.init({pageType:utils.getQueryString("type")||"selectType",siteTypes:null,siteTemplates:null,rootExists:null,sites:null,tableNameList:null,page:utils.getQueryInt("page",1),word:utils.getQueryString("word"),tag:utils.getQueryString("tag"),price:utils.getQueryString("price"),order:utils.getQueryString("order"),themes:null,count:null,pages:null,tags:[],parentIds:[0],form:{guid:null,siteType:null,createType:utils.getQueryString("createType"),localDirectoryName:utils.getQueryString("localDirectoryName"),cloudThemeUserName:utils.getQueryString("cloudThemeUserName"),cloudThemeName:utils.getQueryString("cloudThemeName"),siteName:"",root:!1,parentId:0,siteDir:"",tableRule:"Create",tableChoose:"",tableHandWrite:"",isImportContents:!0,isImportTableStyles:!0},total:1,current:0,message:"",success:!1}),methods={apiGet:function(){var t=this;$api.get($url).then(function(e){var i=e.data;t.siteTypes=i.siteTypes,t.siteTemplates=i.siteTemplates,t.rootExists=i.rootExists,t.sites=i.sites,t.tableNameList=i.tableNameList,t.form.guid=i.guid}).catch(function(t){utils.error(t)}).then(function(){utils.loading(t,!1),"selectCloud"==t.pageType&&t.load()})},apiSubmit:function(){var t=this,e=setTimeout(function(){t.apiProcess()},3e3);utils.loading(this,!0),this.form.parentId=this.parentIds&&this.parentIds.length>0?this.parentIds[this.parentIds.length-1]:0,$api.post($url,this.form).then(function(e){var i=e.data;t.total=1,t.current=1,t.message="站点创建成功！",t.success=!0,setTimeout(function(){parent.location.href=utils.getIndexUrl({siteId:i.value})},1e3)}).catch(function(i){clearTimeout(e),t.pageType="submit",utils.loading(t,!1),utils.error(i)})},apiProcess:function(){var t=this;t.pageType="process",$api.post($url+"/actions/process",{guid:this.form.guid}).then(function(e){var i=e.data;t.success||(t.total=i.total||1,t.current=i.current,t.message=i.message,t.current>t.total&&(t.current=t.total),t.total>t.current&&setTimeout(function(){t.apiProcess()},3e3),utils.loading(t,!1))}).catch(function(t){utils.error(t)})},getTemplatesUrl:function(){return cloud.host+"/templates/"},getDisplayUrl:function(t,e){return cloud.getThemesUrl("template.html?userName="+t+"&name="+e)},getCoverUrl:function(t){return cloud.hostStorage+"/themes/"+t.userName+"/"+t.name+"/"+_.trim(t.coverUrl,"/")},btnImageClick:function(t){window.open(this.getDisplayUrl(t.userName,t.name))},btnPreviewClick:function(t){window.open(cloud.hostDemo+"/"+t.userName+"/"+t.name+"/")},getPageUrl:function(t){return t<1||t>this.pages||t==this.page?"javascript:;":this.getUrl(t,this.word,this.tag,this.price,this.order)},getTagUrl:function(t){return this.getUrl(this.page,this.word,t,this.price,this.order)},getPriceUrl:function(t){return this.getUrl(this.page,this.word,this.tag,t,this.order)},getOrderUrl:function(t){return this.getUrl(this.page,this.word,this.tag,this.price,t)},btnRedirectClick:function(t){location.href=t},handlePageChange:function(t){location.href=this.getPageUrl(t)},getUrl:function(t,e,i,s,r){var a="?type=selectCloud&page="+t;return e&&(a+="&word="+e),i&&(a+="&tag="+i),s&&(a+="&price="+s),r&&(a+="&order="+r),a},priceChanged:function(){this.load()},orderChanged:function(){this.load()},load:function(){var t=this;utils.loading(this,!0),cloud.getThemes(this.page,this.word,this.tag,this.price,this.order).then(function(e){var i=e.data;t.themes=i.themes,t.count=i.count,t.pages=i.pages,t.tags=i.tags}).catch(function(t){utils.error(t)}).then(function(){utils.loading(t,!1)})},btnLocalClick:function(){this.pageType="selectLocal",this.form.createType="local"},btnCloudClick:function(){this.pageType="selectCloud",this.form.createType="cloud",this.load()},btnCancelClick:function(){this.pageType="selectType"},btnCreateEmptyClick:function(){this.form.createType="empty",this.pageType="submit"},btnCreateLocalClick:function(t){this.form.createType="local",this.form.localDirectoryName=t,this.pageType="submit"},btnCreateCloudClick:function(t,e){this.form.createType="cloud",this.form.cloudThemeUserName=t,this.form.cloudThemeName=e,this.pageType="submit"},btnSubmitClick:function(){var t=this;this.$refs.form.validate(function(e){e&&t.apiSubmit()})}},$vue=new Vue({el:"#main",data:data,methods:methods,created:function(){this.apiGet()}});