重构项目文件夹目录
This commit is contained in:
@@ -0,0 +1,469 @@
|
||||
/**
|
||||
* Purpose: auth supports index.js by holding or executing the auth page or API role.
|
||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
const auth = require('../../utils/auth')
|
||||
/**
|
||||
* Purpose: navigation supports index.js by holding or executing the navigation page or API role.
|
||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
const navigation = require('../../utils/navigation')
|
||||
/**
|
||||
* Purpose: cache supports index.js by holding or executing the cache page or API role.
|
||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
const cache = require('../../utils/cache')
|
||||
const { buildProductCards } = require('../../utils/product')
|
||||
const { resolveImageList } = require('../../utils/file')
|
||||
const { DEFAULT_SHOP_IMAGE, CACHE_TTL } = require('../../utils/config')
|
||||
const {
|
||||
createKeyboardSafeData,
|
||||
attachKeyboardSafe,
|
||||
detachKeyboardSafe,
|
||||
handleKeyboardFocus,
|
||||
handleKeyboardBlur,
|
||||
resetKeyboardSafe
|
||||
} = require('../../utils/keyboard-safe')
|
||||
/**
|
||||
* Purpose: productApi supports index.js by holding or executing the product api page or API role.
|
||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
const productApi = require('../../api/product')
|
||||
/**
|
||||
* Purpose: shopApi supports index.js by holding or executing the shop api page or API role.
|
||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
const shopApi = require('../../api/shop')
|
||||
/**
|
||||
* Purpose: userApi supports index.js by holding or executing the user api page or API role.
|
||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
const userApi = require('../../api/user')
|
||||
/**
|
||||
* Purpose: theme supports index.js by holding or executing the theme page or API role.
|
||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
const theme = require('../../utils/theme')
|
||||
|
||||
/**
|
||||
* home page logic.
|
||||
* Call guide: page data drives the WXML template, and each method is called by user events or lifecycle callbacks.
|
||||
*/
|
||||
Page({
|
||||
data: Object.assign(createKeyboardSafeData({
|
||||
cursorSpacing: 96
|
||||
}), theme.pageThemeData(getApp().globalData.shopTheme), {
|
||||
initialized: false,
|
||||
loading: false,
|
||||
loadingMore: false,
|
||||
isLoggedIn: false,
|
||||
userInfo: null,
|
||||
navTitle: '游客模式',
|
||||
greeting: '欢迎来到 Fingertip Designer 指尖设计师',
|
||||
displayName: '先看看门店和作品',
|
||||
searchKeyword: '',
|
||||
bannerImages: [],
|
||||
featuredItems: [],
|
||||
popularItems: [],
|
||||
announcements: [],
|
||||
popularPage: 1,
|
||||
pageSize: 6,
|
||||
hasMore: false,
|
||||
popularTotal: 0
|
||||
}),
|
||||
|
||||
/**
|
||||
* `onLoad` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
onLoad() {
|
||||
this.homeRequestId = 0
|
||||
this.ensureKeyboardSafe()
|
||||
this.loadHomeData()
|
||||
},
|
||||
|
||||
/**
|
||||
* `onShow` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
onShow() {
|
||||
this.ensureKeyboardSafe()
|
||||
this.syncUserState()
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (this.data.initialized && this.data.isLoggedIn) {
|
||||
this.loadUserProfile()
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* `onHide` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
onHide() {
|
||||
resetKeyboardSafe(this)
|
||||
detachKeyboardSafe(this)
|
||||
},
|
||||
|
||||
/**
|
||||
* `onUnload` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
onUnload() {
|
||||
resetKeyboardSafe(this)
|
||||
detachKeyboardSafe(this)
|
||||
},
|
||||
|
||||
async onPullDownRefresh() {
|
||||
cache.removeByPrefix('home:')
|
||||
await this.loadHomeData()
|
||||
wx.stopPullDownRefresh()
|
||||
},
|
||||
|
||||
/**
|
||||
* `onReachBottom` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
onReachBottom() {
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (!this.data.hasMore || this.data.loadingMore) {
|
||||
return
|
||||
}
|
||||
this.loadPopularProducts(false)
|
||||
},
|
||||
|
||||
/**
|
||||
* `ensureKeyboardSafe` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
ensureKeyboardSafe() {
|
||||
attachKeyboardSafe(this, {
|
||||
cursorSpacing: 96,
|
||||
spacerExtraRpx: 24
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* `syncUserState` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
syncUserState() {
|
||||
const app = getApp()
|
||||
const userInfo = auth.getStoredUserInfo()
|
||||
const isLoggedIn = auth.isLoggedIn()
|
||||
const navTitle = userInfo && String(userInfo.shopName || '').trim()
|
||||
? String(userInfo.shopName).trim()
|
||||
: '游客模式'
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (app) {
|
||||
app.globalData.userInfo = userInfo
|
||||
app.globalData.isLoggedIn = isLoggedIn
|
||||
}
|
||||
|
||||
this.setData({
|
||||
isLoggedIn,
|
||||
userInfo,
|
||||
navTitle,
|
||||
greeting: isLoggedIn ? '欢迎回来' : '游客模式',
|
||||
displayName: isLoggedIn
|
||||
? ((userInfo && userInfo.nickname) || 'Yumi 用户')
|
||||
: '先逛逛喜欢的款式和门店',
|
||||
bannerImages: isLoggedIn ? [] : this.data.bannerImages
|
||||
})
|
||||
},
|
||||
|
||||
async loadUserProfile() {
|
||||
if (!auth.isLoggedIn()) {
|
||||
this.syncUserState()
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
const userInfo = await userApi.getUserInfo()
|
||||
getApp().refreshUserInfo(userInfo)
|
||||
this.syncUserState()
|
||||
} catch (error) {}
|
||||
},
|
||||
|
||||
async loadAnnouncements() {
|
||||
if (!auth.isLoggedIn()) {
|
||||
this.setData({ announcements: [] })
|
||||
return
|
||||
}
|
||||
try {
|
||||
const list = await userApi.listMyAnnouncements()
|
||||
this.setData({
|
||||
announcements: Array.isArray(list) ? list.map(item => ({
|
||||
...item,
|
||||
displayText: `${item.publisherName || '平台'}:${item.content || ''}`
|
||||
})) : []
|
||||
})
|
||||
} catch (error) {
|
||||
this.setData({ announcements: [] })
|
||||
}
|
||||
},
|
||||
|
||||
async loadHomeData() {
|
||||
const requestId = ++this.homeRequestId
|
||||
this.setData({ loading: true })
|
||||
this.syncUserState()
|
||||
|
||||
try {
|
||||
const loggedIn = auth.isLoggedIn()
|
||||
await Promise.all([
|
||||
this.loadUserProfile(),
|
||||
this.loadAnnouncements(),
|
||||
loggedIn ? Promise.resolve() : this.loadBannerImages(requestId),
|
||||
this.loadFeaturedProducts(requestId),
|
||||
this.loadPopularProducts(true, requestId)
|
||||
])
|
||||
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (requestId === this.homeRequestId) {
|
||||
this.setData({
|
||||
initialized: true
|
||||
})
|
||||
}
|
||||
} catch (error) {
|
||||
wx.showToast({
|
||||
title: error.message || '首页加载失败',
|
||||
icon: 'none'
|
||||
})
|
||||
} finally {
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (requestId === this.homeRequestId) {
|
||||
this.setData({ loading: false })
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
async loadBannerImages(requestId) {
|
||||
const banners = await cache.remember('home:banners', CACHE_TTL.banner, async () => {
|
||||
const shops = await shopApi.getPublicShops()
|
||||
const list = Array.isArray(shops) ? shops : []
|
||||
const resolved = await Promise.all(list.slice(0, 6).map(async (shop, index) => {
|
||||
const imageIds = shop.coverImageFileId || shop.imageFileIds
|
||||
const urls = await resolveImageList(imageIds, DEFAULT_SHOP_IMAGE)
|
||||
return {
|
||||
id: `${shop.id}-${index}`,
|
||||
shopId: shop.id,
|
||||
shopName: shop.shopName,
|
||||
businessHours: shop.businessHours || '欢迎到店体验',
|
||||
imageUrl: urls[0]
|
||||
}
|
||||
}))
|
||||
return resolved.filter(item => item.imageUrl)
|
||||
})
|
||||
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (requestId === this.homeRequestId) {
|
||||
this.setData({
|
||||
bannerImages: Array.isArray(banners) ? banners : []
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
async loadFeaturedProducts(requestId) {
|
||||
const items = await cache.remember('home:featured', CACHE_TTL.homeList, async () => {
|
||||
const result = await productApi.getProductPage({
|
||||
page: 1,
|
||||
size: 6,
|
||||
tag: '精选'
|
||||
})
|
||||
return buildProductCards(result && result.list ? result.list : [])
|
||||
})
|
||||
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (requestId === this.homeRequestId) {
|
||||
this.setData({
|
||||
featuredItems: Array.isArray(items) ? items : []
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
async loadPopularProducts(reset, requestId) {
|
||||
const currentRequestId = requestId || this.homeRequestId
|
||||
const nextPage = reset ? 1 : this.data.popularPage + 1
|
||||
const loadingState = reset ? { loading: true } : { loadingMore: true }
|
||||
this.setData(loadingState)
|
||||
|
||||
try {
|
||||
const result = await productApi.getProductPage({
|
||||
page: nextPage,
|
||||
size: this.data.pageSize,
|
||||
tag: '热门'
|
||||
})
|
||||
const cards = await buildProductCards(result && result.list ? result.list : [])
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (currentRequestId !== this.homeRequestId) {
|
||||
return
|
||||
}
|
||||
const mergedItems = reset ? cards : this.data.popularItems.concat(cards)
|
||||
const total = Number(result && result.total) || 0
|
||||
this.setData({
|
||||
popularItems: mergedItems,
|
||||
popularPage: nextPage,
|
||||
popularTotal: total,
|
||||
hasMore: mergedItems.length < total
|
||||
})
|
||||
} catch (error) {
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (currentRequestId !== this.homeRequestId) {
|
||||
return
|
||||
}
|
||||
wx.showToast({
|
||||
title: error.message || '热门作品加载失败',
|
||||
icon: 'none'
|
||||
})
|
||||
} finally {
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (currentRequestId === this.homeRequestId) {
|
||||
this.setData({
|
||||
loadingMore: false
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* `handleSearchInput` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
handleSearchInput(event) {
|
||||
this.setData({
|
||||
searchKeyword: event.detail.value
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* `handleSearchFocus` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
handleSearchFocus(event) {
|
||||
handleKeyboardFocus(this, event)
|
||||
},
|
||||
|
||||
/**
|
||||
* `handleSearchBlur` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
handleSearchBlur() {
|
||||
handleKeyboardBlur(this)
|
||||
},
|
||||
|
||||
/**
|
||||
* `handleSearchConfirm` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
handleSearchConfirm() {
|
||||
resetKeyboardSafe(this)
|
||||
navigation.openProducts({
|
||||
keyword: this.data.searchKeyword.trim()
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* `handleBannerTap` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
handleBannerTap(event) {
|
||||
const shopId = event.currentTarget.dataset.shopId
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (!shopId) {
|
||||
return
|
||||
}
|
||||
|
||||
navigation.navigate('/pages/shop-detail/index', {
|
||||
id: shopId,
|
||||
returnTo: navigation.getCurrentPageUrl()
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* `handleProfileTap` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
handleProfileTap() {
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (this.data.isLoggedIn) {
|
||||
navigation.switchTab('/pages/profile/index')
|
||||
return
|
||||
}
|
||||
|
||||
navigation.openAuth()
|
||||
},
|
||||
|
||||
/**
|
||||
* `handleProductSelect` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
handleProductSelect(event) {
|
||||
const product = event.detail || {}
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (!product.id) {
|
||||
return
|
||||
}
|
||||
|
||||
navigation.navigate('/pages/product-detail/index', {
|
||||
id: product.id
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* `handleSeeAllFeatured` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
handleSeeAllFeatured() {
|
||||
navigation.openProducts({
|
||||
tag: '精选'
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* `handleSeeAllPopular` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
handleSeeAllPopular() {
|
||||
navigation.openProducts({
|
||||
tag: '热门'
|
||||
})
|
||||
}
|
||||
})
|
||||
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"usingComponents": {
|
||||
"navigation-bar": "/components/navigation-bar/navigation-bar",
|
||||
"product-card": "/components/product-card/product-card"
|
||||
},
|
||||
"enablePullDownRefresh": true
|
||||
}
|
||||
@@ -0,0 +1,152 @@
|
||||
<view class="home-page-root yumi-page" style="{{themeVars}}">
|
||||
<navigation-bar title="{{navTitle}}" showBack="{{false}}" isTabPage="{{true}}" color="{{navThemeColor || '#4A443F'}}" background="{{navThemeBackground || '#FDFBF9'}}"></navigation-bar>
|
||||
|
||||
<view class="home-scroll">
|
||||
<view class="page-shell home-page {{keyboardVisible ? 'keyboard-active' : ''}}">
|
||||
<view class="page-content">
|
||||
<view class="page-hero home-hero">
|
||||
<text class="hero-kicker">{{isLoggedIn ? greeting : 'YUMI NAIL 小程序'}}</text>
|
||||
<text class="hero-title">{{displayName}}</text>
|
||||
<text class="hero-desc">先选喜欢的作品。</text>
|
||||
|
||||
<view class="hero-action-row">
|
||||
<view class="hero-action primary" bindtap="handleProfileTap">{{isLoggedIn ? '进入个人中心' : '立即登录'}}</view>
|
||||
<view class="hero-action secondary" bindtap="handleSeeAllPopular">看看热门作品</view>
|
||||
</view>
|
||||
|
||||
<view id="home-search-anchor" class="search-box">
|
||||
<input
|
||||
class="search-input"
|
||||
placeholder="搜索作品、风格或门店"
|
||||
placeholder-class="field-placeholder"
|
||||
value="{{searchKeyword}}"
|
||||
bindinput="handleSearchInput"
|
||||
bindconfirm="handleSearchConfirm"
|
||||
bindfocus="handleSearchFocus"
|
||||
bindblur="handleSearchBlur"
|
||||
data-keyboard-anchor="home-search-anchor"
|
||||
adjust-position="false"
|
||||
cursor-spacing="{{keyboardCursorSpacing}}"
|
||||
confirm-type="search"
|
||||
/>
|
||||
<view class="search-btn" bindtap="handleSearchConfirm">搜索</view>
|
||||
</view>
|
||||
|
||||
<swiper wx:if="{{announcements.length}}" class="announcement-strip" autoplay circular vertical interval="2600">
|
||||
<swiper-item wx:for="{{announcements}}" wx:key="id">
|
||||
<view class="announcement-item">{{item.displayText}}</view>
|
||||
</swiper-item>
|
||||
</swiper>
|
||||
|
||||
<view class="summary-strip">
|
||||
<view wx:if="{{!isLoggedIn}}" class="summary-metric">
|
||||
<text class="summary-label">门店橱窗</text>
|
||||
<text class="summary-value">{{bannerImages.length ? bannerImages.length : 0}} 家</text>
|
||||
<text class="summary-note">看环境</text>
|
||||
</view>
|
||||
<view class="summary-metric">
|
||||
<text class="summary-label">精选作品</text>
|
||||
<text class="summary-value">{{featuredItems.length ? featuredItems.length : 0}} 款</text>
|
||||
<text class="summary-note">找灵感</text>
|
||||
</view>
|
||||
<view class="summary-metric">
|
||||
<text class="summary-label">热门推荐</text>
|
||||
<text class="summary-value">{{popularItems.length ? popularItems.length : 0}} 条</text>
|
||||
<text class="summary-note">热门款</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view wx:if="{{!isLoggedIn}}" class="guest-tip">
|
||||
登录后可同步收藏和预约记录。
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view wx:if="{{!isLoggedIn}}" class="section-block">
|
||||
<view class="section-head">
|
||||
<view class="section-copy">
|
||||
<text class="section-kicker">门店氛围</text>
|
||||
<text class="section-title">先看看线下环境</text>
|
||||
<text class="section-subtitle">看店铺环境</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view wx:if="{{bannerImages.length}}" class="banner-box page-card yumi-glass-card">
|
||||
<swiper class="banner-swiper" indicator-dots autoplay circular interval="3200">
|
||||
<swiper-item wx:for="{{bannerImages}}" wx:key="id">
|
||||
<view class="banner-item" data-shop-id="{{item.shopId}}" bindtap="handleBannerTap">
|
||||
<image class="banner-image" src="{{item.imageUrl}}" mode="aspectFill" lazy-load="{{true}}"></image>
|
||||
<view class="banner-mask">
|
||||
<view class="banner-badge">门店实拍</view>
|
||||
<view class="banner-title">{{item.shopName}}</view>
|
||||
<view class="banner-desc">{{item.businessHours}}</view>
|
||||
</view>
|
||||
</view>
|
||||
</swiper-item>
|
||||
</swiper>
|
||||
</view>
|
||||
|
||||
<view wx:else class="page-card yumi-glass-card empty-card">
|
||||
<text class="empty-title">门店内容正在补充中</text>
|
||||
<text class="empty-desc">先看看作品。</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="section-block">
|
||||
<view class="section-head">
|
||||
<view class="section-copy">
|
||||
<text class="section-kicker">快速入门</text>
|
||||
<text class="section-title">精选作品</text>
|
||||
<text class="section-subtitle">先看热门款</text>
|
||||
</view>
|
||||
<view class="section-link" bindtap="handleSeeAllFeatured">查看全部</view>
|
||||
</view>
|
||||
|
||||
<view wx:if="{{featuredItems.length}}" class="featured-panel">
|
||||
<scroll-view class="featured-scroll" scroll-x enable-flex>
|
||||
<view class="featured-list">
|
||||
<view wx:for="{{featuredItems}}" wx:key="id" class="featured-card">
|
||||
<product-card item="{{item}}" bindselect="handleProductSelect"></product-card>
|
||||
</view>
|
||||
</view>
|
||||
</scroll-view>
|
||||
</view>
|
||||
|
||||
<view wx:else class="page-card yumi-glass-card empty-card">
|
||||
<text class="empty-title">精选作品正在整理中</text>
|
||||
<text class="empty-desc">稍后再来看看。</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="section-block">
|
||||
<view class="section-head">
|
||||
<view class="section-copy">
|
||||
<text class="section-kicker">热门预约</text>
|
||||
<text class="section-title">最近大家都在看</text>
|
||||
<text class="section-subtitle">热门款式</text>
|
||||
</view>
|
||||
<view class="section-link" bindtap="handleSeeAllPopular">查看全部</view>
|
||||
</view>
|
||||
|
||||
<view wx:if="{{popularItems.length}}" class="popular-grid">
|
||||
<view wx:for="{{popularItems}}" wx:key="id" class="popular-card">
|
||||
<product-card item="{{item}}" show-stats="{{true}}" bindselect="handleProductSelect"></product-card>
|
||||
</view>
|
||||
</view>
|
||||
<view wx:if="{{popularItems.length && (loadingMore || !hasMore)}}" class="section-load-state">
|
||||
<text class="section-load-text">{{loadingMore ? '正在加载更多热门作品...' : '已经到底了'}}</text>
|
||||
</view>
|
||||
|
||||
<view wx:elif="{{loading}}" class="page-card yumi-glass-card empty-card">
|
||||
<text class="empty-title">正在加载首页内容</text>
|
||||
</view>
|
||||
|
||||
<view wx:else class="page-card yumi-glass-card empty-card">
|
||||
<text class="empty-title">还没有热门作品</text>
|
||||
<text class="empty-desc">稍后再来看看。</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view wx:if="{{keyboardVisible}}" class="keyboard-light-spacer" style="height: {{keyboardInsetRpx}}rpx;"></view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
@@ -0,0 +1,218 @@
|
||||
.home-page-root {
|
||||
min-height: 100vh;
|
||||
padding: 0;
|
||||
color: var(--text-primary);
|
||||
background: var(--theme-page-bg);
|
||||
}
|
||||
|
||||
.home-scroll {
|
||||
min-height: 100%;
|
||||
}
|
||||
|
||||
.home-page {
|
||||
min-height: 100%;
|
||||
background: var(--theme-page-bg);
|
||||
}
|
||||
|
||||
.home-page.keyboard-active {
|
||||
padding-bottom: 0;
|
||||
}
|
||||
|
||||
.home-hero {
|
||||
background: var(--theme-gradient-soft);
|
||||
box-shadow: 0 28rpx 64rpx rgba(74, 68, 63, 0.1);
|
||||
}
|
||||
|
||||
.home-hero .hero-kicker,
|
||||
.section-kicker {
|
||||
color: var(--theme-secondary);
|
||||
}
|
||||
|
||||
.home-hero .hero-title,
|
||||
.section-title,
|
||||
.summary-value,
|
||||
.empty-title {
|
||||
color: var(--text-primary);
|
||||
}
|
||||
|
||||
.home-hero .hero-desc,
|
||||
.section-subtitle,
|
||||
.summary-label,
|
||||
.summary-note,
|
||||
.empty-desc,
|
||||
.field-placeholder {
|
||||
color: var(--text-secondary);
|
||||
}
|
||||
|
||||
.home-hero .hero-action.secondary {
|
||||
border: 1rpx solid var(--theme-border);
|
||||
background: rgba(255, 255, 255, 0.9);
|
||||
color: var(--theme-primary-action);
|
||||
}
|
||||
|
||||
.search-box {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 16rpx;
|
||||
margin-top: 30rpx;
|
||||
padding: 10rpx;
|
||||
border: 1rpx solid var(--theme-border);
|
||||
border-radius: 999rpx;
|
||||
background: rgba(255, 255, 255, 0.92);
|
||||
box-shadow: 0 18rpx 42rpx rgba(74, 68, 63, 0.08);
|
||||
}
|
||||
|
||||
.search-input {
|
||||
flex: 1;
|
||||
height: 72rpx;
|
||||
padding: 0 24rpx;
|
||||
font-size: 28rpx;
|
||||
color: var(--text-primary);
|
||||
}
|
||||
|
||||
.search-btn {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
min-width: 150rpx;
|
||||
height: 72rpx;
|
||||
border-radius: 999rpx;
|
||||
background: var(--theme-gradient);
|
||||
color: #ffffff;
|
||||
font-size: 26rpx;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.guest-tip {
|
||||
margin-top: 24rpx;
|
||||
padding: 20rpx 24rpx;
|
||||
border-radius: 22rpx;
|
||||
background: rgba(255, 255, 255, 0.86);
|
||||
border: 1rpx solid var(--theme-border);
|
||||
color: var(--text-secondary);
|
||||
font-size: 24rpx;
|
||||
line-height: 1.7;
|
||||
}
|
||||
|
||||
.banner-box {
|
||||
overflow: hidden;
|
||||
border-radius: 34rpx;
|
||||
}
|
||||
|
||||
.banner-swiper,
|
||||
.banner-item {
|
||||
width: 100%;
|
||||
height: 396rpx;
|
||||
}
|
||||
|
||||
.banner-item {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.banner-image {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.banner-mask {
|
||||
position: absolute;
|
||||
left: 24rpx;
|
||||
right: 24rpx;
|
||||
bottom: 24rpx;
|
||||
padding: 22rpx 24rpx;
|
||||
border-radius: 24rpx;
|
||||
border: 1rpx solid rgba(255, 255, 255, 0.92);
|
||||
background: rgba(255, 255, 255, 0.9);
|
||||
box-shadow: 0 18rpx 42rpx rgba(74, 68, 63, 0.1);
|
||||
}
|
||||
|
||||
.announcement-strip {
|
||||
height: 58rpx;
|
||||
margin-top: 18rpx;
|
||||
border-radius: 16rpx;
|
||||
background: var(--theme-primary-soft);
|
||||
border: 1rpx solid var(--theme-border);
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.announcement-item {
|
||||
height: 58rpx;
|
||||
line-height: 58rpx;
|
||||
padding: 0 22rpx;
|
||||
font-size: 24rpx;
|
||||
color: var(--theme-neutral);
|
||||
overflow: hidden;
|
||||
white-space: nowrap;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
.banner-badge {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 8rpx 18rpx;
|
||||
border-radius: 999rpx;
|
||||
background: var(--theme-primary-soft);
|
||||
color: var(--theme-primary);
|
||||
font-size: 22rpx;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.banner-title {
|
||||
margin-top: 14rpx;
|
||||
font-size: 34rpx;
|
||||
font-weight: 700;
|
||||
color: var(--text-primary);
|
||||
}
|
||||
|
||||
.banner-desc {
|
||||
margin-top: 8rpx;
|
||||
font-size: 24rpx;
|
||||
color: var(--text-secondary);
|
||||
}
|
||||
|
||||
.featured-panel {
|
||||
padding: 2rpx 0 4rpx;
|
||||
}
|
||||
|
||||
.featured-scroll {
|
||||
width: 100%;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.featured-list {
|
||||
display: inline-flex;
|
||||
gap: 18rpx;
|
||||
padding: 4rpx 2rpx 12rpx;
|
||||
}
|
||||
|
||||
.featured-card {
|
||||
width: 332rpx;
|
||||
}
|
||||
|
||||
.popular-grid {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 18rpx;
|
||||
padding-top: 2rpx;
|
||||
}
|
||||
|
||||
.popular-card {
|
||||
width: calc(50% - 9rpx);
|
||||
}
|
||||
|
||||
.section-load-state {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
padding-top: 18rpx;
|
||||
}
|
||||
|
||||
.section-load-text {
|
||||
font-size: 22rpx;
|
||||
color: var(--text-secondary);
|
||||
}
|
||||
|
||||
.keyboard-light-spacer {
|
||||
width: 100%;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
Reference in New Issue
Block a user