Files
JayuCloud/docs/product/Frontend/assets/HomeView-Da9MIT8W.js
T

2 lines
7.1 KiB
JavaScript
Raw Normal View History

2026-03-21 17:08:36 +08:00
import{c as r,I as K,d as ee,o as se,H as te,b as p,e as s,t as k,f as g,m as H,l as A,s as S,R as j,y as L,z as x,g as oe,r as f,J as ne,K as ae,q as le,B as re,L as ce,T as ie,u as de,j as c,N as ue,O as R,P as pe,Q as fe,G as me}from"./index-bPsB4P3d.js";import{u as ve}from"./user-BRXmSDmz.js";import{p as D}from"./product-wgcUL5oj.js";import{s as _e}from"./shop-DXUqoVUd.js";import{f as ge}from"./file-Out0aTUD.js";import{B as he}from"./BellOutlined-Ct1UTp7O.js";var ye={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M880.1 154H143.9c-24.5 0-39.8 26.7-27.5 48L349 597.4V838c0 17.7 14.2 32 31.8 32h262.4c17.6 0 31.8-14.3 31.8-32V597.4L907.7 202c12.2-21.3-3.1-48-27.6-48zM603.4 798H420.6V642h182.9v156zm9.6-236.6l-9.5 16.6h-183l-9.5-16.6L212.7 226h598.6L613 561.4z"}}]},name:"filter",theme:"outlined"};function q(d){for(var n=1;n<arguments.length;n++){var l=arguments[n]!=null?Object(arguments[n]):{},m=Object.keys(l);typeof Object.getOwnPropertySymbols=="function"&&(m=m.concat(Object.getOwnPropertySymbols(l).filter(function(v){return Object.getOwnPropertyDescriptor(l,v).enumerable}))),m.forEach(function(v){be(d,v,l[v])})}return d}function be(d,n,l){return n in d?Object.defineProperty(d,n,{value:l,enumerable:!0,configurable:!0,writable:!0}):d[n]=l,d}var F=function(n,l){var m=q({},n,l.attrs);return r(K,q({},m,{icon:ye}),null)};F.displayName="FilterOutlined";F.inheritAttrs=!1;const ke={class:"mobile-container"},Ce={class:"header"},Ie={class:"avatar"},we={class:"welcome"},Oe={class:"username"},Be={class:"actions"},Se={class:"search-section"},Pe={class:"banner-container"},Ae={class:"banner-carousel"},ze=["src"],He={class:"banner-content"},Le={class:"section"},xe={class:"section-header"},Fe={class:"horizontal-scroll"},Te={class:"product-info"},Ne={class:"name"},Ve={class:"price"},$e={class:"section popular-section"},Ee={class:"section-header"},Me={class:"product-grid"},Ue={class:"product-info"},je={class:"name"},Re={class:"price"},De={key:0,class:"loading-more"},qe={key:1,class:"no-more"},Ge={key:2,class:"no-products"},Qe=ee({__name:"HomeView",setup(d){const n=de(),l=f({id:0,nickname:"",account:"",avatar:"",type:0,status:0,createTime:"",updateTime:""}),m=f(""),v=f([]),T=f([]),C=f([]),I=f(!1),O=f(!0),N=f(1),B=f(10),G=async()=>{try{const t=await ve.getUserInfo();l.value=t||{}}catch(t){console.error("获取用户信息失败:",t)}},Q=async()=>{try{const t=[],e=await _e.getAllShops();for(const i of e){const h=i;if(h.coverImageFileId){const y=h.coverImageFileId.split(",").filter(w=>w.trim());for(const w of y){const P=parseInt(w);if(!isNaN(P)){const o=ge.getSignedUrl(P).then(b=>b).catch(b=>(console.error("获取店铺banner图签名失败:",b),""));t.push(o)}}}}const u=(await Promise.all(t)).filter(i=>i!=="").map(i=>i.replace(/[`]/g,"").trim()),a=[...new Set(u)];v.value=a.slice(0,10)}catch(t){console.error("获取Banner图片失败:",t)}},J=async()=>{try{const e=await D.getProductsByTag("精选")||[],u=(Array.isArray(e)?e:[]).sort(()=>.5-Math.random());T.value=u.slice(0,5).map(a=>({id:a.id,name:a.name,price:a.price,bgColor:z()}))}catch(t){console.error("获取精选作品失败:",t)}},V=async(t=!1)=>{if(!(I.value||!O.value)){I.value=!0;try{const _=await D.getProductsByTag("热门")||[],u=Array.isArray(_)?_:[];if(t){const a=(N.value-1)*B.value,i=a+B.value,h=u.slice(a,i);h.length<B.value&&(O.value=!1),C.value=[...C.value,...h.map(y=>({id:y.id,name:y.name,price:y.price,bgColor:z()}))]}else C.value=u.slice(0,B.value).map(a=>({id:a.id,name:a.name,price:a.price,bgColor:z()})),u.length<=B.value&&(O.value=!1)}catch(e){console.error("获取热门作品失败:",e)}finally{I.value=!1}}},$=()=>{const t=document.documentElement.scrollTop||document.body.scrollTop,e=document.documentElement.scrollHeight||document.body.scrollHeight,_=document.documentElement.clientHeight;t+_>=e-100&&!I.value&&O.value&&(N.value++,V(!0))};se(()=>{G(),Q(),J(),V(),window.addEventListener("scroll",$)}),te(()=>{window.removeEventListener("scroll",$)});const z=()=>{const t=["#ffe4d6","#d6eaff","#e2ffd6","#fff2d6","#d6ffe4","#e4d6