"use strict";(self["webpackChunkabcdf"]=self["webpackChunkabcdf"]||[]).push([[220],{6220:function(e,t,s){s.r(t),s.d(t,{default:function(){return n}});s(8111),s(116);var a=function(){var e=this,t=e._self._c;return t("div",{staticClass:"product-grid-page"},[e.showFilter?t("div",{staticClass:"filter-bar"},[t("el-select",{staticClass:"filter-select",attrs:{placeholder:"全部分类"},on:{change:e.handleCategoryChange},model:{value:e.selectedCategory,callback:function(t){e.selectedCategory=t},expression:"selectedCategory"}},e._l(e.categories,function(e){return t("el-option",{key:e.id,attrs:{label:e.name,value:e.id}})}),1),t("el-select",{staticClass:"filter-select",attrs:{placeholder:"综合排序"},on:{change:e.handleSortChange},model:{value:e.selectedSort,callback:function(t){e.selectedSort=t},expression:"selectedSort"}},[t("el-option",{attrs:{label:"综合排序",value:"default"}}),t("el-option",{attrs:{label:"销量↑",value:"sales_asc"}}),t("el-option",{attrs:{label:"销量↓",value:"sales_desc"}}),t("el-option",{attrs:{label:"价格↑",value:"price_asc"}}),t("el-option",{attrs:{label:"价格↓",value:"price_desc"}})],1)],1):e._e(),"search"==e.type?t("div",{staticClass:"result-stats"},[t("span",[e._v("全部结果 >")]),e.searchKeyword?t("span",{staticClass:"keyword"},[e._v('"'+e._s(e.searchKeyword)+'"')]):e._e(),e.selectedCategory&&e.categories.find(t=>t.value===e.selectedCategory)?t("span",{staticClass:"category"},[e._v(' "'+e._s(e.categories.find(t=>t.value===e.selectedCategory).label)+'" ')]):e._e(),t("span",[e._v("共"+e._s(e.totalProducts)+"个结果")])]):e._e(),t("div",{staticClass:"product-grid"},[e._l(e.visibleProducts,function(s,a){return t("div",{key:a,staticClass:"product-card",on:{click:function(t){return e.goToDetail(s.id)}}},[t("img",{directives:[{name:"lazy",rawName:"v-lazy",value:s.headimg,expression:"product.headimg"}],staticClass:"product-img",attrs:{alt:s.title,fit:"cover"}}),t("div",{staticClass:"product-info"},[t("div",{staticClass:"product-name"},[e._v(e._s(s.title))]),t("div",{staticClass:"price-row"},[t("span",{staticClass:"current-price"},[e._v("¥"+e._s(s.price/100))]),s.market_price?t("span",{staticClass:"original-price"},[e._v("¥"+e._s(s.market_price/100))]):e._e()]),t("div",{staticClass:"sales-volume"},[t("i",{staticClass:"el-icon-shopping-cart"}),e._v(" 已售 "+e._s(s.sales_number)+" ")]),t("el-button",{staticClass:"cart-btn",attrs:{type:"primary",size:"mini"}},[e._v(" 立即购买 ")])],1)])}),0===e.visibleProducts.length?t("div",{staticClass:"empty-state"},[t("el-empty",{attrs:{description:"暂无符合条件的商品"}})],1):e._e()],2),e.totalProducts>0?t("div",{staticClass:"pagination-container"},[t("el-pagination",{attrs:{"current-page":e.currentPage,"page-sizes":[12,24,36],"page-size":e.pageSize,layout:"total, sizes, prev, pager, next, jumper",total:e.totalProducts},on:{"size-change":e.handleSizeChange,"current-change":e.handleCurrentChange}})],1):e._e()])},r=[],i=(s(4114),s(3518)),c={name:"ProductGridPage",data(){return{type:"",searchKeyword:"",selectedCategory:"",selectedSort:"default",showFilter:!0,currentPage:1,pageSize:12,visibleProducts:[],totalProducts:0,categories:[],id:"",keyword:""}},computed:{...(0,i.L8)(["getSearchText"]),currentOffset(){return(this.currentPage-1)*this.pageSize}},watch:{getSearchText(e,t){e!==t&&(this.searchKeyword=e,this.fetchProducts())}},created(){this.type=this.$route.query?.type,this.searchKeyword=this.getSearchText,this.getTagList()},beforeDestroy(){this.searchKeyword="",this.$store.commit("setSearchText",""),this.currentPage=1,this.selectedCategory="",this.selectedSort="default"},methods:{getTagList(){this.post({pid:683},"/api/product/tag_list").then(e=>{this.categories=e.data,this.categories[0].id=662;const t=this.$route.query.id||662;if(t){this.id=t;const e=this.categories.find(e=>e.id==t);console.log(t,e),e&&(this.selectedCategory=e.name)}this.fetchProducts()})},async fetchProducts(){const e={tag_id:this.id||this.selectedCategory,offset:this.currentOffset,limit:this.pageSize,title:this.searchKeyword,...this.parseSortParams()};this.searchKeyword&&(e.keyword=this.searchKeyword);const t=await this.post(e,"/api/product/get_product_by_tag");this.visibleProducts=t.data.list||[],this.totalProducts=Number(t.data.total)||0},parseSortParams(){if("default"===this.selectedSort)return{};const[e,t]=this.selectedSort.split("_"),s={sales:"sales_number",price:"price"};return{sort:s[e],order:t}},handleCategoryChange(e){this.id=e,this.currentPage=1,this.fetchProducts()},handleSortChange(){this.currentPage=1,this.fetchProducts()},handleSizeChange(e){this.pageSize=e,this.currentPage=1,this.fetchProducts()},handleCurrentChange(e){this.currentPage=e,this.fetchProducts(),window.scrollTo(0,0)},goToDetail(e){this.$router.push(`/Detail/${e}`)}}},l=c,o=s(1656),d=(0,o.A)(l,a,r,!1,null,"f31b94e0",null),n=d.exports}}]); //# sourceMappingURL=220.98d37146.js.map