You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
2 lines
5.1 KiB
2 lines
5.1 KiB
"use strict";(self["webpackChunkshiweisuzhou"]=self["webpackChunkshiweisuzhou"]||[]).push([[512],{2512:function(t,e,s){s.r(e),s.d(e,{default:function(){return n}});s(8111),s(116);var a=function(){var t=this,e=t._self._c;return e("div",{staticClass:"product-grid-page"},[t.showFilter?e("div",{staticClass:"filter-bar"},[e("el-select",{staticClass:"filter-select",attrs:{placeholder:"全部分类"},on:{change:t.handleCategoryChange},model:{value:t.selectedCategory,callback:function(e){t.selectedCategory=e},expression:"selectedCategory"}},t._l(t.categories,function(t){return e("el-option",{key:t.id,attrs:{label:t.name,value:t.id}})}),1),e("el-select",{staticClass:"filter-select",attrs:{placeholder:"综合排序"},on:{change:t.handleSortChange},model:{value:t.selectedSort,callback:function(e){t.selectedSort=e},expression:"selectedSort"}},[e("el-option",{attrs:{label:"综合排序",value:"default"}}),e("el-option",{attrs:{label:"销量↑",value:"sales_asc"}}),e("el-option",{attrs:{label:"销量↓",value:"sales_desc"}}),e("el-option",{attrs:{label:"价格↑",value:"price_asc"}}),e("el-option",{attrs:{label:"价格↓",value:"price_desc"}})],1)],1):t._e(),"search"==t.type?e("div",{staticClass:"result-stats"},[e("span",[t._v("全部结果 >")]),t.searchKeyword?e("span",{staticClass:"keyword"},[t._v('"'+t._s(t.searchKeyword)+'"')]):t._e(),t.selectedCategory&&t.categories.find(e=>e.value===t.selectedCategory)?e("span",{staticClass:"category"},[t._v(' "'+t._s(t.categories.find(e=>e.value===t.selectedCategory).label)+'" ')]):t._e(),e("span",[t._v("共"+t._s(t.totalProducts)+"个结果")])]):t._e(),e("div",{staticClass:"product-grid"},[t._l(t.visibleProducts,function(s,a){return e("div",{key:a,staticClass:"product-card",on:{click:function(e){return t.goToDetail(s.id)}}},[e("img",{directives:[{name:"lazy",rawName:"v-lazy",value:s.headimg,expression:"product.headimg"}],staticClass:"product-img",attrs:{alt:s.title,fit:"cover"}}),e("div",{staticClass:"product-info"},[e("div",{staticClass:"product-name"},[t._v(t._s(s.title))]),e("div",{staticClass:"price-row"},[e("span",{staticClass:"current-price"},[t._v("¥"+t._s(s.price/100))]),s.market_price?e("span",{staticClass:"original-price"},[t._v("¥"+t._s(s.market_price/100))]):t._e()]),e("div",{staticClass:"sales-volume"},[e("i",{staticClass:"el-icon-shopping-cart"}),t._v(" 已售 "+t._s(s.sales_number)+" ")]),e("el-button",{staticClass:"cart-btn",attrs:{type:"primary",size:"mini"}},[t._v(" 立即购买 ")])],1)])}),0===t.visibleProducts.length?e("div",{staticClass:"empty-state"},[e("el-empty",{attrs:{description:"暂无符合条件的商品"}})],1):t._e()],2),t.totalProducts>0?e("div",{staticClass:"pagination-container"},[e("el-pagination",{attrs:{"current-page":t.currentPage,"page-sizes":[12,24,36],"page-size":t.pageSize,layout:"total, sizes, prev, pager, next, jumper",total:t.totalProducts},on:{"size-change":t.handleSizeChange,"current-change":t.handleCurrentChange}})],1):t._e()])},i=[],r=(s(4114),s(7588),s(1701),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,r.L8)(["getSearchText"]),currentOffset(){return(this.currentPage-1)*this.pageSize}},watch:{getSearchText(t,e){t!==e&&(this.searchKeyword=t,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:this.VUE_APP_GLOBAL_TAGS.side_all},"/api/product/tag_list").then(t=>{this.categories=t.data;let e=[];this.post({pid:this.VUE_APP_GLOBAL_TAGS.pc_all},"/api/product/tag_list").then(t=>{t.data.forEach(t=>e.push(t.id));const s=t.data.map(t=>this.post({pid:t.id},"/api/product/tag_list").then(t=>{t.data.forEach(t=>e.push(t.id))}));Promise.all(s).then(()=>{this.categories[0].id=e.join(",");const t=this.$route.query.id;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()}else this.id=e.join(","),this.fetchProducts()})})})},async fetchProducts(){const t={tag_id:this.id||this.selectedCategory,offset:this.currentOffset,limit:this.pageSize,title:this.searchKeyword,...this.parseSortParams()};this.searchKeyword&&(t.keyword=this.searchKeyword);const e=await this.post(t,"/api/product/get_product_by_tag");this.visibleProducts=e.data.list||[],this.totalProducts=Number(e.data.total)||0},parseSortParams(){if("default"===this.selectedSort)return{};const[t,e]=this.selectedSort.split("_"),s={sales:"sales_number",price:"price"};return{sort:s[t],order:e}},handleCategoryChange(t){this.id=t,this.currentPage=1,this.fetchProducts()},handleSortChange(){this.currentPage=1,this.fetchProducts()},handleSizeChange(t){this.pageSize=t,this.currentPage=1,this.fetchProducts()},handleCurrentChange(t){this.currentPage=t,this.fetchProducts(),window.scrollTo(0,0)},goToDetail(t){this.$router.push(`/Detail/${t}`)}}},o=c,l=s(845),d=(0,l.A)(o,a,i,!1,null,"01008c52",null),n=d.exports}}]);
|
|
//# sourceMappingURL=512.f7e0fd2d.js.map
|