shanxia-mp-empty-state-demo.html 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431
  1. <!DOCTYPE html>
  2. <html lang="zh-CN">
  3. <head>
  4. <meta charset="UTF-8" />
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
  6. <title>山峡化工 · 全局空态 Empty State Demo</title>
  7. <link rel="stylesheet" href="shanxia-mp-base.css" />
  8. <style>
  9. body { background: #e8eeeb; }
  10. .page-wrap {
  11. max-width: 1100px;
  12. margin: 0 auto;
  13. padding: 20px 16px 48px;
  14. }
  15. .hero {
  16. background: var(--header-gradient);
  17. color: #fff;
  18. border-radius: 20px;
  19. padding: 22px 20px;
  20. margin-bottom: 16px;
  21. box-shadow: var(--shadow-md);
  22. }
  23. .hero h1 { font-size: 20px; margin-bottom: 6px; }
  24. .hero p { font-size: 13px; opacity: 0.92; line-height: 1.55; }
  25. .pick-bar {
  26. position: sticky;
  27. top: 8px;
  28. z-index: 20;
  29. background: rgba(255,255,255,0.96);
  30. border: 1px solid var(--border);
  31. border-radius: 14px;
  32. padding: 12px;
  33. margin-bottom: 16px;
  34. box-shadow: var(--shadow-sm);
  35. backdrop-filter: blur(8px);
  36. }
  37. .pick-bar__label {
  38. font-size: 11px;
  39. color: var(--text-muted);
  40. margin-bottom: 8px;
  41. }
  42. .pick-tabs {
  43. display: grid;
  44. grid-template-columns: repeat(4, 1fr);
  45. gap: 8px;
  46. }
  47. @media (max-width: 720px) {
  48. .pick-tabs { grid-template-columns: repeat(2, 1fr); }
  49. }
  50. .pick-tab {
  51. border: 1px solid var(--border);
  52. background: #f6faf8;
  53. border-radius: 12px;
  54. padding: 10px 8px;
  55. text-align: center;
  56. font-size: 12px;
  57. font-weight: 600;
  58. color: var(--text-muted);
  59. line-height: 1.35;
  60. }
  61. .pick-tab small {
  62. display: block;
  63. font-weight: 400;
  64. font-size: 10px;
  65. margin-top: 2px;
  66. opacity: 0.9;
  67. }
  68. .pick-tab.active {
  69. color: var(--brand-green-dark);
  70. background: var(--brand-green-soft);
  71. border-color: #b7e6d2;
  72. box-shadow: 0 0 0 2px rgba(10, 159, 109, 0.12);
  73. }
  74. .note {
  75. font-size: 12px;
  76. color: var(--text-muted);
  77. line-height: 1.55;
  78. margin: 0 0 16px;
  79. padding: 12px 14px;
  80. background: #fff;
  81. border: 1px solid var(--border);
  82. border-radius: 12px;
  83. }
  84. .note strong { color: var(--text-primary); }
  85. .stage {
  86. display: none;
  87. }
  88. .stage.active { display: block; }
  89. .phone-frame {
  90. max-width: 390px;
  91. margin: 0 auto;
  92. background: var(--bg-page);
  93. border-radius: 22px;
  94. border: 1px solid var(--border);
  95. box-shadow: var(--shadow-md);
  96. overflow: hidden;
  97. min-height: 640px;
  98. }
  99. .mp-subpage-back { color: #fff; font-size: 13px; opacity: 0.95; }
  100. /* ════════ 方案公共 ════════ */
  101. .empty {
  102. padding: 48px 28px 40px;
  103. text-align: center;
  104. }
  105. .empty__title {
  106. margin: 0;
  107. font-size: 15px;
  108. font-weight: 650;
  109. color: var(--text-primary);
  110. }
  111. .empty__desc {
  112. margin: 8px 0 0;
  113. font-size: 12px;
  114. color: var(--text-muted);
  115. line-height: 1.55;
  116. }
  117. .empty__actions {
  118. margin-top: 18px;
  119. display: flex;
  120. justify-content: center;
  121. gap: 10px;
  122. flex-wrap: wrap;
  123. }
  124. /* ════════ A · 柔和圆底 + 清单图标 ════════ */
  125. .empty-a__badge {
  126. width: 88px;
  127. height: 88px;
  128. margin: 0 auto 16px;
  129. border-radius: 50%;
  130. background: linear-gradient(145deg, #e9f9f2, #dcebe4);
  131. display: flex;
  132. align-items: center;
  133. justify-content: center;
  134. box-shadow: inset 0 0 0 1px rgba(10, 159, 109, 0.08);
  135. }
  136. .empty-a__badge svg { width: 42px; height: 42px; }
  137. /* ════════ B · 插画卡片(文件夹) ════════ */
  138. .empty-b__art {
  139. width: 148px;
  140. height: 112px;
  141. margin: 0 auto 18px;
  142. position: relative;
  143. }
  144. .empty-b__shadow {
  145. position: absolute;
  146. left: 24px; right: 24px; bottom: 6px;
  147. height: 12px;
  148. border-radius: 50%;
  149. background: rgba(15, 30, 25, 0.08);
  150. filter: blur(2px);
  151. }
  152. .empty-b__folder {
  153. position: absolute;
  154. left: 50%;
  155. top: 10px;
  156. transform: translateX(-50%);
  157. width: 108px;
  158. height: 78px;
  159. }
  160. .empty-b__folder-back {
  161. position: absolute;
  162. inset: 0;
  163. border-radius: 12px 12px 14px 14px;
  164. background: linear-gradient(160deg, #b7e6d2, #7dcea0);
  165. }
  166. .empty-b__folder-tab {
  167. position: absolute;
  168. left: 10px; top: -10px;
  169. width: 38px; height: 16px;
  170. border-radius: 8px 8px 0 0;
  171. background: #87d4b0;
  172. }
  173. .empty-b__folder-front {
  174. position: absolute;
  175. left: 0; right: 0; bottom: 0;
  176. height: 58px;
  177. border-radius: 10px 14px 14px 14px;
  178. background: linear-gradient(180deg, #ecfdf5, #dff7ec);
  179. border: 1px solid rgba(8, 127, 87, 0.18);
  180. box-shadow: 0 8px 18px rgba(10, 159, 109, 0.12);
  181. }
  182. .empty-b__lines {
  183. position: absolute;
  184. left: 18px; right: 18px; top: 18px;
  185. }
  186. .empty-b__lines i {
  187. display: block;
  188. height: 6px;
  189. border-radius: 999px;
  190. background: #cfe9dc;
  191. margin-bottom: 8px;
  192. }
  193. .empty-b__lines i:nth-child(2) { width: 70%; }
  194. .empty-b__lines i:nth-child(3) { width: 48%; margin-bottom: 0; }
  195. /* ════════ C · 极简线条图标 ════════ */
  196. .empty-c__glyph {
  197. width: 72px;
  198. height: 72px;
  199. margin: 0 auto 14px;
  200. color: #9aa8a1;
  201. }
  202. .empty-c__glyph svg { width: 100%; height: 100%; }
  203. .empty-c .empty__title { font-weight: 600; color: #5f6f68; }
  204. .empty-c .empty__desc { max-width: 220px; margin-left: auto; margin-right: auto; }
  205. /* ════════ D · 虚线卡片容器 ════════ */
  206. .empty-d__panel {
  207. margin: 8px 8px 0;
  208. border: 1.5px dashed #b7d9c8;
  209. border-radius: 18px;
  210. background: #fbfefc;
  211. padding: 36px 20px 28px;
  212. }
  213. .empty-d__icon {
  214. width: 56px;
  215. height: 56px;
  216. margin: 0 auto 14px;
  217. border-radius: 16px;
  218. background: var(--brand-green-soft);
  219. color: var(--brand-green-dark);
  220. display: flex;
  221. align-items: center;
  222. justify-content: center;
  223. font-size: 22px;
  224. font-weight: 700;
  225. }
  226. /* 搜索无结果变体提示条 */
  227. .scene-tag {
  228. display: inline-flex;
  229. align-items: center;
  230. gap: 6px;
  231. margin: 12px 16px 0;
  232. padding: 4px 10px;
  233. border-radius: 999px;
  234. font-size: 11px;
  235. background: #fff7e8;
  236. color: #a67a1f;
  237. border: 1px solid #f0e0b8;
  238. }
  239. </style>
  240. </head>
  241. <body>
  242. <nav class="proto-nav">
  243. <strong>Demo 导航</strong>
  244. <a href="shanxia-mp-index.html">索引</a>
  245. <a href="shanxia-mp-pattern-index.html">Pattern</a>
  246. <a class="active" href="shanxia-mp-empty-state-demo.html">空态</a>
  247. </nav>
  248. <div class="page-wrap">
  249. <header class="hero">
  250. <h1>全局空态 Empty State</h1>
  251. <p>用于列表无数据 / 搜索无结果。<strong>已采用方案 B · 插画文件夹</strong>,落地组件 <code>miniprogram/components/mp-empty</code>。下方可继续对比未选方案。</p>
  252. </header>
  253. <div class="pick-bar">
  254. <div class="pick-bar__label">已采用 B;点击可切换对比其他方案</div>
  255. <div class="pick-tabs">
  256. <button class="pick-tab" type="button" data-stage="a">A 圆底图标<small>未采用</small></button>
  257. <button class="pick-tab active" type="button" data-stage="b">B 插画文件夹<small>已采用</small></button>
  258. <button class="pick-tab" type="button" data-stage="c">C 极简线条<small>未采用</small></button>
  259. <button class="pick-tab" type="button" data-stage="d">D 虚线卡片<small>未采用</small></button>
  260. </div>
  261. </div>
  262. <p class="note" id="note-a" style="display:none">
  263. <strong>方案 A · 柔和圆底 + SVG 清单图标</strong><br />
  264. 保留「圆底」结构,补上可识别图形与标题/说明/主按钮。选型时备选,未采用。
  265. </p>
  266. <p class="note" id="note-b">
  267. <strong>方案 B · 插画风文件夹(已采用)</strong><br />
  268. 用 CSS 拼出文件夹,品牌绿更明显。对应实现:<code>mp-empty</code> + <code>mp-biz.scss</code> / <code>shanxia-mp-base.css</code> 中的 <code>.mp-empty__*</code>。
  269. </p>
  270. <p class="note" id="note-c" style="display:none">
  271. <strong>方案 C · 极简线条</strong><br />
  272. 单色 stroke 图标,信息密度最低。适合「搜索无结果」或希望页面更安静的场景。
  273. </p>
  274. <p class="note" id="note-d" style="display:none">
  275. <strong>方案 D · 虚线卡片容器</strong><br />
  276. 把空态放进虚线面板,CTA 更突出。适合「尚未创建任何数据,引导新增」的首次空态。
  277. </p>
  278. <!-- ── A ── -->
  279. <section class="stage" id="stage-a">
  280. <div class="phone-frame">
  281. <header class="mp-header">
  282. <div class="mp-header__row">
  283. <a class="mp-subpage-back" href="shanxia-mp-workbench-demo.html">← 工作台</a>
  284. <button class="mp-header__action" type="button">+ 新增</button>
  285. </div>
  286. <h1 class="mp-header__title" style="margin-top:8px">产品分类</h1>
  287. <div class="mp-header__search" style="margin-top:10px">
  288. <span class="mp-header__search-dot"></span>搜索分类名称
  289. </div>
  290. </header>
  291. <span class="scene-tag">场景:列表无数据</span>
  292. <div class="empty empty-a">
  293. <div class="empty-a__badge" aria-hidden="true">
  294. <svg viewBox="0 0 48 48" fill="none">
  295. <rect x="10" y="8" width="28" height="34" rx="4" stroke="#0a9f6d" stroke-width="2.2"/>
  296. <path d="M16 18h16M16 25h16M16 32h10" stroke="#0a9f6d" stroke-width="2.2" stroke-linecap="round"/>
  297. <circle cx="34" cy="34" r="9" fill="#e9f9f2" stroke="#087f57" stroke-width="2"/>
  298. <path d="M34 30v8M30 34h8" stroke="#087f57" stroke-width="2" stroke-linecap="round"/>
  299. </svg>
  300. </div>
  301. <p class="empty__title">暂无产品分类</p>
  302. <p class="empty__desc">还没有分类数据,可先新增一个顶级分类</p>
  303. <div class="empty__actions">
  304. <button class="mp-btn mp-btn--primary" type="button">新增分类</button>
  305. </div>
  306. </div>
  307. </div>
  308. </section>
  309. <!-- ── B(已采用) ── -->
  310. <section class="stage active" id="stage-b">
  311. <div class="phone-frame">
  312. <header class="mp-header">
  313. <div class="mp-header__row">
  314. <a class="mp-subpage-back" href="shanxia-mp-workbench-demo.html">← 工作台</a>
  315. <button class="mp-header__action" type="button">+ 新增</button>
  316. </div>
  317. <h1 class="mp-header__title" style="margin-top:8px">产品分类</h1>
  318. <div class="mp-header__search" style="margin-top:10px">
  319. <span class="mp-header__search-dot"></span>搜索分类名称
  320. </div>
  321. </header>
  322. <span class="scene-tag">场景:列表无数据</span>
  323. <div class="empty empty-b">
  324. <div class="empty-b__art" aria-hidden="true">
  325. <div class="empty-b__shadow"></div>
  326. <div class="empty-b__folder">
  327. <div class="empty-b__folder-tab"></div>
  328. <div class="empty-b__folder-back"></div>
  329. <div class="empty-b__folder-front">
  330. <div class="empty-b__lines"><i></i><i></i><i></i></div>
  331. </div>
  332. </div>
  333. </div>
  334. <p class="empty__title">暂无产品分类</p>
  335. <p class="empty__desc">分类树为空,创建后即可在产品中引用</p>
  336. <div class="empty__actions">
  337. <button class="mp-btn mp-btn--ghost" type="button">刷新</button>
  338. <button class="mp-btn mp-btn--primary" type="button">新增分类</button>
  339. </div>
  340. </div>
  341. </div>
  342. </section>
  343. <!-- ── C ── -->
  344. <section class="stage" id="stage-c">
  345. <div class="phone-frame">
  346. <header class="mp-header">
  347. <div class="mp-header__row">
  348. <a class="mp-subpage-back" href="shanxia-mp-workbench-demo.html">← 工作台</a>
  349. <button class="mp-header__action" type="button">+ 新增</button>
  350. </div>
  351. <h1 class="mp-header__title" style="margin-top:8px">产品分类</h1>
  352. <div class="mp-header__search" style="margin-top:10px">
  353. <span class="mp-header__search-dot"></span>有机溶剂zzz
  354. </div>
  355. </header>
  356. <span class="scene-tag">场景:搜索无结果</span>
  357. <div class="empty empty-c">
  358. <div class="empty-c__glyph" aria-hidden="true">
  359. <svg viewBox="0 0 64 64" fill="none">
  360. <circle cx="28" cy="28" r="14" stroke="currentColor" stroke-width="2.4"/>
  361. <path d="M38 38l12 12" stroke="currentColor" stroke-width="2.4" stroke-linecap="round"/>
  362. <path d="M22 28h12M28 22v12" stroke="currentColor" stroke-width="2" stroke-linecap="round" opacity="0.45"/>
  363. </svg>
  364. </div>
  365. <p class="empty__title">未找到相关分类</p>
  366. <p class="empty__desc">试试更短的关键词,或清除筛选后查看全部</p>
  367. <div class="empty__actions">
  368. <button class="mp-btn mp-btn--ghost" type="button">清除条件</button>
  369. </div>
  370. </div>
  371. </div>
  372. </section>
  373. <!-- ── D ── -->
  374. <section class="stage" id="stage-d">
  375. <div class="phone-frame">
  376. <header class="mp-header">
  377. <div class="mp-header__row">
  378. <a class="mp-subpage-back" href="shanxia-mp-workbench-demo.html">← 工作台</a>
  379. <button class="mp-header__action" type="button">+ 新增</button>
  380. </div>
  381. <h1 class="mp-header__title" style="margin-top:8px">产品分类</h1>
  382. </header>
  383. <span class="scene-tag">场景:首次引导创建</span>
  384. <div class="empty empty-d">
  385. <div class="empty-d__panel">
  386. <div class="empty-d__icon" aria-hidden="true">+</div>
  387. <p class="empty__title">还没有产品分类</p>
  388. <p class="empty__desc">建议先建一级分类(如原料、助剂),再按需添加子类</p>
  389. <div class="empty__actions">
  390. <button class="mp-btn mp-btn--primary" type="button">立即新增</button>
  391. </div>
  392. </div>
  393. </div>
  394. </div>
  395. </section>
  396. </div>
  397. <script>
  398. const notes = {
  399. a: document.getElementById('note-a'),
  400. b: document.getElementById('note-b'),
  401. c: document.getElementById('note-c'),
  402. d: document.getElementById('note-d')
  403. }
  404. document.querySelectorAll('.pick-tab').forEach((tab) => {
  405. tab.addEventListener('click', () => {
  406. const key = tab.dataset.stage
  407. document.querySelectorAll('.pick-tab').forEach((t) => t.classList.remove('active'))
  408. document.querySelectorAll('.stage').forEach((s) => s.classList.remove('active'))
  409. Object.values(notes).forEach((n) => { n.style.display = 'none' })
  410. tab.classList.add('active')
  411. document.getElementById('stage-' + key).classList.add('active')
  412. notes[key].style.display = 'block'
  413. })
  414. })
  415. </script>
  416. </body>
  417. </html>