shareIndex.html 81 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839
  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, viewport-fit=cover">
  6. <meta name="format-detection" content="telephone=no">
  7. <title>U店在哪</title>
  8. <style>
  9. :root {
  10. --orange: #F58220;
  11. --orange-light: #FFF4E8;
  12. --red: #FF4D4F;
  13. --text: #333333;
  14. --text-secondary: #999999;
  15. --border: #EEEEEE;
  16. --bg: #FFFFFF;
  17. --safe-bottom: env(safe-area-inset-bottom, 0px);
  18. }
  19. * {
  20. margin: 0;
  21. padding: 0;
  22. box-sizing: border-box;
  23. }
  24. html {
  25. font-size: 16px;
  26. -webkit-tap-highlight-color: transparent;
  27. overflow-x: hidden;
  28. }
  29. body {
  30. font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", sans-serif;
  31. background: var(--bg);
  32. color: var(--text);
  33. padding-bottom: calc(88px + var(--safe-bottom));
  34. min-height: 100vh;
  35. overflow-x: hidden;
  36. }
  37. /* Header */
  38. .header {
  39. position: sticky;
  40. top: 0;
  41. z-index: 100;
  42. display: flex;
  43. align-items: center;
  44. justify-content: center;
  45. height: 44px;
  46. padding: 0 15px;
  47. background: var(--bg);
  48. border-bottom: 1px solid var(--border);
  49. }
  50. .header__back {
  51. position: absolute;
  52. left: 15px;
  53. width: 24px;
  54. height: 24px;
  55. display: flex;
  56. align-items: center;
  57. justify-content: center;
  58. color: var(--text);
  59. text-decoration: none;
  60. }
  61. .header__title {
  62. font-size: 17px;
  63. font-weight: 600;
  64. color: var(--text);
  65. }
  66. /* Hero carousel */
  67. .hero {
  68. position: relative;
  69. margin: 0 15px;
  70. margin-top: 10px;
  71. border-radius: 0 0 12px 12px;
  72. overflow: hidden;
  73. }
  74. .hero__track {
  75. display: flex;
  76. transition: transform 0.35s ease;
  77. }
  78. .hero__slide {
  79. flex: 0 0 100%;
  80. aspect-ratio: 16 / 10;
  81. background: #f0f0f0;
  82. }
  83. .hero__slide img {
  84. width: 100%;
  85. height: 100%;
  86. object-fit: cover;
  87. display: block;
  88. vertical-align: middle;
  89. }
  90. .hero__dots {
  91. position: absolute;
  92. bottom: 12px;
  93. left: 0;
  94. right: 0;
  95. display: flex;
  96. justify-content: center;
  97. align-items: center;
  98. gap: 6px;
  99. }
  100. .hero__dot {
  101. width: 6px;
  102. height: 6px;
  103. border-radius: 3px;
  104. background: rgba(255, 255, 255, 0.45);
  105. transition: width 0.25s ease, background 0.25s ease;
  106. }
  107. .hero__dot.is-active {
  108. width: 16px;
  109. background: #fff;
  110. }
  111. /* Store block */
  112. .section {
  113. padding: 16px 15px 0;
  114. }
  115. .store-name {
  116. font-size: 20px;
  117. font-weight: 700;
  118. line-height: 1.35;
  119. margin-bottom: 12px;
  120. }
  121. .row {
  122. display: flex;
  123. align-items: center;
  124. justify-content: space-between;
  125. gap: 10px;
  126. }
  127. .rating-row {
  128. margin-bottom: 12px;
  129. }
  130. .stars {
  131. display: inline-flex;
  132. align-items: center;
  133. gap: 2px;
  134. }
  135. .star {
  136. width: 14px;
  137. height: 14px;
  138. color: var(--orange);
  139. }
  140. .rating-num {
  141. font-size: 14px;
  142. font-weight: 600;
  143. color: var(--orange);
  144. }
  145. .store-evaluate-row {
  146. display: none;
  147. flex-direction: row;
  148. flex-wrap: wrap;
  149. align-items: center;
  150. gap: 6px 6px;
  151. margin: 0 0 12px;
  152. padding: 0;
  153. font-size: 13px;
  154. line-height: 1.4;
  155. color: var(--text-secondary);
  156. }
  157. .store-evaluate-row.is-visible {
  158. display: flex;
  159. }
  160. .store-evaluate__item {
  161. white-space: nowrap;
  162. }
  163. .link-muted {
  164. display: inline-flex;
  165. align-items: center;
  166. gap: 2px;
  167. font-size: 13px;
  168. color: var(--text-secondary);
  169. text-decoration: none;
  170. }
  171. .chevron {
  172. width: 14px;
  173. height: 14px;
  174. opacity: 0.6;
  175. }
  176. .hours-row {
  177. /* margin-bottom: 16px; */
  178. align-items: flex-start;
  179. border-bottom:1px solid #eee;
  180. padding-bottom: 20px;
  181. }
  182. .hours-left {
  183. flex: 1;
  184. min-width: 0;
  185. }
  186. .status {
  187. font-size: 14px;
  188. color: var(--red);
  189. margin-right: 8px;
  190. }
  191. .status.is-open {
  192. color: var(--orange);
  193. }
  194. .hours-text {
  195. font-size: 14px;
  196. color: var(--text-secondary);
  197. }
  198. .divider {
  199. height: 8px;
  200. background: #F7F7F7;
  201. margin: 0;
  202. }
  203. /* Location */
  204. .loc-wrap {
  205. display: flex;
  206. padding: 16px 15px;
  207. gap: 12px;
  208. }
  209. .loc-main {
  210. flex: 1;
  211. min-width: 0;
  212. padding-right: 12px;
  213. }
  214. .addr {
  215. font-size: 15px;
  216. font-weight: 600;
  217. line-height: 1.45;
  218. margin-bottom: 10px;
  219. }
  220. .meta-line {
  221. display: flex;
  222. align-items: flex-start;
  223. gap: 6px;
  224. font-size: 13px;
  225. color: var(--text-secondary);
  226. line-height: 1.45;
  227. margin-top: 6px;
  228. }
  229. .meta-line svg,
  230. .meta-line img {
  231. flex-shrink: 0;
  232. margin-top: 2px;
  233. opacity: 0.75;
  234. display: block;
  235. }
  236. .loc-actions {
  237. display: flex;
  238. flex-direction: row;
  239. align-items: center;
  240. justify-content: center;
  241. gap: 18px;
  242. flex-shrink: 0;
  243. }
  244. .act-btn {
  245. display: flex;
  246. flex-direction: column;
  247. align-items: center;
  248. gap: 4px;
  249. background: none;
  250. border: none;
  251. padding: 0;
  252. cursor: pointer;
  253. font-size: 12px;
  254. color: var(--text);
  255. }
  256. .act-btn__icon {
  257. width: 44px;
  258. height: 44px;
  259. border-radius: 10px;
  260. background: #F5F5F5;
  261. display: flex;
  262. align-items: center;
  263. justify-content: center;
  264. color: var(--orange);
  265. }
  266. .act-btn__icon img {
  267. width: 22px;
  268. height: 22px;
  269. object-fit: contain;
  270. display: block;
  271. }
  272. /* businessStatus===99 时仅展示关店提示并隐藏 .share-content;底部 FAB 仍在 #shareBelowContentEl */
  273. .closed-rec-wrap {
  274. display: none;
  275. }
  276. .closed-rec-divider {
  277. height: 8px;
  278. background: #F7F7F7;
  279. margin: 0;
  280. }
  281. .closed-rec-title {
  282. padding: 8px 15px 12px;
  283. font-size: 16px;
  284. font-weight: 700;
  285. }
  286. .closed-rec-grid {
  287. display: grid;
  288. grid-template-columns: repeat(2, 1fr);
  289. gap: 10px;
  290. padding: 0 15px 20px;
  291. }
  292. #shareClosedRecEmpty {
  293. grid-column: 1 / -1;
  294. }
  295. .closed-rec-empty {
  296. padding: 12px;
  297. color: var(--text-secondary);
  298. font-size: 14px;
  299. }
  300. .closed-rec-card {
  301. min-width: 0;
  302. background: #fff;
  303. border-radius: 10px;
  304. overflow: hidden;
  305. box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
  306. }
  307. .closed-rec-card__img {
  308. aspect-ratio: 4 / 3;
  309. background: #eee;
  310. }
  311. .closed-rec-card__img img {
  312. width: 100%;
  313. height: 100%;
  314. object-fit: cover;
  315. display: block;
  316. border-radius: 0;
  317. }
  318. .closed-rec-card__body {
  319. padding: 10px;
  320. }
  321. .closed-rec-card__top {
  322. display: flex;
  323. justify-content: space-between;
  324. align-items: baseline;
  325. gap: 8px;
  326. margin-bottom: 6px;
  327. }
  328. .closed-rec-card__name {
  329. font-size: 15px;
  330. font-weight: 700;
  331. flex: 1;
  332. min-width: 0;
  333. overflow: hidden;
  334. text-overflow: ellipsis;
  335. white-space: nowrap;
  336. }
  337. .closed-rec-card__dist {
  338. font-size: 12px;
  339. color: var(--text-secondary);
  340. flex-shrink: 0;
  341. }
  342. .closed-rec-card__rating {
  343. display: flex;
  344. align-items: center;
  345. flex-wrap: wrap;
  346. gap: 4px 6px;
  347. }
  348. .closed-rec-card__rating .closed-rec-stars {
  349. display: inline-flex;
  350. align-items: center;
  351. gap: 2px;
  352. }
  353. .closed-rec-card__rating .closed-rec-star {
  354. display: block;
  355. flex-shrink: 0;
  356. }
  357. .closed-rec-card__rating .closed-rec-rating-num {
  358. font-size: 12px;
  359. font-weight: 600;
  360. color: var(--orange);
  361. }
  362. .closed-rec-meta {
  363. font-size: 12px;
  364. color: var(--text-secondary);
  365. }
  366. .closed-rec-card__footer {
  367. margin-top: 8px;
  368. font-size: 12px;
  369. color: var(--text-secondary);
  370. overflow: hidden;
  371. text-overflow: ellipsis;
  372. white-space: nowrap;
  373. }
  374. .share-none {
  375. display: none;
  376. text-align: center;
  377. padding: 28px 20px 16px;
  378. color: var(--text-muted);
  379. font-size: 15px;
  380. line-height: 1.5;
  381. }
  382. .share-none img {
  383. width: 240px;
  384. height: 240px;
  385. margin-bottom: 12px;
  386. display: inline-block;
  387. }
  388. .share-none p {
  389. margin: 0;
  390. padding:0 0 60px 0;
  391. color:#999;
  392. }
  393. /* FAB */
  394. .fab-wrap {
  395. position: fixed;
  396. left: 0;
  397. right: 0;
  398. bottom: 0;
  399. z-index: 200;
  400. padding: 12px 24px calc(12px + var(--safe-bottom));
  401. background: linear-gradient(to top, rgba(255, 255, 255, 0.98) 70%, transparent);
  402. pointer-events: none;
  403. }
  404. .fab-wrap .fab {
  405. pointer-events: auto;
  406. }
  407. #fabDock {
  408. display: block;
  409. }
  410. .fab-dock__slot {
  411. position: relative;
  412. width: 100%;
  413. max-width: 320px;
  414. height: 48px;
  415. margin: 0 auto;
  416. }
  417. /* 底层按钮图始终可见;微信 JSSDK 成功后由上层开放标签接收点击 */
  418. #openApp {
  419. pointer-events: auto;
  420. }
  421. .fab-wx-hit {
  422. display: none;
  423. position: absolute;
  424. left: 0;
  425. right: 0;
  426. top: 0;
  427. height: 48px;
  428. z-index: 3;
  429. pointer-events: auto;
  430. }
  431. #fabDock.wx-open-enabled .fab-wx-hit {
  432. display: block;
  433. }
  434. #fabDock.wx-open-enabled #openApp {
  435. pointer-events: none;
  436. }
  437. #launch-btn {
  438. display: block;
  439. width: 100%;
  440. height: 48px;
  441. min-height: 48px;
  442. }
  443. .fab {
  444. display: flex;
  445. align-items: center;
  446. justify-content: center;
  447. gap: 10px;
  448. width: 100%;
  449. max-width: 320px;
  450. margin: 0 auto;
  451. height: 48px;
  452. border: none;
  453. border-radius: 24px;
  454. background: var(--orange);
  455. color: #fff;
  456. font-size: 16px;
  457. font-weight: 600;
  458. box-shadow: 0 4px 16px rgba(245, 130, 32, 0.45);
  459. cursor: pointer;
  460. background:#F47D1F;
  461. }
  462. .fab__logo {
  463. width: 28px;
  464. height: 28px;
  465. flex-shrink: 0;
  466. }
  467. .home-indicator {
  468. height: 5px;
  469. background: #000;
  470. border-radius: 3px;
  471. width: 134px;
  472. margin: 8px auto 4px;
  473. opacity: 0.2;
  474. }
  475. /* 营销活动(getStoreCouponList.marketingList) */
  476. .marketing-section {
  477. padding: 4px 15px 20px;
  478. }
  479. .marketing-section__title {
  480. font-size: 16px;
  481. font-weight: 700;
  482. color: var(--text);
  483. margin: 0 0 12px;
  484. }
  485. .marketing-section__list {
  486. display: flex;
  487. flex-direction: column;
  488. gap: 12px;
  489. }
  490. .marketing-card {
  491. border-radius: 12px;
  492. overflow: hidden;
  493. background: #f0f0f0;
  494. box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
  495. }
  496. .marketing-card__media img,
  497. .marketing-card__media video {
  498. width: 100%;
  499. display: block;
  500. aspect-ratio: 16 / 9;
  501. object-fit: cover;
  502. vertical-align: middle;
  503. }
  504. .marketing-card__media video {
  505. background: #000;
  506. }
  507. .marketing-card--more {
  508. display: none;
  509. }
  510. .marketing-section.is-expanded .marketing-card--more {
  511. display: block;
  512. }
  513. .marketing-section__more {
  514. display: flex;
  515. align-items: center;
  516. justify-content: center;
  517. gap: 4px;
  518. width: 100%;
  519. margin-top: 14px;
  520. padding: 8px 0;
  521. border: none;
  522. background: none;
  523. font-size: 14px;
  524. color: var(--text-secondary);
  525. cursor: pointer;
  526. -webkit-tap-highlight-color: transparent;
  527. }
  528. .marketing-section__more-chevron {
  529. width: 16px;
  530. height: 16px;
  531. flex-shrink: 0;
  532. transition: transform 0.2s ease;
  533. }
  534. .marketing-section.is-expanded .marketing-section__more-chevron {
  535. transform: rotate(180deg);
  536. }
  537. .marketing-section__empty {
  538. display: flex;
  539. flex-direction: column;
  540. justify-content: center;
  541. align-items: center;
  542. padding: 10px 0 8px;
  543. }
  544. .marketing-section__empty img {
  545. width: 200px;
  546. height: 200px;
  547. display: block;
  548. object-fit: contain;
  549. }
  550. .marketing-section__empty-label {
  551. margin: 12px 0 0;
  552. font-size: 14px;
  553. color: var(--text-secondary);
  554. text-align: center;
  555. }
  556. /* 演出安排 performance/list/query */
  557. .performance-section {
  558. padding: 8px 0 20px;
  559. border-top: 1px solid var(--border);
  560. margin-top: 4px;
  561. }
  562. .performance-section__title {
  563. font-size: 16px;
  564. font-weight: 700;
  565. color: var(--text);
  566. margin: 0 15px 12px;
  567. }
  568. .performance-strip {
  569. display: flex;
  570. flex-direction: row;
  571. flex-wrap: nowrap;
  572. gap: 12px;
  573. overflow-x: auto;
  574. overflow-y: hidden;
  575. padding: 0 15px 4px;
  576. -webkit-overflow-scrolling: touch;
  577. scrollbar-width: none;
  578. }
  579. .performance-strip::-webkit-scrollbar {
  580. display: none;
  581. }
  582. .performance-card {
  583. flex: 0 0 auto;
  584. display: flex;
  585. flex-direction: row;
  586. align-items: stretch;
  587. gap: 10px;
  588. width: 272px;
  589. min-width: 272px;
  590. padding: 0;
  591. background: #fff;
  592. border-radius: 12px;
  593. overflow: hidden;
  594. }
  595. .performance-card__poster {
  596. flex: 0 0 76px;
  597. width: 76px;
  598. min-height: 102px;
  599. background: #eee;
  600. align-self: stretch;
  601. }
  602. .performance-card__poster img {
  603. width: 100%;
  604. height: 100%;
  605. min-height: 102px;
  606. object-fit: cover;
  607. display: block;
  608. vertical-align: middle;
  609. }
  610. .performance-card__body {
  611. flex: 1;
  612. min-width: 0;
  613. display: flex;
  614. flex-direction: column;
  615. justify-content: center;
  616. gap: 4px;
  617. padding: 10px 12px 10px 0;
  618. }
  619. .performance-card__name {
  620. font-size: 15px;
  621. font-weight: 700;
  622. color: var(--text);
  623. line-height: 1.3;
  624. overflow: hidden;
  625. text-overflow: ellipsis;
  626. display: -webkit-box;
  627. -webkit-line-clamp: 2;
  628. -webkit-box-orient: vertical;
  629. }
  630. .performance-card__meta {
  631. font-size: 12px;
  632. color: var(--text-secondary);
  633. line-height: 1.35;
  634. overflow: hidden;
  635. text-overflow: ellipsis;
  636. white-space: nowrap;
  637. }
  638. /* 人员阵容 queryStaffListByTitle */
  639. .staff-section {
  640. padding: 8px 0 24px;
  641. border-top: 1px solid var(--border);
  642. margin-top: 4px;
  643. }
  644. .staff-section__head {
  645. display: flex;
  646. align-items: center;
  647. justify-content: space-between;
  648. gap: 12px;
  649. padding: 0 15px;
  650. margin-bottom: 12px;
  651. }
  652. .staff-section__page-title {
  653. font-size: 16px;
  654. font-weight: 700;
  655. color: var(--text);
  656. margin: 0;
  657. flex: 1;
  658. min-width: 0;
  659. }
  660. .staff-section__all {
  661. flex-shrink: 0;
  662. display: inline-flex;
  663. align-items: center;
  664. gap: 2px;
  665. font-size: 13px;
  666. color: #151515;
  667. text-decoration: none;
  668. background: none;
  669. border: none;
  670. padding: 0;
  671. cursor: pointer;
  672. -webkit-tap-highlight-color: transparent;
  673. }
  674. .staff-section__all-chevron {
  675. width: 14px;
  676. height: 14px;
  677. opacity: 0.7;
  678. }
  679. .staff-group {
  680. margin-bottom: 20px;
  681. }
  682. .staff-group:last-child {
  683. margin-bottom: 0;
  684. }
  685. .staff-strip {
  686. display: flex;
  687. flex-direction: row;
  688. flex-wrap: nowrap;
  689. gap: 10px;
  690. overflow-x: auto;
  691. overflow-y: hidden;
  692. padding: 0 15px 4px;
  693. -webkit-overflow-scrolling: touch;
  694. scrollbar-width: none;
  695. }
  696. .staff-strip::-webkit-scrollbar {
  697. display: none;
  698. }
  699. .staff-card {
  700. flex: 0 0 112px;
  701. width: 112px;
  702. min-width: 112px;
  703. }
  704. .staff-card__img-wrap {
  705. position: relative;
  706. border-radius: 10px;
  707. overflow: hidden;
  708. background: #eee;
  709. aspect-ratio: 3 / 4;
  710. }
  711. .staff-card__img-wrap img {
  712. width: 100%;
  713. height: 100%;
  714. object-fit: cover;
  715. display: block;
  716. vertical-align: middle;
  717. }
  718. .staff-card__likes {
  719. position: absolute;
  720. left: 0;
  721. right: 0;
  722. bottom: 0;
  723. padding: 6px 8px;
  724. font-size: 11px;
  725. color: #fff;
  726. line-height: 1.2;
  727. background: linear-gradient(to top, rgba(0, 0, 0, 0.65), transparent);
  728. }
  729. .staff-card__name-row {
  730. display: flex;
  731. align-items: center;
  732. gap: 4px;
  733. margin-top: 8px;
  734. min-width: 0;
  735. }
  736. .staff-card__name {
  737. font-size: 14px;
  738. font-weight: 700;
  739. color: var(--text);
  740. overflow: hidden;
  741. text-overflow: ellipsis;
  742. white-space: nowrap;
  743. flex: 1;
  744. min-width: 0;
  745. }
  746. .staff-card__badge {
  747. flex-shrink: 0;
  748. font-size: 10px;
  749. font-weight: 600;
  750. color: #fff;
  751. background: #ff9d4d;
  752. padding: 2px 5px;
  753. border-radius: 3px;
  754. line-height: 1.2;
  755. white-space: nowrap;
  756. }
  757. .staff-card__meta {
  758. display: flex;
  759. align-items: center;
  760. flex-wrap: wrap;
  761. gap: 0 4px;
  762. margin-top: 4px;
  763. font-size: 12px;
  764. color: var(--text-secondary);
  765. line-height: 1.35;
  766. }
  767. .staff-card__position {
  768. overflow: hidden;
  769. text-overflow: ellipsis;
  770. white-space: nowrap;
  771. max-width: 100%;
  772. }
  773. .staff-card__reviews {
  774. display: inline-flex;
  775. align-items: center;
  776. gap: 4px;
  777. }
  778. .staff-card__sep {
  779. color: #ddd;
  780. font-weight: 300;
  781. }
  782. </style>
  783. </head>
  784. <body>
  785. <div class="share-none" id="shareClosedBanner" aria-hidden="true">
  786. <img src="images/storeNone.png" alt="">
  787. <p>抱歉,商户已关闭,看看别的吧</p>
  788. </div>
  789. <div class="closed-rec-wrap" id="shareClosedRecommendWrap" aria-hidden="true">
  790. <div class="closed-rec-divider"></div>
  791. <h3 class="closed-rec-title">更多推荐</h3>
  792. <div class="closed-rec-grid" id="shareClosedRecList">
  793. <p id="shareClosedRecEmpty" class="closed-rec-empty" style="display:none;">暂无推荐</p>
  794. </div>
  795. </div>
  796. <div class="share-content" id="shareContentEl">
  797. <div class="hero" id="hero">
  798. <div class="hero__track" id="heroTrack">
  799. <div class="hero__slide"><img id="heroFallbackImg" src="images/hero.png" alt="店铺图"></div>
  800. </div>
  801. <div class="hero__dots" id="heroDots" aria-hidden="true"></div>
  802. </div>
  803. <!-- 数据由 getClientStoreDetail(id,userId,jingdu,weidu)填充,见 renderDetail -->
  804. <section class="section" id="mainSection">
  805. <p id="pageError" class="page-error" style="display:none;color:#ff4d4f;padding:12px 0;font-size:14px;"></p>
  806. <h2 class="store-name" id="storeName">加载中…</h2>
  807. <div class="row rating-row">
  808. <div class="row" style="flex:1; justify-content:flex-start;">
  809. <span class="stars" aria-label="5.0 分">
  810. <svg class="star" viewBox="0 0 24 24" fill="currentColor"><path d="M12 2l3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01L12 2z"/></svg>
  811. <svg class="star" viewBox="0 0 24 24" fill="currentColor"><path d="M12 2l3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01L12 2z"/></svg>
  812. <svg class="star" viewBox="0 0 24 24" fill="currentColor"><path d="M12 2l3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01L12 2z"/></svg>
  813. <svg class="star" viewBox="0 0 24 24" fill="currentColor"><path d="M12 2l3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01L12 2z"/></svg>
  814. <svg class="star" viewBox="0 0 24 24" fill="currentColor"><path d="M12 2l3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01L12 2z"/></svg>
  815. </span>
  816. <span class="rating-num" id="scoreAvg">—</span>
  817. <span id="commitCount" style="font-size: 14px;">0</span>
  818. </div>
  819. <!-- <a href="#" class="link-muted"><span id="commitCount">0</span>条评价
  820. <svg class="chevron" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="9 18 15 12 9 6"/></svg>
  821. </a> -->
  822. </div>
  823. <div class="store-evaluate-row" id="storeEvaluateRow" aria-hidden="true">
  824. <span class="store-evaluate__item">酒水:<span id="storeEvaluateScoreOne">—</span></span>
  825. <span class="store-evaluate__item">氛围:<span id="storeEvaluateScoreTwo">—</span></span>
  826. <span class="store-evaluate__item">服务:<span id="storeEvaluateScoreThree">—</span></span>
  827. </div>
  828. <div class="row hours-row">
  829. <div class="hours-left">
  830. <span class="status" id="bizStatus">—</span>
  831. <span class="hours-text" id="hoursText">—</span>
  832. </div>
  833. <a href="#" class="link-muted">详情
  834. <svg class="chevron" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="9 18 15 12 9 6"/></svg>
  835. </a>
  836. </div>
  837. </section>
  838. <div class="loc-wrap">
  839. <div class="loc-main">
  840. <p class="addr" id="storeAddr">—</p>
  841. <div class="meta-line" id="metaDistance" style="display:none;">
  842. <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="#999" stroke-width="2"><path d="M21 10c0 7-9 13-9 13s-9-6-9-13a9 9 0 0 1 18 0z"/><circle cx="12" cy="10" r="3"/></svg>
  843. <span id="distanceText">—</span>
  844. </div>
  845. <div class="meta-line" id="metaSubway" style="display:none;">
  846. <img src="images/iconn.png" alt="" width="12" height="12" decoding="async">
  847. <span id="subwayText">—</span>
  848. </div>
  849. </div>
  850. <div class="loc-actions">
  851. <button type="button" class="act-btn" aria-label="导航">
  852. <span class="act-btn__icon">
  853. <img src="images/loc1.png" alt="" width="22" height="22" decoding="async">
  854. </span>
  855. 导航
  856. </button>
  857. <button type="button" class="act-btn" aria-label="电话">
  858. <span class="act-btn__icon">
  859. <img src="images/loc2.png" alt="" width="22" height="22" decoding="async">
  860. </span>
  861. 电话
  862. </button>
  863. </div>
  864. </div>
  865. <section class="marketing-section" id="shareMarketingSection" style="display:none;" aria-hidden="true">
  866. <h3 class="marketing-section__title">营销活动</h3>
  867. <div class="marketing-section__list" id="marketingListEl"></div>
  868. <button type="button" class="marketing-section__more" id="marketingMoreBtn" style="display:none;">
  869. <span id="marketingMoreText"></span>
  870. <svg class="marketing-section__more-chevron" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true"><polyline points="6 9 12 15 18 9"/></svg>
  871. </button>
  872. </section>
  873. <section class="performance-section" id="sharePerformanceSection" style="display:none;" aria-hidden="true">
  874. <h3 class="performance-section__title" id="performanceSectionTitle">演出安排(0)</h3>
  875. <div class="performance-strip" id="performanceStripEl"></div>
  876. </section>
  877. <section class="staff-section" id="shareStaffSection" style="display:none;" aria-hidden="true">
  878. <div class="staff-section__head">
  879. <h3 class="staff-section__page-title">人员阵容(<span id="staffSectionCountEl">0</span>)</h3>
  880. <button type="button" class="staff-section__all" id="staffSectionAllBtn" aria-label="查看全部">
  881. 查看全部
  882. <svg class="staff-section__all-chevron" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true"><polyline points="9 6 15 12 9 18"/></svg>
  883. </button>
  884. </div>
  885. <div id="staffGroupsMount"></div>
  886. </section>
  887. </div>
  888. <div id="fabDock" class="fab-wrap">
  889. <div class="fab-dock__slot">
  890. <button type="button" class="fab" id="openApp">
  891. <img src="images/uBtn.png" alt="APP内打开" decoding="async">
  892. </button>
  893. <div id="fabWxHit" class="fab-wx-hit" aria-hidden="true">
  894. <wx-open-launch-app id="launch-btn" appid="wx5598889b28511717">
  895. <script type="text/wxtag-template">
  896. <style>
  897. .wx-open-app-btn {
  898. display: block;
  899. width: 100%;
  900. height: 48px;
  901. margin: 0;
  902. padding: 0;
  903. border: none;
  904. background: transparent;
  905. }
  906. .wx-open-app-btn img {
  907. display: block;
  908. width: 100%;
  909. height: 48px;
  910. object-fit: contain;
  911. }
  912. </style>
  913. <button class="wx-open-app-btn" aria-label="APP内打开">
  914. <img src="images/uBtn.png" alt="APP内打开" />
  915. </button>
  916. </script>
  917. </wx-open-launch-app>
  918. </div>
  919. </div>
  920. <div class="home-indicator" aria-hidden="true"></div>
  921. </div>
  922. <script src="https://res.wx.qq.com/open/js/jweixin-1.6.0.js"></script>
  923. <script>
  924. (function () {
  925. 'use strict';
  926. /**
  927. * 与 group_user sharePopup 复制链接时携带的 query 一致,例如:
  928. * ?id=436&storeId=436&userId=628&businessSection=3&lat=...&lon=...&jingdu=...&weidu=...&storeName=...&coverUrl=...&desc=...
  929. *
  930. * 进入页先 GET .../store/info/getOne?id=(与 shareDynamic.html 一致);data.businessStatus===99 时先展示关店区(#shareClosedBanner、#shareClosedRecommendWrap)。
  931. * 关店时点「APP内打开」:深链为 shopro://pages/index/login?…(与 group_user pages/index/login),不再进八区详情。
  932. * 店铺头图/名称/评分/地址等(#mainSection、.loc-wrap):GET .../store/info/getClientStoreDetail?id=&userId=&jingdu=&weidu=
  933. * 经纬度:URL 可用 jingdu/weidu;若无则用 lon/lng、lat(与分享链一致)
  934. * 营销活动: GET .../store/info/getStoreCouponList?storeId= → data.marketingList
  935. * 演出安排: GET .../performance/list/query?storeId=&page=&size= → data.records, data.total(仅 URL businessSection=2 时展示与请求)
  936. * 人员阵容: GET .../storeStaffConfig/queryStaffListByTitle?storeId= → data[]
  937. *
  938. * 注意:用 file:// 打开本页时,浏览器可能因 CORS 拦截跨域请求。
  939. * 请用本地 HTTP 打开(如 VS Code Live Server、npx serve)或让后端为 H5 域名配置 Access-Control-Allow-Origin。
  940. */
  941. var API_BASE = 'https://test.ailien.shop/alienStore';
  942. /** wx-open-launch-app 的 appid(开放平台移动应用;若与公众号不同,只改这里和标签 appid) */
  943. var WECHAT_OPEN_APP_ID = 'wx5598889b28511717';
  944. /** 可选:强制 wx.config 使用的公众号 appId;默认用 getWxConfig 返回的 data.appId */
  945. var WECHAT_MP_APP_ID = '';
  946. /**
  947. * 进入页 GET {API_BASE}/wx/getWxConfig?url={当前页完整 URL,含 ? 参数,不含 #}
  948. * 微信校验签名与 location.href.split('#')[0] 必须一致,不能只签 shareIndex.html 无参数
  949. * 可用 ?wxSignPath= 或 ?wxSignUrl= 覆盖。
  950. */
  951. var WECHAT_GET_WX_CONFIG_PATH = '/wx/getWxConfig';
  952. var H5_PAGE_BASE_FALLBACK = 'https://test.ailien.shop/h5/HBuilderProjects/';
  953. /** 本地 file:// 预览时传给 getWxConfig 的默认 url(无 query) */
  954. var WX_GET_CONFIG_SIGN_URL = 'https://test.ailien.shop/h5/HBuilderProjects/shareIndex.html';
  955. /** wx.config 已成功(开放标签可展示);与「用户已成功唤起 App」不是同一回事 */
  956. var weChatJssdkConfigured = false;
  957. var wxConfigSignRetriedBaseUrl = false;
  958. var wxSignUrlFullBeforeStrip = '';
  959. /**
  960. * 关店(businessStatus=99)更多推荐:POST …/ai/multimodal-services/api/v1/search/global/store-recommend
  961. * 与 shareCheckInUndefined.html 一致;请求体 page、pageSize、storeId、userCity、userLat、userLng 可由 URL 覆盖。
  962. */
  963. var API_LIFE_AI_BASE = 'http://183.252.196.135:9100';
  964. var STORE_GLOBAL_RECOMMEND_PATH =
  965. '/ai/multimodal-services/api/v1/search/global/store-recommend';
  966. var DEFAULT_REC_USER_LAT = 38.925747;
  967. var DEFAULT_REC_USER_LNG = 121.662531;
  968. var DEFAULT_REC_USER_CITY = '大连市';
  969. /**
  970. * 与 group_user 一致:
  971. * - manifest:app-plus.distribute.android.schemes、ios.urltypes → shopro(即 shopro://)
  972. * - Android 包名:manifest 未写 packagename 时与 App.vue 升级配置 androidPackageName 一致(云打包以 HBuilderX 为准)
  973. */
  974. var APP_ANDROID_PACKAGE = 'com.alien.Udianzaina';
  975. var APP_IOS_URL_SCHEME = 'shopro://';
  976. /** businessSection 未传或其它值时的默认落地页(与 1 相同) */
  977. var APP_UNI_STORE_PATH = 'pages/ieisureEntertainment/eightTypeList/delicacyDetails';
  978. function showDownloadTip() {
  979. var msg = '请到应用商店下载';
  980. if (typeof uni !== 'undefined' && typeof uni.showToast === 'function') {
  981. uni.showToast({ title: msg, icon: 'none', duration: 2500 });
  982. } else {
  983. window.alert(msg);
  984. }
  985. }
  986. function showAppOpenFailTip(msg) {
  987. var tip =
  988. msg ||
  989. '未能打开 App,请确认已安装最新版「U店在哪」;微信内请使用页面底部按钮打开。';
  990. if (typeof uni !== 'undefined' && typeof uni.showToast === 'function') {
  991. uni.showToast({ title: tip, icon: 'none', duration: 2800 });
  992. } else if (isWeChatInAppBrowser()) {
  993. window.alert(tip);
  994. } else {
  995. console.warn('[openApp]', tip);
  996. }
  997. }
  998. /** 与公众平台「JS接口安全域名」一致;分享页实际打开的 host 必须在此列表中 */
  999. var WECHAT_JS_SAFE_HOSTS = ['uat.ailien.shop', 'test.ailien.shop'];
  1000. function checkWxJsSafeDomainHint() {
  1001. var host = String(location.hostname || '').toLowerCase();
  1002. if (!host || host === 'localhost' || host === '127.0.0.1') return '';
  1003. if (WECHAT_JS_SAFE_HOSTS.indexOf(host) >= 0) return '';
  1004. return (
  1005. '当前页面域名为「' +
  1006. host +
  1007. '」,未在 WECHAT_JS_SAFE_HOSTS 中;请在公众号后台「JS接口安全域名」添加该域名(不含 https:// 与路径)。'
  1008. );
  1009. }
  1010. /** 详情页 onLoad 使用 storeId;分享链常为 id,补全 storeId 避免 App 内参数为空 */
  1011. function buildAppOpenQueryString() {
  1012. var raw = (location.search && location.search.charAt(0) === '?') ? location.search.slice(1) : (location.search || '');
  1013. var params = new URLSearchParams(raw);
  1014. var sid = params.get('storeId') || params.get('id') || '';
  1015. if (sid && !params.get('storeId')) params.set('storeId', sid);
  1016. var qs = params.toString();
  1017. return qs ? ('?' + qs) : '';
  1018. }
  1019. /**
  1020. * 按 URL 参数 businessSection 打开对应 App 页:
  1021. * 1 → delicacyDetails,2 → barDetails,3 → lifeDetails
  1022. * 关店 businessStatus=99 时进 pages/index/login(见 isClosedMerchantForAppOpen)。
  1023. */
  1024. function getAppUniPathForBusinessSection() {
  1025. if (isClosedMerchantForAppOpen()) {
  1026. return 'pages/index/login';
  1027. }
  1028. var bs = String(q('businessSection') || '').trim();
  1029. if (bs === '1') {
  1030. return 'pages/ieisureEntertainment/eightTypeList/delicacyDetails';
  1031. }
  1032. if (bs === '2') {
  1033. return 'pages/ieisureEntertainment/eightTypeList/barDetails';
  1034. }
  1035. if (bs === '3') {
  1036. return 'pages/ieisureEntertainment/eightTypeList/lifeDetails';
  1037. }
  1038. return String(APP_UNI_STORE_PATH || 'pages/ieisureEntertainment/eightTypeList/delicacyDetails').replace(/^\//, '');
  1039. }
  1040. function buildAppDeepLink() {
  1041. var path = getAppUniPathForBusinessSection().replace(/^\//, '');
  1042. var s = buildAppOpenQueryString();
  1043. var root = APP_IOS_URL_SCHEME.replace(/\/$/, '');
  1044. if (!s) return root + '/' + path;
  1045. return root + '/' + path + s;
  1046. }
  1047. function isWeChatInAppBrowser() {
  1048. return /MicroMessenger/i.test(navigator.userAgent || '');
  1049. }
  1050. function getWeChatJssdkSignRequestUrl() {
  1051. var custom = String(q('wxSignPath') || q('wxSignUrl') || '').trim();
  1052. if (!custom) return '';
  1053. if (/^https?:\/\//i.test(custom)) return custom;
  1054. return API_BASE.replace(/\/$/, '') + (custom.charAt(0) === '/' ? custom : '/' + custom);
  1055. }
  1056. /** 微信 JSSDK 参与签名的 url:完整链(含 ?),不含 # */
  1057. function getWxSignUrlFull() {
  1058. var forced = String(q('wxSignUrl') || '').trim();
  1059. if (forced) return forced.split('#')[0];
  1060. if (location.origin && /^https?:/i.test(location.origin)) {
  1061. return (
  1062. location.origin +
  1063. (location.pathname || '/h5/HBuilderProjects/shareIndex.html') +
  1064. (location.search || '')
  1065. );
  1066. }
  1067. var href = String(location.href || '').split('#')[0];
  1068. if (href && href.indexOf('file:') !== 0) return href;
  1069. return WX_GET_CONFIG_SIGN_URL;
  1070. }
  1071. /** 无 query 的页面地址(后端若只签该地址,须配合 syncBrowserUrlForWxSign) */
  1072. function getWxSignUrlBase() {
  1073. if (location.origin && /^https?:/i.test(location.origin)) {
  1074. return location.origin + (location.pathname || '/h5/HBuilderProjects/shareIndex.html');
  1075. }
  1076. return WX_GET_CONFIG_SIGN_URL;
  1077. }
  1078. function getWxConfigSignUrl() {
  1079. if (String(q('wxSignBaseOnly') || '') === '1') return getWxSignUrlBase();
  1080. return getWxSignUrlFull();
  1081. }
  1082. /**
  1083. * 微信校验签名用的是地址栏当前 url(不含#)。
  1084. * 若后端只签了无参地址,须先把地址栏 sync 成与签名 url 一致再 wx.config。
  1085. */
  1086. function syncBrowserUrlForWxSign(signUrl) {
  1087. var target = String(signUrl || '').split('#')[0];
  1088. if (!target) return;
  1089. var hash = location.hash || '';
  1090. var current = String(location.href || '').split('#')[0];
  1091. if (current !== target) {
  1092. history.replaceState(history.state, document.title, target + hash);
  1093. }
  1094. }
  1095. /** 唤起 App 的 extinfo:保留完整分享链 */
  1096. function getPageUrlForWxSign() {
  1097. return getWxSignUrlFull();
  1098. }
  1099. function buildWxGetConfigRequestUrl(signPageUrl) {
  1100. var base = API_BASE.replace(/\/$/, '');
  1101. return (
  1102. base +
  1103. WECHAT_GET_WX_CONFIG_PATH +
  1104. '?url=' +
  1105. encodeURIComponent(signPageUrl || getWxConfigSignUrl())
  1106. );
  1107. }
  1108. /**
  1109. * 微信开放标签 extinfo:优先传当前 H5 分享链(与 App 解析分享 URL 一致);
  1110. * 超长时再传 path+query JSON,最后才用 shopro://。
  1111. */
  1112. function buildWeChatLaunchExtinfo() {
  1113. var pageUrl = getPageUrlForWxSign();
  1114. if (pageUrl && pageUrl.length <= 1024) return pageUrl;
  1115. var path = getAppUniPathForBusinessSection().replace(/^\//, '');
  1116. var qs = buildAppOpenQueryString().replace(/^\?/, '');
  1117. try {
  1118. var pack = JSON.stringify({
  1119. path: path,
  1120. query: qs,
  1121. h5: pageUrl
  1122. });
  1123. if (pack.length <= 1024) return pack;
  1124. } catch (eJson) {}
  1125. var deep = buildAppDeepLink();
  1126. if (deep && deep.length <= 1024) return deep;
  1127. return pageUrl ? pageUrl.slice(0, 1024) : deep.slice(0, 1024);
  1128. }
  1129. function absH5AssetUrl(rel) {
  1130. rel = String(rel || '').replace(/^\//, '');
  1131. var origin = location.origin;
  1132. if (origin && origin !== 'null' && /^https?:/i.test(origin)) {
  1133. var dir = location.pathname.replace(/[^/]*$/, '');
  1134. return origin + dir + rel;
  1135. }
  1136. return H5_PAGE_BASE_FALLBACK + rel;
  1137. }
  1138. function resolveWxConfigAppIdFromSignData(d) {
  1139. if (!d || typeof d !== 'object') return '';
  1140. var mp =
  1141. d.mpAppId ||
  1142. d.mpAppid ||
  1143. d.officialAppId ||
  1144. d.officialAccountAppId ||
  1145. d.gzhAppId ||
  1146. d.serviceAppId;
  1147. if (mp != null && String(mp).trim() !== '') return String(mp).trim();
  1148. var fromQuery = String(q('wxMpAppId') || WECHAT_MP_APP_ID || '').trim();
  1149. if (fromQuery) return fromQuery;
  1150. var raw = d.appId || d.appid || d.wxAppId;
  1151. if (raw == null || String(raw).trim() === '') return '';
  1152. return String(raw).trim();
  1153. }
  1154. function normalizeWxJssdkSignPayload(res, signUrlUsed) {
  1155. if (!res || typeof res !== 'object') return null;
  1156. var d = res.data != null && typeof res.data === 'object' ? res.data : res;
  1157. if (!d || typeof d !== 'object') return null;
  1158. var appId = resolveWxConfigAppIdFromSignData(d);
  1159. var timestamp = d.timestamp != null ? d.timestamp : d.timeStamp;
  1160. var nonceStr = d.nonceStr || d.noncestr || d.nonce;
  1161. var signature = d.signature || d.sign;
  1162. if (!appId || timestamp == null || !nonceStr || !signature) return null;
  1163. var signedUrl =
  1164. d.signUrl != null && String(d.signUrl).trim() !== ''
  1165. ? String(d.signUrl).trim().split('#')[0]
  1166. : signUrlUsed != null && String(signUrlUsed).trim() !== ''
  1167. ? String(signUrlUsed).trim().split('#')[0]
  1168. : '';
  1169. return {
  1170. appId: String(appId),
  1171. timestamp: Number(timestamp),
  1172. nonceStr: String(nonceStr),
  1173. signature: String(signature),
  1174. signUrl: signedUrl
  1175. };
  1176. }
  1177. function formatWxConfigErrorTip(err, signPageUrl) {
  1178. var errMsg = '';
  1179. if (err && err.errMsg) errMsg = String(err.errMsg);
  1180. else if (typeof err === 'string') errMsg = err;
  1181. var tip = '微信 JSSDK 配置失败';
  1182. if (/invalid signature/i.test(errMsg)) {
  1183. var signUrl = signPageUrl || getWxSignUrlFull();
  1184. var pageNow = String(location.href || '').split('#')[0];
  1185. return (
  1186. tip +
  1187. ':签名无效。请让后端用与地址栏完全相同的 url 参与签名(不含#)。当前地址栏:' +
  1188. pageNow +
  1189. ';本次请求签名 url:' +
  1190. signUrl
  1191. );
  1192. }
  1193. if (/invalid appid/i.test(errMsg)) {
  1194. return tip + ':appId 无效,请使用已认证服务号的公众号 AppID。';
  1195. }
  1196. if (/invalid url/i.test(errMsg)) {
  1197. return tip + ':域名未在公众号 JS 接口安全域名中,或未在开放平台绑定域名与移动应用。';
  1198. }
  1199. if (errMsg) return tip + ':' + errMsg;
  1200. return tip + ',开放标签不可用。';
  1201. }
  1202. function fetchWeChatJssdkSign(signPageUrl) {
  1203. signPageUrl = signPageUrl || getWxConfigSignUrl();
  1204. var urls = [];
  1205. var custom = getWeChatJssdkSignRequestUrl();
  1206. if (custom) {
  1207. var sep0 = custom.indexOf('?') >= 0 ? '&' : '?';
  1208. urls.push(custom + sep0 + 'url=' + encodeURIComponent(signPageUrl));
  1209. } else {
  1210. urls.push(buildWxGetConfigRequestUrl(signPageUrl));
  1211. }
  1212. function tryUrl(idx) {
  1213. if (idx >= urls.length) return Promise.resolve(null);
  1214. return fetch(urls[idx], {
  1215. method: 'GET',
  1216. mode: 'cors',
  1217. credentials: 'omit',
  1218. headers: { Accept: 'application/json' }
  1219. })
  1220. .then(function (r) {
  1221. if (!r.ok) throw new Error('HTTP ' + r.status);
  1222. return r.json();
  1223. })
  1224. .then(function (res) {
  1225. if (res && res.code != null) {
  1226. var c = Number(res.code);
  1227. if (c !== 200 && c !== 0 && res.success !== true) {
  1228. throw new Error(res.msg || 'sign rejected');
  1229. }
  1230. }
  1231. var pack = normalizeWxJssdkSignPayload(res, signPageUrl);
  1232. if (!pack) throw new Error('empty sign payload');
  1233. return pack;
  1234. })
  1235. .catch(function () {
  1236. return tryUrl(idx + 1);
  1237. });
  1238. }
  1239. return tryUrl(0);
  1240. }
  1241. function applyWxConfig(sign, signPageUrl) {
  1242. var urlForWx =
  1243. sign.signUrl && String(sign.signUrl).trim() !== ''
  1244. ? String(sign.signUrl).trim()
  1245. : signPageUrl;
  1246. syncBrowserUrlForWxSign(urlForWx);
  1247. console.log('[wx.config] appId=', sign.appId, 'signUrl=', urlForWx, 'page=', location.href.split('#')[0]);
  1248. return new Promise(function (resolve) {
  1249. wx.config({
  1250. debug: String(q('wxDebug') || '') === '1',
  1251. appId: sign.appId,
  1252. timestamp: sign.timestamp,
  1253. nonceStr: sign.nonceStr,
  1254. signature: sign.signature,
  1255. jsApiList: ['checkJsApi'],
  1256. openTagList: ['wx-open-launch-app']
  1257. });
  1258. wx.ready(function () {
  1259. weChatJssdkConfigured = true;
  1260. if (wxSignUrlFullBeforeStrip) {
  1261. var restore = wxSignUrlFullBeforeStrip + (location.hash || '');
  1262. history.replaceState(history.state, document.title, restore);
  1263. wxSignUrlFullBeforeStrip = '';
  1264. }
  1265. var tag = document.getElementById('launch-btn');
  1266. if (tag) {
  1267. try {
  1268. tag.setAttribute('extinfo', buildWeChatLaunchExtinfo());
  1269. } catch (eReady) {}
  1270. }
  1271. updateFabOpenLayer();
  1272. resolve(true);
  1273. });
  1274. wx.error(function (err) {
  1275. console.warn('[wx.config]', err, 'signUrl=', urlForWx);
  1276. var errMsg = err && err.errMsg ? String(err.errMsg) : '';
  1277. var baseUrl = getWxSignUrlBase();
  1278. var fullUrl = getWxSignUrlFull();
  1279. if (
  1280. !/invalid signature/i.test(errMsg) ||
  1281. wxConfigSignRetriedBaseUrl ||
  1282. baseUrl === fullUrl ||
  1283. urlForWx === baseUrl
  1284. ) {
  1285. weChatJssdkConfigured = false;
  1286. updateFabOpenLayer();
  1287. showAppOpenFailTip(formatWxConfigErrorTip(err, urlForWx));
  1288. resolve(false);
  1289. return;
  1290. }
  1291. wxConfigSignRetriedBaseUrl = true;
  1292. wxSignUrlFullBeforeStrip = fullUrl;
  1293. console.warn('[wx.config] retry with base url (no query):', baseUrl);
  1294. fetchWeChatJssdkSign(baseUrl)
  1295. .then(function (sign2) {
  1296. if (!sign2) {
  1297. weChatJssdkConfigured = false;
  1298. updateFabOpenLayer();
  1299. showAppOpenFailTip(formatWxConfigErrorTip(err, urlForWx));
  1300. resolve(false);
  1301. return;
  1302. }
  1303. applyWxConfig(sign2, baseUrl).then(resolve);
  1304. })
  1305. .catch(function () {
  1306. weChatJssdkConfigured = false;
  1307. updateFabOpenLayer();
  1308. showAppOpenFailTip(formatWxConfigErrorTip(err, urlForWx));
  1309. resolve(false);
  1310. });
  1311. });
  1312. });
  1313. }
  1314. /**
  1315. * 微信内:wx.config 成功后开放标签盖住按钮图,用户必须点到开放标签才能唤起 App。
  1316. * 失败时退回 #openApp + scheme。
  1317. */
  1318. function updateFabOpenLayer() {
  1319. var dock = document.getElementById('fabDock');
  1320. var hit = document.getElementById('fabWxHit');
  1321. var useWx = isWeChatInAppBrowser() && weChatJssdkConfigured;
  1322. if (dock) {
  1323. if (useWx) dock.classList.add('wx-open-enabled');
  1324. else dock.classList.remove('wx-open-enabled');
  1325. }
  1326. if (hit) hit.setAttribute('aria-hidden', useWx ? 'false' : 'true');
  1327. }
  1328. function bindWeChatLaunchTagEvents() {
  1329. var tag = document.getElementById('launch-btn');
  1330. if (!tag) return;
  1331. try {
  1332. tag.setAttribute('extinfo', buildWeChatLaunchExtinfo());
  1333. } catch (eExt) {}
  1334. tag.addEventListener('launch', function () {
  1335. console.log('[wx-open-launch-app] launch ok');
  1336. });
  1337. tag.addEventListener('error', function (e) {
  1338. var detail = e && e.detail;
  1339. console.warn('[wx-open-launch-app]', detail);
  1340. weChatJssdkConfigured = false;
  1341. updateFabOpenLayer();
  1342. var errMsg =
  1343. detail && detail.errMsg
  1344. ? String(detail.errMsg)
  1345. : detail && detail.errmsg
  1346. ? String(detail.errmsg)
  1347. : '';
  1348. if (/launch:fail/i.test(errMsg)) {
  1349. showAppOpenFailTip(
  1350. '微信未能唤起 App(' +
  1351. errMsg +
  1352. ')。请确认已安装 App,且移动应用已与公众号关联。'
  1353. );
  1354. } else {
  1355. showAppOpenFailTip();
  1356. }
  1357. });
  1358. }
  1359. /**
  1360. * 进入页即 GET /wx/getWxConfig(任意浏览器都会请求,便于联调);
  1361. * 仅微信内且签名成功后再 wx.config + 展示开放标签按钮。
  1362. */
  1363. function initWeChatOpenLaunchApp() {
  1364. var inWx = isWeChatInAppBrowser();
  1365. wxConfigSignRetriedBaseUrl = false;
  1366. var signPageUrl = getWxConfigSignUrl();
  1367. var reqUrl = buildWxGetConfigRequestUrl(signPageUrl);
  1368. if (inWx) {
  1369. var domainHint = checkWxJsSafeDomainHint();
  1370. if (domainHint) {
  1371. console.warn('[wx]', domainHint);
  1372. showAppOpenFailTip(domainHint);
  1373. }
  1374. }
  1375. console.log('[wx] GET', reqUrl);
  1376. return fetchWeChatJssdkSign(signPageUrl)
  1377. .then(function (sign) {
  1378. if (!inWx) {
  1379. if (!sign) {
  1380. console.warn('[wx] getWxConfig empty (non-wechat preview)');
  1381. }
  1382. return false;
  1383. }
  1384. if (typeof wx === 'undefined') {
  1385. console.warn('[wx] jweixin not loaded');
  1386. return false;
  1387. }
  1388. bindWeChatLaunchTagEvents();
  1389. if (!sign) {
  1390. console.warn('[wx] GET ' + WECHAT_GET_WX_CONFIG_PATH + ' — empty or invalid sign payload');
  1391. showAppOpenFailTip(
  1392. '微信 JSSDK:getWxConfig 未返回可用的 appId/timestamp/nonceStr/signature。'
  1393. );
  1394. return false;
  1395. }
  1396. return applyWxConfig(sign, signPageUrl);
  1397. })
  1398. .catch(function (e) {
  1399. console.warn('[wx] init failed', e);
  1400. return false;
  1401. });
  1402. }
  1403. function isCustomAppSchemeUrl(url) {
  1404. var s = String(url || '').trim();
  1405. if (!s) return false;
  1406. if (/^https?:/i.test(s)) return false;
  1407. return /^[a-z][a-z0-9+.-]*:/i.test(s);
  1408. }
  1409. function launchAppDeepLink(deepLink) {
  1410. deepLink = String(deepLink || '').trim();
  1411. if (!deepLink) return;
  1412. if (isCustomAppSchemeUrl(deepLink)) {
  1413. var anchor = document.getElementById('appDeepLinkAnchor');
  1414. if (!anchor) {
  1415. anchor = document.createElement('a');
  1416. anchor.id = 'appDeepLinkAnchor';
  1417. anchor.setAttribute('aria-hidden', 'true');
  1418. anchor.style.cssText =
  1419. 'position:fixed;left:-9999px;top:0;width:1px;height:1px;opacity:0;pointer-events:none;';
  1420. document.body.appendChild(anchor);
  1421. }
  1422. anchor.setAttribute('href', deepLink);
  1423. anchor.click();
  1424. return;
  1425. }
  1426. try {
  1427. window.location.href = deepLink;
  1428. } catch (eHref) {}
  1429. }
  1430. /**
  1431. * 有 plus:检测 App 是否安装后 openURL;深链形如 shopro://{APP_UNI_STORE_PATH}?…
  1432. * 系统浏览器:scheme 唤起;微信内优先 wx-open-launch-app,失败再 scheme(不再弹「在浏览器中打开」)。
  1433. */
  1434. function tryOpenHBuilderApp() {
  1435. var inWx = isWeChatInAppBrowser();
  1436. /** 微信内 JSSDK 已就绪:点击由开放标签处理,勿再走 scheme */
  1437. if (inWx && weChatJssdkConfigured) {
  1438. return;
  1439. }
  1440. if (inWx && !weChatJssdkConfigured) {
  1441. showAppOpenFailTip(
  1442. '微信内暂无法唤起 App:请先关注测试号并确保 JSSDK 配置成功(wx.config)。配置成功后底部按钮将自动切换为开放标签唤起。'
  1443. );
  1444. return;
  1445. }
  1446. var deepLink = buildAppDeepLink();
  1447. if (typeof plus !== 'undefined' && plus.runtime) {
  1448. var installed = null;
  1449. try {
  1450. if (typeof plus.runtime.isApplicationExist === 'function') {
  1451. installed = plus.runtime.isApplicationExist({
  1452. pname: APP_ANDROID_PACKAGE,
  1453. action: APP_IOS_URL_SCHEME
  1454. });
  1455. }
  1456. } catch (e) {
  1457. console.warn(e);
  1458. }
  1459. try {
  1460. plus.runtime.openURL(deepLink);
  1461. } catch (e2) {
  1462. console.warn(e2);
  1463. if (installed === false) {
  1464. showDownloadTip();
  1465. } else if (!inWx) {
  1466. showAppOpenFailTip();
  1467. }
  1468. }
  1469. return;
  1470. }
  1471. var done = false;
  1472. function finish() {
  1473. if (done) return;
  1474. done = true;
  1475. document.removeEventListener('visibilitychange', onVis);
  1476. window.removeEventListener('pagehide', onHide);
  1477. }
  1478. function onVis() {
  1479. if (document.visibilityState === 'hidden') finish();
  1480. }
  1481. function onHide() {
  1482. finish();
  1483. }
  1484. document.addEventListener('visibilitychange', onVis);
  1485. window.addEventListener('pagehide', onHide);
  1486. try {
  1487. launchAppDeepLink(deepLink);
  1488. } catch (e3) {
  1489. finish();
  1490. if (!inWx) showAppOpenFailTip();
  1491. return;
  1492. }
  1493. /**
  1494. * 微信内 scheme 常被拦截且页面仍 visible,原 2.6s 后 showDownloadTip 会误报「请到应用商店下载」。
  1495. * 与 shareDynamic 一致:超时仅收尾,不弹下载提示。
  1496. */
  1497. window.setTimeout(function () {
  1498. finish();
  1499. }, 3200);
  1500. }
  1501. function qs() {
  1502. return new URLSearchParams(location.search || '');
  1503. }
  1504. function q(name) {
  1505. var v = qs().get(name);
  1506. return v == null ? '' : String(v);
  1507. }
  1508. function showErr(msg) {
  1509. var el = document.getElementById('pageError');
  1510. el.textContent = msg;
  1511. el.style.display = 'block';
  1512. }
  1513. function getStoreId() {
  1514. return q('id') || q('storeId');
  1515. }
  1516. function shouldShowPerformanceSection() {
  1517. return String(q('businessSection') || '').trim() === '2';
  1518. }
  1519. function apiFetch(path) {
  1520. return fetch(API_BASE + path, {
  1521. method: 'GET',
  1522. mode: 'cors',
  1523. credentials: 'omit',
  1524. headers: { Accept: 'application/json' }
  1525. }).then(function (res) {
  1526. if (!res.ok) throw new Error('HTTP ' + res.status);
  1527. return res.json();
  1528. });
  1529. }
  1530. /** 进入页先拉店铺概要;与 shareDynamic.html fetchGetDeleteFlagByIdIfId 相同路径与 id 参数 */
  1531. function fetchStoreInfoGetOne(storeId) {
  1532. if (!storeId) return Promise.resolve(null);
  1533. var qs = new URLSearchParams();
  1534. qs.set('id', String(storeId).trim());
  1535. return apiFetch('/store/info/getOne?' + qs.toString()).catch(function (e) {
  1536. console.warn('[store/info/getOne]', e);
  1537. return null;
  1538. });
  1539. }
  1540. function isGetOneBusinessStatus99(res) {
  1541. if (!res || typeof res !== 'object') return false;
  1542. var d = res.data;
  1543. if (d && typeof d === 'object') {
  1544. var bs = d.businessStatus;
  1545. if (bs === 99 || bs === '99' || Number(bs) === 99) return true;
  1546. }
  1547. return false;
  1548. }
  1549. var MARKETING_PREVIEW_COUNT = 3;
  1550. var closedMerchantFlag = false;
  1551. /** 关店 businessStatus=99:getOne 已置 closedMerchantFlag,或 URL 带 businessStatus=99;唤起 App 时进登录页 */
  1552. function isClosedMerchantForAppOpen() {
  1553. if (closedMerchantFlag) return true;
  1554. var bs = String(q('businessStatus') || '').trim();
  1555. if (bs === '99' || Number(bs) === 99) return true;
  1556. return false;
  1557. }
  1558. var marketingListCache = [];
  1559. /** 避免详情先返回时用空 cache 误展示「暂无活动」图 */
  1560. var marketingCouponLoaded = false;
  1561. var staffGroupsCache = [];
  1562. var performanceListCache = { records: [], total: 0 };
  1563. function isMp4VideoUrl(url) {
  1564. if (!url || typeof url !== 'string') return false;
  1565. var path = url.split(/[?#]/)[0].toLowerCase();
  1566. return path.length >= 4 && path.slice(-4) === '.mp4';
  1567. }
  1568. function getMp4PlaybackUrl(url) {
  1569. var u = String(url || '').trim();
  1570. if (!u) return '';
  1571. var q = u.indexOf('?');
  1572. var h = u.indexOf('#');
  1573. var cut = u.length;
  1574. if (q >= 0) cut = Math.min(cut, q);
  1575. if (h >= 0) cut = Math.min(cut, h);
  1576. var base = u.slice(0, cut);
  1577. if (/\.mp4$/i.test(base)) return base;
  1578. return u;
  1579. }
  1580. function mp4UrlToJpgUrl(u) {
  1581. var q = u.indexOf('?');
  1582. var h = u.indexOf('#');
  1583. var cut = u.length;
  1584. if (q >= 0) cut = Math.min(cut, q);
  1585. if (h >= 0) cut = Math.min(cut, h);
  1586. var pathPart = u.slice(0, cut);
  1587. var rest = u.slice(cut);
  1588. if (!/\.mp4$/i.test(pathPart)) return '';
  1589. return pathPart.slice(0, -4) + '.jpg' + rest;
  1590. }
  1591. function createMarketingMedia(url) {
  1592. var wrap = document.createElement('div');
  1593. wrap.className = 'marketing-card__media';
  1594. var full = String(url == null ? '' : url).trim();
  1595. if (!full) return wrap;
  1596. if (isMp4VideoUrl(full)) {
  1597. var playUrl = getMp4PlaybackUrl(full);
  1598. var vid = document.createElement('video');
  1599. vid.src = playUrl;
  1600. vid.setAttribute('controls', '');
  1601. vid.setAttribute('playsinline', '');
  1602. vid.setAttribute('webkit-playsinline', '');
  1603. vid.muted = true;
  1604. vid.setAttribute('muted', '');
  1605. vid.setAttribute('autoplay', '');
  1606. vid.preload = 'auto';
  1607. var poster = '';
  1608. if (full.length > playUrl.length) poster = full;
  1609. else poster = mp4UrlToJpgUrl(playUrl);
  1610. if (poster) vid.setAttribute('poster', poster);
  1611. vid.addEventListener('canplay', function onCap() {
  1612. vid.removeEventListener('canplay', onCap);
  1613. var p = vid.play();
  1614. if (p && typeof p.catch === 'function') p.catch(function () {});
  1615. });
  1616. wrap.appendChild(vid);
  1617. } else {
  1618. var img = document.createElement('img');
  1619. img.src = full;
  1620. img.alt = '';
  1621. img.decoding = 'async';
  1622. wrap.appendChild(img);
  1623. }
  1624. return wrap;
  1625. }
  1626. function renderMarketingList(rawList) {
  1627. marketingListCache = Array.isArray(rawList) ? rawList.slice() : [];
  1628. var section = document.getElementById('shareMarketingSection');
  1629. var listEl = document.getElementById('marketingListEl');
  1630. var moreBtn = document.getElementById('marketingMoreBtn');
  1631. var moreText = document.getElementById('marketingMoreText');
  1632. if (!section || !listEl) return;
  1633. listEl.innerHTML = '';
  1634. section.classList.remove('is-expanded');
  1635. if (moreBtn) {
  1636. moreBtn.style.display = 'none';
  1637. moreBtn.setAttribute('aria-expanded', 'false');
  1638. }
  1639. if (closedMerchantFlag) {
  1640. section.style.display = 'none';
  1641. section.setAttribute('aria-hidden', 'true');
  1642. return;
  1643. }
  1644. var items = marketingListCache.filter(function (x) {
  1645. return x && x.imgUrl && String(x.imgUrl).trim();
  1646. }).filter(function (x) {
  1647. var t = x.activityType;
  1648. if (t == null || t === '') return true;
  1649. return String(t).toUpperCase() === 'MARKETING';
  1650. });
  1651. items.sort(function (a, b) {
  1652. var sa = Number(a.imgSort);
  1653. var sb = Number(b.imgSort);
  1654. if (isNaN(sa)) sa = 0;
  1655. if (isNaN(sb)) sb = 0;
  1656. return sa - sb;
  1657. });
  1658. if (!items.length) {
  1659. if (!marketingCouponLoaded) {
  1660. section.style.display = 'none';
  1661. section.setAttribute('aria-hidden', 'true');
  1662. return;
  1663. }
  1664. section.style.display = 'block';
  1665. section.setAttribute('aria-hidden', 'false');
  1666. var emptyWrap = document.createElement('div');
  1667. emptyWrap.className = 'marketing-section__empty';
  1668. emptyWrap.setAttribute('role', 'status');
  1669. var emptyImg = document.createElement('img');
  1670. emptyImg.src = 'images/empty.png';
  1671. emptyImg.alt = '';
  1672. emptyImg.decoding = 'async';
  1673. var emptyLabel = document.createElement('p');
  1674. emptyLabel.className = 'marketing-section__empty-label';
  1675. emptyLabel.textContent = '暂无活动';
  1676. emptyWrap.appendChild(emptyImg);
  1677. emptyWrap.appendChild(emptyLabel);
  1678. listEl.appendChild(emptyWrap);
  1679. return;
  1680. }
  1681. section.style.display = 'block';
  1682. section.setAttribute('aria-hidden', 'false');
  1683. items.forEach(function (item, idx) {
  1684. var card = document.createElement('article');
  1685. card.className = 'marketing-card';
  1686. if (idx >= MARKETING_PREVIEW_COUNT) card.classList.add('marketing-card--more');
  1687. card.appendChild(createMarketingMedia(item.imgUrl));
  1688. listEl.appendChild(card);
  1689. });
  1690. var extra = items.length - MARKETING_PREVIEW_COUNT;
  1691. if (extra > 0 && moreBtn && moreText) {
  1692. moreText.textContent = '查看剩余' + extra + '个活动';
  1693. moreBtn.style.display = 'flex';
  1694. }
  1695. }
  1696. function bindMarketingMore() {
  1697. var section = document.getElementById('shareMarketingSection');
  1698. var moreBtn = document.getElementById('marketingMoreBtn');
  1699. if (!section || !moreBtn || moreBtn.dataset.bound) return;
  1700. moreBtn.dataset.bound = '1';
  1701. moreBtn.addEventListener('click', function () {
  1702. section.classList.add('is-expanded');
  1703. moreBtn.style.display = 'none';
  1704. moreBtn.setAttribute('aria-expanded', 'true');
  1705. });
  1706. }
  1707. function createStaffCardElement(staff) {
  1708. var card = document.createElement('article');
  1709. card.className = 'staff-card';
  1710. var imgWrap = document.createElement('div');
  1711. imgWrap.className = 'staff-card__img-wrap';
  1712. var imgUrl = String(staff.staffImage || '').trim();
  1713. if (imgUrl) {
  1714. var img = document.createElement('img');
  1715. img.src = imgUrl;
  1716. img.alt = String(staff.name || '');
  1717. img.decoding = 'async';
  1718. img.loading = 'lazy';
  1719. imgWrap.appendChild(img);
  1720. }
  1721. var likes = document.createElement('div');
  1722. likes.className = 'staff-card__likes';
  1723. var lc = staff.likeCount != null ? Number(staff.likeCount) : 0;
  1724. if (isNaN(lc)) lc = 0;
  1725. likes.textContent = lc + '人喜欢';
  1726. imgWrap.appendChild(likes);
  1727. var nameRow = document.createElement('div');
  1728. nameRow.className = 'staff-card__name-row';
  1729. var nameEl = document.createElement('span');
  1730. nameEl.className = 'staff-card__name';
  1731. nameEl.textContent = String(staff.name != null ? staff.name : '').trim() || '—';
  1732. nameRow.appendChild(nameEl);
  1733. var perf = staff.hasPerformanceToday;
  1734. if (perf === true || perf === 1 || String(perf).toLowerCase() === 'true') {
  1735. var badge = document.createElement('span');
  1736. badge.className = 'staff-card__badge';
  1737. badge.textContent = '今日演出';
  1738. nameRow.appendChild(badge);
  1739. }
  1740. card.appendChild(imgWrap);
  1741. card.appendChild(nameRow);
  1742. var meta = document.createElement('div');
  1743. meta.className = 'staff-card__meta';
  1744. var pos = document.createElement('span');
  1745. pos.className = 'staff-card__position';
  1746. pos.textContent = String(staff.staffPosition || '').trim() || '\u00a0';
  1747. meta.appendChild(pos);
  1748. var pc = staff.positiveCommentsCount != null ? Number(staff.positiveCommentsCount) : 0;
  1749. if (!isNaN(pc) && pc > 0) {
  1750. var sep = document.createElement('span');
  1751. sep.className = 'staff-card__sep';
  1752. sep.textContent = '|';
  1753. var rev = document.createElement('span');
  1754. rev.className = 'staff-card__reviews';
  1755. rev.textContent = '好评' + pc + '次';
  1756. meta.appendChild(sep);
  1757. meta.appendChild(rev);
  1758. }
  1759. card.appendChild(meta);
  1760. return card;
  1761. }
  1762. function createPerformanceCardElement(row) {
  1763. var card = document.createElement('article');
  1764. card.className = 'performance-card';
  1765. var posterWrap = document.createElement('div');
  1766. posterWrap.className = 'performance-card__poster';
  1767. var posterUrl = String(row.performancePoster || '').trim();
  1768. if (posterUrl) {
  1769. var img = document.createElement('img');
  1770. img.src = posterUrl;
  1771. img.alt = String(row.performanceName || '');
  1772. img.decoding = 'async';
  1773. img.loading = 'lazy';
  1774. posterWrap.appendChild(img);
  1775. }
  1776. var body = document.createElement('div');
  1777. body.className = 'performance-card__body';
  1778. var nameEl = document.createElement('div');
  1779. nameEl.className = 'performance-card__name';
  1780. nameEl.textContent = String(row.performanceName != null ? row.performanceName : '').trim() || '—';
  1781. body.appendChild(nameEl);
  1782. var dr = String(row.dateRange || '').trim();
  1783. if (dr) {
  1784. var line1 = document.createElement('div');
  1785. line1.className = 'performance-card__meta';
  1786. line1.textContent = dr;
  1787. body.appendChild(line1);
  1788. }
  1789. var si = String(row.scheduleInfo || '').trim();
  1790. if (si) {
  1791. var line2 = document.createElement('div');
  1792. line2.className = 'performance-card__meta';
  1793. line2.textContent = si;
  1794. line2.title = si;
  1795. body.appendChild(line2);
  1796. }
  1797. card.appendChild(posterWrap);
  1798. card.appendChild(body);
  1799. return card;
  1800. }
  1801. function renderPerformanceList() {
  1802. var section = document.getElementById('sharePerformanceSection');
  1803. var titleEl = document.getElementById('performanceSectionTitle');
  1804. var strip = document.getElementById('performanceStripEl');
  1805. if (!section || !titleEl || !strip) return;
  1806. strip.innerHTML = '';
  1807. if (!shouldShowPerformanceSection()) {
  1808. section.style.display = 'none';
  1809. section.setAttribute('aria-hidden', 'true');
  1810. return;
  1811. }
  1812. if (closedMerchantFlag) {
  1813. section.style.display = 'none';
  1814. section.setAttribute('aria-hidden', 'true');
  1815. return;
  1816. }
  1817. var records = performanceListCache.records;
  1818. var total = performanceListCache.total;
  1819. if (isNaN(total)) total = records.length;
  1820. titleEl.textContent = '演出安排(' + total + ')';
  1821. if (!records.length) {
  1822. section.style.display = 'none';
  1823. section.setAttribute('aria-hidden', 'true');
  1824. return;
  1825. }
  1826. section.style.display = 'block';
  1827. section.setAttribute('aria-hidden', 'false');
  1828. records.forEach(function (row) {
  1829. if (!row) return;
  1830. strip.appendChild(createPerformanceCardElement(row));
  1831. });
  1832. }
  1833. function renderStaffGroups(raw) {
  1834. staffGroupsCache = Array.isArray(raw) ? raw.slice() : [];
  1835. var section = document.getElementById('shareStaffSection');
  1836. var mount = document.getElementById('staffGroupsMount');
  1837. if (!section || !mount) return;
  1838. var totalStaff = 0;
  1839. staffGroupsCache.forEach(function (g) {
  1840. if (g && Array.isArray(g.staffList)) totalStaff += g.staffList.length;
  1841. });
  1842. var countEl = document.getElementById('staffSectionCountEl');
  1843. if (countEl) countEl.textContent = String(totalStaff);
  1844. mount.innerHTML = '';
  1845. if (closedMerchantFlag) {
  1846. section.style.display = 'none';
  1847. section.setAttribute('aria-hidden', 'true');
  1848. return;
  1849. }
  1850. var groups = staffGroupsCache.filter(function (g) {
  1851. return g && Array.isArray(g.staffList) && g.staffList.length;
  1852. });
  1853. if (!groups.length) {
  1854. section.style.display = 'none';
  1855. section.setAttribute('aria-hidden', 'true');
  1856. return;
  1857. }
  1858. section.style.display = 'block';
  1859. section.setAttribute('aria-hidden', 'false');
  1860. groups.forEach(function (group) {
  1861. var wrap = document.createElement('div');
  1862. wrap.className = 'staff-group';
  1863. if (group.titleId != null) wrap.dataset.titleId = String(group.titleId);
  1864. var strip = document.createElement('div');
  1865. strip.className = 'staff-strip';
  1866. group.staffList.forEach(function (staff) {
  1867. if (!staff) return;
  1868. strip.appendChild(createStaffCardElement(staff));
  1869. });
  1870. wrap.appendChild(strip);
  1871. mount.appendChild(wrap);
  1872. });
  1873. }
  1874. function bindStaffSection() {
  1875. var btn = document.getElementById('staffSectionAllBtn');
  1876. if (!btn || btn.dataset.bound) return;
  1877. btn.dataset.bound = '1';
  1878. btn.addEventListener('click', function (e) {
  1879. e.preventDefault();
  1880. tryOpenHBuilderApp();
  1881. });
  1882. }
  1883. function buildHeroSlides(urls) {
  1884. var track = document.getElementById('heroTrack');
  1885. var dotsWrap = document.getElementById('heroDots');
  1886. track.innerHTML = '';
  1887. dotsWrap.innerHTML = '';
  1888. var list = (urls || []).filter(Boolean);
  1889. if (!list.length) {
  1890. var slide = document.createElement('div');
  1891. slide.className = 'hero__slide';
  1892. var img = document.createElement('img');
  1893. img.src = 'images/hero.png';
  1894. img.alt = '店铺';
  1895. slide.appendChild(img);
  1896. track.appendChild(slide);
  1897. var dot = document.createElement('span');
  1898. dot.className = 'hero__dot is-active';
  1899. dotsWrap.appendChild(dot);
  1900. return initHeroCarousel(1);
  1901. }
  1902. list.forEach(function (url, d) {
  1903. var slide = document.createElement('div');
  1904. slide.className = 'hero__slide';
  1905. var img = document.createElement('img');
  1906. img.src = url;
  1907. img.alt = '店铺图';
  1908. slide.appendChild(img);
  1909. track.appendChild(slide);
  1910. var dot = document.createElement('span');
  1911. dot.className = 'hero__dot' + (d === 0 ? ' is-active' : '');
  1912. dotsWrap.appendChild(dot);
  1913. });
  1914. initHeroCarousel(list.length);
  1915. }
  1916. var heroI = 0;
  1917. var heroTimer = null;
  1918. function initHeroCarousel(slides) {
  1919. var track = document.getElementById('heroTrack');
  1920. var dotsWrap = document.getElementById('heroDots');
  1921. var dots = dotsWrap.querySelectorAll('.hero__dot');
  1922. if (slides < 2) return;
  1923. function go(n) {
  1924. heroI = (n + slides) % slides;
  1925. track.style.transform = 'translateX(' + (-heroI * 100) + '%)';
  1926. dots.forEach(function (el, idx) {
  1927. el.classList.toggle('is-active', idx === heroI);
  1928. });
  1929. }
  1930. if (heroTimer) clearInterval(heroTimer);
  1931. heroTimer = setInterval(function () { go(heroI + 1); }, 4000);
  1932. var hero = document.getElementById('hero');
  1933. var startX = 0;
  1934. hero.addEventListener('touchstart', function (e) {
  1935. startX = e.changedTouches[0].clientX;
  1936. }, { passive: true });
  1937. hero.addEventListener('touchend', function (e) {
  1938. var dx = e.changedTouches[0].clientX - startX;
  1939. if (Math.abs(dx) > 40) go(dx < 0 ? heroI + 1 : heroI - 1);
  1940. }, { passive: true });
  1941. }
  1942. function timeToMinutes(t) {
  1943. var parts = String(t || '').trim().split(':');
  1944. var h = parseInt(parts[0], 10) || 0;
  1945. var m = parseInt(parts[1], 10) || 0;
  1946. return h * 60 + m;
  1947. }
  1948. function isTimeInRange(startTime, endTime) {
  1949. var s = String(startTime || '').trim();
  1950. var e = String(endTime || '').trim();
  1951. if (s === '00:00' && e === '00:00') return true;
  1952. if (s === '00:00' && e === '23:59') return true;
  1953. var cur = new Date().getHours() * 60 + new Date().getMinutes();
  1954. var sm = timeToMinutes(s);
  1955. var em = timeToMinutes(e);
  1956. if (em < sm) {
  1957. return cur >= sm || cur <= em;
  1958. }
  1959. return cur >= sm && cur <= em;
  1960. }
  1961. function parseHolidayDate(str) {
  1962. if (!str) return null;
  1963. var d = new Date(String(str).trim().replace(/-/g, '/'));
  1964. return isNaN(d.getTime()) ? null : d;
  1965. }
  1966. function isTodayInHolidayRange(holidayInfo) {
  1967. if (!holidayInfo) return false;
  1968. var hi = holidayInfo;
  1969. if (typeof hi === 'string') {
  1970. try {
  1971. hi = JSON.parse(hi);
  1972. } catch (err) {
  1973. return false;
  1974. }
  1975. }
  1976. var start = hi.startDate || hi.holidayStartDate || hi.beginDate || hi.start || hi.holidayStart;
  1977. var end = hi.endDate || hi.holidayEndDate || hi.finishDate || hi.end || hi.holidayEnd;
  1978. if (!start || !end) return false;
  1979. var startD = parseHolidayDate(start);
  1980. var endD = parseHolidayDate(end);
  1981. if (!startD || !endD) return false;
  1982. var today = new Date();
  1983. today.setHours(0, 0, 0, 0);
  1984. startD.setHours(0, 0, 0, 0);
  1985. endD.setHours(0, 0, 0, 0);
  1986. return today >= startD && today <= endD;
  1987. }
  1988. function findNormalBusinessInfo(list) {
  1989. var wdJs = new Date().getDay();
  1990. var i;
  1991. var x;
  1992. var w;
  1993. for (i = 0; i < list.length; i++) {
  1994. x = list[i];
  1995. if (!x || x.holidayInfo) continue;
  1996. w = x.weekDay != null ? x.weekDay : x.week;
  1997. if (w === undefined || w === null) continue;
  1998. if (Number(w) === wdJs) return x;
  1999. }
  2000. var wdMap = wdJs === 0 ? 7 : wdJs;
  2001. for (i = 0; i < list.length; i++) {
  2002. x = list[i];
  2003. if (!x || x.holidayInfo) continue;
  2004. w = x.weekDay != null ? x.weekDay : x.week;
  2005. if (w === undefined || w === null) continue;
  2006. if (Number(w) === wdMap) return x;
  2007. }
  2008. for (i = 0; i < list.length; i++) {
  2009. x = list[i];
  2010. if (x && !x.holidayInfo && (x.startTime || x.endTime)) return x;
  2011. }
  2012. return null;
  2013. }
  2014. /** 营业状态:暂停营业 | 商家暂未配置营业时间 | 休息中 | 营业中 xx:xx至xx:xx | 营业中 全天营业 */
  2015. function computeBusinessStatusDisplay(d) {
  2016. if (!d) return { text: '—', isOpen: false };
  2017. if (Number(d.businessStatus) === 99) {
  2018. return { text: '商户已关闭', isOpen: false };
  2019. }
  2020. if (Number(d.businessStatus) === 1) {
  2021. return { text: '暂停营业', isOpen: false };
  2022. }
  2023. var list = d.storeBusinessInfoVos || d.storeBusinessInfos || [];
  2024. if (!list.length) {
  2025. return { text: '商家暂未配置营业时间', isOpen: false };
  2026. }
  2027. var holidayList = Array.isArray(d.holidayBusinessInfoList) && d.holidayBusinessInfoList.length
  2028. ? d.holidayBusinessInfoList
  2029. : list.filter(function (item) { return item && item.holidayInfo; });
  2030. var todayHolidayItem = holidayList.find(function (item) {
  2031. return isTodayInHolidayRange(item.holidayInfo);
  2032. });
  2033. var normal = d.normalBusinessInfo || d.normalBusinessInfoVo || findNormalBusinessInfo(list);
  2034. var isOpen = false;
  2035. var currentItem = null;
  2036. if (todayHolidayItem) {
  2037. isOpen = isTimeInRange(todayHolidayItem.startTime, todayHolidayItem.endTime);
  2038. currentItem = todayHolidayItem;
  2039. } else if (normal) {
  2040. isOpen = isTimeInRange(normal.startTime, normal.endTime);
  2041. currentItem = normal;
  2042. }
  2043. if (!currentItem) return { text: '休息中', isOpen: false };
  2044. if (!isOpen) return { text: '休息中', isOpen: false };
  2045. var st = String(currentItem.startTime || '').trim();
  2046. var et = String(currentItem.endTime || '').trim();
  2047. if (st === '00:00' && et === '00:00') return { text: '营业中 全天营业', isOpen: true };
  2048. if (st === '00:00' && et === '23:59') return { text: '营业中 全天营业', isOpen: true };
  2049. var needNextDay = timeToMinutes(et) < timeToMinutes(st);
  2050. var suffix = (needNextDay ? '次日' : '') + et;
  2051. return { text: ('营业中 ' + st + ' 至 ' + suffix).trim(), isOpen: true };
  2052. }
  2053. /**
  2054. * 分项评分:可能在 storeEvaluate 对象内,或为 JSON 字符串;部分接口把字段放在详情根上。
  2055. */
  2056. function parseStoreEvaluateRaw(raw) {
  2057. if (raw == null || raw === '') return null;
  2058. if (typeof raw === 'string') {
  2059. var t = raw.trim();
  2060. if (!t) return null;
  2061. try {
  2062. raw = JSON.parse(t);
  2063. } catch (e) {
  2064. return null;
  2065. }
  2066. }
  2067. if (Array.isArray(raw) && raw.length && raw[0] && typeof raw[0] === 'object') {
  2068. raw = raw[0];
  2069. }
  2070. if (raw && typeof raw === 'object' && !Array.isArray(raw)) return raw;
  2071. return null;
  2072. }
  2073. function getStoreEvaluateScores(d) {
  2074. var ev = parseStoreEvaluateRaw(d.storeEvaluate)
  2075. || parseStoreEvaluateRaw(d.evaluate)
  2076. || parseStoreEvaluateRaw(d.evaluateInfo);
  2077. function lane(key, snake) {
  2078. var v;
  2079. if (ev && ev[key] != null && ev[key] !== '') v = ev[key];
  2080. else if (d[key] != null && d[key] !== '') v = d[key];
  2081. else if (snake && d[snake] != null && d[snake] !== '') v = d[snake];
  2082. else return null;
  2083. var n = Number(v);
  2084. return !isNaN(n) ? n : null;
  2085. }
  2086. return {
  2087. scoreOne: lane('scoreOne', 'score_one'),
  2088. scoreTwo: lane('scoreTwo', 'score_two'),
  2089. scoreThree: lane('scoreThree', 'score_three')
  2090. };
  2091. }
  2092. function fmtEvalScore(n) {
  2093. return n != null && !isNaN(n) ? Number(n).toFixed(1) : null;
  2094. }
  2095. var CLOSED_REC_STAR_PATH =
  2096. 'M12 17.27L18.18 21l-1.64-7.03L22 9.24l-7.19-.61L12 2 9.19 8.63 2 9.24l5.46 4.73L5.82 21z';
  2097. function closedRecEscHtml(s) {
  2098. return String(s == null ? '' : s)
  2099. .replace(/&/g, '&amp;')
  2100. .replace(/</g, '&lt;')
  2101. .replace(/>/g, '&gt;')
  2102. .replace(/"/g, '&quot;');
  2103. }
  2104. function closedRecStarsHtml(score) {
  2105. var s = Number(score);
  2106. if (isNaN(s)) s = 0;
  2107. s = Math.max(0, Math.min(5, s));
  2108. var rounded = Math.round(s);
  2109. var parts = [];
  2110. var i;
  2111. for (i = 1; i <= 5; i++) {
  2112. var fill = i <= rounded ? '#F58220' : '#E5E5E5';
  2113. parts.push(
  2114. '<svg class="closed-rec-star" width="11" height="11" viewBox="0 0 24 24" aria-hidden="true">' +
  2115. '<path fill="' + fill + '" d="' + CLOSED_REC_STAR_PATH + '"/></svg>'
  2116. );
  2117. }
  2118. return '<span class="closed-rec-stars">' + parts.join('') + '</span>';
  2119. }
  2120. function closedRecFormatDistance(item) {
  2121. if (item.distance != null && item.distance !== '') {
  2122. var km = Number(item.distance);
  2123. if (!isNaN(km) && km >= 0) {
  2124. return Math.round(km * 1000) + '米';
  2125. }
  2126. return String(item.distance).trim();
  2127. }
  2128. if (item.position != null && String(item.position).trim() !== '') {
  2129. return String(item.position).trim();
  2130. }
  2131. if (item.dist != null && item.dist !== '') {
  2132. var dn = Number(item.dist);
  2133. if (!isNaN(dn)) {
  2134. return dn >= 1 ? dn.toFixed(dn % 1 === 0 ? 0 : 1) + 'km' : Math.round(dn * 1000) + '米';
  2135. }
  2136. }
  2137. return '';
  2138. }
  2139. function closedRecPickScore(item) {
  2140. var x =
  2141. item.scoreAvg != null ? Number(item.scoreAvg)
  2142. : item.score != null ? Number(item.score)
  2143. : item.rating != null ? Number(item.rating)
  2144. : item.starScore != null ? Number(item.starScore)
  2145. : NaN;
  2146. return isNaN(x) ? null : x;
  2147. }
  2148. function closedRecPickReviewCount(item) {
  2149. var n =
  2150. item.commitCount != null ? Number(item.commitCount)
  2151. : item.commentCount != null ? Number(item.commentCount)
  2152. : item.reviewCount != null ? Number(item.reviewCount)
  2153. : item.evaluateCount != null ? Number(item.evaluateCount)
  2154. : NaN;
  2155. return isNaN(n) ? 0 : Math.max(0, Math.floor(n));
  2156. }
  2157. function normalizeClosedStoreRecommendList(res) {
  2158. if (!res || typeof res !== 'object') return [];
  2159. var raw = res.data != null ? res.data : res.result;
  2160. if (Array.isArray(raw)) return raw;
  2161. if (raw && typeof raw === 'object') {
  2162. if (Array.isArray(raw.list)) return raw.list;
  2163. if (Array.isArray(raw.records)) return raw.records;
  2164. if (Array.isArray(raw.rows)) return raw.rows;
  2165. if (Array.isArray(raw.content)) return raw.content;
  2166. if (Array.isArray(raw.stores)) return raw.stores;
  2167. if (Array.isArray(raw.storeList)) return raw.storeList;
  2168. if (Array.isArray(raw.storeVos)) return raw.storeVos;
  2169. if (Array.isArray(raw.items)) return raw.items;
  2170. }
  2171. if (Array.isArray(res.list)) return res.list;
  2172. if (Array.isArray(res.records)) return res.records;
  2173. return [];
  2174. }
  2175. function fetchShareClosedStoreRecommend(storeIdStr) {
  2176. var latRaw = (q('userLat') || q('latitude') || q('lat') || q('weidu')).trim();
  2177. var lngRaw = (q('userLng') || q('longitude') || q('lon') || q('jingdu')).trim();
  2178. var userLat =
  2179. latRaw !== '' && !isNaN(Number(latRaw)) ? Number(latRaw) : DEFAULT_REC_USER_LAT;
  2180. var userLng =
  2181. lngRaw !== '' && !isNaN(Number(lngRaw)) ? Number(lngRaw) : DEFAULT_REC_USER_LNG;
  2182. var page = parseInt(q('page') || '1', 10);
  2183. var pageSize = parseInt(q('pageSize') || '10', 10);
  2184. if (isNaN(page) || page < 1) page = 1;
  2185. if (isNaN(pageSize) || pageSize < 1) pageSize = 10;
  2186. var userCityRaw = (q('userCity') || q('city') || '').trim();
  2187. var userCity = userCityRaw !== '' ? userCityRaw : DEFAULT_REC_USER_CITY;
  2188. var body = {
  2189. page: page,
  2190. pageSize: pageSize,
  2191. storeId: String(storeIdStr || ''),
  2192. userCity: userCity,
  2193. userLat: userLat,
  2194. userLng: userLng
  2195. };
  2196. return fetch(API_LIFE_AI_BASE + STORE_GLOBAL_RECOMMEND_PATH, {
  2197. method: 'POST',
  2198. mode: 'cors',
  2199. credentials: 'omit',
  2200. headers: {
  2201. Accept: 'application/json',
  2202. 'Content-Type': 'application/json;charset=UTF-8'
  2203. },
  2204. body: JSON.stringify(body)
  2205. }).then(function (res) {
  2206. if (!res.ok) throw new Error('HTTP ' + res.status);
  2207. return res.json();
  2208. });
  2209. }
  2210. function renderShareClosedRecommended(list) {
  2211. var wrap = document.getElementById('shareClosedRecList');
  2212. var empty = document.getElementById('shareClosedRecEmpty');
  2213. if (!wrap || !empty) return;
  2214. wrap.querySelectorAll('.closed-rec-card').forEach(function (n) {
  2215. n.remove();
  2216. });
  2217. if (!list || !list.length) {
  2218. empty.style.display = 'block';
  2219. return;
  2220. }
  2221. empty.style.display = 'none';
  2222. list.forEach(function (item) {
  2223. if (!item || typeof item !== 'object') return;
  2224. var imgUrlField = item.imgUrl != null ? String(item.imgUrl).trim() : '';
  2225. var home = item.homeImage != null ? String(item.homeImage).trim() : '';
  2226. if (home && /\.mp4(\?|#|$)/i.test(home)) {
  2227. var vf = item.videoFirstFrame != null ? String(item.videoFirstFrame).trim() : '';
  2228. if (vf) home = vf;
  2229. }
  2230. var imgUrl =
  2231. imgUrlField ||
  2232. home ||
  2233. (item.coverUrl != null ? String(item.coverUrl).trim() : '') ||
  2234. (item.mainImage != null ? String(item.mainImage).trim() : '') ||
  2235. (item.goodsImage != null ? String(item.goodsImage).trim() : '') ||
  2236. (item.entranceImage != null ? String(item.entranceImage).trim() : '') ||
  2237. (Array.isArray(item.goodsImageList) && item.goodsImageList[0]) ||
  2238. (Array.isArray(item.imageList) && item.imageList[0]) ||
  2239. (Array.isArray(item.storeAlbumUrlList) && item.storeAlbumUrlList[0]) ||
  2240. '';
  2241. var name = item.title != null && String(item.title).trim() !== ''
  2242. ? String(item.title).replace(/\r?\n/g, ' ').replace(/\s+/g, ' ').trim()
  2243. : (item.storeName || item.goodsName || item.secondGoodsTitle || item.name || '推荐');
  2244. var dist = closedRecFormatDistance(item);
  2245. var scoreVal = closedRecPickScore(item);
  2246. var displayScore = scoreVal != null ? scoreVal.toFixed(1) : '—';
  2247. var starScore = scoreVal != null ? scoreVal : 0;
  2248. var rc = closedRecPickReviewCount(item);
  2249. var reviewLabel = rc > 0 ? rc + '条评价' : '';
  2250. var seller =
  2251. item.userName != null && String(item.userName).trim() !== ''
  2252. ? String(item.userName).trim()
  2253. : (item.nickName != null && String(item.nickName).trim() !== ''
  2254. ? String(item.nickName).trim()
  2255. : '');
  2256. var card = document.createElement('article');
  2257. card.className = 'closed-rec-card';
  2258. card.innerHTML =
  2259. '<div class="closed-rec-card__img"><img class="closed-rec-card__cover" src="" alt="" decoding="async"></div>' +
  2260. '<div class="closed-rec-card__body">' +
  2261. '<div class="closed-rec-card__top">' +
  2262. '<span class="closed-rec-card__name">' + closedRecEscHtml(name) + '</span>' +
  2263. (dist ? '<span class="closed-rec-card__dist">' + closedRecEscHtml(dist) + '</span>' : '') +
  2264. '</div>' +
  2265. '<div class="closed-rec-card__rating">' +
  2266. closedRecStarsHtml(starScore) +
  2267. '<span class="closed-rec-rating-num">' + closedRecEscHtml(displayScore) + '</span>' +
  2268. (reviewLabel ? '<span class="closed-rec-meta">' + closedRecEscHtml(reviewLabel) + '</span>' : '') +
  2269. '</div>' +
  2270. (seller ? '<div class="closed-rec-card__footer">' + closedRecEscHtml(seller) + '</div>' : '') +
  2271. '</div>';
  2272. var coverIm = card.querySelector('img.closed-rec-card__cover');
  2273. if (coverIm) {
  2274. coverIm.src = imgUrl;
  2275. coverIm.onerror = function () {
  2276. this.onerror = null;
  2277. this.src = '';
  2278. };
  2279. }
  2280. wrap.appendChild(card);
  2281. });
  2282. }
  2283. function loadShareClosedRecommendations() {
  2284. var sid = getStoreId();
  2285. if (!sid) {
  2286. renderShareClosedRecommended([]);
  2287. return;
  2288. }
  2289. fetchShareClosedStoreRecommend(sid)
  2290. .then(function (res) {
  2291. var list = normalizeClosedStoreRecommendList(res);
  2292. if (!list.length && res && res.msg) {
  2293. console.warn('[store-recommend]', res.msg);
  2294. }
  2295. renderShareClosedRecommended(list);
  2296. })
  2297. .catch(function (e) {
  2298. console.error(e);
  2299. renderShareClosedRecommended([]);
  2300. });
  2301. }
  2302. function applyShareIndexClosedMerchantUi(closed) {
  2303. var wasClosed = closedMerchantFlag;
  2304. closedMerchantFlag = closed;
  2305. var banner = document.getElementById('shareClosedBanner');
  2306. var contentEl = document.getElementById('shareContentEl');
  2307. var belowEl = document.getElementById('shareBelowContentEl');
  2308. var recWrap = document.getElementById('shareClosedRecommendWrap');
  2309. if (banner) {
  2310. banner.style.display = closed ? 'block' : 'none';
  2311. banner.setAttribute('aria-hidden', closed ? 'false' : 'true');
  2312. }
  2313. if (contentEl) {
  2314. contentEl.style.display = closed ? 'none' : '';
  2315. contentEl.setAttribute('aria-hidden', closed ? 'true' : 'false');
  2316. }
  2317. if (belowEl) {
  2318. belowEl.style.display = '';
  2319. belowEl.setAttribute('aria-hidden', 'false');
  2320. }
  2321. if (recWrap) {
  2322. if (closed) {
  2323. recWrap.style.display = 'block';
  2324. recWrap.setAttribute('aria-hidden', 'false');
  2325. if (!wasClosed) {
  2326. loadShareClosedRecommendations();
  2327. }
  2328. } else {
  2329. recWrap.style.display = 'none';
  2330. recWrap.setAttribute('aria-hidden', 'true');
  2331. renderShareClosedRecommended([]);
  2332. }
  2333. }
  2334. }
  2335. function renderDetail(d) {
  2336. if (!d) return;
  2337. document.getElementById('storeName').textContent = d.storeName || '—';
  2338. var score = d.scoreAvg != null ? Number(d.scoreAvg) : NaN;
  2339. document.getElementById('scoreAvg').textContent = !isNaN(score) ? score.toFixed(1) : '—';
  2340. document.getElementById('commitCount').textContent = d.commitCount != null ? String(d.commitCount)+'条' : '0';
  2341. var evRow = document.getElementById('storeEvaluateRow');
  2342. var evOne = document.getElementById('storeEvaluateScoreOne');
  2343. var evTwo = document.getElementById('storeEvaluateScoreTwo');
  2344. var evThree = document.getElementById('storeEvaluateScoreThree');
  2345. if (evRow && evOne && evTwo && evThree) {
  2346. evRow.classList.remove('is-visible');
  2347. evRow.setAttribute('aria-hidden', 'true');
  2348. var es = getStoreEvaluateScores(d);
  2349. var a = fmtEvalScore(es.scoreOne);
  2350. var b = fmtEvalScore(es.scoreTwo);
  2351. var c = fmtEvalScore(es.scoreThree);
  2352. if (a !== null || b !== null || c !== null) {
  2353. evOne.textContent = a !== null ? a : '—';
  2354. evTwo.textContent = b !== null ? b : '—';
  2355. evThree.textContent = c !== null ? c : '—';
  2356. evRow.classList.add('is-visible');
  2357. evRow.setAttribute('aria-hidden', 'false');
  2358. }
  2359. }
  2360. var bizDisp = computeBusinessStatusDisplay(d);
  2361. var bizEl = document.getElementById('bizStatus');
  2362. bizEl.textContent = bizDisp.text;
  2363. bizEl.className = 'status' + (bizDisp.isOpen ? ' is-open' : '');
  2364. document.getElementById('hoursText').textContent = '';
  2365. document.getElementById('storeAddr').textContent = d.queryAddress || d.storeAddress || '—';
  2366. if (d.distance != null) {
  2367. document.getElementById('metaDistance').style.display = 'flex';
  2368. document.getElementById('distanceText').textContent =
  2369. '距您' + (Number(d.distance) > 1 ? d.distance + '千米' : Math.round(Number(d.distance) * 1000) + '米');
  2370. }
  2371. if (d.subwayName && d.distance2 != null) {
  2372. document.getElementById('metaSubway').style.display = 'flex';
  2373. document.getElementById('subwayText').textContent =
  2374. '距' + d.subwayName + '步行' + (Number(d.distance2) >= 1000
  2375. ? (Number(d.distance2) / 1000).toFixed(1) + 'km'
  2376. : Math.round(Number(d.distance2)) + 'm');
  2377. }
  2378. var imgs = [];
  2379. if (Array.isArray(d.storeAlbumUrlList) && d.storeAlbumUrlList.length) imgs = d.storeAlbumUrlList.slice();
  2380. else if (d.entranceImage) imgs = [d.entranceImage];
  2381. buildHeroSlides(imgs);
  2382. var closedMerchant = Number(d.businessStatus) === 99;
  2383. applyShareIndexClosedMerchantUi(closedMerchant);
  2384. renderMarketingList(marketingListCache);
  2385. renderPerformanceList();
  2386. renderStaffGroups(staffGroupsCache);
  2387. }
  2388. function getLngForApi() {
  2389. var v = q('jingdu');
  2390. if (v) return v;
  2391. return q('lon') || q('lng') || q('longitude');
  2392. }
  2393. function getLatForApi() {
  2394. var v = q('weidu');
  2395. if (v) return v;
  2396. return q('lat') || q('latitude');
  2397. }
  2398. function mergeSearchAndHashParamsForRedirect() {
  2399. var params = new URLSearchParams();
  2400. function ingest(slice) {
  2401. if (!slice) return;
  2402. var p = new URLSearchParams(slice);
  2403. p.forEach(function (val, key) {
  2404. params.set(key, val);
  2405. });
  2406. }
  2407. if (location.search && location.search.length > 1) {
  2408. ingest(location.search.slice(1));
  2409. }
  2410. var hash = location.hash || '';
  2411. var qi = hash.indexOf('?');
  2412. if (qi >= 0) {
  2413. ingest(hash.slice(qi + 1));
  2414. }
  2415. return params;
  2416. }
  2417. /** getClientStoreDetail 无承载数据时进 shareCheckInUndefined(businessStatus=99 与落地页约定一致) */
  2418. function buildShareCheckInUndefinedRedirectHref() {
  2419. var p = mergeSearchAndHashParamsForRedirect();
  2420. p.set('businessStatus', '99');
  2421. var sid = getStoreId();
  2422. if (sid && !p.has('storeId')) {
  2423. p.set('storeId', sid);
  2424. }
  2425. var j = getLngForApi();
  2426. var w = getLatForApi();
  2427. if (j && !p.has('userLng')) {
  2428. p.set('userLng', j);
  2429. }
  2430. if (w && !p.has('userLat')) {
  2431. p.set('userLat', w);
  2432. }
  2433. var qs = p.toString();
  2434. return 'shareCheckInUndefined.html' + (qs ? ('?' + qs) : '?businessStatus=99');
  2435. }
  2436. function run() {
  2437. var sid = getStoreId();
  2438. var userId = q('userId');
  2439. var jingdu = getLngForApi();
  2440. var weidu = getLatForApi();
  2441. if (!sid) {
  2442. showErr('缺少店铺 id(请从 App 分享链接打开,URL 需带 id 或 storeId)');
  2443. document.getElementById('storeName').textContent = '参数错误';
  2444. return;
  2445. }
  2446. var detailPath = '/store/info/getClientStoreDetail?' +
  2447. 'id=' + encodeURIComponent(sid) +
  2448. '&userId=' + encodeURIComponent(userId) +
  2449. '&jingdu=' + encodeURIComponent(jingdu) +
  2450. '&weidu=' + encodeURIComponent(weidu);
  2451. fetchStoreInfoGetOne(sid).then(function (getOneRes) {
  2452. if (isGetOneBusinessStatus99(getOneRes)) {
  2453. applyShareIndexClosedMerchantUi(true);
  2454. }
  2455. apiFetch(detailPath)
  2456. .then(function (res) {
  2457. var tip = res && res.msg != null ? String(res.msg).trim() : '';
  2458. if (tip === '暂无承载数据') {
  2459. if (closedMerchantFlag) {
  2460. return;
  2461. }
  2462. window.location.replace(buildShareCheckInUndefinedRedirectHref());
  2463. return;
  2464. }
  2465. if (res.code !== 200 || !res.data) {
  2466. showErr(res.msg || '店铺详情加载失败');
  2467. return;
  2468. }
  2469. renderDetail(res.data);
  2470. })
  2471. .catch(function (e) {
  2472. console.error(e);
  2473. showErr('店铺详情请求失败(若为 file:// 打开,请检查 CORS 或改用 http 访问本页)');
  2474. });
  2475. var couponPath = '/store/info/getStoreCouponList?storeId=' + encodeURIComponent(sid);
  2476. marketingCouponLoaded = false;
  2477. apiFetch(couponPath)
  2478. .then(function (res) {
  2479. marketingCouponLoaded = true;
  2480. var list = (res && res.code === 200 && res.data && res.data.marketingList) || [];
  2481. if (!Array.isArray(list)) list = [];
  2482. renderMarketingList(list);
  2483. })
  2484. .catch(function (e) {
  2485. marketingCouponLoaded = true;
  2486. console.warn('[getStoreCouponList]', e);
  2487. renderMarketingList([]);
  2488. });
  2489. if (shouldShowPerformanceSection()) {
  2490. var perfPath = '/performance/list/query?storeId=' + encodeURIComponent(sid) + '&page=1&size=100';
  2491. apiFetch(perfPath)
  2492. .then(function (res) {
  2493. var d = (res && res.code === 200 && res.data) || null;
  2494. if (!d || typeof d !== 'object') {
  2495. performanceListCache.records = [];
  2496. performanceListCache.total = 0;
  2497. } else {
  2498. performanceListCache.records = Array.isArray(d.records) ? d.records.slice() : [];
  2499. var pt = d.total;
  2500. performanceListCache.total = pt != null && !isNaN(Number(pt))
  2501. ? Number(pt)
  2502. : performanceListCache.records.length;
  2503. }
  2504. renderPerformanceList();
  2505. })
  2506. .catch(function (e) {
  2507. console.warn('[performance/list/query]', e);
  2508. performanceListCache.records = [];
  2509. performanceListCache.total = 0;
  2510. renderPerformanceList();
  2511. });
  2512. } else {
  2513. performanceListCache.records = [];
  2514. performanceListCache.total = 0;
  2515. renderPerformanceList();
  2516. }
  2517. var staffPath = '/storeStaffConfig/queryStaffListByTitle?storeId=' + encodeURIComponent(sid);
  2518. apiFetch(staffPath)
  2519. .then(function (res) {
  2520. var arr = (res && res.code === 200 && res.data) || [];
  2521. if (!Array.isArray(arr)) arr = [];
  2522. renderStaffGroups(arr);
  2523. })
  2524. .catch(function (e) {
  2525. console.warn('[queryStaffListByTitle]', e);
  2526. renderStaffGroups([]);
  2527. });
  2528. });
  2529. }
  2530. function boot() {
  2531. run();
  2532. bindMarketingMore();
  2533. bindStaffSection();
  2534. var openBtn = document.getElementById('openApp');
  2535. if (openBtn) {
  2536. openBtn.addEventListener('click', function () {
  2537. tryOpenHBuilderApp();
  2538. });
  2539. }
  2540. updateFabOpenLayer();
  2541. initWeChatOpenLaunchApp();
  2542. }
  2543. if (document.readyState === 'complete') {
  2544. boot();
  2545. } else {
  2546. window.onload = boot;
  2547. }
  2548. })();
  2549. </script>
  2550. </body>
  2551. </html>