diff --git a/pages/goods-detail/goods-detail.js b/pages/goods-detail/goods-detail.js
index 7be4cf3..0e53dde 100644
--- a/pages/goods-detail/goods-detail.js
+++ b/pages/goods-detail/goods-detail.js
@@ -303,6 +303,40 @@ function checkLoginStatus() {
return !!(openid && userId);
}
+// 格式化日期时间函数
+function formatDateTime(dateString) {
+ if (!dateString) return '';
+
+ // 尝试解析日期字符串
+ const date = new Date(dateString);
+
+ // 检查是否是有效的日期对象
+ if (isNaN(date.getTime())) {
+ // 如果解析失败,返回原始字符串
+ return dateString;
+ }
+
+ // 如果是 ISO 格式的字符串(包含 T 字符),则转换为本地时间格式,只保留日期部分
+ if (typeof dateString === 'string' && dateString.includes('T')) {
+ const year = date.getFullYear();
+ const month = (date.getMonth() + 1).toString().padStart(2, '0');
+ const day = date.getDate().toString().padStart(2, '0');
+ return `${year}-${month}-${day}`;
+ }
+
+ // 对于其他格式的字符串,尝试提取日期部分
+ if (typeof dateString === 'string') {
+ // 检查是否包含空格,提取空格前的日期部分
+ const spaceIndex = dateString.indexOf(' ');
+ if (spaceIndex !== -1) {
+ return dateString.substring(0, spaceIndex);
+ }
+ }
+
+ // 如果以上都不匹配,直接返回
+ return dateString;
+}
+
// 处理净重、件数、规格和价格数据,将逗号分隔的字符串转换为一一对应的数组
function processWeightAndQuantityData(weightSpecString, quantityString, specString, priceString) {
console.log('===== 处理净重、件数、规格和价格数据 =====');
@@ -2484,12 +2518,17 @@ Page({
// 提取省份信息
const province = extractProvince(goods.region || '');
+ // 格式化日期
+ const updatedAt = goods.updated_at || goods.updatedAt;
+ const formattedDate = formatDateTime(updatedAt);
+
return {
...goods,
price: priceString, // 确保price字段是字符串类型
mediaItems: processMediaUrls(goods.imageUrls),
weightQuantityData: weightQuantityData,
- province: province // 添加省份字段
+ province: province, // 添加省份字段
+ formattedDate: formattedDate // 添加格式化的日期字段
};
}).filter(goods => {
// 只有当当前商品有明确的规格时才进行筛选
@@ -2697,12 +2736,17 @@ Page({
// 处理数据
const weightQuantityData = processWeightAndQuantityData(weightSpecString, quantityString, '', priceString);
+ // 格式化日期
+ const updatedAt = product.updated_at || product.updatedAt;
+ const formattedDate = formatDateTime(updatedAt);
+
return {
...product,
price: priceString, // 确保price字段是字符串类型
mediaItems: processMediaUrls(product.imageUrls),
province: province, // 添加省份字段
- weightQuantityData: weightQuantityData // 添加价格处理数据
+ weightQuantityData: weightQuantityData, // 添加价格处理数据
+ formattedDate: formattedDate // 添加格式化的日期字段
};
});
console.log('所有商品详情获取完成,有效商品数量:', validProducts.length);
@@ -2754,12 +2798,17 @@ Page({
// 处理数据
const weightQuantityData = processWeightAndQuantityData(weightSpecString, quantityString, '', priceString);
+ // 格式化日期
+ const updatedAt = product.updated_at || product.updatedAt;
+ const formattedDate = formatDateTime(updatedAt);
+
return {
...product,
price: priceString, // 确保price字段是字符串类型
mediaItems: processMediaUrls(product.imageUrls),
province: province, // 添加省份字段
- weightQuantityData: weightQuantityData // 添加价格处理数据
+ weightQuantityData: weightQuantityData, // 添加价格处理数据
+ formattedDate: formattedDate // 添加格式化的日期字段
};
});
diff --git a/pages/goods-detail/goods-detail.wxml b/pages/goods-detail/goods-detail.wxml
index 65e0324..d9b5ea8 100644
--- a/pages/goods-detail/goods-detail.wxml
+++ b/pages/goods-detail/goods-detail.wxml
@@ -268,10 +268,19 @@
{{item.name}}
- {{item.specification || item.spec || item.specs || '暂无规格'}}
- {{item.quantity || '暂无件数'}}件
- 价格: {{item.price}}
- {{item.province || item.region || '暂无地区'}}
+
+
+
+ {{specItem.display}}
+
+
+
+ {{item.specification || item.spec || item.specs || '暂无规格'}}|{{item.quantity || '暂无件数'}}件
+
+
+
+ {{item.province || item.region || '暂无地区'}} | 售出时间:{{item.formattedDate || '暂无时间'}}
+
@@ -308,10 +317,19 @@
{{item.name}}
- {{item.specification || item.spec || item.specs || '暂无规格'}}
- {{item.quantity || '暂无件数'}}件
- 价格: {{item.price.split(',')[0]}}
- {{item.province || item.region || '暂无地区'}}
+
+
+
+ {{specItem.display}}
+
+
+
+ {{item.specification || item.spec || item.specs || '暂无规格'}}|{{item.quantity || '暂无件数'}}件
+
+
+
+ {售出时间}{{item.province || item.region || '暂无地区'}} | {{item.formattedDate || '暂无时间'}}
+
diff --git a/pages/goods-detail/goods-detail.wxss b/pages/goods-detail/goods-detail.wxss
index dd55d21..4f1296f 100644
--- a/pages/goods-detail/goods-detail.wxss
+++ b/pages/goods-detail/goods-detail.wxss
@@ -857,15 +857,16 @@ video.slider-media .wx-video-volume-icon {
.compare-goods-list {
flex: 1;
overflow-y: auto;
- padding: 16rpx;
+ padding: 12rpx;
}
.compare-goods-item {
display: flex;
+ align-items: center;
background-color: #fff;
- border-radius: 16rpx;
- padding: 16rpx;
- margin-bottom: 16rpx;
+ border-radius: 12rpx;
+ padding: 12rpx;
+ margin-bottom: 12rpx;
box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.08);
transition: all 0.3s ease;
border: 1rpx solid #f0f0f0;
@@ -879,8 +880,8 @@ video.slider-media .wx-video-volume-icon {
.compare-goods-image {
width: 120rpx;
height: 120rpx;
- border-radius: 12rpx;
- margin-right: 16rpx;
+ border-radius: 10rpx;
+ margin-right: 12rpx;
object-fit: cover;
background: linear-gradient(135deg, #f0f4ff 0%, #d9e4ff 100%);
}
@@ -889,8 +890,8 @@ video.slider-media .wx-video-volume-icon {
.product-image-wrapper {
width: 120rpx;
height: 120rpx;
- border-radius: 12rpx;
- margin-right: 16rpx;
+ border-radius: 10rpx;
+ margin-right: 12rpx;
overflow: hidden;
position: relative;
background: linear-gradient(135deg, #f0f4ff 0%, #d9e4ff 100%);
@@ -912,15 +913,15 @@ video.slider-media .wx-video-volume-icon {
flex: 1;
display: flex;
flex-direction: column;
- justify-content: space-between;
+ justify-content: flex-start;
}
.compare-goods-name {
font-size: 32rpx;
color: #222;
font-weight: 600;
- line-height: 1.4;
- margin-bottom: 8rpx;
+ line-height: 1.3;
+ margin-bottom: 4rpx;
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
@@ -955,6 +956,20 @@ video.slider-media .wx-video-volume-icon {
color: #999;
}
+.compare-goods-spec-quantity {
+ font-size: 28rpx;
+ color: #666;
+ line-height: 1.1;
+ margin: 2rpx 0;
+}
+
+.compare-goods-region-time {
+ font-size: 26rpx;
+ color: #999;
+ line-height: 1.1;
+ margin-top: 2rpx;
+}
+
.compare-empty {
text-align: center;
padding: 80rpx 0;
diff --git a/pages/index/index.json b/pages/index/index.json
index 23ea9ee..d0caaa6 100644
--- a/pages/index/index.json
+++ b/pages/index/index.json
@@ -2,7 +2,7 @@
"usingComponents": {
"navigation-bar": "/components/navigation-bar/navigation-bar"
},
- "enablePullDownRefresh": true,
+ "enablePullDownRefresh": false,
"backgroundTextStyle": "dark",
"backgroundColor": "#f8f8f8"
}
\ No newline at end of file