Explorar o código

当设置了涨价设置,花束列表的有价格商品会展示出:已涨价的价格与原价格

shizhongqi hai 11 meses
pai
achega
d887916509

+ 56 - 2
hdApp/src/admin/goods/list.vue

@@ -38,7 +38,15 @@
                       <view class="goods-name" style="font-size:29upx;font-weight:bold;	overflow: hidden;text-overflow: ellipsis;white-space: nowrap;width:350upx;">{{ goodsItem.name||'' }}</view>
                     </view>
                     <view class="operate-wrap" style="margin-bottom:15upx;">
-                      <view class="goods-price" style="font-size:26upx;" v-if="goodsItem.priceType == 1">¥{{ goodsItem.price?parseFloat(goodsItem.price):0 }}</view>
+                      <view v-if="goodsItem.priceType == 1">
+                        <!-- 当涨价开关开启时,显示涨价后价格和原价 -->
+                        <view v-if="riseSwitch" class="price-container">
+                          <text class="goods-price" style="font-size:26upx;">¥{{ risePrice(goodsItem).toFixed(2) }}</text>
+                          <text class="original-price" style="font-size:22upx;">¥{{ goodsItem.price?parseFloat(goodsItem.price).toFixed(2):0 }}</text>
+                        </view>
+                        <!-- 当涨价开关关闭时,显示原价 -->
+                        <view v-else class="goods-price" style="font-size:26upx;">¥{{ goodsItem.price?parseFloat(goodsItem.price):0 }}</view>
+                      </view>
                       <view class="goods-price" style="font-size:26upx;" v-else>---</view>
                     </view>
                     <view class="operate-wrap">
@@ -130,7 +138,7 @@
 <script>
 import AppSearchModule from "@/components/module/app-search"
 import AppWrapperEmpty from "@/components/app-wrapper-empty"
-import {categoryListInfo,getCategoryToGoods,print} from "@/api/goods"
+import {categoryListInfo,getCategoryToGoods,print,getRise} from "@/api/goods"
 import { list } from "@/mixins"
 export default {
   name: "list",
@@ -147,6 +155,8 @@ export default {
       catId: "",
       flowerNum:0,
       searchText:'',
+      riseSwitch: false, // 价格上涨开关
+      riseData: {}, // 价格上涨配置
       lookStock:0, // 1:有库存 2:无库存
       lookPrice:0, // 1:有价格 2:无价格
       // 新增筛选相关数据
@@ -196,6 +206,7 @@ export default {
   methods: {
     init(){
       this.getCategoryData()
+      this.getRiseData()
     },
     
     // 新的筛选相关方法
@@ -334,6 +345,35 @@ export default {
         this.resetList();
         this.getGoodsList();
       }
+    },
+    getRiseData() {
+      getRise().then(res => {
+        this.riseData = res.data;
+        //console.log('riseData: ' , this.riseData)
+        this.riseSwitch = this.riseData.riseSwitch == '1' ? true : false;
+      })
+    },
+    
+    // 计算涨价后的价格
+    risePrice(goodsItem) {
+      if (!goodsItem.price || !this.riseData.riseAmount) {
+        return parseFloat(goodsItem.price) || 0;
+      }
+      
+      const originalPrice = parseFloat(goodsItem.price);
+      let newPrice = 0;
+      
+      if (this.riseData.riseType == '0') {
+        // 按比率上涨
+        newPrice = originalPrice * (1 + this.riseData.riseAmount / 100);
+      } else if (this.riseData.riseType == '1') {
+        // 按金额数上涨
+        newPrice = originalPrice + parseFloat(this.riseData.riseAmount);
+      } else {
+        newPrice = originalPrice;
+      }
+      
+      return newPrice;
     }
   }
 };
@@ -464,6 +504,20 @@ page {
           color: #ff2842;
           font-weight: bold;
         }
+        
+        // 价格容器样式
+        .price-container {
+          display: flex;
+          align-items: center;
+          gap: 15upx;
+        }
+        
+        // 原价格划线样式
+        .original-price {
+          color: #999999;
+          text-decoration: line-through;
+          margin-left: 10upx;
+        }
       }
     }
   }

+ 0 - 4
mallApp/src/pages/home/category.vue

@@ -402,10 +402,6 @@ page {
 	}
 }
 
-
-
-
-
 @keyframes fadeInFrames {
 	0% {
 		opacity: 0;

+ 4 - 1
mallApp/src/pages/item/item.vue

@@ -56,7 +56,10 @@
 								<view v-if="productItem.presell && productItem.presell == 1" style="position:absolute;top:150upx;font-size:26upx;color:#3385ff;white-space: nowrap;text-overflow: hidden;">
 									配送日期:
 									<block v-if="!$util.isEmpty(productItem.presellDateShow)">
-										<text v-for="(dateItem, dateIndex) in productItem.presellDateShow" :key="dateIndex" style="">{{dateItem}}<text v-if="dateIndex!=productItem.presellDateShow.length-1">,</text></text>
+										<text v-for="(dateItem, dateIndex) in productItem.presellDateShow" :key="dateIndex" style="">
+											{{dateItem}}
+											<text v-if="dateIndex!=productItem.presellDateShow.length-1">,</text>
+										</text>
 									</block>
 								</view>
 							</view>