shareIndex.html 86 KB

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