fix(homepage-buttons): 全面审查并纠正首页所有按钮跳转链路,支持平滑滚动与锚点防遮挡

这个提交包含在:
wikiboss
2026-10-08 18:36:05 +08:00
父节点 758c1bbbdb
当前提交 e8c5345539
共有 7 个文件被更改,包括 304 次插入 和 13 次删除

查看文件

@@ -47,7 +47,7 @@
<li><a href="{:addon_url('official/web.official_case_show/list',[':pid'=>14,':sid'=>14])}" class="nhc-footer-link">标杆案例</a></li>
<li><a href="{:addon_url('official/web.official_home/single',[':pid'=>1,':sid'=>1])}" class="nhc-footer-link">关于我们</a></li>
<li><a href="{:addon_url('official/web.official_online_message/list',[':pid'=>18,':sid'=>18])}" class="nhc-footer-link">需求预约</a></li>
<li><a href="#process" class="nhc-footer-link">交付流程</a></li>
<li><a href="{:addon_url('official/web.official_home/index')}#process" class="nhc-footer-link">交付流程</a></li>
</ul>
</div>

查看文件

@@ -253,7 +253,7 @@
<!-- 右侧行动按钮 -->
<div class="nhc-nav-actions">
<a href="#contact" class="nhc-btn nhc-btn-primary nhc-btn-sm">
<a href="{:addon_url('official/web.official_home/index')}#contact" class="nhc-btn nhc-btn-primary nhc-btn-sm">
<span>预约演示</span>
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M5 12h14M12 5l7 7-7 7"/></svg>
</a>

查看文件

