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.
yanzong/public/assets/pages-category-index.981ce6...

1 lines
14 KiB

import{E as e,$ as t,o as s,c as a,w as l,a as o,b as i,d as n,F as d,e as c,i as r,r as u,f as g,t as h,g as m,h as p,n as _,j as y,k as f,l as C,m as S,p as k,q as v,u as L,s as b,v as x,x as I,y as E,z as T,A as w}from"./index-4ddb689d.js";import{W as P}from"./wxofficial.956096a5.js";import{S as A}from"./index.c375f920.js";import{E as B}from"./index.25c5a396.js";import{_ as N}from"./_plugin-vue_export-helper.1b428a4d.js";import{M as R,_ as $}from"./mescroll-mixins.a7931123.js";import{r as G}from"./uni-app.es.24af5d4f.js";import{h as D}from"./color.813a9497.js";import{S as O}from"./SpecType.cb8615db.js";import{a as V}from"./cart.86d426b5.js";import{s as j,l as H}from"./index.85d62ccb.js";import{G as M}from"./index.0d19d98b.js";const U={onPageScroll(e){this.handlePageScroll(e)},onReachBottom(){this.handleReachBottom()},onPullDownRefresh(){this.handlePullDownRefresh()},data(){return{mescroll:{onPageScroll:e=>{this.handlePageScroll(e)},onReachBottom:()=>{this.handleReachBottom()},onPullDownRefresh:()=>{this.handlePullDownRefresh()}}}},methods:{handlePageScroll(e){let t=this.$refs.mescrollItem;t&&t.mescroll&&t.mescroll.onPageScroll(e)},handleReachBottom(){let e=this.$refs.mescrollItem;e&&e.mescroll&&e.mescroll.onReachBottom()},handlePullDownRefresh(){let e=this.$refs.mescrollItem;e&&e.mescroll&&e.mescroll.onPullDownRefresh()}}},z=new e([{key:"ONE_LEVEL_BIG",name:"一级分类[大图]",value:10},{key:"ONE_LEVEL_SMALL",name:"一级分类[小图]",value:11},{key:"TWO_LEVEL",name:"二级分类",value:20},{key:"COMMODITY",name:"一级分类+商品",value:30}]),W="category/list";let F;const Y=N({components:{Search:A,Primary:N({components:{Empty:B},props:{display:{type:Number,default:10},list:{type:Array,default:[]}},data:()=>({PageCategoryStyleEnum:z}),methods:{onTargetGoodsList(e){this.$navTo("pages/goods/list",{categoryId:e})}}},[["render",function(e,t,p,_,y,f){const C=m,S=r,k=u("empty");return s(),a(S,{class:"primary"},{default:l((()=>[p.list.length>0&&p.display==y.PageCategoryStyleEnum.ONE_LEVEL_BIG.value?(s(),a(S,{key:0,class:"cate-content"},{default:l((()=>[o(S,{class:"cate-wrapper cate_style__10 clearfix"},{default:l((()=>[(s(!0),i(d,null,n(p.list,((e,t)=>(s(),a(S,{class:"cate-item",key:t,onClick:t=>f.onTargetGoodsList(e.category_id)},{default:l((()=>[e.image?(s(),a(C,{key:0,class:"image",mode:"widthFix",src:e.image.preview_url},null,8,["src"])):c("",!0)])),_:2},1032,["onClick"])))),128))])),_:1})])),_:1})):c("",!0),p.list.length>0&&p.display==y.PageCategoryStyleEnum.ONE_LEVEL_SMALL.value?(s(),a(S,{key:1,class:"cate-content"},{default:l((()=>[o(S,{class:"cate-wrapper cate_style__11 clearfix"},{default:l((()=>[(s(!0),i(d,null,n(p.list,((e,t)=>(s(),a(S,{class:"cate-item",key:t,onClick:t=>f.onTargetGoodsList(e.category_id)},{default:l((()=>[e.image?(s(),a(C,{key:0,class:"image",mode:"scaleToFill",src:e.image.preview_url},null,8,["src"])):c("",!0),o(S,{class:"cate-name"},{default:l((()=>[g(h(e.name),1)])),_:2},1024)])),_:2},1032,["onClick"])))),128))])),_:1})])),_:1})):c("",!0),p.list.length?c("",!0):(s(),a(k,{key:2,tips:"亲,暂无商品分类"+p.display},null,8,["tips"]))])),_:1})}],["__scopeId","data-v-784c3793"]]),Secondary:N({components:{Empty:B},props:{list:{type:Array,default:[]}},data:()=>({PageCategoryStyleEnum:z,scrollHeight:0,curIndex:0,scrollTop:0}),created(){this.setListHeight()},methods:{setListHeight(){const{windowHeight:e}=uni.getSystemInfoSync();this.scrollHeight=e-p(96)},handleSelectNav(e){this.curIndex=e,this.scrollTop=0},onTargetGoodsList(e){this.$navTo("pages/goods/list",{categoryId:e})}}},[["render",function(e,t,p,S,k,v){const L=C,b=y,x=m,I=r,E=u("empty");return p.list.length>0?(s(),a(I,{key:0,class:"secondary",style:_(e.appThemeStyle)},{default:l((()=>[o(I,{class:"cate-content"},{default:l((()=>[o(b,{class:"cate-left","scroll-y":!0,style:_({height:`${k.scrollHeight}px`})},{default:l((()=>[(s(!0),i(d,null,n(p.list,((e,t)=>(s(),a(L,{class:f(["type-nav",{selected:k.curIndex==t}]),key:t,onClick:e=>v.handleSelectNav(t)},{default:l((()=>[g(h(e.name),1)])),_:2},1032,["class","onClick"])))),128))])),_:1},8,["style"]),o(b,{class:"cate-right","scroll-top":k.scrollTop,"scroll-y":!0,style:_({height:`${k.scrollHeight}px`})},{default:l((()=>[p.list[k.curIndex]?(s(),a(I,{key:0,class:"cate-right-cont"},{default:l((()=>[o(I,{class:"cate-two-box"},{default:l((()=>[o(I,{class:"cate-cont-box"},{default:l((()=>[(s(!0),i(d,null,n(p.list[k.curIndex].children,((e,t)=>(s(),a(I,{class:"flex-three",key:t,onClick:t=>v.onTargetGoodsList(e.category_id)},{default:l((()=>[o(I,{class:"cate-img-padding"},{default:l((()=>[e.image?(s(),a(I,{key:0,class:"cate-img"},{default:l((()=>[o(x,{class:"image",mode:"scaleToFill",src:e.image.preview_url},null,8,["src"])])),_:2},1024)):c("",!0)])),_:2},1024),o(L,{class:"name oneline-hide"},{default:l((()=>[g(h(e.name),1)])),_:2},1024)])),_:2},1032,["onClick"])))),128))])),_:1})])),_:1})])),_:1})):c("",!0)])),_:1},8,["scroll-top","style"])])),_:1}),p.list.length?c("",!0):(s(),a(E,{key:0}))])),_:1},8,["style"])):c("",!0)}],["__scopeId","data-v-bf2ff15c"]]),Commodity:N({components:{AddCartBtn:N({props:{btnStyle:{type:Number,default:1}},data:()=>({value:!1,goodsInfo:{}}),methods:{handleAddCart(){this.$emit("handleAddCart")}}},[["render",function(e,t,i,n,d,c){const u=C,g=r;return s(),a(g,{class:"add-cart",onClick:S(c.handleAddCart,["stop"])},{default:l((()=>[o(u,{class:f(["icon iconfont",[`icon-jiagou${i.btnStyle}`]])},null,8,["class"])])),_:1},8,["onClick"])}],["__scopeId","data-v-0f678d54"]]),AddCartPopup:N({components:{GoodsSkuPopup:M},props:{btnStyle:{type:Number,default:1}},data:()=>({visible:!1,goods:{},localdata:{}}),computed:{activedBtnBackgroundColor(){return D(this.appTheme.mainBg,.1)}},methods:{async handle(e){this.goods=e,e.spec_type==O.SINGLE.value&&this.singleEvent(),e.spec_type==O.MULTI.value&&this.multiEvent()},singleEvent(){const{goods:e}=this;this.addCart({goods_id:e.goods_id,goods_sku_id:"0",buy_num:1})},async multiEvent(){const e=this,{goods:t}=e,{data:{specData:s}}=await j(t.goods_id);t.skuList=s.skuList,t.specList=s.specList,e.localdata={_id:t.goods_id,name:t.goods_name,goods_thumb:t.goods_image,sku_list:e.getSkuList(),spec_list:e.getSpecList()},this.visible=!0},onChangeValue(e){this.visible=e},getSkuList(){const e=this,{goods:{goods_name:t,goods_image:s,skuList:a}}=e,l=[];return a.forEach((a=>{l.push({_id:a.id,goods_sku_id:a.goods_sku_id,goods_id:a.goods_id,goods_name:t,image:a.image_url?a.image_url:s,price:100*a.goods_price,stock:a.stock_num,spec_value_ids:a.spec_value_ids,sku_name_arr:e.getSkuNameArr(a.spec_value_ids)})})),l},getSkuNameArr(e){const t=this,s=[];return e&&e.forEach(((e,a)=>{const l=t.getSpecValueName(e,a);s.push(l)})),s.length?s:["默认"]},getSpecValueName(e,t){const{goods:{specList:s}}=this;return s[t].valueList.find((t=>t.spec_value_id==e)).spec_value},getSpecList(){const{goods:{specList:e}}=this,t=[];return e.forEach((e=>{const s=[];e.valueList.forEach((e=>{s.push({name:e.spec_value})})),t.push({name:e.spec_name,list:s})})),t.length?t:[{name:"默认",list:[{name:"默认"}]}]},addCart(e){const t=this,{goods_id:s,goods_sku_id:a,buy_num:l}=e;V(s,a,l).then((e=>{t.$toast(e.message,1e3,!1),t.onChangeValue(!1);const s=e.data.cartTotal;k(s),t.$emit("addCart",s)}))}}},[["render",function(e,t,l,o,i,n){const d=u("goods-sku-popup");return s(),a(d,{modelValue:i.visible,onInput:n.onChangeValue,"border-radius":"20",localdata:i.localdata,mode:2,maskCloseAble:!0,priceColor:e.appTheme.mainBg,buyNowBackgroundColor:e.appTheme.mainBg,addCartColor:e.appTheme.viceText,addCartBackgroundColor:e.appTheme.viceBg,activedStyle:{color:e.appTheme.mainBg,borderColor:e.appTheme.mainBg,backgroundColor:n.activedBtnBackgroundColor},onAddCart:n.addCart,buyNowText:"立即购买"},null,8,["modelValue","onInput","localdata","priceColor","buyNowBackgroundColor","addCartColor","addCartBackgroundColor","activedStyle","onAddCart"])}]])},mixins:[R],props:{list:{type:Array,default:[]},setting:{type:Object,default:()=>{}}},data:()=>({PageCategoryStyleEnum:z,scrollHeight:0,curIndex:-1,showSubCate:!1,curIndex2:-1,goodsList:v(),upOption:{auto:!0,page:{size:15},noMoreSize:3,toTop:{right:30,bottom:48,zIndex:9}}}),created(){this.setListHeight()},computed:{subCateList(){return this.list[this.curIndex]&&this.list[this.curIndex].children?this.list[this.curIndex].children:[]}},methods:{upCallback(e){const t=this;t.getGoodsList(e.num).then((e=>{const s=e.data.length,a=e.data.total;t.mescroll.endBySize(s,a)})).catch((()=>t.mescroll.endErr()))},getGoodsList(e=1){const t=this,s=t.getCategoryId();return new Promise(((a,l)=>{H({categoryId:s,page:e},{load:!1}).then((s=>{const l=s.data.list;t.goodsList.data=L(l,t.goodsList,e),t.goodsList.last_page=l.last_page,a(l)})).catch(l)}))},getCategoryId(){const e=this;return e.curIndex2>-1?e.subCateList[e.curIndex2].category_id:e.curIndex>-1?e.list[e.curIndex].category_id:0},setListHeight(){const{windowHeight:e}=uni.getSystemInfoSync();this.scrollHeight=e-p(88)},handleSelectNav(e){this.curIndex=e,this.onRefreshList(),this.showSubCate=!1,this.curIndex2=-1},handleSelectSubCate(e){this.curIndex2=e,this.showSubCate=!1,this.onRefreshList()},onRefreshList(){this.goodsList=v(),setTimeout((()=>this.mescroll.resetUpScroll()),120)},onTargetGoods(e){this.$navTo("pages/goods/detail",{goodsId:e})},handleAddCart(e){this.$refs.AddCartPopup.handle(e)},onUpdateCartTabBadge(){console.log("onUpdateCartTabBadge"),b()},handleShowSubCate(){this.showSubCate=!this.showSubCate}}},[["render",function(e,t,p,k,v,L){const b=C,T=y,w=r,P=m,A=u("add-cart-btn"),B=u("AddCartPopup"),N=G(E("mescroll-body"),$);return s(),a(w,{class:"container",style:_(e.appThemeStyle)},{default:l((()=>[o(T,{class:"cate-left","scroll-y":!0,style:_({height:`${v.scrollHeight}px`}),onTouchmove:t[1]||(t[1]=S((()=>{}),["stop","prevent"]))},{default:l((()=>[o(b,{class:f(["type-nav",{selected:-1==v.curIndex}]),onClick:t[0]||(t[0]=e=>L.handleSelectNav(-1))},{default:l((()=>[g("全部")])),_:1},8,["class"]),(s(!0),i(d,null,n(p.list,((e,t)=>(s(),a(b,{class:f(["type-nav",{selected:v.curIndex==t}]),key:t,onClick:e=>L.handleSelectNav(t)},{default:l((()=>[g(h(e.name),1)])),_:2},1032,["class","onClick"])))),128))])),_:1},8,["style"]),o(N,{ref:"mescrollRef",sticky:!0,onInit:e.mescrollInit,down:{use:!1},up:v.upOption,bottombar:!1,onUp:L.upCallback},{default:l((()=>[o(w,{class:"cate-content"},{default:l((()=>[L.subCateList.length?(s(),a(w,{key:0,class:f(["sub-cate-list clearfix",{"display-fold":!v.showSubCate}]),onTouchmove:t[3]||(t[3]=S((()=>{}),["stop","prevent"]))},{default:l((()=>[o(w,{class:"nav-icon",onClick:L.handleShowSubCate},{default:l((()=>[o(b,{class:f(["iconfont",[v.showSubCate?"icon-arrow-up":"icon-arrow-down"]])},null,8,["class"])])),_:1},8,["onClick"]),o(w,{class:f(["sub-cate-item",{selected:-1==v.curIndex2}]),onClick:t[2]||(t[2]=e=>L.handleSelectSubCate(-1))},{default:l((()=>[o(b,null,{default:l((()=>[g("全部")])),_:1})])),_:1},8,["class"]),(s(!0),i(d,null,n(L.subCateList,((e,t)=>(s(),a(w,{class:f(["sub-cate-item",{selected:v.curIndex2==t}]),key:t,onClick:e=>L.handleSelectSubCate(t)},{default:l((()=>[o(b,null,{default:l((()=>[g(h(e.name),1)])),_:2},1024)])),_:2},1032,["class","onClick"])))),128))])),_:1},8,["class"])):c("",!0),o(w,{class:"goods-list"},{default:l((()=>[(s(!0),i(d,null,n(v.goodsList.data,((e,t)=>(s(),a(w,{class:"goods-item--container",key:t},{default:l((()=>[o(w,{class:"goods-item",onClick:t=>L.onTargetGoods(e.goods_id)},{default:l((()=>[o(w,{class:"goods-item-left"},{default:l((()=>[o(P,{class:"image",src:e.goods_image},null,8,["src"])])),_:2},1024),o(w,{class:"goods-item-right"},{default:l((()=>[o(w,{class:"goods-name"},{default:l((()=>[o(b,{class:"twoline-hide"},{default:l((()=>[g(h(e.goods_name),1)])),_:2},1024)])),_:2},1024),o(w,{class:"goods-item-desc"},{default:l((()=>[o(w,{class:"desc-footer"},{default:l((()=>[o(w,{class:"item-prices oneline-hide"},{default:l((()=>[o(b,{class:"price-x"},{default:l((()=>[g("¥"+h(e.goods_price_min),1)])),_:2},1024),e.line_price_min>0?(s(),a(b,{key:0,class:"price-y"},{default:l((()=>[g("¥"+h(e.line_price_min),1)])),_:2},1024)):c("",!0)])),_:2},1024),p.setting.showAddCart?(s(),a(A,{key:0,btnStyle:p.setting.cartStyle,onHandleAddCart:t=>L.handleAddCart(e)},null,8,["btnStyle","onHandleAddCart"])):c("",!0)])),_:2},1024)])),_:2},1024)])),_:2},1024)])),_:2},1032,["onClick"])])),_:2},1024)))),128))])),_:1}),x(o(w,{class:"mask",onTouchmove:t[4]||(t[4]=S((()=>{}),["stop","prevent"])),onClick:L.handleShowSubCate},null,8,["onClick"]),[[I,v.showSubCate]]),o(B,{ref:"AddCartPopup",onAddCart:L.onUpdateCartTabBadge},null,8,["onAddCart"])])),_:1})])),_:1},8,["onInit","up","onUp"])])),_:1},8,["style"])}],["__scopeId","data-v-9e6882bd"]])},mixins:[U,P],data:()=>({PageCategoryStyleEnum:z,list:[],setting:{},isLoading:!0}),onLoad(){this.onRefreshPage()},onShow(){(new Date).getTime()-F>3e5&&this.onRefreshPage()},methods:{onRefreshPage(){F=(new Date).getTime(),this.getPageData(),b()},getPageData(){const e=this;e.isLoading=!0,Promise.all([T.data(!1),t.get(W)]).then((t=>{e.initSetting(t[0]),e.initCategory(t[1]),e.setWxofficialShareData()})).finally((()=>e.isLoading=!1))},initSetting(e){this.setting=e[w.PAGE_CATEGORY_TEMPLATE.value]},initCategory(e){this.list=e.data.list},setWxofficialShareData(){const{setting:e}=this;this.updateShareCardData({title:e.shareTitle})}},onShareAppMessage(){return{title:_this.templet.shareTitle,path:"/pages/category/index?"+this.$getShareUrlParams()}},onShareTimeline(){return{title:_this.templet.shareTitle,path:"/pages/category/index?"+this.$getShareUrlParams()}}},[["render",function(e,t,i,n,d,g){const h=u("search"),m=r,p=u("primary"),_=u("secondary"),y=u("commodity");return s(),a(m,{class:"container"},{default:l((()=>[o(m,{class:"search"},{default:l((()=>[o(h,{tips:"搜索商品",onEvent:t[0]||(t[0]=t=>e.$navTo("pages/search/index"))})])),_:1}),d.setting.style==d.PageCategoryStyleEnum.ONE_LEVEL_BIG.value||d.setting.style==d.PageCategoryStyleEnum.ONE_LEVEL_SMALL.value?(s(),a(p,{key:0,display:d.setting.style,list:d.list},null,8,["display","list"])):c("",!0),d.setting.style==d.PageCategoryStyleEnum.TWO_LEVEL.value?(s(),a(_,{key:1,list:d.list},null,8,["list"])):c("",!0),d.setting.style==d.PageCategoryStyleEnum.COMMODITY.value?(s(),a(y,{key:2,ref:"mescrollItem",list:d.list,setting:d.setting},null,8,["list","setting"])):c("",!0)])),_:1})}],["__scopeId","data-v-a2e4a355"]]);export{Y as default};