shareIndex.html 81 KB

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