Browse Source

主页布局价格处理价格小数点大小显示

master
dy-hu 1 year ago
parent
commit
28f8f81773
  1. 8
      components/canvasShow/basics/classifyHeader/app/index.vue
  2. 82
      components/canvasShow/basics/product/app/index.vue
  3. 6
      main.js
  4. 27
      utils/priceFilter.js

8
components/canvasShow/basics/classifyHeader/app/index.vue

@ -73,7 +73,8 @@
</image> </image>
<!-- #endif --> <!-- #endif -->
<div class="price"> <div class="price">
¥ {{item.price}}
¥<span style="margin-left: 5rpx">{{item.price | radixPointBefore}}</span>
<span style="font-size: 20rpx">{{item.price | radixPointAfter}}</span>
</div> </div>
<!-- <div class="original-price">--> <!-- <div class="original-price">-->
<!-- ¥ {{item.originalPrice}}--> <!-- ¥ {{item.originalPrice}}-->
@ -240,6 +241,7 @@ const API = require('../../../../../config/api')
height: auto; height: auto;
overflow: hidden; overflow: hidden;
margin: 5upx 34upx; margin: 5upx 34upx;
background-color: #FAFAFA;
&+.btn-more { &+.btn-more {
margin-top: 20upx; margin-top: 20upx;
@ -268,8 +270,8 @@ const API = require('../../../../../config/api')
} }
&-warp { &-warp {
height: 540upx;
width: 386upx !important;
height: 575rpx;
width: 386rpx !important;
margin-left: 18upx; margin-left: 18upx;
margin-right: 18upx; margin-right: 18upx;
} }

82
components/canvasShow/basics/product/app/index.vue

