|
@@ -11,9 +11,6 @@
|
|
|
<view class="product-card" v-for="prod in displayProducts" :key="prod.id" @click="onProductClick(prod)">
|
|
<view class="product-card" v-for="prod in displayProducts" :key="prod.id" @click="onProductClick(prod)">
|
|
|
<image class="product-img" :src="getImageUrl(prod.coverImage) || '/static/default-product.png'" mode="aspectFill" />
|
|
<image class="product-img" :src="getImageUrl(prod.coverImage) || '/static/default-product.png'" mode="aspectFill" />
|
|
|
<text class="product-name line-clamp-2">{{ prod.name }}</text>
|
|
<text class="product-name line-clamp-2">{{ prod.name }}</text>
|
|
|
- <view class="weight-badges" v-if="prod._badges && prod._badges.length">
|
|
|
|
|
- <text class="weight-badge" v-for="badge in prod._badges" :key="badge.name" :style="{ background: badge.color + '20', color: badge.color }">{{ badge.name }}{{ badge.weight }}%</text>
|
|
|
|
|
- </view>
|
|
|
|
|
<view class="price-row">
|
|
<view class="price-row">
|
|
|
<text class="product-price" v-if="prod.priceLabel">{{ prod.priceLabel }}</text>
|
|
<text class="product-price" v-if="prod.priceLabel">{{ prod.priceLabel }}</text>
|
|
|
<text class="product-price" v-else-if="prod.price">{{ formatPriceWithSymbol(prod.price) }}</text>
|
|
<text class="product-price" v-else-if="prod.price">{{ formatPriceWithSymbol(prod.price) }}</text>
|
|
@@ -35,14 +32,6 @@
|
|
|
import { getDimensionProducts, clickRepurchaseReminder } from '../utils/api.js'
|
|
import { getDimensionProducts, clickRepurchaseReminder } from '../utils/api.js'
|
|
|
import config from '@/config.js'
|
|
import config from '@/config.js'
|
|
|
|
|
|
|
|
-var DIMENSION_MAP = {
|
|
|
|
|
- body: { name: '身', color: '#FF8C42' },
|
|
|
|
|
- mind: { name: '心', color: '#FF6B9D' },
|
|
|
|
|
- wisdom: { name: '智', color: '#6366F1' },
|
|
|
|
|
- action: { name: '行', color: '#10B981' },
|
|
|
|
|
- wealth: { name: '富', color: '#F59E0B' }
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
export default {
|
|
export default {
|
|
|
props: {
|
|
props: {
|
|
|
dimensionCode: { type: String, default: '' },
|
|
dimensionCode: { type: String, default: '' },
|
|
@@ -62,12 +51,7 @@ export default {
|
|
|
},
|
|
},
|
|
|
computed: {
|
|
computed: {
|
|
|
displayProducts: function() {
|
|
displayProducts: function() {
|
|
|
- var list = this.products && this.products.length > 0 ? this.products : this.selfProducts
|
|
|
|
|
- var self = this
|
|
|
|
|
- return (list || []).map(function(item) {
|
|
|
|
|
- item._badges = self.parseWeights(item.dimensionWeights)
|
|
|
|
|
- return item
|
|
|
|
|
- })
|
|
|
|
|
|
|
+ return this.products && this.products.length > 0 ? this.products : this.selfProducts
|
|
|
},
|
|
},
|
|
|
emptyText: function() {
|
|
emptyText: function() {
|
|
|
// 有 familyId(已登录且选中孩子)但推荐接口无数据
|
|
// 有 familyId(已登录且选中孩子)但推荐接口无数据
|
|
@@ -122,21 +106,6 @@ export default {
|
|
|
if (price == null) return '免费'
|
|
if (price == null) return '免费'
|
|
|
return '¥' + (Number(price) / 100).toFixed(2)
|
|
return '¥' + (Number(price) / 100).toFixed(2)
|
|
|
},
|
|
},
|
|
|
- parseWeights: function(str) {
|
|
|
|
|
- if (!str) return []
|
|
|
|
|
- try {
|
|
|
|
|
- var obj = JSON.parse(str)
|
|
|
|
|
- var result = []
|
|
|
|
|
- for (var key in obj) {
|
|
|
|
|
- if (obj[key] > 0 && DIMENSION_MAP[key]) {
|
|
|
|
|
- result.push({ name: DIMENSION_MAP[key].name, color: DIMENSION_MAP[key].color, weight: obj[key] })
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- return result
|
|
|
|
|
- } catch (e) {
|
|
|
|
|
- return []
|
|
|
|
|
- }
|
|
|
|
|
- },
|
|
|
|
|
getImageUrl: function(path) {
|
|
getImageUrl: function(path) {
|
|
|
return config.API_BASE_URL + path
|
|
return config.API_BASE_URL + path
|
|
|
}
|
|
}
|
|
@@ -189,19 +158,6 @@ export default {
|
|
|
color: #333;
|
|
color: #333;
|
|
|
padding: 12rpx 16rpx 0;
|
|
padding: 12rpx 16rpx 0;
|
|
|
}
|
|
}
|
|
|
-.weight-badges {
|
|
|
|
|
- display: flex;
|
|
|
|
|
- flex-direction: row;
|
|
|
|
|
- flex-wrap: wrap;
|
|
|
|
|
- gap: 4rpx;
|
|
|
|
|
- padding: 4rpx 16rpx 0;
|
|
|
|
|
-}
|
|
|
|
|
-.weight-badge {
|
|
|
|
|
- font-size: 16rpx;
|
|
|
|
|
- padding: 1rpx 8rpx;
|
|
|
|
|
- border-radius: 6rpx;
|
|
|
|
|
- font-weight: 500;
|
|
|
|
|
-}
|
|
|
|
|
.price-row {
|
|
.price-row {
|
|
|
display: flex;
|
|
display: flex;
|
|
|
flex-direction: row;
|
|
flex-direction: row;
|