index.ee223782.js 7.8 KB

1
  1. import{d as g,y as m,j as i,aT as y,A as s,B as h,$ as C,N as n,aS as b}from"./ResizeObserver.es.39b48a47.js";import{R as v,C as u}from"./index.16ffd6ad.js";import{T as p}from"./index.34ac729a.js";import{S as _}from"./index.608320e9.js";import"./index.0e35d2fb.js";import{T as L,a as S}from"./index.5d4d28cc.js";import{T as A}from"./index.94d55063.js";import{S as T,i as w}from"./index.e10a1ae2.js";import{C as F}from"./index.db115763.js";import{R as k,a as V}from"./index.bb84a3aa.js";import"./index.3c44a6d7.js";import{D as B}from"./index.093181ab.js";import{u as $}from"./hooks.6df65925.js";import{C as x}from"./index.970ad07b.js";import"./use-id.b004ff17.js";import"./use-tab-status.bcc0c503.js";import"./use-refs.07204da6.js";import"./index.6c529ad4.js";import"./index.c527ae4e.js";import"./index.fcbcb027.js";import"./index.c88884de.js";import"./icon-sell-out.98742fd0.js";import"./shop-mall.eb722a4b.js";import"./index.428ab1a8.js";const P="_active_1vale_13",I="_filterBtn_1vale_17",N="_filterTagWrap_1vale_20",E="_filterTag_1vale_20",G="_filterSort_1vale_66",R="_iconSort_1vale_76";var r={"filter-top":"_filter-top_1vale_1",active:P,filterBtn:I,filterTagWrap:N,filterTag:E,"filter-productCategory":"_filter-productCategory_1vale_36","filter-tag":"_filter-tag_1vale_52","filter-tag-checked":"_filter-tag-checked_1vale_62",filterSort:G,"icon-active":"_icon-active_1vale_73",iconSort:R};const j="_loading_1wy15_1",q="_titlePopup_1wy15_7",W="_title_1wy15_7",z="_radio_1wy15_21",D="_filterAction_1wy15_57";var o={loading:j,titlePopup:q,title:W,"radio-group":"_radio-group_1wy15_21",radio:z,filterAction:D};function O(t){return typeof t=="function"||Object.prototype.toString.call(t)==="[object Object]"&&!C(t)}const f=()=>({productCategorySmallVoList:null,productAttributeCategoryList:null,brandList:null});var U=g({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:f()}},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 c=l.findIndex(d=>d.id==this.cateGoryId);this.params.productCategorySmallVoList=c>-1?c: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:o.loading},[i(y,{color:"var(--van-primary)"},null)]),i("div",{class:o.filterWrap},[i("div",{class:o.titlePopup},[s("\u7B5B\u9009")]),Object.keys(this.params).map(t=>i(F,{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(k,{class:o["radio-group"],modelValue:this.params[t],"onUpdate:modelValue":a=>this.params[t]=a},O(e=this[t].map((a,l)=>{const d=l===this.params[t]?"primary":"default";return i(V,{class:o.radio,name:l,onClick:()=>{}},{default:()=>[i(p,{size:"large",type:d},{default:()=>[a.name]})]})}))?e:{default:()=>[e]})}})),i(B,{style:{margin:"0"}},null),i("div",{class:o.filterAction},[i(h,{round:!0,style:{marginRight:"8px"},onClick:()=>this.params=f()},{default:()=>[s("\u91CD\u7F6E")]}),i(h,{round:!0,type:"primary",style:{marginLeft:"8px"},onClick:()=>this.onFilterClick()},{default:()=>[s("\u786E\u8BA4")]})])])])}}),mt=g({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,$("\u5546\u54C1\u5217\u8868")},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(){this.$refs.tabList.loading||this.$nextTick(()=>{this.onSearch()})},onClearTag(t){this[t]={id:0,name:""};const 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,console.log(this.keyword),this.$nextTick(()=>{this.onSearch()})}},render(){return i("div",null,[i(_,null,{default:()=>[i(x,{border:!1},null),i(T,{modelValue:this.keyword,onSearch:this.searchBtn},null),i(v,{class:r["filter-top"],align:"center"},{default:()=>[i(u,{span:6,class:this.filterActive===0?r.active:"",onClick:()=>this.onFilter(0)},{default:()=>[s("\u7EFC\u5408\u6392\u5E8F")]}),i(u,{span:6,class:this.filterActive===3||this.filterActive===4?r.active:"",onClick:()=>this.onFilter(3)},{default:()=>[s("\u4EF7\u683C"),i("div",{class:r.filterSort},[i(n,{class:this.filterActive===3?r["icon-active"]:"",style:{transform:"rotate(-90deg)"},name:"play",size:12},null),i(n,{class:[r.iconSort,this.filterActive===4?[r["icon-active"]]:""],style:{transform:"rotate(90deg)"},name:"play",size:12},null)])]}),i(u,{style:{marginLeft:"auto"},span:6,class:r.filterBtn,onClick:()=>this.filterListShow=!0},{default:()=>[s("\u7B5B\u9009"),i(n,{name:w,size:18},null)]})]}),this.productCategory.id&&this.productCategory.children&&this.productCategory.children.length?i(L,{class:r["filter-productCategory"],shrink:!0,ellipsis:!1,active:this.productCategory.active,"onUpdate:active":t=>this.productCategory.active=t,onChange:()=>this.onToggleTag()},{default:()=>[this.productCategory&&this.productCategory.children.map((t,e)=>i(S,{name:e,title:t.name},{title:()=>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(p,{class:r.filterTag,closeable:!0,onClose:()=>this.onClearTag("productAttributeCategory")},{default:()=>[this.productAttributeCategory.name]}):"",this.brand.id?i(p,{class:r.filterTag,closeable:!0,onClose:()=>this.onClearTag("brand")},{default:()=>[this.brand.name]}):""]),this.tabListShow?i(A,{ref:"tabList",typeId:Number(this.getProductAttributeCategory),productAttributeCategoryId:this.productAttributeCategory.id,brandId:this.brand.id,sort:this.filterActive,keyword:this.keyword},null):null,i(b,{show:this.filterListShow,closeable:!0,position:"bottom",round:!0,onClose:()=>{this.filterListShow=!1}},{default:()=>[i(U,{cateGoryId:this.productCategory.id,ref:"goodsFilter",setFilter:this.setFilter},null)]})])}});export{mt as default};