@ -96,13 +96,14 @@
</div> </div>
<div class="item3" v-if="componentContent.productStyleValue == '3'"> <div class="item3" v-if="componentContent.productStyleValue == '3'">
<div class="item3_name">{{ item.productName }}</div>
<!-- <div class="item3_name">{{ item.productName }}</div>-->
<div class="item3_image"> <div class="item3_image">
<img :src="item.image" fit="contain"></img> <img :src="item.image" fit="contain"></img>
</div> </div>
<div class="item3_btn_row">
<div class="item3_btn">点击</div>
</div>
<div class="item3_name">{{ item.productName }}</div>
<!-- <div class="item3_btn_row">
</div>-->
</div> </div>
<div class="item4" v-if="componentContent.productStyleValue == '4'"> <div class="item4" v-if="componentContent.productStyleValue == '4'">
@ -117,7 +118,7 @@
</div> </div>
<div class="item4_arrow"> <div class="item4_arrow">
<img src="../../../static/images/product/icon_right_arrow.png">
<img src="http://36.138.125.206:8081/ceres-local-file/image/home_item_forward.png">
</div> </div>
</div> </div>
@ -239,13 +240,14 @@
<div class="item3" @click="jumpProductDetail(item)" <div class="item3" @click="jumpProductDetail(item)"
v-if="componentContent.productStyleValue == '3'"> v-if="componentContent.productStyleValue == '3'">
<div class="item3_name">{{ item.productName }}</div>
<!-- <div class="item3_name">{{ item.productName }}</div>-->
<div class="item3_image"> <div class="item3_image">
<img :src="item.image" fit="contain"></img> <img :src="item.image" fit="contain"></img>
</div> </div>
<div class="item3_btn_row">
<!-- <div class="item3_btn_row">
<div class="item3_btn">点击</div> <div class="item3_btn">点击</div>
</div>
</div>-->
<div class="item3_name">{{ item.productName }}</div>
</div> </div>
<div class="item4" @click="jumpProductDetail(item)" <div class="item4" @click="jumpProductDetail(item)"
@ -257,11 +259,15 @@
</div> </div>
<div class="item4_info"> <div class="item4_info">
<div class="item4_name">{{ item.productName }}</div> <div class="item4_name">{{ item.productName }}</div>
<div class="item4_price">¥{{ item.price }}</div>
<!-- <div class="item4_price">¥{{ item.price }}</div>-->
<div class="item4_price">
¥<span style="margin-left: 5rpx">{{item.price | radixPointBefore}}</span>
<span style="font-size: 20rpx">{{item.price | radixPointAfter}}</span>
</div>
</div> </div>
<div class="item4_arrow"> <div class="item4_arrow">
<img src="../../../static/images/product/icon_right_arrow.png">
<img src="http://36.138.125.206:8081/ceres-local-file/image/home_item_forward.png">
</div> </div>
</div> </div>
@ -299,7 +305,14 @@
methods: { methods: {
swiperChange(e) { swiperChange(e) {
this.swiperCurrent = e.detail.current; this.swiperCurrent = e.detail.current;
}
},
handlePrice(price) {
//
let splitPrice = price.splice('.')
//使
return `${splitPrice[0]}.<span style="font-size:12px;">${splitPrice[1]}</span>`
}
} }
} }
</script> </script>
@ -327,7 +340,7 @@
flex-direction: row; flex-direction: row;
&.swiper { &.swiper {
height: 470upx;
height: 415rpx;
} }
} }
@ -608,31 +621,36 @@
align-content: center; align-content: center;
justify-content: center; justify-content: center;
align-items: center; align-items: center;
background: #F6F6F8;
box-shadow: 0upx 12upx 24upx 0upx #EDEDED;
border-radius: 24upx;
border: 1upx solid #FFFFFF;
width: 280upx;
height: 430upx;
margin: 10upx 20upx;
background: #ffffff;
box-shadow: 0rpx 12rpx 24rpx 0rpx #EDEDED;
border-radius: 24rpx;
border: 1rpx solid #FFFFFF;
width: 280rpx;
height: 380rpx;
margin: 10rpx 20rpx;
.item3_name { .item3_name {
height: 90rpx;
font-family: Source Han Sans CN; font-family: Source Han Sans CN;
font-weight: 400; font-weight: 400;
font-size: 24upx;
font-size: 24rpx;
color: #252744; color: #252744;
margin-top: 15upx;
//text-align: center;
margin-top:20rpx;
padding-left: 10rpx;
padding-right: 10rpx;
} }
.item3_image { .item3_image {
margin: 15upx;
//margin: 15rpx;
width: 100%; width: 100%;
padding: 10upx;
//padding: 10rpx;
box-sizing:border-box; box-sizing:border-box;
img { img {
width: 100%;
width: 99.5%;
border-top-left-radius: 24rpx;
border-top-right-radius: 24rpx;
} }
} }
@ -700,8 +718,8 @@
.item4_info { .item4_info {
height: 100%; height: 100%;
padding-top: 46upx;
padding-bottom: 46upx;
padding-top: 30rpx;
padding-bottom: 30rpx;
flex: 1; flex: 1;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
@ -714,21 +732,21 @@
.item4_name { .item4_name {
font-family: Microsoft YaHei; font-family: Microsoft YaHei;
font-weight: bold; font-weight: bold;
font-size: 28upx;
font-size: 32rpx;
color: #252744; color: #252744;
} }
.item4_price { .item4_price {
font-family: Source Han Sans CN; font-family: Source Han Sans CN;
font-weight: 400;
font-size: 28upx;
font-weight: bold;
font-size: 32rpx;
color: #252744; color: #252744;
} }
} }
.item4_arrow { .item4_arrow {
width: 20upx;
height: 20upx;
width: 21rpx;
height: 36rpx;
margin: 24upx; margin: 24upx;
img { img {

6
main.js

@ -16,6 +16,12 @@ Vue.config.productionTip = false
import store from './store' import store from './store'
import _ from 'lodash' import _ from 'lodash'
import { PriceFilter } from './utils/priceFilter.js'
// 遍历文件中的所有方法注册为一个个的过滤器
Object.keys(PriceFilter).forEach(key => {
Vue.filter(key, PriceFilter[key])
})
import {jump,jumpToTabbar,goBack,getJumpParam} from './utils/jumpUtil' import {jump,jumpToTabbar,goBack,getJumpParam} from './utils/jumpUtil'
Vue.prototype.$store = store Vue.prototype.$store = store

27
utils/priceFilter.js

@ -0,0 +1,27 @@
// 分别截取 价格小数点前后的数字
export const PriceFilter = {
// 小数点前
radixPointBefore: price => {
if (price == undefined) {
return
}
price = price.toString()
if (price && price.indexOf(".") != -1) {
return price.substring(0, price.indexOf("."))
} else {
return price;
}
},
// 小数点后
radixPointAfter: price => {
if (price == undefined) {
return
}
price = price.toString()
if (price && price.indexOf(".") != -1) {
return price.substring(price.indexOf("."), price.length)
} else {
return ".00";
}
}
}
Loading…
Cancel
Save