import{_ as r,a as n,b as c,c as d,d as _,e as g}from"./perfume.7f4fef75.js";import{n as u,p as l,_ as h}from"./index.13f93d3a.js";import{_ as p}from"./success.b7dfa7d0.js";const m={name:"upload-huabook",data(){return{category:{},categories:[],thirdCategories:[],subcategoryId:"",thirdCategoryId:"",subCategoryTypes:{}}},mounted(){const a=JSON.parse(sessionStorage.getItem("conf_categories"));this.category=a.find(e=>e.id===this.id),this.subCategoryTypes=l[this.id];const s=this.$t("common.failure");this.$axios.get("/api/upload_type_list",{params:{pid:this.id}}).then(e=>{const{code:t,msg:i=s,data:o=[]}=e.data;t==0?this.categories=this.rebuildCategories(o):this.$message.error(i||s)}).catch(()=>{this.$message.error(s)})},methods:{backToInformation(){this.$router.push({path:"/upload/information",query:{id:this.id,category:"huabook"}})},rebuildCategories(a){return a.map(s=>{const e=this.subCategoryTypes[s.id];return{...s,type:e,image:new URL(Object.assign({"../../../assets/images/nav/index/base.png":r,"../../../assets/images/nav/index/body.png":n,"../../../assets/images/nav/index/gift.png":c,"../../../assets/images/nav/index/makeup.png":d,"../../../assets/images/nav/index/men.png":_,"../../../assets/images/nav/index/perfume.png":g})[`../../../assets/images/nav/index/${e}.png`],self.location).href}})},uploadFile(){const a=this.$t("common.failure"),s=JSON.parse(sessionStorage.getItem("conf_upload"));this.$axios.post("/api/product/add_product",{...s,type:[this.id,this.subcategoryId,this.thirdCategoryId]}).then(e=>{const{code:t,msg:i=a}=e.data;t==0?this.toSuccess():this.$message.error(i||a)}).catch(()=>{this.$message.error(a)})},toSuccess(){this.$router.push({path:"/upload/success"})},changeSubcategoryId(a){this.subcategoryId=a;const s=this.$t("common.failure");this.$axios.get("/api/upload_type_list",{params:{pid:a}}).then(e=>{const{code:t,msg:i=s,data:o=[]}=e.data;t==0?this.thirdCategories=o:this.$message.error(i||s)}).catch(()=>{this.$message.error(s)})},changeThirdCategoryId(a){this.thirdCategoryId=a}},computed:{id(){const{id:a}=this.$route.query;return parseInt(a)},disabled(){return!this.thirdCategoryId},nameKey(){return this.$store.state.nameKey}}};var y=function(){var s=this,e=s._self._c;return e("div",{staticClass:"upload-huabook"},[e("div",{staticClass:"back",on:{click:s.backToInformation}},[e("img",{attrs:{src:h,alt:"back"}})]),e("div",{staticClass:"center"},[e("div",{staticClass:"center-title"},[e("b",[s._v(s._s(s.$t("upload.category.selectGoods")))])]),e("div",{staticClass:"center-sub-title"},[e("div",{staticClass:"dot red"}),s._v(" "+s._s(s.category[s.nameKey])+" ")]),e("div",{staticClass:"center-goods"},[e("ul",s._l(s.categories,function(t){return e("li",{key:t.id,class:["goods-item",t.type,s.subcategoryId===t.id?"selected":""],on:{click:function(i){return s.changeSubcategoryId(t.id)}}},[e("img",{staticClass:"success",attrs:{src:p,alt:"success"}}),e("img",{staticClass:"category",attrs:{src:t.image}}),s._v(" "+s._s(t[s.nameKey])+" ")])}),0)]),e("div",{staticClass:"center-sub-goods"},[e("ul",s._l(s.thirdCategories,function(t){return e("li",{key:t.id,class:["sub-goods-item",s.thirdCategoryId===t.id?"selected":""],on:{click:function(i){return s.changeThirdCategoryId(t.id)}}},[s._v(" "+s._s(s.$t(`${t[s.nameKey]}`))+" ")])}),0)])]),e("div",{staticClass:"button"},[e("el-button",{attrs:{type:"primary",disabled:s.disabled,round:""},on:{click:s.uploadFile}},[s._v(s._s(s.$t("common.save")))])],1)])},b=[],v=u(m,y,b,!1,null,"eb9c8d99",null,null);const I=v.exports;export{I as default};
