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

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