feat(h5): 首页跑马灯/三数据卡接同源 /api/v1/platform/*(原地更新,mock 兜底)
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -10154,6 +10154,32 @@ function closeHomePicker() {
|
||||
<script>
|
||||
/* H1:首页静态壳,导航/触发类先 no-op,H2-H4 接 SGBridge */
|
||||
window.go=function(){};window.onTriClaimClick=function(){};window.onHomeCompareClick=function(){};window.goAuthLocation=function(){};
|
||||
|
||||
/* H1:三数据卡 + 跑马灯接同源 /api/v1/platform/*(均不鉴权;失败回落原型 mock) */
|
||||
(function(){
|
||||
// 三数据卡:替换静态数字(顺序 帮助用户/完成比价/累计节省)
|
||||
fetch('/api/v1/platform/stats').then(function(r){return r.ok?r.json():null;}).then(function(s){
|
||||
if(!s) return;
|
||||
var v=document.querySelectorAll('.home-3stat .h3s-value');
|
||||
if(v.length<3) return;
|
||||
v[0].innerHTML=s.help_users+'<span class="h3s-unit">人</span>';
|
||||
v[1].innerHTML=s.total_compares+'<span class="h3s-unit">次</span>';
|
||||
v[2].innerHTML=(s.total_saved_cents/100).toFixed(1)+'<span class="h3s-unit">元</span>';
|
||||
}).catch(function(){});
|
||||
// 跑马灯:原地更新现有行文本(不重建 DOM→保住滚动);末行是首条副本,用 data[0] 保无缝循环
|
||||
fetch('/api/v1/platform/savings-feed?limit=8').then(function(r){return r.ok?r.json():null;}).then(function(d){
|
||||
if(!d||!d.items||!d.items.length) return;
|
||||
var rows=document.querySelectorAll('#homeMarqueeTrack .home-mq-item');
|
||||
if(!rows.length) return;
|
||||
var data=d.items;
|
||||
rows.forEach(function(el,i){
|
||||
var src=(i===rows.length-1)?data[0]:data[i%data.length];
|
||||
var t=el.querySelector('.mq-time'); if(t)t.textContent=src.time;
|
||||
var u=el.querySelector('.mq-user'); if(u)u.textContent=src.masked_user;
|
||||
var a=el.querySelector('.mq-amt'); if(a)a.textContent=(src.saved_amount_cents/100).toFixed(2);
|
||||
});
|
||||
}).catch(function(){});
|
||||
})();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user