sanqiang-client-ui-demo.html 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391
  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>叁强鲜配 - 客户端UI Demo</title>
  7. <style>
  8. :root {
  9. --brand-green: #0a9f6d;
  10. --brand-green-soft: #e9f9f2;
  11. --barley-yellow: #d6a343;
  12. --bg: #f5f8f7;
  13. --card: #ffffff;
  14. --text: #1f2a26;
  15. --muted: #6b7b74;
  16. --border: #dcebe4;
  17. --danger: #d14343;
  18. --shadow: 0 8px 20px rgba(10, 159, 109, 0.12);
  19. }
  20. * { box-sizing: border-box; margin: 0; padding: 0; }
  21. body { background: var(--bg); color: var(--text); font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", sans-serif; }
  22. .phone { max-width: 420px; margin: 0 auto; min-height: 100vh; padding-bottom: 94px; }
  23. .top {
  24. position: sticky; top: 0; z-index: 30;
  25. background: linear-gradient(145deg, #0a9f6d 0%, #11b37a 70%, #d6a343 160%);
  26. padding: 14px 16px 16px;
  27. border-bottom-left-radius: 22px; border-bottom-right-radius: 22px;
  28. box-shadow: var(--shadow);
  29. }
  30. .top-row { display: flex; align-items: center; justify-content: space-between; color: #fff; font-size: 14px; margin-bottom: 10px; }
  31. .search { background: #fff; min-height: 44px; border-radius: 22px; display: flex; align-items: center; padding: 0 14px; color: #8aa39a; font-size: 14px; }
  32. .section { margin: 12px 16px; }
  33. .section-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
  34. .section-head h3 { font-size: 17px; }
  35. .section-head span { font-size: 12px; color: var(--muted); }
  36. .first-level {
  37. display: flex;
  38. gap: 10px;
  39. overflow-x: auto;
  40. scroll-snap-type: x mandatory;
  41. padding: 2px 2px 2px;
  42. scrollbar-width: none;
  43. }
  44. .first-level::-webkit-scrollbar {
  45. display: none;
  46. }
  47. .first-level-indicator {
  48. display: flex;
  49. justify-content: center;
  50. gap: 8px;
  51. margin: 8px auto 0;
  52. }
  53. .indicator-dot {
  54. width: 18px;
  55. height: 4px;
  56. border-radius: 999px;
  57. background: #dbe9e2;
  58. cursor: pointer;
  59. transition: all 0.2s ease;
  60. }
  61. .indicator-dot.active {
  62. width: 28px;
  63. background: linear-gradient(145deg, #11b37a, #0a9f6d);
  64. }
  65. .first-page {
  66. flex: 0 0 100%;
  67. display: grid;
  68. grid-template-columns: repeat(5, 1fr);
  69. gap: 8px;
  70. padding: 4px;
  71. background: #fff;
  72. border: 1px solid var(--border);
  73. border-radius: 14px;
  74. scroll-snap-align: start;
  75. }
  76. .first-chip {
  77. min-height: 92px;
  78. border-radius: 14px;
  79. display: flex;
  80. flex-direction: column;
  81. align-items: center;
  82. justify-content: center;
  83. gap: 8px;
  84. font-size: 11px;
  85. border: none;
  86. background: transparent;
  87. color: #4f665d;
  88. text-align: center;
  89. line-height: 1.2;
  90. box-shadow: none;
  91. }
  92. .first-chip::before {
  93. content: "";
  94. width: 42px;
  95. height: 42px;
  96. border-radius: 12px;
  97. background: linear-gradient(145deg, #dff1e8, #cdebdc);
  98. box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.04);
  99. }
  100. .first-chip.active {
  101. background: linear-gradient(145deg, #e7f8f0, #f1fbf6);
  102. color: var(--brand-green);
  103. border: none;
  104. font-weight: 600;
  105. box-shadow: 0 8px 16px rgba(10, 159, 109, 0.16);
  106. transform: translateY(-2px);
  107. }
  108. .first-chip.active::before {
  109. background: linear-gradient(145deg, #0a9f6d, #11b37a);
  110. }
  111. .category-layout {
  112. margin-top: 10px;
  113. background: #fff;
  114. border: 1px solid var(--border);
  115. border-radius: 16px;
  116. overflow: hidden;
  117. display: grid;
  118. grid-template-columns: 92px 1fr;
  119. min-height: 440px;
  120. }
  121. .second-level {
  122. background: #f8fcfa;
  123. border-right: 1px solid #edf5f1;
  124. padding: 6px 0;
  125. }
  126. .second-item {
  127. min-height: 42px;
  128. display: flex;
  129. align-items: center;
  130. justify-content: center;
  131. padding: 0 8px;
  132. color: #5f726a;
  133. font-size: 12px;
  134. text-align: center;
  135. border-left: 3px solid transparent;
  136. }
  137. .second-item.active {
  138. color: var(--brand-green);
  139. background: #fff;
  140. font-weight: 600;
  141. border-left-color: var(--brand-green);
  142. }
  143. .goods-area { padding: 10px; }
  144. .goods-tip {
  145. min-height: 30px;
  146. background: #f4fbf8;
  147. border: 1px solid #ddefe7;
  148. border-radius: 8px;
  149. color: #5e746a;
  150. font-size: 11px;
  151. display: flex;
  152. align-items: center;
  153. padding: 0 10px;
  154. margin-bottom: 10px;
  155. }
  156. .goods-list { display: grid; grid-template-columns: 1fr; gap: 10px; }
  157. .goods-card {
  158. display: grid;
  159. grid-template-columns: 92px 1fr;
  160. gap: 10px;
  161. border: 1px solid var(--border);
  162. border-radius: 12px;
  163. overflow: hidden;
  164. background: #fff;
  165. }
  166. .thumb { background: linear-gradient(145deg, #f4fbf8, #e4f6ef); min-height: 92px; }
  167. .info { padding: 8px 10px 8px 0; }
  168. .name { font-size: 13px; line-height: 1.35; min-height: 34px; }
  169. .meta { color: var(--muted); font-size: 11px; margin: 4px 0 8px; }
  170. .price-row { display: flex; align-items: center; justify-content: space-between; }
  171. .price { color: var(--danger); font-size: 16px; font-weight: 700; }
  172. .add { width: 32px; height: 32px; border-radius: 50%; background: var(--brand-green); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 20px; }
  173. .cart-bar {
  174. position: fixed;
  175. left: 50%;
  176. transform: translateX(-50%);
  177. bottom: 72px;
  178. width: min(420px, 100%);
  179. padding: 0 12px;
  180. z-index: 40;
  181. }
  182. .cart-inner {
  183. min-height: 58px;
  184. border-radius: 18px;
  185. background: linear-gradient(145deg, #ffffff, #f5fbf8);
  186. border: 1px solid #d9ebe3;
  187. color: var(--text);
  188. display: flex;
  189. align-items: center;
  190. justify-content: space-between;
  191. padding: 8px;
  192. box-shadow: 0 8px 18px rgba(10, 159, 109, 0.12);
  193. }
  194. .cart-left {
  195. display: flex;
  196. align-items: center;
  197. gap: 10px;
  198. padding-left: 4px;
  199. }
  200. .cart-count {
  201. min-width: 26px;
  202. height: 26px;
  203. border-radius: 13px;
  204. background: linear-gradient(145deg, #0a9f6d, #11b37a);
  205. display: inline-flex;
  206. align-items: center;
  207. justify-content: center;
  208. font-size: 12px;
  209. font-weight: 700;
  210. color: #fff;
  211. }
  212. .cart-text { display: flex; flex-direction: column; gap: 1px; }
  213. .cart-items { font-size: 11px; color: #6f8179; }
  214. .cart-total { font-size: 16px; font-weight: 700; letter-spacing: 0.2px; color: #1f2a26; }
  215. .settle {
  216. min-height: 42px;
  217. padding: 0 18px;
  218. border-radius: 14px;
  219. background: linear-gradient(145deg, #d6a343, #e4b458);
  220. color: #fff;
  221. display: inline-flex;
  222. align-items: center;
  223. font-size: 14px;
  224. font-weight: 700;
  225. box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.1);
  226. }
  227. .tab {
  228. position: fixed; left: 50%; transform: translateX(-50%); bottom: 0; width: min(420px, 100%);
  229. background: #fff; border-top: 1px solid var(--border); min-height: 64px; display: grid; grid-template-columns: repeat(4, 1fr); z-index: 45;
  230. }
  231. .tab-item { font-size: 11px; color: #7f8c87; display: flex; flex-direction: column; gap: 4px; align-items: center; justify-content: center; }
  232. .tab-item.active { color: var(--brand-green); font-weight: 600; }
  233. .tab-dot { width: 20px; height: 20px; border-radius: 6px; background: #dfeee7; }
  234. </style>
  235. </head>
  236. <body>
  237. <main class="phone">
  238. <header class="top">
  239. <div class="top-row">
  240. <span>配送到:南山区科技园</span>
  241. <span>叁强鲜配</span>
  242. </div>
  243. <div class="search">搜索商品、品牌、一级/二级分类</div>
  244. </header>
  245. <section class="section">
  246. <div class="section-head">
  247. <h3>商品分类</h3>
  248. <span>选大类后再选二级分类</span>
  249. </div>
  250. <div class="first-level" id="firstLevelPager">
  251. <div class="first-page">
  252. <div class="first-chip active">蔬菜</div>
  253. <div class="first-chip">水果</div>
  254. <div class="first-chip">肉禽蛋</div>
  255. <div class="first-chip">水产海鲜</div>
  256. <div class="first-chip">粮油干货</div>
  257. <div class="first-chip">冻品速食</div>
  258. <div class="first-chip">豆乳制品</div>
  259. <div class="first-chip">调味辅料</div>
  260. <div class="first-chip">鲜面主食</div>
  261. <div class="first-chip">饮品冲调</div>
  262. </div>
  263. <div class="first-page">
  264. <div class="first-chip">烘焙甜品</div>
  265. <div class="first-chip">地方特产</div>
  266. <div class="first-chip">净菜套餐</div>
  267. <div class="first-chip">节日礼盒</div>
  268. <div class="first-chip">门店热销</div>
  269. <div class="first-chip">新品上市</div>
  270. <div class="first-chip">限时秒杀</div>
  271. <div class="first-chip">企业采购</div>
  272. <div class="first-chip">食堂专供</div>
  273. <div class="first-chip">更多分类</div>
  274. </div>
  275. </div>
  276. <div class="first-level-indicator" id="firstLevelIndicator">
  277. <span class="indicator-dot active" data-page="0"></span>
  278. <span class="indicator-dot" data-page="1"></span>
  279. </div>
  280. <div class="category-layout">
  281. <aside class="second-level">
  282. <div class="second-item active">全部</div>
  283. <div class="second-item">叶菜类</div>
  284. <div class="second-item">根茎类</div>
  285. <div class="second-item">菌菇类</div>
  286. <div class="second-item">豆制品</div>
  287. <div class="second-item">净菜半成品</div>
  288. </aside>
  289. <section class="goods-area">
  290. <div class="goods-tip">当前:一级分类「蔬菜」 / 二级分类「全部」</div>
  291. <div class="goods-list">
  292. <article class="goods-card">
  293. <div class="thumb"></div>
  294. <div class="info">
  295. <div class="name">云南有机小青菜 500g</div>
  296. <div class="meta">叶菜类 · 24 小时内采收</div>
  297. <div class="price-row"><span class="price">¥8.80</span><span class="add">+</span></div>
  298. </div>
  299. </article>
  300. <article class="goods-card">
  301. <div class="thumb"></div>
  302. <div class="info">
  303. <div class="name">山东胡萝卜 500g</div>
  304. <div class="meta">根茎类 · 脆甜少渣</div>
  305. <div class="price-row"><span class="price">¥6.50</span><span class="add">+</span></div>
  306. </div>
  307. </article>
  308. <article class="goods-card">
  309. <div class="thumb"></div>
  310. <div class="info">
  311. <div class="name">杏鲍菇 400g</div>
  312. <div class="meta">菌菇类 · 门店直发</div>
  313. <div class="price-row"><span class="price">¥9.90</span><span class="add">+</span></div>
  314. </div>
  315. </article>
  316. </div>
  317. </section>
  318. </div>
  319. </section>
  320. </main>
  321. <div class="cart-bar">
  322. <div class="cart-inner">
  323. <div class="cart-left">
  324. <span class="cart-count">6</span>
  325. <span class="cart-text">
  326. <span class="cart-items">已选商品</span>
  327. <span class="cart-total">¥148.30</span>
  328. </span>
  329. </div>
  330. <span class="settle">去结算</span>
  331. </div>
  332. </div>
  333. <nav class="tab">
  334. <a class="tab-item active"><span class="tab-dot"></span><span>首页</span></a>
  335. <a class="tab-item"><span class="tab-dot"></span><span>订单</span></a>
  336. <a class="tab-item"><span class="tab-dot"></span><span>购物车</span></a>
  337. <a class="tab-item"><span class="tab-dot"></span><span>我的</span></a>
  338. </nav>
  339. <script>
  340. (function () {
  341. var pager = document.getElementById("firstLevelPager");
  342. var indicator = document.getElementById("firstLevelIndicator");
  343. if (!pager || !indicator) return;
  344. var dots = Array.prototype.slice.call(indicator.querySelectorAll(".indicator-dot"));
  345. var pages = Array.prototype.slice.call(pager.querySelectorAll(".first-page"));
  346. function setActive(index) {
  347. dots.forEach(function (dot, i) {
  348. if (i === index) dot.classList.add("active");
  349. else dot.classList.remove("active");
  350. });
  351. }
  352. function scrollToPage(index) {
  353. var page = pages[index];
  354. if (!page) return;
  355. pager.scrollTo({ left: page.offsetLeft, behavior: "smooth" });
  356. setActive(index);
  357. }
  358. dots.forEach(function (dot) {
  359. dot.addEventListener("click", function () {
  360. var page = Number(dot.getAttribute("data-page") || 0);
  361. scrollToPage(page);
  362. });
  363. });
  364. pager.addEventListener("scroll", function () {
  365. var pageWidth = pager.clientWidth;
  366. if (!pageWidth) return;
  367. var idx = Math.round(pager.scrollLeft / pageWidth);
  368. if (idx < 0) idx = 0;
  369. if (idx > dots.length - 1) idx = dots.length - 1;
  370. setActive(idx);
  371. });
  372. })();
  373. </script>
  374. </body>
  375. </html>