|
|
@@ -18,7 +18,7 @@
|
|
|
<text class="row-name">{{ g.name }}</text>
|
|
|
<text class="row-sold">已售 {{ formatSold(g.sold) }}</text>
|
|
|
</view>
|
|
|
- <text class="price">¥{{ formatPrice(g.price) }}</text>
|
|
|
+ <text class="price">¥{{ displayPrice(g) }}</text>
|
|
|
<view class="add-btn" @click.stop="handleCartClick(g)">+</view>
|
|
|
</view>
|
|
|
</view>
|
|
|
@@ -33,7 +33,7 @@
|
|
|
<text class="grid-name">{{ g.name }}</text>
|
|
|
<view class="grid-bottom-row">
|
|
|
<view class="grid-price-col">
|
|
|
- <text class="price">¥{{ formatPrice(g.price) }}</text>
|
|
|
+ <text class="price">¥{{ displayPrice(g) }}</text>
|
|
|
<text class="sold">已售 {{ formatSold(g.sold) }}</text>
|
|
|
</view>
|
|
|
<!-- 加购:圆形底 + 白色购物车 SVG,与设计稿一致 -->
|
|
|
@@ -96,11 +96,28 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
|
+ /**
|
|
|
+ * 无价格商品(priceType=0):列表不展示数字价,统一用 -- 提示需询价
|
|
|
+ * @param {Object} g 商品
|
|
|
+ * @returns {boolean}
|
|
|
+ */
|
|
|
+ isNoPrice(g) {
|
|
|
+ return Number(g && g.priceType) === 0
|
|
|
+ },
|
|
|
formatPrice(val) {
|
|
|
const n = parseFloat(val)
|
|
|
if (isNaN(n)) return '0'
|
|
|
return n % 1 === 0 ? String(n) : n.toFixed(2)
|
|
|
},
|
|
|
+ /**
|
|
|
+ * 列表价格文案:无价格商品显示 --,其余走数字格式化
|
|
|
+ * @param {Object} g 商品
|
|
|
+ * @returns {string}
|
|
|
+ */
|
|
|
+ displayPrice(g) {
|
|
|
+ if (this.isNoPrice(g)) return '--'
|
|
|
+ return this.formatPrice(g && g.price)
|
|
|
+ },
|
|
|
formatSold(val) {
|
|
|
const n = parseInt(val, 10) || 0
|
|
|
if (n >= 10000) return (n / 10000).toFixed(1) + '万+'
|
|
|
@@ -109,13 +126,17 @@ export default {
|
|
|
goDetail(g) {
|
|
|
this.pageTo({ url: `/pages/goods/detail?id=${g.id}&account=${this.account}&hdId=${this.hdId}` })
|
|
|
},
|
|
|
- /** 单规格直接加购,多规格跳转详情选规格 */
|
|
|
+ /** 单规格直接加购,多规格跳转详情选规格;无价格商品拦截并提示询价 */
|
|
|
handleCartClick(g) {
|
|
|
if (!g || !g.id) return
|
|
|
if (Number(g.specEnabled) === 1) {
|
|
|
this.goDetail(g)
|
|
|
return
|
|
|
}
|
|
|
+ if (this.isNoPrice(g)) {
|
|
|
+ this.$msg('暂无价格,请向商家询价')
|
|
|
+ return
|
|
|
+ }
|
|
|
if (!(Number(g.price) > 0)) {
|
|
|
this.$msg('商品还没有价格哦')
|
|
|
return
|
|
|
@@ -128,7 +149,7 @@ export default {
|
|
|
}
|
|
|
const goods = {
|
|
|
...g,
|
|
|
- priceType: 1,
|
|
|
+ priceType: g.priceType != null ? g.priceType : 1,
|
|
|
cover: g.coverUrl || g.cover,
|
|
|
smallCover: g.coverUrl || g.cover
|
|
|
}
|