Browse Source

feat: 添加新鲜程度和采购价格字段显示

pull/8/head
徐飞洋 2 months ago
parent
commit
7e24001a52
  1. 4
      pages/goods-update/goods-update.js
  2. 12
      pages/goods-update/goods-update.wxml
  3. 2
      pages/goods/index.wxml
  4. 3
      server-example/server-mysql.js

4
pages/goods-update/goods-update.js

@ -519,7 +519,9 @@ Page({
// 确保地区信息正确显示,放在最后覆盖所有来源的值
region: finalRegion,
// 确保reservedCount字段使用我们计算得到的值,放在最后以覆盖其他来源的值
reservedCount: finalReservationCount
reservedCount: finalReservationCount,
// 添加新鲜程度字段
freshness: product.freshness || ''
};
console.log('最终formattedGoods.region:', formattedGoods.region);

12
pages/goods-update/goods-update.wxml

@ -66,8 +66,12 @@
</view>
<view class="goods-price" style="position: relative; display: flex; align-items: center; justify-content: space-between;">
<view style="display: flex; align-items: center;">
<text class="price-symbol">价格:</text>
<text class="price-value">{{goodsDetail.price}}</text>
<text class="price-symbol">销售价格:</text>
<text class="price-value">{{goodsDetail.price || '暂无'}}</text>
</view>
<view style="display: flex; align-items: center;">
<text class="price-symbol">采购价格:</text>
<text class="price-value">{{goodsDetail.costprice || '暂无'}}</text>
</view>
</view>
</view>
@ -86,10 +90,10 @@
<view class="info-item">
<view class="info-label-container">
<text class="info-label">关注人数</text>
<text class="info-label">新鲜程度</text>
</view>
<view class="info-value-container">
<text class="info-value">{{goodsDetail.reservedCount || '0'}}</text>
<text class="info-value">{{goodsDetail.freshness || '暂无'}}</text>
</view>
</view>
</view>

2
pages/goods/index.wxml

@ -100,7 +100,7 @@
</view>
<view class="product-spec">{{item.specification || item.spec || '无'}}<text wx:if="{{item.yolk}}"> | {{item.yolk}}</text></view>
<view class="product-meta">
<text class="product-price">{{item.costprice ? '¥' + item.costprice : '无采购价'}}</text>
<text class="product-price">{{item.price ? '¥' + item.price : '无销售价格'}}</text>
<text class="product-location">{{item.region || ''}}</text>
</view>
<view class="product-description">{{item.description || ''}}</view>

3
server-example/server-mysql.js

@ -3866,7 +3866,7 @@ app.post('/api/products/detail', async (req, res) => {
// 查询商品详情 - 排除hidden状态商品,直接使用Product表中的reservedCount字段
const product = await Product.findOne({
attributes: ['productId', 'productName', 'price', 'quantity', 'grossWeight', 'imageUrls', 'created_at', 'specification', 'yolk', 'sourceType', 'supplyStatus', 'producting', 'product_contact', 'contact_phone', 'region'],
attributes: ['productId', 'productName', 'price', 'quantity', 'grossWeight', 'imageUrls', 'created_at', 'specification', 'yolk', 'sourceType', 'supplyStatus', 'producting', 'product_contact', 'contact_phone', 'region', 'freshness', 'costprice','description'],
where: {
productId,
status: { [Sequelize.Op.not]: 'hidden' }
@ -3944,6 +3944,7 @@ app.post('/api/products/detail', async (req, res) => {
console.log('商品详情 - 最终返回的毛重值:', updatedProduct.grossWeight, '类型:', typeof updatedProduct.grossWeight);
console.log('商品详情 - 返回的收藏人数:', updatedProduct.reservedCount, '类型:', typeof updatedProduct.reservedCount);
console.log('商品详情 - producting字段:', updatedProduct.producting, '类型:', typeof updatedProduct.producting);
console.log('商品详情 - description字段:', updatedProduct.description, '类型:', typeof updatedProduct.description);
res.json({
success: true,

Loading…
Cancel
Save