feat: 🎨 在config中新增5个便捷功能选项,更加简单便捷配置以及使用代码。优化部分冗余的代码

This commit is contained in:
学习很差啦
2022-10-10 18:53:14 +08:00
parent 1225a41de4
commit 7179ca41de
19 changed files with 100 additions and 168 deletions

View File

@@ -370,15 +370,6 @@ export default {
return array;
}
},
// 格式化金钱 1999 --> [1999,00]
formatPrice(val) {
if (typeof val == "undefined") {
return val;
}
return parseInt(val).toFixed(2).split(".");
},
// 展示更多数据
showMore() {
this.loadOldKeyword(this.oldKeywordIndex);

View File

@@ -147,9 +147,9 @@
<p class="goods-prices">
<span></span>
<span class="goods-price">{{
formatPrice(val.goodsSku.price)[0]
$options.filters.goodsFormatPrice(val.goodsSku.price)[0]
}}</span>
<span>.{{ formatPrice(val.goodsSku.price)[1] }}</span>
<span>.{{ $options.filters.goodsFormatPrice(val.goodsSku.price)[1] }}</span>
</p>
</div>
</div>
@@ -315,10 +315,10 @@
<div v-if="!orderMessage.priceDetailDTO.payPoint" class="number">
<span>¥</span>
<span class="price">{{
formatPrice(orderMessage.priceDetailDTO.flowPrice)[0]
$options.filters.goodsFormatPrice(orderMessage.priceDetailDTO.flowPrice)[0]
}}</span>
<span
>.{{ formatPrice(orderMessage.priceDetailDTO.flowPrice)[1] }}
>.{{ $options.filters.goodsFormatPrice(orderMessage.priceDetailDTO.flowPrice)[1] }}
</span>
</div>
<span v-else class="number"
@@ -455,13 +455,6 @@ export default {
mounted() {},
methods: {
// 格式化金钱 1999 --> [1999,00]
formatPrice(val) {
if (typeof val == "undefined") {
return val;
}
return parseInt(val).toFixed(2).split(".");
},
//发票回调 选择发票之后刷新购物车
async callbackInvoice(val) {
this.invoiceFlag = false;

View File

@@ -151,12 +151,12 @@
<span v-else>
<span v-if="wholesaleList.length">
<span>¥</span><span class="price">{{ formatPrice(wholesaleList[wholesaleList.length-1].price)[0] }}</span>.{{ formatPrice(wholesaleList[wholesaleList.length-1].price)[1] }}
<span>¥</span><span class="price">{{ $options.filters.goodsFormatPrice(wholesaleList[wholesaleList.length-1].price)[0] }}</span>.{{ $options.filters.goodsFormatPrice(wholesaleList[wholesaleList.length-1].price)[1] }}
~
<span>¥</span><span class="price">{{ formatPrice(wholesaleList[0].price)[0] }}</span>.{{ formatPrice(wholesaleList[0].price)[1] }}
<span>¥</span><span class="price">{{ $options.filters.goodsFormatPrice(wholesaleList[0].price)[0] }}</span>.{{ $options.filters.goodsFormatPrice(wholesaleList[0].price)[1] }}
</span>
<span v-else>
<span>¥</span><span class="price">{{ formatPrice(goodsDetail.price)[0] }}</span>.{{ formatPrice(goodsDetail.price)[1] }}
<span>¥</span><span class="price">{{ $options.filters.goodsFormatPrice(goodsDetail.price)[0] }}</span>.{{ $options.filters.goodsFormatPrice(goodsDetail.price)[1] }}
</span>
</span>
</view>
@@ -752,14 +752,6 @@ export default {
// // #endif
},
// 格式化金钱 1999 --> [1999,00]
formatPrice(val) {
if (typeof val == "undefined") {
return val;
}
return parseInt(val).toFixed(2).split(".");
},
/**选择商品 */
changedGoods(val) {
this.selectedGoods = val;

View File

@@ -21,15 +21,15 @@
>
<span class="flex-price">
{{ formatPrice(detail.promotionPrice)[0] }}.{{
formatPrice(detail.promotionPrice)[1]
{{ $options.filters.goodsFormatPrice(detail.promotionPrice)[0] }}.{{
$options.filters.goodsFormatPrice(detail.promotionPrice)[1]
}}</span
>
</span>
<view class="u-group-flex" v-if="detail.price != undefined">
<span class="old-price"
>¥{{ formatPrice(detail.price)[0] }}.{{
formatPrice(detail.price)[1]
>¥{{ $options.filters.goodsFormatPrice(detail.price)[0] }}.{{
$options.filters.goodsFormatPrice(detail.price)[1]
}}</span
>
<view class="promotion">限时抢购</view>
@@ -42,8 +42,8 @@
<span
class="flex-price"
v-if="promotion.groupbuy_goods_vo.price != undefined"
>¥{{ formatPrice(promotion.groupbuy_goods_vo.price)[0] }}.{{
formatPrice(promotion.groupbuy_goods_vo.price)[1]
>¥{{ $options.filters.goodsFormatPrice(promotion.groupbuy_goods_vo.price)[0] }}.{{
$options.filters.goodsFormatPrice(promotion.groupbuy_goods_vo.price)[1]
}}</span
>
<!-- <span v-if="promotion.point">+{{promotion.point}}积分</span> -->
@@ -53,9 +53,9 @@
class="old-price"
v-if="promotion.groupbuy_goods_vo.original_price != undefined"
>¥{{
formatPrice(promotion.groupbuy_goods_vo.original_price)[0]
$options.filters.goodsFormatPrice(promotion.groupbuy_goods_vo.original_price)[0]
}}.{{
formatPrice(promotion.groupbuy_goods_vo.original_price)[1]
$options.filters.goodsFormatPrice(promotion.groupbuy_goods_vo.original_price)[1]
}}</span
>
<view class="promotion">团购活动</view>
@@ -68,13 +68,13 @@
v-if="detail.promotionPrice != undefined"
>
¥<span class="flex-price">
{{ formatPrice(detail.promotionPrice)[0] }}.</span
>{{ formatPrice(detail.promotionPrice)[1] }}
{{ $options.filters.goodsFormatPrice(detail.promotionPrice)[0] }}.</span
>{{ $options.filters.goodsFormatPrice(detail.promotionPrice)[1] }}
</span>
<view class="u-group-flex" v-if="detail.price != undefined">
<span class="old-price"
>¥{{ formatPrice(detail.price)[0] }}.{{
formatPrice(detail.price)[1]
>¥{{ $options.filters.goodsFormatPrice(detail.price)[0] }}.{{
$options.filters.goodsFormatPrice(detail.price)[1]
}}</span
>
<view class="promotion">拼团活动</view>
@@ -141,13 +141,6 @@ export default {
},
mounted() {},
methods: {
// 格式化金钱 1999 --> [1999,00]
formatPrice(val) {
if (typeof val == "undefined") {
return val;
}
return parseInt(val).toFixed(2).split(".");
},
getCountDownTime(val) {
let date = new Date(val);
let timeSimple = new Date(date).getTime() / 1000;

View File

@@ -32,7 +32,7 @@
{{ item.content.goodsName }}
</view>
<view class="item-price" v-if="item.price != undefined">
<span class="item-price-blod">{{ formatPrice(item.content.price)[0] }}</span>.{{ formatPrice(item.content.price)[1] }}
<span class="item-price-blod">{{ $options.filters.goodsFormatPrice(item.content.price)[0] }}</span>.{{ $options.filters.goodsFormatPrice(item.content.price)[1] }}
</view>
</view>
</view>
@@ -48,13 +48,6 @@ export default {
props: ["res", "goodsDetail", "storeDetail"],
mounted() {},
methods: {
// 格式化金钱 1999 --> [1999,00]
formatPrice(val) {
if (typeof val == "undefined") {
return val;
}
return parseInt(val).toFixed(2).split(".");
},
// 点击商品
clickGoods(val) {
uni.navigateTo({

View File

@@ -82,13 +82,7 @@ export default {
this.storeList = [];
this.init();
},
// 格式化金钱 1999 --> [1999,00]
formatPrice(val) {
if (typeof val == "undefined") {
return val;
}
return parseInt(val).toFixed(2).split(".");
},
async init() {
let res = await getStoreList(this.params);
if (res.data.success) {

View File

@@ -58,7 +58,7 @@
<!-- menu -->
<!-- 商品 -->
<div class="contant" v-if="current == 0">
<div class="content" v-if="current == 0">
<u-empty style='margin-top:100rpx' v-if="goodsList.length == 0" class="empty" text='暂无商品信息'></u-empty>
<goodsTemplate v-else :res="goodsList" :storeName="false" />
@@ -382,11 +382,11 @@ export default {
color: #999;
}
.contant {
.content {
margin-top: 20rpx;
display: flex;
flex-wrap: wrap;
justify-content: space-between;
// display: flex;
// flex-wrap: wrap;
// justify-content: space-between;
> .empty {
width: 100%;
display: flex;

View File

@@ -79,8 +79,8 @@
<view class="sp-price">
<div class="default-color" :class="{'main-color':Object.keys(skuItem.promotionMap).length ==0 }">
<span>{{ formatPrice(skuItem.goodsSku.price)[0] }}</span>
<span>.{{ formatPrice(skuItem.goodsSku.price)[1] }}</span>
<span>{{ $options.filters.goodsFormatPrice(skuItem.goodsSku.price)[0] }}</span>
<span>.{{ $options.filters.goodsFormatPrice(skuItem.goodsSku.price)[1] }}</span>
</div>
</view>
<view>
@@ -108,8 +108,8 @@
<!-- 如果有活动 并且是选中的状态,显示预估到手价格 -->
<div class="priceDetail-flowPrice" :class="{'main-color':skuItem.priceDetailDTO}"
v-if="skuItem.priceDetailDTO && skuItem.invalid == 0 && Object.keys(skuItem.promotionMap).length != 0 && skuItem.checked && skuItem.checked">
预估到手价 <span>{{ formatPrice(skuItem.priceDetailDTO.flowPrice)[0]}}</span>
<span>.{{ formatPrice(skuItem.priceDetailDTO.flowPrice)[1] }} </span>
预估到手价 <span>{{ $options.filters.goodsFormatPrice(skuItem.priceDetailDTO.flowPrice)[0]}}</span>
<span>.{{ $options.filters.goodsFormatPrice(skuItem.priceDetailDTO.flowPrice)[1] }} </span>
</div>
<div style='margin-left: 20rpx;' v-if="!skuItem.checked && skuItem.errorMessage">
{{skuItem.errorMessage}}
@@ -131,7 +131,7 @@
<div class="fullPrice">
<span class="number" v-if="cartDetail && cartDetail.priceDetailDTO">
总计:
<span>¥{{ formatPrice(cartDetail.priceDetailDTO.flowPrice)[0] }}</span>.<span>{{ formatPrice(cartDetail.priceDetailDTO.flowPrice)[1] }}</span>
<span>¥{{ $options.filters.goodsFormatPrice(cartDetail.priceDetailDTO.flowPrice)[0] }}</span>.<span>{{ $options.filters.goodsFormatPrice(cartDetail.priceDetailDTO.flowPrice)[1] }}</span>
</span>
<span class="number" v-else>总计:0.00</span>
</div>
@@ -256,17 +256,6 @@ export default {
discountDetails() {
this.discountDetailsFlag = true;
},
/**
* 格式化金钱 1999 --> [1999,00]
*/
formatPrice(val) {
if (typeof val == "undefined") {
return val;
}
return parseInt(val).toFixed(2).split(".");
},
/**
* 左滑打开删除
*/

View File

@@ -24,8 +24,8 @@
{{ item.title }}
</div>
<div class="goods-bottom">
<div class="goods-price"> ¥<span>{{ formatPrice(item.price )[0] }} </span>.{{
formatPrice(item.price )[1]
<div class="goods-price"> ¥<span>{{ $options.filters.goodsFormatPrice(item.price )[0] }} </span>.{{
$options.filters.goodsFormatPrice(item.price)[1]
}}</div>
</div>
</div>
@@ -58,13 +58,6 @@ export default {
},
mounted() {},
methods: {
// 格式化金钱 1999 --> [1999,00]
formatPrice(val) {
if (typeof val == "undefined") {
return val;
}
return parseInt(val).toFixed(2).split(".");
},
handleClick(item) {
uni.navigateTo({
url: `/pages/product/goods?id=${item.id}&goodsId=${item.goodsId}`,