优化了样式,抽象出了 WXSS/JS 库

This commit is contained in:
2026-06-13 18:19:46 +08:00
parent 6fbae9b32c
commit 3dc03f6fe5
51 changed files with 7154 additions and 9035 deletions

View File

@@ -4,11 +4,12 @@ import { ensureLogin } from '../../utils/login';
import { fetchShopGoods, bindShop } from '../../utils/shop';
import { backfillUserProfileCache, getSessionToken } from '../../utils/role-tab-bar';
import PopupService from '../../services/popupService.js';
import { createPage } from '../../utils/base-page.js';
// 扫码场景参数名
const SCENE_PARAM = 'scene';
Page({
Page(createPage({
data: {
ossImageUrl: '',
lunbozhanwei: '',
@@ -26,7 +27,7 @@ Page({
isLoading: false,
isRefreshing: false,
hasInitialized: false,
currentTime: ''
},
@@ -43,7 +44,7 @@ Page({
console.error('scene解码失败', e);
}
}
// 等待全局配置加载完成
this.waitForConfigAndInit();
// 已登录时才检查弹窗
@@ -107,16 +108,6 @@ Page({
}
},
registerNotificationComponent() {
const notificationComp = this.selectComponent('#global-notification');
if (notificationComp && notificationComp.showNotification) {
app.globalData.globalNotification = {
show: (data) => notificationComp.showNotification(data),
hide: () => notificationComp.hideNotification()
};
}
},
getCurrentTime() {
const now = new Date();
const year = now.getFullYear();
@@ -234,12 +225,12 @@ Page({
*/
filterShangpinData() {
const { selectedLeixingId, shangpinzhuanqu, shangpinliebiao } = this.data;
if (!selectedLeixingId || !shangpinzhuanqu || !shangpinliebiao) {
this.setData({ filteredData: [] });
return;
}
const zhuanquByLeixing = new Map();
shangpinzhuanqu.forEach(zhuanqu => {
if (zhuanqu.leixing_id === selectedLeixingId) {
@@ -249,7 +240,7 @@ Page({
zhuanquByLeixing.get(selectedLeixingId).push(zhuanqu);
}
});
const shangpinByZhuanqu = new Map();
shangpinliebiao.forEach(shangpin => {
if (shangpin.leixing_id === selectedLeixingId && shangpin.zhuanqu_id) {
@@ -257,7 +248,7 @@ Page({
if (!shangpinByZhuanqu.has(zhuanquId)) {
shangpinByZhuanqu.set(zhuanquId, []);
}
const jiage = parseFloat(shangpin.jiage) || 0;
const priceInteger = Math.floor(jiage);
let priceDecimal = '00';
@@ -265,7 +256,7 @@ Page({
if (decimalPart > 0) {
priceDecimal = decimalPart.toString().split('.')[1];
}
shangpinByZhuanqu.get(zhuanquId).push({
id: shangpin.id,
biaoqian: shangpin.biaoqian,
@@ -278,10 +269,10 @@ Page({
});
}
});
const filteredData = [];
const currentZhuanquList = zhuanquByLeixing.get(selectedLeixingId) || [];
currentZhuanquList.forEach(zhuanqu => {
const shangpinList = shangpinByZhuanqu.get(zhuanqu.id) || [];
if (shangpinList.length > 0) {
@@ -295,14 +286,14 @@ Page({
});
}
});
const sortedFilteredData = filteredData.sort((a, b) => {
const paixuA = a.zhuanqu.paixu || 0;
const paixuB = b.zhuanqu.paixu || 0;
if (paixuB !== paixuA) return paixuB - paixuA;
return a.zhuanqu.id - b.zhuanqu.id;
});
this.setData({ filteredData: sortedFilteredData });
},
@@ -315,18 +306,21 @@ Page({
},
showGonggaoDetail() {
this.setData({
this.setData({
showGonggaoModal: true,
_modalLeaving: false,
gonggaoAnim: false,
currentTime: this.getCurrentTime()
});
},
hideGonggaoDetail() {
this.setData({
this.setData({
showGonggaoModal: false,
gonggaoAnim: true
_modalLeaving: true,
gonggaoAnim: true
});
setTimeout(() => this.setData({ _modalLeaving: false }), 300);
},
/**
@@ -388,4 +382,4 @@ Page({
onUnload() {
this.setData({ gonggaoAnim: false });
}
});
}))

View File

@@ -146,9 +146,9 @@
</view>
<!-- 公告详情弹窗 -->
<view class="gonggao-modal" wx:if="{{showGonggaoModal}}">
<view class="modal-mask" bindtap="hideGonggaoDetail"></view>
<view class="modal-content">
<view class="gonggao-modal {{showGonggaoModal ? 'gonggao-modal--show' : 'gonggao-modal--hide'}}" wx:if="{{showGonggaoModal || _modalLeaving}}">
<view class="modal-mask {{showGonggaoModal ? 'modal-mask--in' : 'modal-mask--out'}}" bindtap="hideGonggaoDetail"></view>
<view class="modal-content {{showGonggaoModal ? 'modal-content--in' : 'modal-content--out'}}">
<view class="modal-header">
<text class="modal-title">公告详情</text>
<view class="modal-close" bindtap="hideGonggaoDetail">×</view>

View File

@@ -411,3 +411,82 @@
align-items: center;
}
.gonggao-modal .modal-mask {
position: absolute;
top: 0; left: 0; right: 0; bottom: 0;
background: rgba(0, 0, 0, 0.5);
z-index: 0;
transition: opacity 0.25s ease;
}
.gonggao-modal .modal-mask--in {
opacity: 1;
}
.gonggao-modal .modal-mask--out {
opacity: 0;
}
.gonggao-modal .modal-content {
position: relative;
z-index: 1;
width: 620rpx;
max-height: 70vh;
background: #fff;
border-radius: 20rpx;
overflow: hidden;
display: flex;
flex-direction: column;
transition: transform 0.25s ease, opacity 0.25s ease;
}
.gonggao-modal .modal-content--in {
transform: scale(1);
opacity: 1;
}
.gonggao-modal .modal-content--out {
transform: scale(0.9);
opacity: 0;
}
.gonggao-modal .modal-header {
display: flex;
align-items: center;
justify-content: space-between;
padding: 28rpx 32rpx 20rpx;
border-bottom: 1rpx solid #f0f0f0;
}
.gonggao-modal .modal-title {
font-size: 30rpx;
font-weight: 700;
color: #1a1a1a;
}
.gonggao-modal .modal-close {
width: 48rpx;
height: 48rpx;
display: flex;
align-items: center;
justify-content: center;
font-size: 36rpx;
color: #999;
border-radius: 50%;
background: #f5f5f5;
line-height: 1;
}
.gonggao-modal .modal-body {
flex: 1;
padding: 28rpx 32rpx 36rpx;
max-height: 55vh;
}
.gonggao-modal .modal-text {
font-size: 28rpx;
color: #444;
line-height: 1.8;
word-break: break-all;
}