|
@@ -34,7 +34,7 @@
|
|
|
</view>
|
|
</view>
|
|
|
<!-- 五维权重彩条 -->
|
|
<!-- 五维权重彩条 -->
|
|
|
<view v-if="article.relatedDimensions" class="detail-dimensions">
|
|
<view v-if="article.relatedDimensions" class="detail-dimensions">
|
|
|
- <view v-for="dim in parseDimensions(article.relatedDimensions)" :key="dim.code" class="dim-bar-item">
|
|
|
|
|
|
|
+ <view v-for="dim in parseDimensions(article)" :key="dim.code" class="dim-bar-item">
|
|
|
<view class="dim-bar" :style="{ background: dim.color, width: dim.weight + '%' }"></view>
|
|
<view class="dim-bar" :style="{ background: dim.color, width: dim.weight + '%' }"></view>
|
|
|
<text class="dim-label">{{ dim.name }}</text>
|
|
<text class="dim-label">{{ dim.name }}</text>
|
|
|
</view>
|
|
</view>
|
|
@@ -191,17 +191,46 @@ export default {
|
|
|
if (!dateStr) return ''
|
|
if (!dateStr) return ''
|
|
|
return dateStr.slice(0, 10)
|
|
return dateStr.slice(0, 10)
|
|
|
},
|
|
},
|
|
|
- parseDimensions(str) {
|
|
|
|
|
- if (!str) return []
|
|
|
|
|
|
|
+ parseDimensions: function(article) {
|
|
|
var dimMap = {
|
|
var dimMap = {
|
|
|
- body: { code: 'body', color: '#FF8C42', name: '身', weight: 20 },
|
|
|
|
|
- mind: { code: 'mind', color: '#6366F1', name: '智', weight: 20 },
|
|
|
|
|
- wisdom: { code: 'wisdom', color: '#FF6B9D', name: '心', weight: 20 },
|
|
|
|
|
- action: { code: 'action', color: '#10B981', name: '行', weight: 20 },
|
|
|
|
|
- wealth: { code: 'wealth', color: '#F59E0B', name: '富', weight: 20 }
|
|
|
|
|
|
|
+ body: { code: 'body', color: '#FF8C42', name: '身' },
|
|
|
|
|
+ mind: { code: 'mind', color: '#FF6B9D', name: '心' },
|
|
|
|
|
+ wisdom: { code: 'wisdom', color: '#6366F1', name: '智' },
|
|
|
|
|
+ action: { code: 'action', color: '#10B981', name: '行' },
|
|
|
|
|
+ wealth: { code: 'wealth', color: '#F59E0B', name: '富' }
|
|
|
}
|
|
}
|
|
|
- var codes = str.split(',').map(function(s) { return s.trim().toLowerCase() })
|
|
|
|
|
- return codes.filter(function(c) { return dimMap[c] }).map(function(c) { return dimMap[c] })
|
|
|
|
|
|
|
+ var raw = article && article.relatedDimensions
|
|
|
|
|
+ ? article.relatedDimensions.split(',').map(function(s) { return s.trim().toLowerCase() })
|
|
|
|
|
+ : []
|
|
|
|
|
+ var weights = null
|
|
|
|
|
+ if (article && article.dimensionWeights) {
|
|
|
|
|
+ try {
|
|
|
|
|
+ var w = JSON.parse(article.dimensionWeights)
|
|
|
|
|
+ if (w && typeof w === 'object') weights = w
|
|
|
|
|
+ } catch (e) {}
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!weights) {
|
|
|
|
|
+ var n = raw.filter(function(c) { return dimMap[c] }).length
|
|
|
|
|
+ if (n > 0) {
|
|
|
|
|
+ var base = Math.floor(100 / n)
|
|
|
|
|
+ var rem = 100 - base * n
|
|
|
|
|
+ weights = {}
|
|
|
|
|
+ var i = 0
|
|
|
|
|
+ raw.forEach(function(c) {
|
|
|
|
|
+ if (!dimMap[c]) return
|
|
|
|
|
+ weights[c] = i < rem ? base + 1 : base
|
|
|
|
|
+ i++
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ return raw.filter(function(c) { return dimMap[c] }).map(function(c) {
|
|
|
|
|
+ return {
|
|
|
|
|
+ code: dimMap[c].code,
|
|
|
|
|
+ name: dimMap[c].name,
|
|
|
|
|
+ color: dimMap[c].color,
|
|
|
|
|
+ weight: (weights && weights[c]) ? weights[c] : 20
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
},
|
|
},
|
|
|
getOptionLetter(idx) {
|
|
getOptionLetter(idx) {
|
|
|
return String.fromCharCode(65 + idx)
|
|
return String.fromCharCode(65 + idx)
|