Browse Source

fix: 修复iOS滑动时箭头消失问题并优化箭头样式

蛋吧eggbar
Trae AI 1 month ago
parent
commit
5feaa32898
  1. 10
      pages/goods-detail/goods-detail.wxss
  2. 49
      pages/index/index.js

10
pages/goods-detail/goods-detail.wxss

@ -787,21 +787,23 @@ video.slider-media .wx-video-volume-icon {
/* 价格变化箭头样式 */
.price-change-arrow {
margin-left: 8rpx;
font-size: 32rpx;
font-size: 36rpx;
font-weight: bold;
font-family: 'Arial', sans-serif;
}
.price-change-arrow.up {
color: #ff4d4f;
animation: pulse 2s infinite;
text-shadow: 0 1rpx 2rpx rgba(255, 77, 79, 0.3);
}
.price-change-arrow.down {
color: #52c41a;
animation: pulse 2s infinite;
text-shadow: 0 1rpx 2rpx rgba(82, 196, 26, 0.3);
}
@keyframes pulse {
/* 移除可能导致iOS滑动时箭头消失的动画效果 */
/* @keyframes pulse {
0% {
opacity: 1;
transform: scale(1);

49
pages/index/index.js

@ -1326,6 +1326,50 @@ Page({
// 格式化规格显示
const formattedSpec = this.formatSpecification(product.specification || product.spec || '', product.yolk || '');
// 处理价格波动
const processPriceChange = (productLog) => {
if (!productLog || !Array.isArray(productLog) || productLog.length === 0) {
return {
hasPriceChange: false,
priceChangeDirection: null
};
}
// 检查是否有同规格的第二次日志
const specLogs = {};
productLog.forEach(log => {
if (typeof log === 'string') {
// 提取规格信息
const specMatch = log.match(/将(.+?)规格的销售价格/);
if (specMatch && specMatch[1]) {
const spec = specMatch[1].trim();
if (!specLogs[spec]) {
specLogs[spec] = [];
}
specLogs[spec].push(log);
}
}
});
// 检查是否有规格有多次价格调整
let hasPriceChange = false;
for (const spec in specLogs) {
if (specLogs[spec].length >= 2) {
hasPriceChange = true;
break;
}
}
return {
hasPriceChange,
priceChangeDirection: null // 默认为null,在商品详情页中计算具体方向
};
};
// 检查所有可能的产品日志字段名
const productLog = product.product_log || product.productLog || [];
const priceChangeInfo = processPriceChange(productLog);
return {
...product,
id: productId, // 统一使用id字段
@ -1355,7 +1399,10 @@ Page({
originalTotalStock: totalStock, // 保留原始计算值用于调试
displaySpecification: formattedSpec.displaySpec, // 格式化后的规格
displayYolk: formattedSpec.displayYolk, // 格式化后的蛋黄
price: product.price !== undefined ? product.price : '' // 确保price字段存在
price: product.price !== undefined ? product.price : '', // 确保price字段存在
// 添加价格波动信息
hasPriceChange: priceChangeInfo.hasPriceChange,
priceChangeDirection: priceChangeInfo.priceChangeDirection
}
})

Loading…
Cancel
Save