shareIndex.html 81 KB

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