@@ -158,7 +158,7 @@
历经千万级真实交易峰值考验的标准模块化产品体系。支持多商户分销清算、断网离线收银与多端硬件联动、多仓库多批次进销存盘点,支持公有云订阅与专有云源码买断部署。
</p>
<div class="nhc-hero-cta">
<a href="#products" class="nhc-btn nhc-btn-primary nhc-btn-lg">
<a href="{:addon_url('official/web.official_product/list',[':pid'=>22,':sid'=>22])}#demo-sandbox" class="nhc-btn nhc-btn-primary nhc-btn-lg">
<span>申请全功能在线演示</span>
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M5 12h14M12 5l7 7-7 7"/></svg>
</a>
@@ -298,8 +298,8 @@
<li class="nhc-service-item">业务审批、数据分析与工单智能自动化</li>
<li class="nhc-service-item">大模型本地私有化部署与敏感数据防护</li>
</ul>
<a href="{:addon_url('official/web.official_product/list',[':pid'=>19,':sid'=>19])}" class="nhc-service-link">
<span>探索智能体落地案例</span>
<a href="{:addon_url('official/web.official_product/list',[':pid'=>19,':sid'=>19])}#services-list" class="nhc-service-link">
<span>探索智能体开发方案</span>
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M5 12h14M12 5l7 7-7 7"/></svg>
</a>
</div>
@@ -350,7 +350,7 @@
</ul>
<div class="nhc-product-footer">
<span class="nhc-product-tag">支持 SaaS / 私有化</span>
<a href="{:addon_url('official/web.official_product/list',[':pid'=>22,':sid'=>22])}" class="nhc-btn nhc-btn-outline nhc-btn-sm">查看详情</a>
<a href="{:addon_url('official/web.official_product/list',[':pid'=>22,':sid'=>22])}#product-matrix" class="nhc-btn nhc-btn-outline nhc-btn-sm">查看详情</a>
</div>
</div>
@@ -379,7 +379,7 @@
</ul>
<div class="nhc-product-footer">
<span class="nhc-product-tag">软硬件深度集成</span>
<a href="{:addon_url('official/web.official_product/list',[':pid'=>22,':sid'=>22])}" class="nhc-btn nhc-btn-outline nhc-btn-sm">申请演示</a>
<a href="{:addon_url('official/web.official_product/list',[':pid'=>22,':sid'=>22])}#demo-sandbox" class="nhc-btn nhc-btn-outline nhc-btn-sm">申请演示</a>
</div>
</div>
@@ -408,7 +408,7 @@
</ul>
<div class="nhc-product-footer">
<span class="nhc-product-tag">业财协同标准版</span>
<a href="{:addon_url('official/web.official_product/list',[':pid'=>22,':sid'=>22])}" class="nhc-btn nhc-btn-outline nhc-btn-sm">查看详情</a>
<a href="{:addon_url('official/web.official_product/list',[':pid'=>22,':sid'=>22])}#product-matrix" class="nhc-btn nhc-btn-outline nhc-btn-sm">查看详情</a>
</div>
</div>
@@ -437,7 +437,7 @@
</ul>
<div class="nhc-product-footer">
<span class="nhc-product-tag">按需订阅 / 敏捷交付</span>
<a href="{:addon_url('official/web.official_product/list',[':pid'=>22,':sid'=>22])}" class="nhc-btn nhc-btn-primary nhc-btn-sm">立即开通</a>
<a href="{:addon_url('official/web.official_product/list',[':pid'=>22,':sid'=>22])}#demo-sandbox" class="nhc-btn nhc-btn-primary nhc-btn-sm">立即开通</a>
</div>
</div>
</div>
@@ -493,6 +493,12 @@
<div class="nhc-case-metric-sub">日峰值订单处理</div>
</div>
</div>
<div style="margin-top: 20px; display: flex; justify-content: flex-end;">
<a href="{:addon_url('official/web.official_case_show/list',[':pid'=>14,':sid'=>14])}" class="nhc-case-card-link">
<span>查看案例复盘与实测数据</span>
<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5"><path d="M5 12h14M12 5l7 7-7 7"/></svg>
</a>
</div>
</div>
<!-- 案例 2 -->
@@ -526,6 +532,12 @@
<div class="nhc-case-metric-sub">全国门店稳定部署</div>
</div>
</div>
<div style="margin-top: 20px; display: flex; justify-content: flex-end;">
<a href="{:addon_url('official/web.official_case_show/list',[':pid'=>14,':sid'=>14])}" class="nhc-case-card-link">
<span>查看案例复盘与实测数据</span>
<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5"><path d="M5 12h14M12 5l7 7-7 7"/></svg>
</a>
</div>
</div>
<!-- 案例 3 -->
@@ -559,6 +571,12 @@
<div class="nhc-case-metric-sub">采购采购周期缩短</div>
</div>
</div>
<div style="margin-top: 20px; display: flex; justify-content: flex-end;">
<a href="{:addon_url('official/web.official_case_show/list',[':pid'=>14,':sid'=>14])}" class="nhc-case-card-link">
<span>查看案例复盘与实测数据</span>
<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5"><path d="M5 12h14M12 5l7 7-7 7"/></svg>
</a>
</div>
</div>
<!-- 案例 4 -->
@@ -592,6 +610,12 @@
<div class="nhc-case-metric-sub">业务采纳准确率</div>
</div>
</div>
<div style="margin-top: 20px; display: flex; justify-content: flex-end;">
<a href="{:addon_url('official/web.official_case_show/list',[':pid'=>14,':sid'=>14])}" class="nhc-case-card-link">
<span>查看案例复盘与实测数据</span>
<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5"><path d="M5 12h14M12 5l7 7-7 7"/></svg>
</a>
</div>
</div>
</div>
@@ -667,6 +691,13 @@
</p>
</div>
</div>
<div style="text-align: center; margin-top: 40px;">
<a href="{:addon_url('official/web.official_product/list',[':pid'=>19,':sid'=>19])}#services-list" class="nhc-btn nhc-btn-outline nhc-btn-sm">
<span>查阅标准化研发流程与质量规范</span>
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M5 12h14M12 5l7 7-7 7"/></svg>
</a>
</div>
</div>
</section>
<!-- 交付流程 (Process Section) 结束 -->

查看文件

