index.fb05c725.js 7.4 KB

1
  1. import{d as p,a as i,L as C,j as o,q as b,a9 as _,aa as v,z as u,x as L,aj as S,B as f,S as A,k as g,l as d,u as h,P as w}from"./vendor.f57b7239.js";/* empty css *//* empty css *//* empty css */import{T as x}from"./index.a2e3c2e3.js";import{C as T,i as F}from"./index.d616afcd.js";import{r as m}from"./index.b39df320.js";/* empty css *//* empty css *//* empty css *//* empty css *//* empty css */import"./index.65faf0e7.js";/* empty css *//* empty css *//* empty css */const j="_active_1wl5e_13",k="_filterBtn_1wl5e_17",V="_filterTagWrap_1wl5e_20",B="_filterTag_1wl5e_20",P="_filterSort_1wl5e_62",$="_iconSort_1wl5e_72";var r={"filter-top":"_filter-top_1wl5e_1",active:j,filterBtn:k,filterTagWrap:V,filterTag:B,"filter-productCategory":"_filter-productCategory_1wl5e_36","filter-tag":"_filter-tag_1wl5e_49","filter-tag-checked":"_filter-tag-checked_1wl5e_58",filterSort:P,"icon-active":"_icon-active_1wl5e_69",iconSort:$};const I="_loading_1wy15_1",q="_titlePopup_1wy15_7",G="_title_1wy15_7",N="_radio_1wy15_21",z="_filterAction_1wy15_57";var s={loading:I,titlePopup:q,title:G,"radio-group":"_radio-group_1wy15_21",radio:N,filterAction:z};function E(t){return typeof t=="function"||Object.prototype.toString.call(t)==="[object Object]"&&!L(t)}const y=()=>({productCategorySmallVoList:null,productAttributeCategoryList:null,brandList:null});var W=p({name:"goods-filter-list",props:{setFilter:{type:Function,default:t=>{}},cateGoryId:{type:Number,default:0}},data(){return{dataShow:!0,loading:!1,brandList:[],productAttributeCategoryList:[],productCategorySmallVoList:[],params:y()}},mounted(){this.getFilterList()},methods:{async getFilterList(){this.loading=!0;try{const t=await m.get("/api-mall-portal/product/search/condition");this.dataShow=t.code===200;const{brandList:e=[],productAttributeCategoryList:a=[],productCategorySmallVoList:l=[]}=t.data||{};if(this.brandList=e,this.productAttributeCategoryList=a,this.productCategorySmallVoList=l,this.cateGoryId){let n=l.findIndex(c=>c.id==this.cateGoryId);this.params.productCategorySmallVoList=n>-1?n:null}}catch{this.dataShow=!1}this.loading=!1},onFilterClick(){this.setFilter({productCategory:this.productCategorySmallVoList[this.params.productCategorySmallVoList],productAttributeCategory:this.productAttributeCategoryList[this.params.productAttributeCategoryList],brand:this.brandList[this.params.brandList]})},setParams(t){this.params[t]=null}},render(){return i("div",null,[this.loading&&i("div",{class:s.loading},[i(C,{color:"var(--van-primary)"},null)]),i("div",{class:s.filterWrap},[i("div",{class:s.titlePopup},[o("\u7B5B\u9009")]),Object.keys(this.params).map(t=>i(b,{border:!1},{title:()=>i("div",null,[t==="productCategorySmallVoList"?"\u5546\u54C1\u5206\u7C7B":t==="productAttributeCategoryList"?"\u5546\u54C1\u7C7B\u578B":"\u54C1\u724C"]),label:()=>{let e;return i(_,{class:s["radio-group"],modelValue:this.params[t],"onUpdate:modelValue":a=>this.params[t]=a},E(e=this[t].map((a,l)=>{const c=l===this.params[t]?"primary":"default";return i(v,{class:s.radio,name:l,onClick:()=>{}},{default:()=>[i(u,{size:"large",type:c},{default:()=>[a.name]})]})}))?e:{default:()=>[e]})}})),i(S,{style:{margin:"0"}},null),i("div",{class:s.filterAction},[i(f,{round:!0,style:{marginRight:"8px"},onClick:()=>this.params=y()},{default:()=>[o("\u91CD\u7F6E")]}),i(f,{round:!0,type:"primary",style:{marginLeft:"8px"},onClick:()=>this.onFilterClick()},{default:()=>[o("\u786E\u8BA4")]})])])])}}),at=p({name:"goods-list",data(){const t=this.$route.query;return{tabListShow:!t.id,typeId:0,filterActive:0,filterListShow:!1,productCategory:{active:0,name:t.tag||"",id:Number(t.id)||0,children:[]},productAttributeCategory:{children:[],name:"",id:0},brand:{name:"",id:0},keyword:"",autofocus:!1}},computed:{getProductAttributeCategory(){if(this.productCategory.id){if(this.productCategory.children)return(this.productCategory.children[this.productCategory.active]||{}).id||"";this.productCategory.id}return 0}},async mounted(){if(this.$nextTick(()=>{this.$route.query.input==="focus"&&document.querySelector(".van-field__control").focus()}),this.productCategory.id)try{const t=await m.get("/api-mall-portal/product/search/condition");t.code===200&&this.setFilter({productCategory:t.data.productCategorySmallVoList.find(e=>e.id===this.productCategory.id),productAttributeCategory:void 0,brand:void 0})}catch{}this.tabListShow=!0},methods:{onFilter(t){this.filterActive===3&&t===3&&(t=4),this.filterActive===4&&t===3&&(t=3),this.filterActive!==t&&(this.filterActive=t,this.$nextTick(()=>{this.onSearch()}))},setFilter({productCategory:t,productAttributeCategory:e,brand:a}){t&&t.active===void 0&&(t.active=0),this.productCategory=t||{id:0,name:""},this.productAttributeCategory=e||{id:0,name:""},this.brand=a||{id:0,name:""},this.$nextTick(()=>{this.onSearch(),this.filterListShow=!1})},onToggleTag(t){this.$refs.tabList.loading||(this.productCategory.active=t,this.$nextTick(()=>{this.onSearch()}))},onClearTag(t){this[t]={id:0,name:""};let e=this.$refs.goodsFilter;e&&(t==="productCategory"?e.setParams("productCategorySmallVoList"):t==="productAttributeCategory"?e.setParams("productAttributeCategoryList"):e.setParams("brandList")),this.$nextTick(()=>{this.onSearch()})},onSearch(){this.$refs.tabList.onSearch()},searchBtn(t){this.keyword=t,this.$nextTick(()=>{this.onSearch()})}},render(){return i("div",null,[i(A,null,{default:()=>[i(T,{modelValue:this.keyword,onSearch:this.searchBtn},null),i(g,{class:r["filter-top"],align:"center"},{default:()=>[i(d,{span:6,class:this.filterActive===0?r.active:"",onClick:()=>this.onFilter(0)},{default:()=>[o("\u7EFC\u5408\u6392\u5E8F")]}),i(d,{span:6,class:this.filterActive===3||this.filterActive===4?r.active:"",onClick:()=>this.onFilter(3)},{default:()=>[o("\u4EF7\u683C"),i("div",{class:r.filterSort},[i(h,{class:this.filterActive===3?r["icon-active"]:"",style:{transform:"rotate(-90deg)"},name:"play",size:12},null),i(h,{class:[r.iconSort,this.filterActive===4?[r["icon-active"]]:""],style:{transform:"rotate(90deg)"},name:"play",size:12},null)])]}),i(d,{span:6,class:this.filterActive===2?r.active:"",onClick:()=>this.onFilter(2)},{default:()=>[o("\u9500\u91CF")]}),i(d,{span:6,class:r.filterBtn,onClick:()=>this.filterListShow=!0},{default:()=>[o("\u7B5B\u9009"),i(h,{name:F,size:18},null)]})]}),this.productCategory.id?i(g,{class:r["filter-productCategory"]},{default:()=>[this.productCategory&&this.productCategory.children.map((t,e)=>i(d,{onClick:()=>this.onToggleTag(e)},{default:()=>[i("div",{class:[r["filter-tag"],this.productCategory.active===e?r["filter-tag-checked"]:""]},[t.name])]}))]}):null]}),i("div",{class:r.filterTagWrap},[this.productAttributeCategory.id?i(u,{class:r.filterTag,closeable:!0,onClose:()=>this.onClearTag("productAttributeCategory")},{default:()=>[this.productAttributeCategory.name]}):"",this.brand.id?i(u,{class:r.filterTag,closeable:!0,onClose:()=>this.onClearTag("brand")},{default:()=>[this.brand.name]}):""]),this.tabListShow?i(x,{ref:"tabList",typeId:Number(this.getProductAttributeCategory),productAttributeCategoryId:this.productAttributeCategory.id,brandId:this.brand.id,sort:this.filterActive,keyword:this.keyword},null):null,i(w,{show:this.filterListShow,closeable:!0,position:"bottom",round:!0,onClose:()=>{this.filterListShow=!1}},{default:()=>[i(W,{cateGoryId:this.productCategory.id,ref:"goodsFilter",setFilter:this.setFilter},null)]})])}});export{at as default};