diff --git a/h5/home/assets/home/index/banner-top-cropped.png b/h5/home/assets/home/index/banner-top-cropped.png new file mode 100644 index 0000000..930b1c6 Binary files /dev/null and b/h5/home/assets/home/index/banner-top-cropped.png differ diff --git a/h5/home/assets/home/index/banner-top.png b/h5/home/assets/home/index/banner-top.png new file mode 100644 index 0000000..46a3d6e Binary files /dev/null and b/h5/home/assets/home/index/banner-top.png differ diff --git a/h5/home/assets/home/index/card-stats-bg.png b/h5/home/assets/home/index/card-stats-bg.png new file mode 100644 index 0000000..54d9994 Binary files /dev/null and b/h5/home/assets/home/index/card-stats-bg.png differ diff --git a/h5/home/assets/home/index/card-waimai-bg.png b/h5/home/assets/home/index/card-waimai-bg.png new file mode 100644 index 0000000..63dd02e Binary files /dev/null and b/h5/home/assets/home/index/card-waimai-bg.png differ diff --git a/h5/home/assets/home/index/categories/express.png b/h5/home/assets/home/index/categories/express.png new file mode 100644 index 0000000..5c4038e Binary files /dev/null and b/h5/home/assets/home/index/categories/express.png differ diff --git a/h5/home/assets/home/index/categories/hotel.png b/h5/home/assets/home/index/categories/hotel.png new file mode 100644 index 0000000..478665e Binary files /dev/null and b/h5/home/assets/home/index/categories/hotel.png differ diff --git a/h5/home/assets/home/index/categories/invite-earn.png b/h5/home/assets/home/index/categories/invite-earn.png new file mode 100644 index 0000000..621b9c7 Binary files /dev/null and b/h5/home/assets/home/index/categories/invite-earn.png differ diff --git a/h5/home/assets/home/index/categories/movie.png b/h5/home/assets/home/index/categories/movie.png new file mode 100644 index 0000000..1fe6802 Binary files /dev/null and b/h5/home/assets/home/index/categories/movie.png differ diff --git a/h5/home/assets/home/index/categories/taxi.png b/h5/home/assets/home/index/categories/taxi.png new file mode 100644 index 0000000..9ff52f4 Binary files /dev/null and b/h5/home/assets/home/index/categories/taxi.png differ diff --git a/h5/home/assets/home/index/chevron-double-fade.png b/h5/home/assets/home/index/chevron-double-fade.png new file mode 100644 index 0000000..3e71d69 Binary files /dev/null and b/h5/home/assets/home/index/chevron-double-fade.png differ diff --git a/h5/home/assets/home/index/chevron-double.png b/h5/home/assets/home/index/chevron-double.png new file mode 100644 index 0000000..4731397 Binary files /dev/null and b/h5/home/assets/home/index/chevron-double.png differ diff --git a/h5/home/assets/home/index/coupon-claim-bg.png b/h5/home/assets/home/index/coupon-claim-bg.png new file mode 100644 index 0000000..f6349c0 Binary files /dev/null and b/h5/home/assets/home/index/coupon-claim-bg.png differ diff --git a/h5/home/assets/home/index/coupon-ticket-cluster.png b/h5/home/assets/home/index/coupon-ticket-cluster.png new file mode 100644 index 0000000..342ea3b Binary files /dev/null and b/h5/home/assets/home/index/coupon-ticket-cluster.png differ diff --git a/h5/home/assets/home/index/feed/chabaidao.png b/h5/home/assets/home/index/feed/chabaidao.png new file mode 100644 index 0000000..839cb64 Binary files /dev/null and b/h5/home/assets/home/index/feed/chabaidao.png differ diff --git a/h5/home/assets/home/index/feed/jubaoyuan.png b/h5/home/assets/home/index/feed/jubaoyuan.png new file mode 100644 index 0000000..d00185f Binary files /dev/null and b/h5/home/assets/home/index/feed/jubaoyuan.png differ diff --git a/h5/home/assets/home/index/feed/luckin.png b/h5/home/assets/home/index/feed/luckin.png new file mode 100644 index 0000000..577e0e9 Binary files /dev/null and b/h5/home/assets/home/index/feed/luckin.png differ diff --git a/h5/home/assets/home/index/feed/mcdonalds.png b/h5/home/assets/home/index/feed/mcdonalds.png new file mode 100644 index 0000000..c7ecfac Binary files /dev/null and b/h5/home/assets/home/index/feed/mcdonalds.png differ diff --git a/h5/home/assets/home/index/feed/pizzahut.png b/h5/home/assets/home/index/feed/pizzahut.png new file mode 100644 index 0000000..c98d5a9 Binary files /dev/null and b/h5/home/assets/home/index/feed/pizzahut.png differ diff --git a/h5/home/assets/home/index/feed/subway.png b/h5/home/assets/home/index/feed/subway.png new file mode 100644 index 0000000..7dce2cc Binary files /dev/null and b/h5/home/assets/home/index/feed/subway.png differ diff --git a/h5/home/assets/home/index/feed/yoshinoya.png b/h5/home/assets/home/index/feed/yoshinoya.png new file mode 100644 index 0000000..0255fcd Binary files /dev/null and b/h5/home/assets/home/index/feed/yoshinoya.png differ diff --git a/h5/home/assets/home/index/home-tri-arrow-button.svg b/h5/home/assets/home/index/home-tri-arrow-button.svg new file mode 100644 index 0000000..159b613 --- /dev/null +++ b/h5/home/assets/home/index/home-tri-arrow-button.svg @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/h5/home/assets/home/index/money-bag.png b/h5/home/assets/home/index/money-bag.png new file mode 100644 index 0000000..a5ad643 Binary files /dev/null and b/h5/home/assets/home/index/money-bag.png differ diff --git a/h5/home/assets/home/index/no-deal-search.png b/h5/home/assets/home/index/no-deal-search.png new file mode 100644 index 0000000..de623d9 Binary files /dev/null and b/h5/home/assets/home/index/no-deal-search.png differ diff --git a/h5/home/assets/home/index/oneclick-claim.png b/h5/home/assets/home/index/oneclick-claim.png new file mode 100644 index 0000000..3710296 Binary files /dev/null and b/h5/home/assets/home/index/oneclick-claim.png differ diff --git a/h5/home/assets/home/index/piggy-bank.png b/h5/home/assets/home/index/piggy-bank.png new file mode 100644 index 0000000..73be580 Binary files /dev/null and b/h5/home/assets/home/index/piggy-bank.png differ diff --git a/h5/home/assets/home/index/tap-hand-generated.png b/h5/home/assets/home/index/tap-hand-generated.png new file mode 100644 index 0000000..9a59318 Binary files /dev/null and b/h5/home/assets/home/index/tap-hand-generated.png differ diff --git a/h5/home/assets/shared/badges/lowest-price.png b/h5/home/assets/shared/badges/lowest-price.png new file mode 100644 index 0000000..d39ea1e Binary files /dev/null and b/h5/home/assets/shared/badges/lowest-price.png differ diff --git a/h5/home/assets/shared/cta/compare-result.png b/h5/home/assets/shared/cta/compare-result.png new file mode 100644 index 0000000..4af3995 Binary files /dev/null and b/h5/home/assets/shared/cta/compare-result.png differ diff --git a/h5/home/assets/shared/cta/one-click-compare-gray.png b/h5/home/assets/shared/cta/one-click-compare-gray.png new file mode 100644 index 0000000..380a34d Binary files /dev/null and b/h5/home/assets/shared/cta/one-click-compare-gray.png differ diff --git a/h5/home/assets/shared/cta/one-click-compare-square.png b/h5/home/assets/shared/cta/one-click-compare-square.png new file mode 100644 index 0000000..10ca133 Binary files /dev/null and b/h5/home/assets/shared/cta/one-click-compare-square.png differ diff --git a/h5/home/assets/shared/cta/one-click-compare.png b/h5/home/assets/shared/cta/one-click-compare.png new file mode 100644 index 0000000..4af3995 Binary files /dev/null and b/h5/home/assets/shared/cta/one-click-compare.png differ diff --git a/h5/home/assets/shared/cta/tap-hint.svg b/h5/home/assets/shared/cta/tap-hint.svg new file mode 100644 index 0000000..daeda05 --- /dev/null +++ b/h5/home/assets/shared/cta/tap-hint.svg @@ -0,0 +1,3 @@ + + + diff --git a/h5/home/assets/shared/cta/today-coupon-orange.png b/h5/home/assets/shared/cta/today-coupon-orange.png new file mode 100644 index 0000000..f886244 Binary files /dev/null and b/h5/home/assets/shared/cta/today-coupon-orange.png differ diff --git a/h5/home/assets/shared/gestures/tap-hint.svg b/h5/home/assets/shared/gestures/tap-hint.svg new file mode 100644 index 0000000..daeda05 --- /dev/null +++ b/h5/home/assets/shared/gestures/tap-hint.svg @@ -0,0 +1,3 @@ + + + diff --git a/h5/home/assets/shared/home-snapshots/sb-home.png b/h5/home/assets/shared/home-snapshots/sb-home.png new file mode 100644 index 0000000..873147f Binary files /dev/null and b/h5/home/assets/shared/home-snapshots/sb-home.png differ diff --git a/h5/home/assets/shared/icons/README.md b/h5/home/assets/shared/icons/README.md new file mode 100644 index 0000000..5555930 --- /dev/null +++ b/h5/home/assets/shared/icons/README.md @@ -0,0 +1,43 @@ +# Shared Icons + +通用图标的单一事实源(canonical source)。每个图标都是独立 SVG 文件,但**实际页面里必须内联 SVG markup**(不用 `` 或 `` 引用),符合 prototypes 仓库"每个 HTML 自包含"原则。 + +## 工作流 + +1. 改图标 → 改这里的 SVG 文件 +2. 在所有用到的 HTML 里同步替换内联 SVG markup +3. DESIGN.md 引用本目录路径作为基准 + +## 现有图标 + +| 文件 | 用途 | 推荐内联尺寸 | +|---|---|---| +| `back-chevron.svg` | 顶部导航返回按钮 | 24×24 | +| `tab-home-outline.svg` | 底 tab "首页" 未选中态 | 24×24 | +| `tab-home-filled.svg` | 底 tab "首页" 选中态(黄填充)| 24×24 | +| `tab-welfare-outline.svg` | 底 tab "福利" 未选中态 | 24×24 | +| `tab-welfare-filled.svg` | 底 tab "福利" 选中态(黄填充)| 24×24 | +| `tab-profile-outline.svg` | 底 tab "我的" 未选中态 | 24×24 | +| `tab-profile-filled.svg` | 底 tab "我的" 选中态(黄填充)| 24×24 | + +## 标准 button 包装 + +```html + +``` + +```css +.btn-back { + width: 44px; height: 44px; + display: flex; align-items: center; justify-content: center; + background: transparent; border: none; padding: 0; + cursor: pointer; -webkit-tap-highlight-color: transparent; + flex-shrink: 0; +} +.btn-back:active { opacity: 0.5; } +.btn-back svg { width: 24px; height: 24px; display: block; } +``` diff --git a/h5/home/assets/shared/icons/back-chevron.svg b/h5/home/assets/shared/icons/back-chevron.svg new file mode 100644 index 0000000..5eeb353 --- /dev/null +++ b/h5/home/assets/shared/icons/back-chevron.svg @@ -0,0 +1,3 @@ + + + diff --git a/h5/home/assets/shared/icons/tab-home-filled.svg b/h5/home/assets/shared/icons/tab-home-filled.svg new file mode 100644 index 0000000..2e6fe3d --- /dev/null +++ b/h5/home/assets/shared/icons/tab-home-filled.svg @@ -0,0 +1,4 @@ + + + + diff --git a/h5/home/assets/shared/icons/tab-home-outline.svg b/h5/home/assets/shared/icons/tab-home-outline.svg new file mode 100644 index 0000000..f453eca --- /dev/null +++ b/h5/home/assets/shared/icons/tab-home-outline.svg @@ -0,0 +1,4 @@ + + + + diff --git a/h5/home/assets/shared/icons/tab-profile-filled.svg b/h5/home/assets/shared/icons/tab-profile-filled.svg new file mode 100644 index 0000000..defee4c --- /dev/null +++ b/h5/home/assets/shared/icons/tab-profile-filled.svg @@ -0,0 +1,4 @@ + + + + diff --git a/h5/home/assets/shared/icons/tab-profile-outline.svg b/h5/home/assets/shared/icons/tab-profile-outline.svg new file mode 100644 index 0000000..57c4dab --- /dev/null +++ b/h5/home/assets/shared/icons/tab-profile-outline.svg @@ -0,0 +1,4 @@ + + + + diff --git a/h5/home/assets/shared/icons/tab-welfare-filled.svg b/h5/home/assets/shared/icons/tab-welfare-filled.svg new file mode 100644 index 0000000..6cb269c --- /dev/null +++ b/h5/home/assets/shared/icons/tab-welfare-filled.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/h5/home/assets/shared/icons/tab-welfare-outline.svg b/h5/home/assets/shared/icons/tab-welfare-outline.svg new file mode 100644 index 0000000..b597121 --- /dev/null +++ b/h5/home/assets/shared/icons/tab-welfare-outline.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/h5/home/assets/shared/logos/jd-waimai.png b/h5/home/assets/shared/logos/jd-waimai.png new file mode 100644 index 0000000..6de9605 Binary files /dev/null and b/h5/home/assets/shared/logos/jd-waimai.png differ diff --git a/h5/home/assets/shared/logos/jd.png b/h5/home/assets/shared/logos/jd.png new file mode 100644 index 0000000..ed939da Binary files /dev/null and b/h5/home/assets/shared/logos/jd.png differ diff --git a/h5/home/assets/shared/logos/meituan-waimai.png b/h5/home/assets/shared/logos/meituan-waimai.png new file mode 100644 index 0000000..9ef0783 Binary files /dev/null and b/h5/home/assets/shared/logos/meituan-waimai.png differ diff --git a/h5/home/assets/shared/logos/meituan.png b/h5/home/assets/shared/logos/meituan.png new file mode 100644 index 0000000..71cede9 Binary files /dev/null and b/h5/home/assets/shared/logos/meituan.png differ diff --git a/h5/home/assets/shared/logos/sb-brand-vector.svg b/h5/home/assets/shared/logos/sb-brand-vector.svg new file mode 100644 index 0000000..1451bff --- /dev/null +++ b/h5/home/assets/shared/logos/sb-brand-vector.svg @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/h5/home/assets/shared/logos/sb-brand.old.png b/h5/home/assets/shared/logos/sb-brand.old.png new file mode 100644 index 0000000..106b7c5 Binary files /dev/null and b/h5/home/assets/shared/logos/sb-brand.old.png differ diff --git a/h5/home/assets/shared/logos/sb-brand.png b/h5/home/assets/shared/logos/sb-brand.png new file mode 100644 index 0000000..c8f1c13 Binary files /dev/null and b/h5/home/assets/shared/logos/sb-brand.png differ diff --git a/h5/home/assets/shared/logos/taobao-shanguang.png b/h5/home/assets/shared/logos/taobao-shanguang.png new file mode 100644 index 0000000..3091d33 Binary files /dev/null and b/h5/home/assets/shared/logos/taobao-shanguang.png differ diff --git a/h5/home/assets/shared/logos/taobao.png b/h5/home/assets/shared/logos/taobao.png new file mode 100644 index 0000000..7e0f742 Binary files /dev/null and b/h5/home/assets/shared/logos/taobao.png differ diff --git a/h5/home/assets/shared/overlays/aurora-decoration.png b/h5/home/assets/shared/overlays/aurora-decoration.png new file mode 100644 index 0000000..6f0a98f Binary files /dev/null and b/h5/home/assets/shared/overlays/aurora-decoration.png differ diff --git a/h5/home/assets/shared/overlays/floating-window.jpg b/h5/home/assets/shared/overlays/floating-window.jpg new file mode 100644 index 0000000..6d3f2c2 Binary files /dev/null and b/h5/home/assets/shared/overlays/floating-window.jpg differ diff --git a/h5/home/assets/shared/products/aomiao-detergent.jpg b/h5/home/assets/shared/products/aomiao-detergent.jpg new file mode 100644 index 0000000..20595ec Binary files /dev/null and b/h5/home/assets/shared/products/aomiao-detergent.jpg differ diff --git a/h5/home/assets/shared/products/coca-cola.jpg b/h5/home/assets/shared/products/coca-cola.jpg new file mode 100644 index 0000000..3eb4a36 Binary files /dev/null and b/h5/home/assets/shared/products/coca-cola.jpg differ diff --git a/h5/home/assets/shared/products/hfs-shampoo.jpg b/h5/home/assets/shared/products/hfs-shampoo.jpg new file mode 100644 index 0000000..d9086c8 Binary files /dev/null and b/h5/home/assets/shared/products/hfs-shampoo.jpg differ diff --git a/h5/home/assets/shared/products/jly-rice.jpg b/h5/home/assets/shared/products/jly-rice.jpg new file mode 100644 index 0000000..f304d5f Binary files /dev/null and b/h5/home/assets/shared/products/jly-rice.jpg differ diff --git a/h5/home/assets/shared/products/vinda-tissue.jpg b/h5/home/assets/shared/products/vinda-tissue.jpg new file mode 100644 index 0000000..ed70010 Binary files /dev/null and b/h5/home/assets/shared/products/vinda-tissue.jpg differ diff --git a/h5/home/assets/shared/products/yili-milk.jpg b/h5/home/assets/shared/products/yili-milk.jpg new file mode 100644 index 0000000..da6d3c5 Binary files /dev/null and b/h5/home/assets/shared/products/yili-milk.jpg differ diff --git a/h5/home/assets/welfare/index/checkin-coins-600.png b/h5/home/assets/welfare/index/checkin-coins-600.png new file mode 100644 index 0000000..3fb3bf4 Binary files /dev/null and b/h5/home/assets/welfare/index/checkin-coins-600.png differ diff --git a/h5/home/assets/welfare/index/coin-icon.png b/h5/home/assets/welfare/index/coin-icon.png new file mode 100644 index 0000000..02861d3 Binary files /dev/null and b/h5/home/assets/welfare/index/coin-icon.png differ diff --git a/h5/home/index.html b/h5/home/index.html new file mode 100644 index 0000000..941ff5e --- /dev/null +++ b/h5/home/index.html @@ -0,0 +1,10397 @@ + + + + + + + + +比价APP 高保真原型 (外卖版) + + + + + + + + + +
+ +
+

