重构项目文件夹目录

This commit is contained in:
2026-06-15 15:53:55 +08:00
parent 8093e07190
commit 7cbe5b3de5
1098 changed files with 34 additions and 4441 deletions
@@ -0,0 +1,182 @@
/**
* Purpose: navigation supports navigation-bar.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')
Component({
options: {
multipleSlots: true,
},
properties: {
extClass: {
type: String,
value: '',
},
title: {
type: String,
value: '',
},
background: {
type: String,
value: '',
},
color: {
type: String,
value: '',
},
back: {
type: Boolean,
value: true,
},
showBack: {
type: Boolean,
value: true,
},
isTabPage: {
type: Boolean,
value: false,
},
fallbackPath: {
type: String,
value: '/pages/home/index',
},
loading: {
type: Boolean,
value: false,
},
homeButton: {
type: Boolean,
value: false,
},
animated: {
type: Boolean,
value: true,
},
show: {
type: Boolean,
value: true,
observer(show) {
this._showChange(show)
},
},
delta: {
type: Number,
value: 1,
},
safeAreaMode: {
type: String,
value: 'solid',
},
},
observers: {
'back, showBack, isTabPage': function () {
this.updateResolvedBack()
},
},
/**
* Purpose: data supports navigation-bar.js by holding or executing the data page or API role.
* Usage: import, call, read, or update this page-data from the owning page/module while preserving the surrounding loading and permission flow.
*/
data: {
/**
* Purpose: displayStyle supports navigation-bar.js by holding or executing the display style page or API role.
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
*/
displayStyle: '',
/**
* Purpose: resolvedShowBack supports navigation-bar.js by holding or executing the resolved show back page or API role.
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
*/
resolvedShowBack: false,
},
/**
* Purpose: lifetimes supports navigation-bar.js by holding or executing the lifetimes page or API role.
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
*/
lifetimes: {
attached() {
const rect = wx.getMenuButtonBoundingClientRect()
const deviceInfo = (typeof wx.getDeviceInfo === 'function' ? wx.getDeviceInfo() : wx.getSystemInfoSync()) || {}
const windowInfo = (typeof wx.getWindowInfo === 'function' ? wx.getWindowInfo() : wx.getSystemInfoSync()) || {}
const platform = deviceInfo.platform
const isAndroid = platform === 'android'
const isDevtools = platform === 'devtools'
const safeArea = windowInfo.safeArea || {}
const top = safeArea.top || 0
const windowWidth = windowInfo.windowWidth || deviceInfo.windowWidth || 375
this.setData({
/**
* Purpose: ios supports navigation-bar.js by holding or executing the ios page or API role.
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
*/
ios: !isAndroid,
/**
* Purpose: innerPaddingRight supports navigation-bar.js by holding or executing the inner padding right page or API role.
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
*/
innerPaddingRight: `padding-right: ${windowWidth - rect.left}px`,
/**
* Purpose: leftWidth supports navigation-bar.js by holding or executing the left width page or API role.
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
*/
leftWidth: `width: ${windowWidth - rect.left}px`,
/**
* Purpose: safeAreaTop supports navigation-bar.js by holding or executing the safe area top page or API role.
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
*/
safeAreaTop: isDevtools || isAndroid ? `height: calc(var(--height) + ${top}px); padding-top: ${top}px` : '',
})
this.updateResolvedBack()
},
},
/**
* Purpose: methods supports navigation-bar.js by holding or executing the methods page or API role.
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
*/
methods: {
updateResolvedBack() {
const resolvedShowBack = !this.data.isTabPage && Boolean(this.data.showBack && this.data.back)
this.setData({
resolvedShowBack,
})
},
_showChange(show) {
const animated = this.data.animated
let displayStyle = ''
if (animated) {
displayStyle = `opacity: ${show ? '1' : '0'};transition:opacity 0.3s;`
} else {
displayStyle = `display: ${show ? '' : 'none'}`
}
this.setData({
displayStyle,
})
},
back() {
const pages = getCurrentPages()
if (this.data.delta && pages.length > this.data.delta) {
wx.navigateBack({
/**
* Purpose: delta supports navigation-bar.js by holding or executing the delta page or API role.
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
*/
delta: this.data.delta,
})
return
}
navigation.goBack(this.data.fallbackPath || '/pages/home/index')
},
home() {
wx.switchTab({
/**
* Purpose: url supports navigation-bar.js by holding or executing the url page or API role.
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
*/
url: '/pages/home/index',
})
},
},
})
@@ -0,0 +1,5 @@
{
"component": true,
"styleIsolation": "apply-shared",
"usingComponents": {}
}
@@ -0,0 +1,56 @@
<view class="weui-navigation-bar {{extClass}} {{safeAreaMode === 'overlay' ? 'weui-navigation-bar--overlay' : ''}}">
<view
class="weui-navigation-bar__inner {{ios ? 'ios' : 'android'}}"
style="color: {{color}}; background: {{background}}; {{displayStyle}}; {{innerPaddingRight}}; {{safeAreaTop}};"
>
<view class="weui-navigation-bar__left" style="{{leftWidth}};">
<block wx:if="{{resolvedShowBack || homeButton}}">
<view wx:if="{{resolvedShowBack}}" class="weui-navigation-bar__buttons">
<view
bindtap="back"
class="weui-navigation-bar__action"
hover-class="weui-navigation-bar__action--active"
hover-stay-time="80"
aria-role="button"
aria-label="返回"
>
<text class="weui-navigation-bar__arrow">‹</text>
<text class="weui-navigation-bar__label">返回</text>
</view>
</view>
<view wx:if="{{homeButton}}" class="weui-navigation-bar__buttons">
<view
bindtap="home"
class="weui-navigation-bar__action"
hover-class="weui-navigation-bar__action--active"
hover-stay-time="80"
aria-role="button"
aria-label="首页"
>
<text class="weui-navigation-bar__home-dot"></text>
<text class="weui-navigation-bar__label">首页</text>
</view>
</view>
</block>
<block wx:else>
<slot name="left"></slot>
</block>
</view>
<view class="weui-navigation-bar__center">
<view wx:if="{{loading}}" class="weui-navigation-bar__loading" aria-role="alert">
<view class="weui-loading" aria-role="img" aria-label="加载中"></view>
</view>
<block wx:if="{{title}}">
<text>{{title}}</text>
</block>
<block wx:else>
<slot name="center"></slot>
</block>
</view>
<view class="weui-navigation-bar__right">
<slot name="right"></slot>
</view>
</view>
</view>
@@ -0,0 +1,141 @@
.weui-navigation-bar {
--weui-FG-0: var(--theme-neutral);
--height: 44px;
--left: 20rpx;
color: var(--weui-FG-0);
position: relative;
z-index: 30;
}
.weui-navigation-bar .android {
--height: 48px;
}
.weui-navigation-bar--overlay {
position: sticky;
top: 0;
}
.weui-navigation-bar__inner {
position: relative;
z-index: 1;
height: calc(var(--height) + env(safe-area-inset-top));
display: flex;
flex-direction: row;
align-items: center;
justify-content: center;
padding-top: env(safe-area-inset-top);
width: 100%;
box-sizing: border-box;
color: var(--theme-neutral);
border-bottom: 1rpx solid var(--theme-border);
backdrop-filter: blur(20rpx);
}
.weui-navigation-bar__left,
.weui-navigation-bar__right {
position: relative;
display: flex;
flex-direction: row;
align-items: center;
height: 100%;
box-sizing: border-box;
}
.weui-navigation-bar__left {
padding-left: var(--left);
}
.weui-navigation-bar__right {
justify-content: flex-end;
min-width: 120rpx;
padding-right: 24rpx;
}
.weui-navigation-bar__buttons {
display: flex;
align-items: center;
height: 100%;
}
.weui-navigation-bar__action {
display: inline-flex;
align-items: center;
gap: 10rpx;
min-height: 64rpx;
padding: 0 18rpx 0 8rpx;
border-radius: 999rpx;
background: rgba(255, 255, 255, 0.86);
border: 1rpx solid rgba(255, 255, 255, 0.94);
color: var(--theme-neutral);
box-shadow: 0 10rpx 28rpx rgba(74, 68, 63, 0.08);
}
.weui-navigation-bar__action--active {
opacity: 0.7;
}
.weui-navigation-bar__arrow {
font-size: 40rpx;
font-weight: 700;
line-height: 1;
}
.weui-navigation-bar__home-dot {
width: 20rpx;
height: 20rpx;
border-radius: 999rpx;
background: currentColor;
}
.weui-navigation-bar__label {
font-size: 24rpx;
font-weight: 700;
line-height: 1;
}
.weui-navigation-bar__center {
font-size: 17px;
text-align: center;
position: relative;
display: flex;
flex-direction: row;
align-items: center;
justify-content: center;
font-weight: 700;
flex: 1;
height: 100%;
min-width: 0;
}
.weui-navigation-bar__center text {
max-width: 100%;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.weui-navigation-bar__loading {
margin-right: 8rpx;
display: flex;
align-items: center;
}
.weui-loading {
font-size: 16px;
width: 16px;
height: 16px;
display: block;
background: transparent url("data:image/svg+xml,%3C%3Fxml version='1.0' encoding='UTF-8'%3F%3E%3Csvg width='80px' height='80px' viewBox='0 0 80 80' version='1.1' xmlns='http://www.w3.org/2000/svg'%3E%3Cg stroke='none' stroke-width='1' fill='none' fill-rule='evenodd' opacity='0.9'%3E%3Cg%3E%3Cpath d='M40,0 C62.09139,0 80,17.90861 80,40 C80,62.09139 62.09139,80 40,80 L40,73 C58.2253967,73 73,58.2253967 73,40 C73,21.7746033 58.2253967,7 40,7 L40,0 Z' fill='rgba(96,96,96,0.3)'/%3E%3Cpath d='M40,0 L40,7 C21.7746033,7 7,21.7746033 7,40 C7,58.2253967 21.7746033,73 40,73 L40,80 C17.90861,80 0,62.09139 0,40 C0,17.90861 17.90861,0 40,0 Z' fill='%23606060'/%3E%3Ccircle fill='%23606060' cx='40.5' cy='3.5' r='3.5'%3E%3C/circle%3E%3C/g%3E%3C/g%3E%3C/svg%3E") no-repeat;
background-size: 100%;
animation: loading 1s linear infinite;
}
@keyframes loading {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}
@@ -0,0 +1,34 @@
Component({
properties: {
item: {
type: Object,
value: {}
},
showMeta: {
type: Boolean,
value: true
},
showStats: {
type: Boolean,
value: false
},
showQuickAdd: {
type: Boolean,
value: false
},
inCart: {
type: Boolean,
value: false
}
},
methods: {
handleTap() {
this.triggerEvent('select', this.properties.item)
},
handleQuickAdd() {
this.triggerEvent('quickadd', this.properties.item)
}
}
})
@@ -0,0 +1,3 @@
{
"component": true
}
@@ -0,0 +1,34 @@
<view class="product-card" bindtap="handleTap">
<view class="product-cover-wrap">
<image class="product-cover" src="{{item.coverUrl}}" mode="aspectFill" lazy-load="{{true}}"></image>
<view class="product-cover-shadow"></view>
<view wx:if="{{showMeta && item.metaText}}" class="product-meta-badge">{{item.metaText}}</view>
</view>
<view class="product-body">
<view class="product-title">{{item.displayTitle}}</view>
<view wx:if="{{item.shopNameText}}" class="product-shop">{{item.shopNameText}}</view>
<view wx:if="{{!showMeta && item.metaText}}" class="product-meta">{{item.metaText}}</view>
<view wx:if="{{item.tagsPreview && item.tagsPreview.length}}" class="product-tags">
<text wx:for="{{item.tagsPreview}}" wx:key="*this" class="tag-item">{{item}}</text>
</view>
<view class="product-footer">
<view class="product-price-wrap">
<text class="product-price">{{item.priceText}}</text>
<text wx:if="{{showStats}}" class="product-stats">{{item.statsText}}</text>
</view>
<view wx:if="{{showQuickAdd}}" class="product-actions">
<view wx:if="{{!inCart}}" class="product-quick-add" catchtap="handleQuickAdd">
<view class="product-quick-add-icon">
<view class="product-quick-add-handle"></view>
<view class="product-quick-add-basket"></view>
<view class="product-quick-add-wheel product-quick-add-wheel--left"></view>
<view class="product-quick-add-wheel product-quick-add-wheel--right"></view>
<view class="product-quick-add-plus product-quick-add-plus--horizontal"></view>
<view class="product-quick-add-plus product-quick-add-plus--vertical"></view>
</view>
</view>
<view wx:else class="product-in-cart">购物车已有</view>
</view>
</view>
</view>
</view>
@@ -0,0 +1,227 @@
.product-card {
display: flex;
flex-direction: column;
min-width: 0;
overflow: hidden;
border-radius: 28rpx;
background: rgba(255, 255, 255, 0.86);
border: 1rpx solid var(--theme-border);
box-shadow: 0 18rpx 42rpx rgba(74, 68, 63, 0.08);
}
.product-cover-wrap {
position: relative;
}
.product-cover {
width: 100%;
height: 288rpx;
background: var(--theme-primary-soft);
}
.product-cover-shadow {
position: absolute;
left: 0;
right: 0;
bottom: 0;
height: 120rpx;
background: linear-gradient(180deg, rgba(28, 23, 26, 0), rgba(28, 23, 26, 0.28));
}
.product-meta-badge {
position: absolute;
left: 16rpx;
top: 16rpx;
max-width: calc(100% - 32rpx);
padding: 8rpx 14rpx;
border-radius: 999rpx;
background: rgba(255, 255, 255, 0.92);
color: var(--theme-primary-action);
font-size: 19rpx;
font-weight: 700;
}
.product-body {
display: flex;
flex-direction: column;
gap: 10rpx;
min-height: 220rpx;
padding: 20rpx 20rpx 22rpx;
}
.product-title {
min-height: 74rpx;
font-size: 27rpx;
font-weight: 700;
line-height: 1.38;
color: var(--text-primary);
word-break: break-all;
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
}
.product-meta {
font-size: 22rpx;
color: var(--text-secondary);
line-height: 1.4;
}
.product-tags {
display: flex;
flex-wrap: wrap;
gap: 8rpx;
}
.tag-item {
display: inline-flex;
align-items: center;
justify-content: center;
max-width: 100%;
padding: 6rpx 14rpx;
border-radius: 999rpx;
background: var(--theme-primary-soft);
color: var(--theme-primary);
font-size: 18rpx;
line-height: 1;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.product-footer {
display: flex;
align-items: flex-end;
gap: 14rpx;
margin-top: auto;
}
.product-price-wrap {
flex: 1;
min-width: 0;
}
.product-actions {
display: flex;
align-items: center;
flex-shrink: 0;
}
.product-price {
display: block;
font-size: 34rpx;
line-height: 1.12;
font-weight: 800;
color: var(--theme-accent);
}
.product-stats {
display: block;
margin-top: 6rpx;
font-size: 20rpx;
line-height: 1.4;
color: var(--text-secondary);
}
.product-quick-add {
display: inline-flex;
align-items: center;
justify-content: center;
width: 64rpx;
height: 64rpx;
border-radius: 22rpx;
background: var(--theme-gradient);
box-shadow: 0 14rpx 30rpx rgba(232, 180, 184, 0.26);
}
.product-quick-add-icon {
position: relative;
width: 32rpx;
height: 28rpx;
}
.product-quick-add-handle {
position: absolute;
left: 2rpx;
top: 2rpx;
width: 12rpx;
height: 4rpx;
border-radius: 999rpx;
background: #ffffff;
transform: rotate(20deg);
transform-origin: left center;
}
.product-quick-add-basket {
position: absolute;
left: 6rpx;
top: 8rpx;
width: 18rpx;
height: 11rpx;
border: 3rpx solid #ffffff;
border-top: 0;
border-radius: 0 0 6rpx 6rpx;
}
.product-quick-add-wheel {
position: absolute;
top: 22rpx;
width: 6rpx;
height: 6rpx;
border-radius: 50%;
background: #ffffff;
}
.product-quick-add-wheel--left {
left: 10rpx;
}
.product-quick-add-wheel--right {
left: 22rpx;
}
.product-quick-add-plus {
position: absolute;
border-radius: 999rpx;
background: #ffffff;
}
.product-quick-add-plus--horizontal {
top: 2rpx;
right: 0;
width: 10rpx;
height: 3rpx;
}
.product-quick-add-plus--vertical {
top: -1rpx;
right: 4rpx;
width: 3rpx;
height: 10rpx;
}
.product-in-cart {
display: inline-flex;
align-items: center;
justify-content: center;
height: 56rpx;
padding: 0 18rpx;
border-radius: 999rpx;
background: var(--theme-primary-soft);
color: var(--theme-accent);
font-size: 20rpx;
font-weight: 700;
white-space: nowrap;
}
.product-shop {
margin-top: 6rpx;
color: var(--text-secondary);
font-size: 22rpx;
line-height: 1.45;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}