shareIndex.html 83 KB

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