方案切换

+
暂无多方案模块
在 variants 配置中添加模块即可
+
+
+ +
+ +
返回
+ + + + +
+ +
+ + + + + + + +
+ +
+
+ + 傻瓜比价 +
+ 跨平台比价,用傻瓜 +
+
+ +
+
+
+ 如何使用傻瓜比价 · 新手指南 +
+
+
+
邀好友 赚金币
+
立即邀请 ›
+
🎁
+
+
+
+
+ + +
+
+ + +
+
+
+
+ + 14:23:18省***手比价后节省88888.88 +
+
+ + 14:22:451***2比价后节省42.40 +
+
+ + 14:20:31小**比价后节省7.90 +
+
+ + 14:18:077***0比价后节省156.30 +
+
+ + 14:15:42团**比价后节省23.50 +
+
+ + 14:11:296***0比价后节省89.40 +
+ +
+ + 14:23:18省***手比价后节省88888.88 +
+
+
+
+ + +
+
+
帮助用户
+
12847
+
+
+
完成比价
+
86532
+
+
+
累计节省
+
37621.4
+
+
+ + + + +
+ +
+
今日大额优惠券
+
AI 一键自动领
+
+ +
+ + +
+ + +
+
点外卖,赚金币
+
快去解锁全网底价
+
+ +
+
+ + + +
+ +
+
+ + + + + +
+
+
智能推荐
+
距离最近
+
销量最高
+
+ + + + + + + + + +
+ +
+
+
+
首页
+
赚钱
+
记录
+
我的
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
+
🍱
+
请选择您常用的平台
+
进入平台选好商品后,AI 一键替你比多家
+
+
+
+ + + +
+
+ +
连续签到14天 最高可领2888金币
+