@@ -172,7 +172,7 @@
千万级真实交易峰值淬炼的标准成熟产品矩阵,支持即开即用公有云 SaaS 与私有化部署。
</p>
<div class="nhc-hero-cta">
<a href="#products" class="nhc-btn nhc-btn-primary">
<a href="{:addon_url('official/web.official_product/list',[':pid'=>22,':sid'=>22])}#demo-sandbox" class="nhc-btn nhc-btn-primary">
<span>申请全系统演示</span>
</a>
<a href="#contact" class="nhc-btn nhc-btn-outline">
@@ -249,6 +249,12 @@
<li class="nhc-service-item">业务中台整合与跨系统数据打通</li>
<li class="nhc-service-item">金融级数据加密与私有化安全部署</li>
</ul>
<div style="margin-top: 14px;">
<a href="{:addon_url('official/web.official_product/list',[':pid'=>19,':sid'=>19])}#services-list" class="nhc-service-link" style="display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--primary);">
<span>了解中台定制方案</span>
<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M5 12h14M12 5l7 7-7 7"/></svg>
</a>
</div>
</div>
<div class="nhc-service-card">
@@ -262,6 +268,12 @@
<li class="nhc-service-item">微信小程序、企业微信生态深度闭环</li>
<li class="nhc-service-item">蓝牙硬件与物联网 IoT 边缘设备对接</li>
</ul>
<div style="margin-top: 14px;">
<a href="{:addon_url('official/web.official_product/list',[':pid'=>19,':sid'=>19])}#services-list" class="nhc-service-link" style="display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--primary);">
<span>查看移动端定制能力</span>
<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M5 12h14M12 5l7 7-7 7"/></svg>
</a>
</div>
</div>
<div class="nhc-service-card">
@@ -275,8 +287,21 @@
<li class="nhc-service-item">多智能体(Multi-Agent)协同决策与执行</li>
<li class="nhc-service-item">业务审批、数据分析与工单智能自动化</li>
</ul>
<div style="margin-top: 14px;">
<a href="{:addon_url('official/web.official_product/list',[':pid'=>19,':sid'=>19])}#services-list" class="nhc-service-link" style="display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--primary);">
<span>探索智能体开发方案</span>
<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M5 12h14M12 5l7 7-7 7"/></svg>
</a>
</div>
</div>
</div>
<div style="text-align: center; margin-top: 24px;">
<a href="{:addon_url('official/web.official_product/list',[':pid'=>19,':sid'=>19])}" class="nhc-btn nhc-btn-outline" style="width: 100%; justify-content: center;">
<span>查看完整软件开发与交付能力</span>
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M5 12h14M12 5l7 7-7 7"/></svg>
</a>
</div>
</div>
</section>
@@ -297,23 +322,42 @@
<span class="nhc-product-type-badge">全渠道商城</span>
<h3 class="nhc-product-name">商城</h3>
<p class="nhc-product-desc">B2B2C 多商户入驻、社交裂变营销与全域私域流量精细化运营系统。</p>
<div style="margin-top: 12px;">
<a href="{:addon_url('official/web.official_product/list',[':pid'=>22,':sid'=>22])}#product-matrix" class="nhc-btn nhc-btn-outline nhc-btn-sm" style="width: 100%; justify-content: center;">查看详情</a>
</div>
</div>
<div class="nhc-product-card">
<span class="nhc-product-type-badge">毫秒级收银</span>
<h3 class="nhc-product-name">收银</h3>
<p class="nhc-product-desc">软硬件一体智能收银系统,聚合支付秒级核销,断网离线平稳记账。</p>
<div style="margin-top: 12px;">
<a href="{:addon_url('official/web.official_product/list',[':pid'=>22,':sid'=>22])}#demo-sandbox" class="nhc-btn nhc-btn-outline nhc-btn-sm" style="width: 100%; justify-content: center;">申请演示</a>
</div>
</div>
<div class="nhc-product-card">
<span class="nhc-product-type-badge">业财一体化</span>
<h3 class="nhc-product-name">进销存</h3>
<p class="nhc-product-desc">采购、销售、仓储与财务全链路打通,多仓实时调拨与智能补货预警。</p>
<div style="margin-top: 12px;">
<a href="{:addon_url('official/web.official_product/list',[':pid'=>22,':sid'=>22])}#product-matrix" class="nhc-btn nhc-btn-outline nhc-btn-sm" style="width: 100%; justify-content: center;">查看详情</a>
</div>
</div>
<div class="nhc-product-card">
<span class="nhc-product-type-badge">多租户平台</span>
<h3 class="nhc-product-name">SaaS版本</h3>
<p class="nhc-product-desc">云原生高可用多租户架构,开箱即用免运维,弹性扩展金融级容灾。</p>
<div style="margin-top: 12px;">
<a href="{:addon_url('official/web.official_product/list',[':pid'=>22,':sid'=>22])}#demo-sandbox" class="nhc-btn nhc-btn-primary nhc-btn-sm" style="width: 100%; justify-content: center;">立即开通</a>
</div>
</div>
</div>
<div style="text-align: center; margin-top: 24px;">
<a href="{:addon_url('official/web.official_product/list',[':pid'=>22,':sid'=>22])}" class="nhc-btn nhc-btn-outline" style="width: 100%; justify-content: center;">
<span>浏览完整商业产品矩阵</span>
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M5 12h14M12 5l7 7-7 7"/></svg>
</a>
</div>
</div>
</section>
@@ -343,6 +387,12 @@
<div class="nhc-case-metric-sub">日峰值订单</div>
</div>
</div>
<div style="margin-top: 14px;">
<a href="{:addon_url('official/web.official_case_show/list',[':pid'=>14,':sid'=>14])}" class="nhc-case-card-link" style="display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--primary);">
<span>查看案例复盘与实测</span>
<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M5 12h14M12 5l7 7-7 7"/></svg>
</a>
</div>
</div>
<div class="nhc-case-card">
@@ -358,8 +408,21 @@
<div class="nhc-case-metric-sub">门店稳定运行</div>
</div>
</div>
<div style="margin-top: 14px;">
<a href="{:addon_url('official/web.official_case_show/list',[':pid'=>14,':sid'=>14])}" class="nhc-case-card-link" style="display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--primary);">
<span>查看案例复盘与实测</span>
<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M5 12h14M12 5l7 7-7 7"/></svg>
</a>
</div>
</div>
</div>
<div style="text-align: center; margin-top: 24px;">
<a href="{:addon_url('official/web.official_case_show/list',[':pid'=>14,':sid'=>14])}" class="nhc-btn nhc-btn-outline" style="width: 100%; justify-content: center;">
<span>浏览全部标杆案例</span>
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M5 12h14M12 5l7 7-7 7"/></svg>
</a>
</div>
</div>
</section>
@@ -397,6 +460,13 @@
<h4 class="nhc-process-step-title">私有化与维保</h4>
</div>
</div>
<div style="text-align: center; margin-top: 20px;">
<a href="{:addon_url('official/web.official_product/list',[':pid'=>19,':sid'=>19])}#services-list" class="nhc-btn nhc-btn-outline nhc-btn-sm" style="width: 100%; justify-content: center;">
<span>查阅标准化研发流程与质量规范</span>
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M5 12h14M12 5l7 7-7 7"/></svg>
</a>
</div>
</div>
</section>
@@ -438,8 +508,12 @@
资深系统架构师团队随时待命,为您提供深度业务剖析与技术方案规划。
</p>
</div>
<div class="nhc-cta-buttons" style="margin-top: 20px;">
<a href="tel:{:__config('site_mobile','value')}" class="nhc-btn nhc-cta-btn-light">
<div class="nhc-cta-buttons" style="margin-top: 20px; display: flex; flex-direction: column; gap: 12px;">
<a href="{:addon_url('official/web.official_online_message/list',[':pid'=>18,':sid'=>18])}" class="nhc-btn nhc-cta-btn-light" style="width: 100%; justify-content: center;">
<span>在线预约专家咨询</span>
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M5 12h14M12 5l7 7-7 7"/></svg>
</a>
<a href="tel:{:__config('site_mobile','value')}" class="nhc-btn nhc-cta-btn-ghost" style="width: 100%; justify-content: center; border: 1px solid rgba(255,255,255,0.4); color: #fff;">
<span>致电专家咨询</span>
</a>
</div>

