shareIndex.html 87 KB

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