签到领取今日金币

+
已连续签到 2 天,今天可领 220 金币
+ +
+
+
已领取
+
180
+
+
+
已领取
+
380
+
+
+
+
220
+
+
+
+
260
+
+
+
+
888
+
+
+ +
+
+
第1天
+
第2天
+
今天
+
明天
+
第7天
+
+ + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +
+
🎉🎊✨🎊🎉
+
新手大礼包
+
专享新客福利,开启领取
+
+
+
+
+
+
+
+
+
+
+
+
🎁
+
+
+5,000金币
+
已存入「福利」,随时可提现
+ +
+
+ + +
+5,000 金币
+ +
+ + + + + + +
+ +

「开启省钱之旅」按钮样式

+
点击切换,预览不同方案
+
+
红橙渐变当前
+
黄底黑字品牌主色
+
黑底黄字高对比
+
金色光泽动态扫光
+
玻璃质感立体黄
+
描边偏移克制款
+
红包喜庆红+金
+
呼吸跳动动效款
+
蜜糖渐变黄→琥珀
+
金币描边深金细边
+
+ +
+

领券弹窗副标题样式

+
主标题下那行小字,强化"收益"信号
+
+
基线灰当前最弱
+
金币胶囊品牌黄徽章
+
关键词高亮黄色荧光笔
+
优惠券小票齿边+朱红
+
数字徽章预计立省¥
+
双行节奏预告+承诺
+
V2b 金币翻转动效活力
+
V2c 双色分段黑黄拼接
+
V2d 闪光描边轻盈款
+
V2e 数字嵌入¥18+ 内嵌
+
V2f 双图标金币+闪电
+
V2g 立体浮起金属高光
+
流程植入领券→比价→底价
+
+ +
+