查看文件

@@ -38,12 +38,23 @@
}
/* 基础重置与重构 */
html {
scroll-behavior: smooth;
}
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
/* 锚点跳转平滑定位偏移,避免被 76px 顶部固定导航栏遮挡标题 */
section[id],
div[id] {
scroll-margin-top: 86px;
}
body.body_index {
background-color: var(--bg-primary);
color: var(--text-secondary);
@@ -941,6 +952,22 @@ img {
transform: translateY(-3px);
}
.nhc-case-card-link {
display: inline-flex;
align-items: center;
gap: 6px;
font-size: 13px;
font-weight: 500;
color: var(--primary);
margin-top: 18px;
transition: all 0.2s ease;
}
.nhc-case-card-link:hover {
color: var(--primary-hover);
transform: translateX(4px);
}
.nhc-case-meta {
display: flex;
align-items: center;

查看文件

@@ -252,6 +252,15 @@ def test_natural_copywriting_suite():
res.assert_true(test_result.wasSuccessful(), f"务实工程文案断言全部通过 (共 {test_result.testsRun} 项)")
return res.summary()
def test_homepage_button_links_suite():
res = TestResult("首页按钮跳转与链路专项测试 (HomepageButtonLinks)")
from tests.test_homepage_button_links import HomepageButtonLinksTest
suite = unittest.TestLoader().loadTestsFromTestCase(HomepageButtonLinksTest)
runner = unittest.TextTestRunner(verbosity=0)
test_result = runner.run(suite)
res.assert_true(test_result.wasSuccessful(), f"首页所有按钮点击与跳转断言全部通过 (共 {test_result.testsRun} 项)")
return res.summary()
def main():
import unittest
results = [
@@ -264,7 +273,8 @@ def main():
test_no_ai_flavor_suite(),
test_client_rigor_suite(),
test_ad_law_compliance_suite(),
test_natural_copywriting_suite()
test_natural_copywriting_suite(),
test_homepage_button_links_suite()
]
sys.exit(0 if all(results) else 1)

查看文件

@@ -0,0 +1,149 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
首页按钮点击与跳转审查自动化测试 (TDD)
验证首页所有按钮(PC 端与移动端)均准确跳转到对应的业务位置或锚点
"""
import os
import re
import unittest
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
class HomepageButtonLinksTest(unittest.TestCase):
def setUp(self):
self.pc_home_path = os.path.join(BASE_DIR, 'addons', 'official', 'view', 'web', 'official_home', 'index.html')
self.mobile_home_path = os.path.join(BASE_DIR, 'addons', 'official', 'view', 'web', 'official_home', 'index_e.html')
self.pc_nav_path = os.path.join(BASE_DIR, 'addons', 'official', 'view', 'web', 'official_common', 'pc', 'nav.html')
self.css_path = os.path.join(BASE_DIR, 'public', 'assets', 'addons', 'official', 'css', 'modern_nhc.css')
with open(self.pc_home_path, 'r', encoding='utf-8') as f:
self.pc_html = f.read()
with open(self.mobile_home_path, 'r', encoding='utf-8') as f:
self.mobile_html = f.read()
with open(self.pc_nav_path, 'r', encoding='utf-8') as f:
self.pc_nav = f.read()
with open(self.css_path, 'r', encoding='utf-8') as f:
self.css = f.read()
def test_01_pc_hero_carousel_buttons(self):
"""PC 首页首屏轮播图所有按钮跳转必须精准"""
# 幻灯片 1:预约架构师评估 与 浏览成熟产品
self.assertIn('#contact', self.pc_html, "首屏应包含直达联系模块的锚点跳转")
self.assertIn('#products', self.pc_html, "首屏应包含直达产品矩阵的锚点跳转")
# 幻灯片 2:软件开发能力 与 标杆案例
self.assertTrue(
"official_product/list" in self.pc_html and ":pid'=>19" in self.pc_html,
"幻灯片2必须准确跳转到服务页 (:pid=>19)"
)
self.assertTrue(
"official_case_show/list" in self.pc_html and ":pid'=>14" in self.pc_html,
"幻灯片2必须准确跳转到案例页 (:pid=>14)"
)
# 幻灯片 4:申请全功能在线演示 - 严禁粗糙跳到没有演示功能的 #products
# 必须跳转到产品页演示沙箱 demo-sandbox 或联系预约
self.assertFalse(
re.search(r'<a\s+href="#products"[^>]*>(?:(?!</a>)[\s\S])*?申请全功能在线演示', self.pc_html),
"申请全功能在线演示严禁跳往 #products,必须精准跳转演示沙箱或预约页面"
)
self.assertTrue(
"demo-sandbox" in self.pc_html or "official_online_message/list" in self.pc_html,
"申请在线演示必须链接到 demo-sandbox 或联系预约"
)
def test_02_pc_service_section_buttons(self):
"""PC 首页服务板块跳转必须准确一致"""
# 核心服务一与二必须跳转服务页
self.assertTrue(
re.search(r'href="\{:addon_url\(\'official/web\.official_product/list\',\[\':pid\'=>19,\':sid\'=>19\]\)[^"]*"[^>]*>[\s\S]*?软件开发', self.pc_html) or
re.search(r'软件开发方案[\s\S]*?\{:addon_url\(\'official/web\.official_product/list\'', self.pc_html) or
("了解软件开发" in self.pc_html and ":pid'=>19" in self.pc_html),
"软件开发服务卡片必须跳转到服务页"
)
# 核心服务三:如果是“探索智能体开发方案”,跳转到服务页;如果是“案例”,必须跳案例页,文案与链接不能精神分裂
if "探索智能体落地案例" in self.pc_html:
# 如果文案是案例,则链接必须是案例页
self.assertTrue(
"official_case_show/list" in self.pc_html,
"探索智能体落地案例必须指向案例页"
)
def test_03_pc_product_section_buttons(self):
"""PC 首页四大成熟商用系统按钮必须跳转到对应位置"""
# 收银「申请演示」必须跳往产品页的演示沙箱 #demo-sandbox 或联系页
self.assertTrue(
re.search(r'href="\{:addon_url\(\'official/web\.official_product/list\',\[\':pid\'=>22,\':sid\'=>22\]\)\}#demo-sandbox"[^>]*>[\s\S]*?申请演示', self.pc_html) or
("demo-sandbox" in self.pc_html and "申请演示" in self.pc_html),
"收银系统【申请演示】必须精准跳转到产品独立页演示沙箱"
)
# SaaS版本「立即开通」必须跳往演示开通沙箱或预约
self.assertTrue(
re.search(r'href="\{:addon_url\(\'official/web\.official_product/list\',\[\':pid\'=>22,\':sid\'=>22\]\)\}#demo-sandbox"[^>]*>[\s\S]*?立即开通', self.pc_html) or
("demo-sandbox" in self.pc_html and "立即开通" in self.pc_html) or
("official_online_message/list" in self.pc_html and "立即开通" in self.pc_html),
"SaaS版本【立即开通】必须跳转到产品演示沙箱或咨询开通"
)
def test_04_pc_case_cards_clickable(self):
"""PC 首页案例卡片必须具备可点击跳转到案例页的入口"""
# 每个案例卡片应包含查看详情链接或整卡可点击
case_links_count = len(re.findall(r'official_case_show/list', self.pc_html))
self.assertGreaterEqual(case_links_count, 3, "首页案例板块及卡片必须包含足够的案例页跳转链接")
self.assertIn("浏览全部标杆案例", self.pc_html, "首页案例板块必须包含【浏览全部标杆案例】主按钮")
def test_05_pc_process_and_cta_buttons(self):
"""PC 首页交付流程与底部 CTA 按钮跳转"""
# 底部 CTA 必须有预约架构师技术初审和致电专线
self.assertTrue(
"official_online_message/list" in self.pc_html and ":pid'=>18" in self.pc_html,
"底部 CTA 必须准确跳转到联系留言独立页 (:pid=>18)"
)
self.assertIn('tel:{:__config(\'site_mobile\',\'value\')}', self.pc_html, "底部 CTA 必须包含拨打电话链接")
def test_06_nav_actions_button(self):
"""导航栏右上角行动按钮必须全局可用,不能是单页孤立锚点"""
self.assertFalse(
re.search(r'<a\s+href="#contact"\s+class="nhc-btn\s+nhc-btn-primary\s+nhc-btn-sm"', self.pc_nav),
"导航栏右上角【预约演示】不能是单纯的 #contact,否则在非首页子页面点击无效"
)
def test_07_mobile_home_buttons(self):
"""移动端首页各板块必须具备完整的操作与跳转按钮"""
# 轮播图幻灯片4
self.assertFalse(
re.search(r'<a\s+href="#products"[^>]*>(?:(?!</a>)[\s\S])*?申请全系统演示', self.mobile_html),
"移动端申请全系统演示严禁跳转 #products,必须跳转演示沙箱或联系预约"
)
# 服务、产品、案例必须有链接或按钮跳转到独立页
self.assertTrue(
"official_product/list" in self.mobile_html and ":pid'=>19" in self.mobile_html,
"移动端服务板块必须有直达服务独立页的跳转链接"
)
self.assertTrue(
"official_product/list" in self.mobile_html and ":pid'=>22" in self.mobile_html,
"移动端产品板块必须有直达产品独立页的跳转链接"
)
self.assertTrue(
"official_case_show/list" in self.mobile_html and ":pid'=>14" in self.mobile_html,
"移动端案例板块必须有直达案例独立页的跳转链接"
)
# 移动端底部 CTA 必须有在线咨询与致电
self.assertTrue(
"official_online_message/list" in self.mobile_html or "tel:" in self.mobile_html,
"移动端底部 CTA 必须具备有效联络跳转"
)
def test_08_smooth_scroll_and_offset(self):
"""CSS 必须具备平滑滚动与避免 fixed 导航遮挡的 scroll-margin-top"""
self.assertIn('scroll-behavior: smooth', self.css, "CSS 必须配置 scroll-behavior: smooth")
self.assertIn('scroll-margin-top', self.css, "CSS 必须配置 scroll-margin-top 防止锚点被 fixed 导航遮挡")
if __name__ == '__main__':
unittest.main()