|
|
@@ -227,13 +227,14 @@
|
|
|
<view class="data-card-icon">⌚</view>
|
|
|
<view class="data-card-info">
|
|
|
<text class="data-card-title">运动手环 · 华为健康<text v-if="huaweiMock" class="data-card-badge">mock</text></text>
|
|
|
- <text class="data-card-desc">{{ huaweiBound ? '已绑定 · 数据来自华为运动健康 · 撤销即停止同步' : '绑定华为运动健康,同步步数/心率/睡眠/体重,仅用于家庭健康档案' }}</text>
|
|
|
+ <text class="data-card-desc">{{ huaweiDescText }}</text>
|
|
|
</view>
|
|
|
- <view v-if="huaweiBound" class="data-card-actions">
|
|
|
+ <view v-if="huaweiBound && !huaweiSyncing" class="data-card-actions">
|
|
|
<button class="data-card-btn" @click.stop="syncHuawei">同步</button>
|
|
|
<button class="data-card-btn data-card-btn--ghost" @click.stop="revokeHuawei">撤销</button>
|
|
|
</view>
|
|
|
- <button v-else class="data-card-btn" @click.stop="bindHuawei">绑定</button>
|
|
|
+ <button v-else-if="!huaweiBound" class="data-card-btn" @click.stop="bindHuawei">绑定</button>
|
|
|
+ <text v-else class="data-card-syncing">同步中…</text>
|
|
|
</view>
|
|
|
</view>
|
|
|
|
|
|
@@ -343,7 +344,9 @@ export default {
|
|
|
registryReady: false,
|
|
|
// 运动手环 · 华为健康(H2):绑定状态(默认未绑定,由 status 接口刷新)
|
|
|
huaweiBound: false,
|
|
|
- huaweiMock: false
|
|
|
+ huaweiMock: false,
|
|
|
+ // 同步中态(H4-7 三态之一):手动同步接口返回前展示「同步中」
|
|
|
+ huaweiSyncing: false
|
|
|
}
|
|
|
},
|
|
|
computed: {
|
|
|
@@ -452,6 +455,13 @@ export default {
|
|
|
},
|
|
|
guestHasDemoConfig: function() {
|
|
|
return this.guestBodyDims.length > 0 || this.guestCogDims.length > 0
|
|
|
+ },
|
|
|
+ // ── 运动手环 · 华为健康卡片描述文案(H4 三态:未绑定 / 已绑定 / 同步中) ──
|
|
|
+ // 未绑定态用途说明须覆盖 6 项数据(步数/距离/心率/睡眠/体重/身高),仅用于家庭健康档案展示(H4-4)
|
|
|
+ huaweiDescText: function() {
|
|
|
+ if (this.huaweiSyncing) return '同步中 · 正在从华为运动健康拉取数据,请稍候'
|
|
|
+ if (this.huaweiBound) return '已绑定 · 数据来自华为运动健康 · 撤销即停止同步'
|
|
|
+ return '绑定华为运动健康,读取步数/距离/心率/睡眠/体重/身高,仅用于家庭健康档案'
|
|
|
}
|
|
|
},
|
|
|
onShow() {
|
|
|
@@ -799,20 +809,45 @@ export default {
|
|
|
uni.showToast({ title: '获取授权链接失败', icon: 'none' })
|
|
|
})
|
|
|
},
|
|
|
- // 手动同步(接口3,空 dataType=全量 5 类)
|
|
|
+ // 手动同步(接口3,空 dataType=全量 5 类):同步中→结果按 dataType 分型给具体错误文案(H4-1)
|
|
|
syncHuawei: function() {
|
|
|
var self = this
|
|
|
+ self.huaweiSyncing = true
|
|
|
this._huaweiApi().huaweiSync({}).then(function(res) {
|
|
|
+ self.huaweiSyncing = false
|
|
|
if (!res || res.code !== 200) {
|
|
|
- var msg = (res && res.message) || '同步失败,请重新授权'
|
|
|
- uni.showToast({ title: msg, icon: 'none' })
|
|
|
+ // 全量同步失败时,优先按 dataType 分型给出具体文案(如「睡眠数据同步失败,请重新授权」)
|
|
|
+ var results = (res && res.data && (res.data.results || res.data.list)) || []
|
|
|
+ var dataTypeMsg = self._huaweiDataTypeErrorText(results)
|
|
|
+ uni.showToast({ title: dataTypeMsg, icon: 'none' })
|
|
|
return
|
|
|
}
|
|
|
uni.showToast({ title: '已触发同步', icon: 'success' })
|
|
|
}).catch(function() {
|
|
|
+ self.huaweiSyncing = false
|
|
|
uni.showToast({ title: '同步失败,请重试', icon: 'none' })
|
|
|
})
|
|
|
},
|
|
|
+ // H4-1:按 dataType 分型组装同步失败文案
|
|
|
+ _huaweiDataTypeErrorText: function(results) {
|
|
|
+ var dataTypeMap = {
|
|
|
+ step: '步数数据同步失败,请重新授权',
|
|
|
+ distance: '距离数据同步失败,请重新授权',
|
|
|
+ heartRate: '心率数据同步失败,请重新授权',
|
|
|
+ heart_rate: '心率数据同步失败,请重新授权',
|
|
|
+ sleep: '睡眠数据同步失败,请重新授权',
|
|
|
+ weight: '体重数据同步失败,请重新授权',
|
|
|
+ height: '身高数据同步失败,请重新授权'
|
|
|
+ }
|
|
|
+ for (var i = 0; i < results.length; i++) {
|
|
|
+ var it = results[i] || {}
|
|
|
+ if (it.success === false) {
|
|
|
+ var dataType = it.dataType || it.data_type || ''
|
|
|
+ if (dataTypeMap[dataType]) return dataTypeMap[dataType]
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return '同步失败,请重新授权'
|
|
|
+ },
|
|
|
// 撤销授权(合规必需,接口4):二次确认后撤销
|
|
|
revokeHuawei: function() {
|
|
|
var self = this
|
|
|
@@ -1000,6 +1035,7 @@ export default {
|
|
|
.data-card-btn { flex-shrink: 0; margin-left: 16rpx; padding: 0 24rpx; height: 56rpx; line-height: 56rpx; border-radius: 28rpx; font-size: calc(24rpx * var(--font-scale, 1)); background: $brand-primary; color: $app-surface; border: none; }
|
|
|
.data-card-btn--ghost { background: transparent; color: $brand-primary; border: 1rpx solid $brand-primary; }
|
|
|
.data-card-badge { display: inline-block; margin-left: 8rpx; padding: 0 12rpx; border-radius: 16rpx; font-size: calc(18rpx * var(--font-scale, 1)); font-weight: normal; color: #b26a00; background: #fff3d6; vertical-align: middle; }
|
|
|
+.data-card-syncing { flex-shrink: 0; margin-left: 16rpx; padding: 0 20rpx; height: 56rpx; line-height: 56rpx; border-radius: 28rpx; font-size: calc(24rpx * var(--font-scale, 1)); color: $brand-primary; background: rgba(64, 116, 230, 0.08); }
|
|
|
.data-card-assessment { flex-direction: column; align-items: stretch; padding: 24rpx; }
|
|
|
.data-card-head { display: flex; align-items: center; margin-bottom: 16rpx; }
|
|
|
.data-card-subtitle { font-size: calc(22rpx * var(--font-scale, 1)); color: $facade-text-muted; margin-left: 12rpx; }
|