「完成设置」弹窗版式

+
点击切换,下次进入弹窗即生效
+
+
轻收尾·重期待承上小,起下大
+
分割式三段节奏
+
叙事流递进式
+
行为优先主舞台让给行为
+
徽章+行动卡chip 强调最后一步
+
进度条推进脉动黄推进感
+
数字步骤① ✓ → ② 当前
+
极简专注大字承担引导
+
+ +
+ + + + + + + + + + + + + + + + + + diff --git a/h5/shared/bridge.js b/h5/shared/bridge.js index a61f187..cbacdf7 100644 --- a/h5/shared/bridge.js +++ b/h5/shared/bridge.js @@ -124,6 +124,29 @@ else console.log('[SGBridge mock] closePage'); } + /** H5「去授权」→ 触发系统定位权限窗(原生侧永久拒绝跳设置)。结果异步,H5 回前台 visibilitychange 自行重查。 */ + function requestLocationPermission() { + if (hasNative && native.requestLocationPermission) native.requestLocationPermission(); + else console.log('[SGBridge mock] requestLocationPermission'); + } + + /** 定位权限是否已授予(FINE/COARSE)。H5 据此切「未授权空态 / feed」。浏览器无原生 → mock 返 true(便于预览 feed)。 */ + function isLocationGranted() { + if (hasNative && native.isLocationGranted) return !!native.isLocationGranted(); + return true; + } + + /** 取设备当前经纬度 → {longitude, latitude};原生拿不到(未授权/无缓存)返 null,浏览器无原生 mock 北京。 + * 原生侧同步返宿主缓存的 lastLocation(见 SGBridge.kt getLocation);H5 拿到 null 自行落默认坐标。 */ + function getLocation() { + if (hasNative && native.getLocation) { + var o = safeParse(native.getLocation(), null); + if (o && typeof o.longitude === 'number' && typeof o.latitude === 'number') return o; + return null; + } + return { longitude: 116.404, latitude: 39.928 }; + } + // ====== 原生 → H5 事件总线 ====== var listeners = {}; // event → [fn] @@ -153,6 +176,8 @@ getAppVersion: getAppVersion, getInstalledApps: getInstalledApps, getCouponClaimedToday: getCouponClaimedToday, + isLocationGranted: isLocationGranted, + getLocation: getLocation, // 动作 navigate: navigate, requestLogin: requestLogin, @@ -162,6 +187,7 @@ startCouponClaim: startCouponClaim, launchApp: launchApp, closePage: closePage, + requestLocationPermission: requestLocationPermission, // 事件 on: on, _emit: _emit, diff --git a/tests/test_h5_hosting.py b/tests/test_h5_hosting.py index 1acd149..9f1d4b0 100644 --- a/tests/test_h5_hosting.py +++ b/tests/test_h5_hosting.py @@ -30,3 +30,72 @@ def test_h5_records_served_and_migrated(client) -> None: assert "NativeBridge" not in body # 旧桥名清零 assert "getApiBase" not in body # 同源:绝对地址拼接已移除 assert "../shared/bridge.js" in body + + +def test_h5_home_served(client) -> None: + resp = client.get("/h5/home/index.html") + assert resp.status_code == 200 + assert resp.headers.get("cache-control") == "no-cache" + body = resp.text + assert 'id="home"' in body + assert "data-cc-id" not in body # 原型编辑器留痕已剥 + assert "../../assets/" not in body # 素材路径已本地化 + assert "/api/v1/platform/stats" in body # 已接同源数据 + assert body.count('class="screen') == 1 # 只剩首页一屏 + + +def test_h5_home_asset_served(client) -> None: + resp = client.get("/h5/home/assets/shared/logos/sb-brand.png") + assert resp.status_code == 200 + + +def test_h5_bridge_has_get_location(client) -> None: + # H2b: 首页 feed 需经纬度, bridge 暴露同步 getLocation()(无桥 mock 北京) + resp = client.get("/h5/shared/bridge.js") + assert resp.status_code == 200 + body = resp.text + assert "getLocation" in body + assert "116.404" in body and "39.928" in body # 浏览器 mock 北京兜底 + + +def test_h5_home_feed_wired(client) -> None: + # H2b: 首页 feed 接真实美团端点 + 抢换链;mock 静态卡已移除 + resp = client.get("/h5/home/index.html") + assert resp.status_code == 200 + body = resp.text + assert "/api/v1/meituan/feed" in body # rec/distance + assert "/api/v1/meituan/top-sales" in body # 销量最高 + assert "/api/v1/meituan/referral-link" in body # 抢 + assert "HomeFeed" in body # feed 模块已挂 + assert "茶百道" not in body # 写死的 mock 卡(店名)已移除 + assert "chabaidao.png" not in body # 写死的 mock 头图已移除 + assert "比团购省 5.5 元" not in body # 随原生:mock 卡的「比团购省」标签已删(渲染只用 price_label/rank_label) + + +def test_h5_home_last_compare_wired(client) -> None: + # 「上次比价」横幅改接真实 /api/v1/compare/records + 4 分钟新鲜窗口;原写死 mock 默认值已移除 + resp = client.get("/h5/home/index.html") + assert resp.status_code == 200 + body = resp.text + assert "/api/v1/compare/records" in body # 接真实比价记录端点 + assert "pickFreshLastCompare" in body # 4 分钟新鲜窗口逻辑 + assert "DEFAULT_LAST_COMPARE_RECORD" not in body # 写死 mock 默认已移除 + assert 'id="lastCompareShop">窑鸡王' not in body # 横幅店名静态 mock 占位已清空 + + +def test_compare_records_requires_auth(client) -> None: + # 横幅靠 Bearer token 才拿得到数据;无鉴权必须 401(无桥/未登录时横幅隐藏) + resp = client.get("/api/v1/compare/records?limit=5") + assert resp.status_code == 401 + + +def test_h5_home_coupon_popup_coin_icon_served(client) -> None: + # 「去领取」弹窗右上角金币图标:welfare 资源子树曾漏本地化 → 404 不显示;补齐后须 200 + resp = client.get("/h5/home/assets/welfare/index/coin-icon.png") + assert resp.status_code == 200 + + +def test_h5_home_coupon_ad_reward_coins_served(client) -> None: + # 领券「看广告赚金币」到账 toast(showCouponAdRewardToast)的金币堆图标:同属漏拷的 welfare 子树,补齐后须 200 + resp = client.get("/h5/home/assets/welfare/index/checkin-coins-600.png") + assert resp.status_code == 200