|
|
@@ -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;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|