shareIndex.html 84 KB

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