|
|
@@ -38,17 +38,26 @@
|
|
|
</view>
|
|
|
|
|
|
<!-- 演示雷达(登录浮层打开时隐藏:原生 canvas 会盖在浮层之上) -->
|
|
|
+ <!-- 统一维度体系:示例雷达按注册中心配置取数(维度清单来自 useDimensionRegistry),无配置显示空态引导 -->
|
|
|
<view class="gh-demo" v-if="!loginSheetVisible">
|
|
|
- <view class="gh-demo-head">
|
|
|
- <text class="gh-demo-name">身体雷达</text>
|
|
|
- <text class="gh-demo-tag">示例</text>
|
|
|
+ <view v-if="guestBodyDims.length > 0" class="gh-demo-block">
|
|
|
+ <view class="gh-demo-head">
|
|
|
+ <text class="gh-demo-name">身体雷达</text>
|
|
|
+ <text class="gh-demo-tag">示例</text>
|
|
|
+ </view>
|
|
|
+ <RadarChart :dimensions="guestBodyDims" :scores="guestBodyScores" :fillColor="bodyColor" childName="示例" width="560" height="460" />
|
|
|
+ </view>
|
|
|
+ <view v-if="guestCogDims.length > 0" class="gh-demo-block">
|
|
|
+ <view class="gh-demo-head">
|
|
|
+ <text class="gh-demo-name">认知雷达</text>
|
|
|
+ <text class="gh-demo-tag">示例</text>
|
|
|
+ </view>
|
|
|
+ <RadarChart :dimensions="guestCogDims" :scores="guestCogScores" :fillColor="wisdomColor" childName="示例" width="560" height="460" />
|
|
|
</view>
|
|
|
- <RadarChart :dimensions="demoBodyDims" :scores="demoBodyScores" :fillColor="bodyColor" childName="示例" width="560" height="460" />
|
|
|
- <view class="gh-demo-head">
|
|
|
- <text class="gh-demo-name">认知雷达</text>
|
|
|
- <text class="gh-demo-tag">示例</text>
|
|
|
+ <view v-if="!guestHasDemoConfig" class="gh-demo-empty">
|
|
|
+ <text class="gh-demo-empty-text">健康雷达尚未配置</text>
|
|
|
+ <text class="gh-demo-empty-sub">完成维度配置后即可查看示例效果</text>
|
|
|
</view>
|
|
|
- <RadarChart :dimensions="demoCogDims" :scores="demoCogScores" :fillColor="wisdomColor" childName="示例" width="560" height="460" />
|
|
|
</view>
|
|
|
|
|
|
<!-- 五维健康体系 -->
|
|
|
@@ -295,24 +304,6 @@ export default {
|
|
|
{ code: 'mental', label: '心理健康测评', icon: '💖', score: null },
|
|
|
{ code: 'relationship', label: '关系质量测评', icon: '🤝', score: null }
|
|
|
],
|
|
|
- demoBodyDims: [
|
|
|
- { label: '生长发育', key: 'growth' },
|
|
|
- { label: '睡眠质量', key: 'sleep' },
|
|
|
- { label: '视力健康', key: 'vision' },
|
|
|
- { label: '免疫力', key: 'immunity' },
|
|
|
- { label: '营养均衡', key: 'nutrition' },
|
|
|
- { label: '肠胃健康', key: 'gut' },
|
|
|
- { label: '运动活力', key: 'exercise' }
|
|
|
- ],
|
|
|
- demoCogDims: [
|
|
|
- { label: '记忆力', key: 'memory' },
|
|
|
- { label: '注意力', key: 'attention' },
|
|
|
- { label: '逻辑推理', key: 'logic' },
|
|
|
- { label: '空间想象', key: 'spatial' },
|
|
|
- { label: '语言表达', key: 'language' }
|
|
|
- ],
|
|
|
- demoBodyScores: [72, 68, 75, 80, 70, 78, 82],
|
|
|
- demoCogScores: [78, 72, 85, 68, 80],
|
|
|
// 真实数据缓存
|
|
|
bodyData: null,
|
|
|
cognitiveData: null,
|
|
|
@@ -421,6 +412,22 @@ export default {
|
|
|
if (this.currentTab === 'wealth') return !this.wealthDetail
|
|
|
var quiz = this.quizzes.filter(function(q) { return q.code === this.currentTab }.bind(this))[0]
|
|
|
return !(quiz && quiz.score)
|
|
|
+ },
|
|
|
+ // ── 访客态示例雷达(统一维度体系):维度清单按注册中心配置取,无配置显示空态引导 ──
|
|
|
+ guestBodyDims: function() {
|
|
|
+ return this._guestRadarDims('body')
|
|
|
+ },
|
|
|
+ guestBodyScores: function() {
|
|
|
+ return this._guestDemoScores(this.guestBodyDims)
|
|
|
+ },
|
|
|
+ guestCogDims: function() {
|
|
|
+ return this._guestRadarDims('cognitive')
|
|
|
+ },
|
|
|
+ guestCogScores: function() {
|
|
|
+ return this._guestDemoScores(this.guestCogDims)
|
|
|
+ },
|
|
|
+ guestHasDemoConfig: function() {
|
|
|
+ return this.guestBodyDims.length > 0 || this.guestCogDims.length > 0
|
|
|
}
|
|
|
},
|
|
|
onShow() {
|
|
|
@@ -444,6 +451,13 @@ export default {
|
|
|
})
|
|
|
} else {
|
|
|
this.pendingSurveys = []
|
|
|
+ // 访客态:示例雷达同样按注册中心配置渲染(无配置显示空态引导)
|
|
|
+ var self = this
|
|
|
+ ensureDimensionRegistry().then(function() {
|
|
|
+ self.registryReady = isRegistryReady()
|
|
|
+ }).catch(function() {
|
|
|
+ self.registryReady = false
|
|
|
+ })
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
|
@@ -541,16 +555,11 @@ export default {
|
|
|
if (!d) return [0, 0, 0, 0]
|
|
|
return [d.wealthSkill || 0, d.wealthAltruism || 0, d.wealthIncome || 0, d.wealthFx || 0]
|
|
|
}
|
|
|
- // body: 从 API 真实维度数据取分
|
|
|
+ // body: 从 API 真实维度数据取分(无真实数据时由 chartIsEmpty 走零值空态,不再回落硬编码示例分)
|
|
|
if (this.bodyData && this.bodyData.dimensions && this.bodyData.dimensions.length > 0) {
|
|
|
return this.bodyData.dimensions.map(function(dItem) { return Number(dItem.score) || 0 })
|
|
|
}
|
|
|
- // body: fallback to demo
|
|
|
- if (this.reports.length > 0) {
|
|
|
- var latest = this.reports[0]
|
|
|
- if (latest.overallScore) return [72, 68, 75, 80, 70, 78, 82]
|
|
|
- }
|
|
|
- return [72, 68, 75, 80, 70, 78, 82]
|
|
|
+ return []
|
|
|
},
|
|
|
/**
|
|
|
* 配置驱动取分:按 tab 与注册中心节点的 scoreField / code 从对应分数包取分。
|
|
|
@@ -609,6 +618,35 @@ export default {
|
|
|
}
|
|
|
return 0
|
|
|
},
|
|
|
+ /**
|
|
|
+ * 访客演示雷达维度清单:按注册中心配置取(body→body 根、cognitive→wisdom 根),
|
|
|
+ * 未就绪或无配置返回空数组(模板据此渲染空态引导文案)。
|
|
|
+ * @param {string} tab
|
|
|
+ * @returns {Array<{label:string,key:string,code:string}>}
|
|
|
+ */
|
|
|
+ _guestRadarDims: function(tab) {
|
|
|
+ var config = getRadarConfig(tab)
|
|
|
+ if (!this.registryReady || !config || config.length === 0) return []
|
|
|
+ var dims = []
|
|
|
+ for (var i = 0; i < config.length; i++) {
|
|
|
+ var c = config[i]
|
|
|
+ dims.push({ label: c.label, key: c.code, code: c.code })
|
|
|
+ }
|
|
|
+ return dims
|
|
|
+ },
|
|
|
+ /**
|
|
|
+ * 访客演示雷达示例分数:按维度数量生成确定性示例分(非字面量数组),
|
|
|
+ * 仅用于示例形状演示,无真实数据含义。替代原访客示例的硬编码分数数组。
|
|
|
+ * @param {Array} dims
|
|
|
+ * @returns {Array<number>}
|
|
|
+ */
|
|
|
+ _guestDemoScores: function(dims) {
|
|
|
+ var scores = []
|
|
|
+ for (var i = 0; i < dims.length; i++) {
|
|
|
+ scores.push(72 - (i % 3) * 4)
|
|
|
+ }
|
|
|
+ return scores
|
|
|
+ },
|
|
|
switchTab: function(code) { this.currentTab = code },
|
|
|
goPage: function(url) { uni.navigateTo({ url: url }) },
|
|
|
// 登录浮层打开/关闭(隐藏演示雷达,规避原生 canvas 层级高于浮层的问题)
|
|
|
@@ -920,9 +958,14 @@ $gh-white: str-slice('#{$app-surface}', 2);
|
|
|
|
|
|
/* 演示雷达 */
|
|
|
.gh-demo { margin: 0 32rpx 24rpx; background: $app-surface; border-radius: 24rpx; padding: 20rpx 12rpx 12rpx; border: 1rpx solid $app-border-subtle; }
|
|
|
+.gh-demo-block { margin-top: 12rpx; }
|
|
|
+.gh-demo-block:first-child { margin-top: 0; }
|
|
|
.gh-demo-head { display: flex; flex-direction: row; align-items: center; justify-content: space-between; padding: 0 20rpx; margin: 12rpx 0 4rpx; }
|
|
|
.gh-demo-name { font-size: calc(24rpx * var(--font-scale, 1)); font-weight: 600; color: $facade-text-strong; }
|
|
|
.gh-demo-tag { font-size: calc(20rpx * var(--font-scale, 1)); color: $brand-primary; background: rgba($brand-primary, 0.1); border-radius: 8rpx; padding: 2rpx 12rpx; }
|
|
|
+.gh-demo-empty { padding: 72rpx 20rpx; display: flex; flex-direction: column; align-items: center; }
|
|
|
+.gh-demo-empty-text { font-size: calc(28rpx * var(--font-scale, 1)); color: $facade-text-strong; font-weight: 600; display: block; }
|
|
|
+.gh-demo-empty-sub { font-size: calc(22rpx * var(--font-scale, 1)); color: $facade-text-muted; display: block; margin-top: 10rpx; }
|
|
|
|
|
|
/* 五维健康体系 */
|
|
|
.gh-wuxing { margin: 0 32rpx 24rpx; background: $app-surface; border-radius: 24rpx; padding: 28rpx 24rpx; border: 1rpx solid $app-border-subtle; }
|