shareIndex.html 82 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908
  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. var qs = params.toString();
  1019. return qs ? ('?' + qs) : '';
  1020. }
  1021. /**
  1022. * 按 URL 参数 businessSection 打开对应 App 页:
  1023. * 1 → delicacyDetails,2 → barDetails,3 → lifeDetails
  1024. * 关店 businessStatus=99 时进 pages/index/login(见 isClosedMerchantForAppOpen)。
  1025. */
  1026. function getAppUniPathForBusinessSection() {
  1027. if (isClosedMerchantForAppOpen()) {
  1028. return 'pages/index/login';
  1029. }
  1030. var bs = String(q('businessSection') || '').trim();
  1031. if (bs === '1') {
  1032. return 'pages/ieisureEntertainment/eightTypeList/delicacyDetails';
  1033. }
  1034. if (bs === '2') {
  1035. return 'pages/ieisureEntertainment/eightTypeList/barDetails';
  1036. }
  1037. if (bs === '3') {
  1038. return 'pages/ieisureEntertainment/eightTypeList/lifeDetails';
  1039. }
  1040. return String(APP_UNI_STORE_PATH || 'pages/ieisureEntertainment/eightTypeList/delicacyDetails').replace(/^\//, '');
  1041. }
  1042. function buildAppDeepLink() {
  1043. var path = getAppUniPathForBusinessSection().replace(/^\//, '');
  1044. var s = buildAppOpenQueryString();
  1045. var root = APP_IOS_URL_SCHEME.replace(/\/$/, '');
  1046. if (!s) return root + '/' + path;
  1047. return root + '/' + path + s;
  1048. }
  1049. function isWeChatInAppBrowser() {
  1050. return /MicroMessenger/i.test(navigator.userAgent || '');
  1051. }
  1052. function readQueryParam(name) {
  1053. try {
  1054. var v = new URLSearchParams(location.search || '').get(name);
  1055. return v == null ? '' : String(v);
  1056. } catch (eQ) {
  1057. return '';
  1058. }
  1059. }
  1060. function isWxDebugOn() {
  1061. return readQueryParam('wxDebug') === '1';
  1062. }
  1063. /** PC 联调:测试域 / localhost 自动开启;也可显式 ?wxForce=1 */
  1064. function isWxForceDebug() {
  1065. return readQueryParam('wxForce') === '1';
  1066. }
  1067. function isWxConfigOnClickDebug() {
  1068. return readQueryParam('wxConfigOnClick') === '1';
  1069. }
  1070. function isWxPcAutoDebugHost() {
  1071. var h = (location.hostname || '').toLowerCase();
  1072. if (h === 'localhost' || h === '127.0.0.1') return true;
  1073. for (var i = 0; i < WECHAT_JS_SAFE_HOSTS.length; i++) {
  1074. if (WECHAT_JS_SAFE_HOSTS[i] === h) return true;
  1075. }
  1076. return false;
  1077. }
  1078. function isWxPcBrowser() {
  1079. return !isWeChatInAppBrowser();
  1080. }
  1081. function shouldInitWeChatJssdkOnLoad() {
  1082. if (isWeChatInAppBrowser()) return true;
  1083. return isWxForceDebug() || isWxPcAutoDebugHost();
  1084. }
  1085. function shouldFetchWxConfig(fromUserClick) {
  1086. if (isWeChatInAppBrowser()) return true;
  1087. if (fromUserClick) return true;
  1088. return isWxForceDebug() || isWxPcAutoDebugHost();
  1089. }
  1090. /**
  1091. * 教程 Step6:htmlUrl = location.href.split('#')[0]
  1092. * 浏览器访问的 url 与传给后端签名的 url 必须一致(含微信附加的 from 等参数)。
  1093. */
  1094. function getWxHtmlUrl() {
  1095. var forced = String(q('wxSignUrl') || '').trim();
  1096. if (forced) return forced.split('#')[0];
  1097. return String(location.href || '').split('#')[0];
  1098. }
  1099. function getWxSignPageUrlForApi() {
  1100. var htmlUrl = getWxHtmlUrl();
  1101. if (htmlUrl && /^https?:\/\//i.test(htmlUrl)) return htmlUrl;
  1102. return WX_GET_CONFIG_SIGN_URL;
  1103. }
  1104. function getWxSignUrlFull() {
  1105. return getWxSignPageUrlForApi();
  1106. }
  1107. /** 仅 pathname;后端若按无参 url 签名可 ?wxSignBaseOnly=1 */
  1108. function getWxHtmlUrlBase() {
  1109. var htmlUrl = getWxSignPageUrlForApi();
  1110. try {
  1111. var u = new URL(htmlUrl);
  1112. return u.origin + u.pathname;
  1113. } catch (eU) {
  1114. return WX_GET_CONFIG_SIGN_URL;
  1115. }
  1116. }
  1117. function getWxConfigSignUrl() {
  1118. if (String(q('wxSignBaseOnly') || '') === '1') return getWxHtmlUrlBase();
  1119. return getWxSignPageUrlForApi();
  1120. }
  1121. function buildWxGetConfigRequestUrl(htmlUrl) {
  1122. return (
  1123. API_BASE.replace(/\/$/, '') +
  1124. WECHAT_GET_WX_CONFIG_PATH +
  1125. '?url=' +
  1126. encodeURIComponent(String(htmlUrl || '').split('#')[0].trim())
  1127. );
  1128. }
  1129. function resolveWxConfigAppIdFromSignData(d) {
  1130. if (!d || typeof d !== 'object') return '';
  1131. var mp =
  1132. d.mpAppId ||
  1133. d.mpAppid ||
  1134. d.officialAppId ||
  1135. d.gzhAppId ||
  1136. d.serviceAppId;
  1137. if (mp != null && String(mp).trim() !== '') return String(mp).trim();
  1138. var fromQuery = String(q('wxMpAppId') || WECHAT_MP_APP_ID || '').trim();
  1139. if (fromQuery) return fromQuery;
  1140. var raw = d.appId || d.appid || d.wxAppId;
  1141. return raw != null && String(raw).trim() !== '' ? String(raw).trim() : '';
  1142. }
  1143. function normalizeWxJssdkSignPayload(res, signUrlUsed) {
  1144. if (!res || typeof res !== 'object') return null;
  1145. var d = res.data != null && typeof res.data === 'object' ? res.data : res;
  1146. if (!d || typeof d !== 'object') return null;
  1147. var appId = resolveWxConfigAppIdFromSignData(d);
  1148. var timestamp = d.timestamp != null ? d.timestamp : d.timeStamp;
  1149. /* 官方字段名为 nonceStr(S 大写),与 wx.config 保持一致 */
  1150. var nonceStr =
  1151. d.nonceStr != null && String(d.nonceStr) !== ''
  1152. ? d.nonceStr
  1153. : d.noncestr != null && String(d.noncestr) !== ''
  1154. ? d.noncestr
  1155. : d.nonce;
  1156. var signature = d.signature || d.sign;
  1157. if (!appId || timestamp == null || nonceStr == null || nonceStr === '' || !signature) {
  1158. return null;
  1159. }
  1160. var signedUrl = String(signUrlUsed || '')
  1161. .split('#')[0]
  1162. .trim();
  1163. return {
  1164. appId: String(appId),
  1165. timestamp: Number(timestamp),
  1166. nonceStr: String(nonceStr),
  1167. signature: String(signature),
  1168. signUrl: signedUrl
  1169. };
  1170. }
  1171. function getWxErrMsg(err) {
  1172. if (!err) return '';
  1173. if (err.errMsg) return String(err.errMsg);
  1174. if (typeof err === 'string') return err;
  1175. try {
  1176. return JSON.stringify(err);
  1177. } catch (e) {
  1178. return String(err);
  1179. }
  1180. }
  1181. function formatWxConfigErrorTip(err, signPageUrl) {
  1182. var errMsg = getWxErrMsg(err);
  1183. var tip = '微信 JSSDK 配置失败';
  1184. if (/invalid signature/i.test(errMsg)) {
  1185. return (
  1186. tip +
  1187. ':签名无效。请核对:①后端用与前端相同的 url 签名;②url=' +
  1188. (signPageUrl || getWxHtmlUrl()) +
  1189. ';③nonceStr/timestamp 与接口返回一致;④appId=' +
  1190. WECHAT_MP_APP_ID
  1191. );
  1192. }
  1193. if (/require\s*subscribe/i.test(errMsg)) {
  1194. return tip + ':' + errMsg + '(服务号需用户已关注)';
  1195. }
  1196. return errMsg ? tip + ':' + errMsg : tip;
  1197. }
  1198. function buildWeChatLaunchExtinfo() {
  1199. var pageUrl = getWxSignUrlFull();
  1200. if (pageUrl && pageUrl.length <= 1024) return pageUrl;
  1201. var path = getAppUniPathForBusinessSection().replace(/^\//, '');
  1202. var qs = buildAppOpenQueryString().replace(/^\?/, '');
  1203. try {
  1204. var pack = JSON.stringify({ path: path, query: qs, h5: pageUrl });
  1205. if (pack.length <= 1024) return pack;
  1206. } catch (eJ) {}
  1207. var deep = buildAppDeepLink();
  1208. return deep.length <= 1024 ? deep : (pageUrl || deep).slice(0, 1024);
  1209. }
  1210. function setWxInitError(msg) {
  1211. wxInitLastError = String(msg || '').trim();
  1212. if (wxInitLastError) console.warn('[wx]', wxInitLastError);
  1213. }
  1214. /**
  1215. * 教程标准流程:
  1216. * htmlUrl = location.href.split('#')[0]
  1217. * GET getWxConfig?url=encodeURIComponent(htmlUrl)
  1218. * success → wx.config({ appId, timestamp, nonceStr, signature, ... })
  1219. * 不修改地址栏,保证「浏览器 url」与「签名 url」一致。
  1220. */
  1221. function requestWeChatJssdkSignAndConfig(htmlUrlOptional) {
  1222. var htmlUrl = String(
  1223. htmlUrlOptional != null ? htmlUrlOptional : getWxConfigSignUrl()
  1224. )
  1225. .split('#')[0]
  1226. .trim();
  1227. if (!htmlUrl || !/^https?:\/\//i.test(htmlUrl)) {
  1228. htmlUrl = WX_GET_CONFIG_SIGN_URL;
  1229. }
  1230. if (isWxDebugOn()) {
  1231. try {
  1232. window.alert('htmlUrl(签名用,应与地址栏一致):\n' + htmlUrl);
  1233. } catch (eDbg) {}
  1234. }
  1235. var requestUrl = buildWxGetConfigRequestUrl(htmlUrl);
  1236. console.log('[wx] htmlUrl=', htmlUrl);
  1237. console.log('[wx] GET getWxConfig →', requestUrl);
  1238. return fetch(requestUrl, {
  1239. method: 'GET',
  1240. mode: 'cors',
  1241. credentials: 'omit',
  1242. headers: { Accept: 'application/json' }
  1243. })
  1244. .then(function (r) {
  1245. if (r.ok) return r.json();
  1246. return r
  1247. .text()
  1248. .catch(function () {
  1249. return '';
  1250. })
  1251. .then(function (text) {
  1252. var hint = '';
  1253. try {
  1254. var j = JSON.parse(text);
  1255. hint = j.msg || j.message || '';
  1256. } catch (eP) {
  1257. if (text) hint = text.slice(0, 120);
  1258. }
  1259. throw new Error('getWxConfig HTTP ' + r.status + (hint ? ':' + hint : ''));
  1260. });
  1261. })
  1262. .then(function (res) {
  1263. if (res && res.code != null) {
  1264. var c = Number(res.code);
  1265. if (c !== 200 && c !== 0 && res.success !== true) {
  1266. throw new Error(res.msg || res.message || 'getWxConfig code ' + c);
  1267. }
  1268. }
  1269. var sign = normalizeWxJssdkSignPayload(res, htmlUrl);
  1270. if (!sign) {
  1271. console.warn('[wx] getWxConfig 响应字段不全', res, 'htmlUrl=', htmlUrl);
  1272. throw new Error(
  1273. 'getWxConfig 缺少 appId/timestamp/nonceStr/signature(见控制台)'
  1274. );
  1275. }
  1276. if (sign.appId !== WECHAT_MP_APP_ID) {
  1277. console.warn(
  1278. '[wx] 后端 appId=' + sign.appId + ',期望服务号 ' + WECHAT_MP_APP_ID
  1279. );
  1280. }
  1281. if (typeof wx === 'undefined') {
  1282. if (isWxPcBrowser()) {
  1283. console.log('[wx] PC getWxConfig 成功(无 jweixin)', sign);
  1284. return true;
  1285. }
  1286. setWxInitError('jweixin.js 未加载');
  1287. return false;
  1288. }
  1289. return applyWxConfigFromSign(sign, htmlUrl);
  1290. });
  1291. }
  1292. function applyWxConfigFromSign(sign, htmlUrl) {
  1293. var wxConfigParams = {
  1294. debug: isWxDebugOn(),
  1295. appId: String(sign.appId),
  1296. timestamp: sign.timestamp,
  1297. nonceStr: String(sign.nonceStr),
  1298. signature: String(sign.signature),
  1299. jsApiList: [],
  1300. openTagList: ['wx-open-launch-app']
  1301. };
  1302. return new Promise(function (resolve) {
  1303. if (isWxDebugOn()) {
  1304. try {
  1305. window.alert(
  1306. 'htmlUrl:\n' +
  1307. htmlUrl +
  1308. '\n\nwx.config:\n' +
  1309. JSON.stringify(wxConfigParams, null, 2)
  1310. );
  1311. } catch (alertErr) {}
  1312. }
  1313. wx.config(wxConfigParams);
  1314. wx.ready(function () {
  1315. weChatJssdkConfigured = true;
  1316. document.body.classList.add('wx-jssdk-ready');
  1317. refreshWxLaunchTagAttrs();
  1318. console.log('[wx.config] ready, htmlUrl=', htmlUrl);
  1319. resolve(true);
  1320. });
  1321. wx.error(function (err) {
  1322. weChatJssdkConfigured = false;
  1323. document.body.classList.remove('wx-jssdk-ready');
  1324. wxJssdkInitPromise = null;
  1325. var errMsg = getWxErrMsg(err);
  1326. setWxInitError(formatWxConfigErrorTip(err, htmlUrl));
  1327. if (isWxDebugOn()) window.alert(wxInitLastError);
  1328. console.warn('[wx.config]', errMsg, 'htmlUrl=', htmlUrl);
  1329. var baseUrl = getWxHtmlUrlBase();
  1330. var fullUrl = getWxSignPageUrlForApi();
  1331. if (
  1332. !/invalid signature/i.test(errMsg) ||
  1333. wxConfigSignRetriedBaseUrl ||
  1334. baseUrl === fullUrl ||
  1335. htmlUrl === baseUrl
  1336. ) {
  1337. resolve(false);
  1338. return;
  1339. }
  1340. wxConfigSignRetriedBaseUrl = true;
  1341. requestWeChatJssdkSignAndConfig(baseUrl).then(resolve);
  1342. });
  1343. });
  1344. }
  1345. function refreshWxLaunchTagAttrs() {
  1346. var tag = document.getElementById('launch-btn');
  1347. if (!tag) return;
  1348. try {
  1349. tag.setAttribute('appid', WECHAT_OPEN_APP_ID);
  1350. tag.setAttribute('extinfo', buildWeChatLaunchExtinfo());
  1351. } catch (eA) {}
  1352. }
  1353. function bindWeChatLaunchTagEvents() {
  1354. var tag = document.getElementById('launch-btn');
  1355. if (!tag || tag._wxLaunchBound) return;
  1356. tag._wxLaunchBound = true;
  1357. refreshWxLaunchTagAttrs();
  1358. tag.addEventListener('launch', function () {
  1359. console.log('[wx-open-launch-app] launch ok');
  1360. showFabToast('正在打开 U店在哪…');
  1361. });
  1362. tag.addEventListener('error', function (e) {
  1363. var detail = e && e.detail;
  1364. var errMsg =
  1365. detail && detail.errMsg
  1366. ? String(detail.errMsg)
  1367. : detail && detail.errmsg
  1368. ? String(detail.errmsg)
  1369. : '';
  1370. console.warn('[wx-open-launch-app]', detail);
  1371. showAppOpenFailTip(
  1372. errMsg
  1373. ? '未能唤起 App:' + errMsg
  1374. : '未能唤起 App,请确认已安装 U店在哪,且开放平台已绑定服务号与移动应用。'
  1375. );
  1376. });
  1377. }
  1378. function initWeChatOpenLaunchApp(fromUserClick) {
  1379. if (!shouldFetchWxConfig(!!fromUserClick)) {
  1380. console.log('[wx] 未调用 getWxConfig');
  1381. return Promise.resolve(false);
  1382. }
  1383. if (isWxPcBrowser()) {
  1384. console.warn(
  1385. '[wx] PC:请求 getWxConfig' + (fromUserClick ? '(按钮)' : '(进页)')
  1386. );
  1387. }
  1388. if (wxJssdkInitPromise && !fromUserClick) return wxJssdkInitPromise;
  1389. wxConfigSignRetriedBaseUrl = false;
  1390. wxInitLastError = '';
  1391. var htmlUrl = getWxConfigSignUrl();
  1392. bindWeChatLaunchTagEvents();
  1393. wxJssdkInitPromise = requestWeChatJssdkSignAndConfig(htmlUrl)
  1394. .then(function (ok) {
  1395. if (ok === true) return true;
  1396. if (!wxInitLastError) {
  1397. setWxInitError('wx.config 失败,可加 ?wxDebug=1 查看 htmlUrl');
  1398. }
  1399. return false;
  1400. })
  1401. .catch(function (e) {
  1402. var msg = e && e.message ? e.message : 'getWxConfig 请求失败';
  1403. setWxInitError(msg);
  1404. console.warn('[wx] requestWeChatJssdkSignAndConfig failed', msg, 'htmlUrl=', htmlUrl);
  1405. if (isWeChatInAppBrowser() && isWxDebugOn()) window.alert(msg);
  1406. return false;
  1407. })
  1408. .finally(function () {
  1409. if (!weChatJssdkConfigured) wxJssdkInitPromise = null;
  1410. });
  1411. return wxJssdkInitPromise;
  1412. }
  1413. /** 进页即尝试拉签名;jweixin 晚到时自动重试 */
  1414. function scheduleWeChatJssdkBootstrap() {
  1415. if (!shouldInitWeChatJssdkOnLoad()) return;
  1416. var attempts = 0;
  1417. function tick() {
  1418. attempts += 1;
  1419. if (weChatJssdkConfigured) return;
  1420. initWeChatOpenLaunchApp();
  1421. if (!weChatJssdkConfigured && attempts < 8 && typeof wx === 'undefined') {
  1422. setTimeout(tick, 400);
  1423. }
  1424. }
  1425. tick();
  1426. }
  1427. function showFabToast(msg, ms) {
  1428. var tip = String(msg || '').trim();
  1429. if (!tip) return;
  1430. var el = document.getElementById('openAppToast');
  1431. if (el) {
  1432. el.textContent = tip;
  1433. el.style.display = 'block';
  1434. if (showFabToast._t) clearTimeout(showFabToast._t);
  1435. showFabToast._t = setTimeout(function () {
  1436. el.style.display = 'none';
  1437. }, ms || 2800);
  1438. }
  1439. console.log('[openApp]', tip);
  1440. }
  1441. function showAppOpenFailTip(msg) {
  1442. var tip = msg || '未能打开 App,请确认已安装最新版「U店在哪」。';
  1443. if (typeof uni !== 'undefined' && typeof uni.showToast === 'function') {
  1444. uni.showToast({ title: tip, icon: 'none', duration: 2800 });
  1445. } else if (isWeChatInAppBrowser()) {
  1446. window.alert(tip);
  1447. } else {
  1448. console.warn('[openApp]', tip);
  1449. }
  1450. }
  1451. /** 部分 WebView 对 location.href 拦截,用 a 标签点击略稳 */
  1452. function launchAppDeepLink(deepLink) {
  1453. try {
  1454. var a = document.createElement('a');
  1455. a.href = deepLink;
  1456. a.setAttribute('target', '_self');
  1457. document.body.appendChild(a);
  1458. a.click();
  1459. document.body.removeChild(a);
  1460. } catch (e1) {}
  1461. try {
  1462. window.location.href = deepLink;
  1463. } catch (e2) {}
  1464. }
  1465. /**
  1466. * 有 plus:检测 App 是否安装后 openURL;深链形如 shopro://{APP_UNI_STORE_PATH}?…
  1467. * 系统浏览器:唤起 scheme;微信内常拦截 scheme,需「在浏览器打开」。
  1468. */
  1469. function tryFetchWxConfigOnPcClick() {
  1470. if (!isWxPcBrowser()) return Promise.resolve(false);
  1471. showFabToast('正在请求 getWxConfig…');
  1472. wxJssdkInitPromise = null;
  1473. return initWeChatOpenLaunchApp(true).then(function (ok) {
  1474. if (ok) {
  1475. showFabToast(
  1476. weChatJssdkConfigured
  1477. ? 'getWxConfig 成功,wx.config 已就绪'
  1478. : 'getWxConfig 成功'
  1479. );
  1480. } else {
  1481. showFabToast(wxInitLastError || 'getWxConfig 失败');
  1482. }
  1483. return ok;
  1484. });
  1485. }
  1486. function tryOpenHBuilderApp() {
  1487. /* 微信内须直接点击 wx-open-launch-app,scheme 会被拦截 */
  1488. if (isWeChatInAppBrowser()) return;
  1489. tryFetchWxConfigOnPcClick().then(function () {
  1490. if (isWxConfigOnClickDebug() && !isWxForceDebug() && !isWxPcAutoDebugHost()) {
  1491. return;
  1492. }
  1493. tryOpenHBuilderAppViaScheme();
  1494. });
  1495. }
  1496. function tryOpenHBuilderAppViaScheme() {
  1497. showFabToast('正在打开 U店在哪…');
  1498. var deepLink = buildAppDeepLink();
  1499. if (typeof plus !== 'undefined' && plus.runtime) {
  1500. var installed = null;
  1501. try {
  1502. if (typeof plus.runtime.isApplicationExist === 'function') {
  1503. installed = plus.runtime.isApplicationExist({
  1504. pname: APP_ANDROID_PACKAGE,
  1505. action: APP_IOS_URL_SCHEME
  1506. });
  1507. }
  1508. } catch (e) {
  1509. console.warn(e);
  1510. }
  1511. if (installed === false) {
  1512. showDownloadTip();
  1513. return;
  1514. }
  1515. try {
  1516. plus.runtime.openURL(deepLink);
  1517. } catch (e2) {
  1518. console.warn(e2);
  1519. showDownloadTip();
  1520. }
  1521. return;
  1522. }
  1523. var t0 = Date.now();
  1524. var done = false;
  1525. function finish() {
  1526. if (done) return;
  1527. done = true;
  1528. document.removeEventListener('visibilitychange', onVis);
  1529. window.removeEventListener('pagehide', onHide);
  1530. }
  1531. function onVis() {
  1532. if (document.visibilityState === 'hidden') finish();
  1533. }
  1534. function onHide() {
  1535. finish();
  1536. }
  1537. document.addEventListener('visibilitychange', onVis);
  1538. window.addEventListener('pagehide', onHide);
  1539. try {
  1540. launchAppDeepLink(deepLink);
  1541. } catch (e3) {
  1542. finish();
  1543. showDownloadTip();
  1544. return;
  1545. }
  1546. window.setTimeout(function () {
  1547. finish();
  1548. }, 2600);
  1549. }
  1550. function qs() {
  1551. return new URLSearchParams(location.search || '');
  1552. }
  1553. function q(name) {
  1554. var v = qs().get(name);
  1555. return v == null ? '' : String(v);
  1556. }
  1557. function showErr(msg) {
  1558. var el = document.getElementById('pageError');
  1559. el.textContent = msg;
  1560. el.style.display = 'block';
  1561. }
  1562. function getStoreId() {
  1563. return q('id') || q('storeId');
  1564. }
  1565. function shouldShowPerformanceSection() {
  1566. return String(q('businessSection') || '').trim() === '2';
  1567. }
  1568. function apiFetch(path) {
  1569. return fetch(API_BASE + path, {
  1570. method: 'GET',
  1571. mode: 'cors',
  1572. credentials: 'omit',
  1573. headers: { Accept: 'application/json' }
  1574. }).then(function (res) {
  1575. if (!res.ok) throw new Error('HTTP ' + res.status);
  1576. return res.json();
  1577. });
  1578. }
  1579. /** 进入页先拉店铺概要;与 shareDynamic.html fetchGetDeleteFlagByIdIfId 相同路径与 id 参数 */
  1580. function fetchStoreInfoGetOne(storeId) {
  1581. if (!storeId) return Promise.resolve(null);
  1582. var qs = new URLSearchParams();
  1583. qs.set('id', String(storeId).trim());
  1584. return apiFetch('/store/info/getOne?' + qs.toString()).catch(function (e) {
  1585. console.warn('[store/info/getOne]', e);
  1586. return null;
  1587. });
  1588. }
  1589. function isGetOneBusinessStatus99(res) {
  1590. if (!res || typeof res !== 'object') return false;
  1591. var d = res.data;
  1592. if (d && typeof d === 'object') {
  1593. var bs = d.businessStatus;
  1594. if (bs === 99 || bs === '99' || Number(bs) === 99) return true;
  1595. }
  1596. return false;
  1597. }
  1598. var MARKETING_PREVIEW_COUNT = 3;
  1599. var closedMerchantFlag = false;
  1600. /** 关店 businessStatus=99:getOne 已置 closedMerchantFlag,或 URL 带 businessStatus=99;唤起 App 时进登录页 */
  1601. function isClosedMerchantForAppOpen() {
  1602. if (closedMerchantFlag) return true;
  1603. var bs = String(q('businessStatus') || '').trim();
  1604. if (bs === '99' || Number(bs) === 99) return true;
  1605. return false;
  1606. }
  1607. var marketingListCache = [];
  1608. /** 避免详情先返回时用空 cache 误展示「暂无活动」图 */
  1609. var marketingCouponLoaded = false;
  1610. var staffGroupsCache = [];
  1611. var performanceListCache = { records: [], total: 0 };
  1612. function isMp4VideoUrl(url) {
  1613. if (!url || typeof url !== 'string') return false;
  1614. var path = url.split(/[?#]/)[0].toLowerCase();
  1615. return path.length >= 4 && path.slice(-4) === '.mp4';
  1616. }
  1617. function getMp4PlaybackUrl(url) {
  1618. var u = String(url || '').trim();
  1619. if (!u) return '';
  1620. var q = u.indexOf('?');
  1621. var h = u.indexOf('#');
  1622. var cut = u.length;
  1623. if (q >= 0) cut = Math.min(cut, q);
  1624. if (h >= 0) cut = Math.min(cut, h);
  1625. var base = u.slice(0, cut);
  1626. if (/\.mp4$/i.test(base)) return base;
  1627. return u;
  1628. }
  1629. function mp4UrlToJpgUrl(u) {
  1630. var q = u.indexOf('?');
  1631. var h = u.indexOf('#');
  1632. var cut = u.length;
  1633. if (q >= 0) cut = Math.min(cut, q);
  1634. if (h >= 0) cut = Math.min(cut, h);
  1635. var pathPart = u.slice(0, cut);
  1636. var rest = u.slice(cut);
  1637. if (!/\.mp4$/i.test(pathPart)) return '';
  1638. return pathPart.slice(0, -4) + '.jpg' + rest;
  1639. }
  1640. function createMarketingMedia(url) {
  1641. var wrap = document.createElement('div');
  1642. wrap.className = 'marketing-card__media';
  1643. var full = String(url == null ? '' : url).trim();
  1644. if (!full) return wrap;
  1645. if (isMp4VideoUrl(full)) {
  1646. var playUrl = getMp4PlaybackUrl(full);
  1647. var vid = document.createElement('video');
  1648. vid.src = playUrl;
  1649. vid.setAttribute('controls', '');
  1650. vid.setAttribute('playsinline', '');
  1651. vid.setAttribute('webkit-playsinline', '');
  1652. vid.muted = true;
  1653. vid.setAttribute('muted', '');
  1654. vid.setAttribute('autoplay', '');
  1655. vid.preload = 'auto';
  1656. var poster = '';
  1657. if (full.length > playUrl.length) poster = full;
  1658. else poster = mp4UrlToJpgUrl(playUrl);
  1659. if (poster) vid.setAttribute('poster', poster);
  1660. vid.addEventListener('canplay', function onCap() {
  1661. vid.removeEventListener('canplay', onCap);
  1662. var p = vid.play();
  1663. if (p && typeof p.catch === 'function') p.catch(function () {});
  1664. });
  1665. wrap.appendChild(vid);
  1666. } else {
  1667. var img = document.createElement('img');
  1668. img.src = full;
  1669. img.alt = '';
  1670. img.decoding = 'async';
  1671. wrap.appendChild(img);
  1672. }
  1673. return wrap;
  1674. }
  1675. function renderMarketingList(rawList) {
  1676. marketingListCache = Array.isArray(rawList) ? rawList.slice() : [];
  1677. var section = document.getElementById('shareMarketingSection');
  1678. var listEl = document.getElementById('marketingListEl');
  1679. var moreBtn = document.getElementById('marketingMoreBtn');
  1680. var moreText = document.getElementById('marketingMoreText');
  1681. if (!section || !listEl) return;
  1682. listEl.innerHTML = '';
  1683. section.classList.remove('is-expanded');
  1684. if (moreBtn) {
  1685. moreBtn.style.display = 'none';
  1686. moreBtn.setAttribute('aria-expanded', 'false');
  1687. }
  1688. if (closedMerchantFlag) {
  1689. section.style.display = 'none';
  1690. section.setAttribute('aria-hidden', 'true');
  1691. return;
  1692. }
  1693. var items = marketingListCache.filter(function (x) {
  1694. return x && x.imgUrl && String(x.imgUrl).trim();
  1695. }).filter(function (x) {
  1696. var t = x.activityType;
  1697. if (t == null || t === '') return true;
  1698. return String(t).toUpperCase() === 'MARKETING';
  1699. });
  1700. items.sort(function (a, b) {
  1701. var sa = Number(a.imgSort);
  1702. var sb = Number(b.imgSort);
  1703. if (isNaN(sa)) sa = 0;
  1704. if (isNaN(sb)) sb = 0;
  1705. return sa - sb;
  1706. });
  1707. if (!items.length) {
  1708. if (!marketingCouponLoaded) {
  1709. section.style.display = 'none';
  1710. section.setAttribute('aria-hidden', 'true');
  1711. return;
  1712. }
  1713. section.style.display = 'block';
  1714. section.setAttribute('aria-hidden', 'false');
  1715. var emptyWrap = document.createElement('div');
  1716. emptyWrap.className = 'marketing-section__empty';
  1717. emptyWrap.setAttribute('role', 'status');
  1718. var emptyImg = document.createElement('img');
  1719. emptyImg.src = 'images/empty.png';
  1720. emptyImg.alt = '';
  1721. emptyImg.decoding = 'async';
  1722. var emptyLabel = document.createElement('p');
  1723. emptyLabel.className = 'marketing-section__empty-label';
  1724. emptyLabel.textContent = '暂无活动';
  1725. emptyWrap.appendChild(emptyImg);
  1726. emptyWrap.appendChild(emptyLabel);
  1727. listEl.appendChild(emptyWrap);
  1728. return;
  1729. }
  1730. section.style.display = 'block';
  1731. section.setAttribute('aria-hidden', 'false');
  1732. items.forEach(function (item, idx) {
  1733. var card = document.createElement('article');
  1734. card.className = 'marketing-card';
  1735. if (idx >= MARKETING_PREVIEW_COUNT) card.classList.add('marketing-card--more');
  1736. card.appendChild(createMarketingMedia(item.imgUrl));
  1737. listEl.appendChild(card);
  1738. });
  1739. var extra = items.length - MARKETING_PREVIEW_COUNT;
  1740. if (extra > 0 && moreBtn && moreText) {
  1741. moreText.textContent = '查看剩余' + extra + '个活动';
  1742. moreBtn.style.display = 'flex';
  1743. }
  1744. }
  1745. function bindMarketingMore() {
  1746. var section = document.getElementById('shareMarketingSection');
  1747. var moreBtn = document.getElementById('marketingMoreBtn');
  1748. if (!section || !moreBtn || moreBtn.dataset.bound) return;
  1749. moreBtn.dataset.bound = '1';
  1750. moreBtn.addEventListener('click', function () {
  1751. section.classList.add('is-expanded');
  1752. moreBtn.style.display = 'none';
  1753. moreBtn.setAttribute('aria-expanded', 'true');
  1754. });
  1755. }
  1756. function createStaffCardElement(staff) {
  1757. var card = document.createElement('article');
  1758. card.className = 'staff-card';
  1759. var imgWrap = document.createElement('div');
  1760. imgWrap.className = 'staff-card__img-wrap';
  1761. var imgUrl = String(staff.staffImage || '').trim();
  1762. if (imgUrl) {
  1763. var img = document.createElement('img');
  1764. img.src = imgUrl;
  1765. img.alt = String(staff.name || '');
  1766. img.decoding = 'async';
  1767. img.loading = 'lazy';
  1768. imgWrap.appendChild(img);
  1769. }
  1770. var likes = document.createElement('div');
  1771. likes.className = 'staff-card__likes';
  1772. var lc = staff.likeCount != null ? Number(staff.likeCount) : 0;
  1773. if (isNaN(lc)) lc = 0;
  1774. likes.textContent = lc + '人喜欢';
  1775. imgWrap.appendChild(likes);
  1776. var nameRow = document.createElement('div');
  1777. nameRow.className = 'staff-card__name-row';
  1778. var nameEl = document.createElement('span');
  1779. nameEl.className = 'staff-card__name';
  1780. nameEl.textContent = String(staff.name != null ? staff.name : '').trim() || '—';
  1781. nameRow.appendChild(nameEl);
  1782. var perf = staff.hasPerformanceToday;
  1783. if (perf === true || perf === 1 || String(perf).toLowerCase() === 'true') {
  1784. var badge = document.createElement('span');
  1785. badge.className = 'staff-card__badge';
  1786. badge.textContent = '今日演出';
  1787. nameRow.appendChild(badge);
  1788. }
  1789. card.appendChild(imgWrap);
  1790. card.appendChild(nameRow);
  1791. var meta = document.createElement('div');
  1792. meta.className = 'staff-card__meta';
  1793. var pos = document.createElement('span');
  1794. pos.className = 'staff-card__position';
  1795. pos.textContent = String(staff.staffPosition || '').trim() || '\u00a0';
  1796. meta.appendChild(pos);
  1797. var pc = staff.positiveCommentsCount != null ? Number(staff.positiveCommentsCount) : 0;
  1798. if (!isNaN(pc) && pc > 0) {
  1799. var sep = document.createElement('span');
  1800. sep.className = 'staff-card__sep';
  1801. sep.textContent = '|';
  1802. var rev = document.createElement('span');
  1803. rev.className = 'staff-card__reviews';
  1804. rev.textContent = '好评' + pc + '次';
  1805. meta.appendChild(sep);
  1806. meta.appendChild(rev);
  1807. }
  1808. card.appendChild(meta);
  1809. return card;
  1810. }
  1811. function createPerformanceCardElement(row) {
  1812. var card = document.createElement('article');
  1813. card.className = 'performance-card';
  1814. var posterWrap = document.createElement('div');
  1815. posterWrap.className = 'performance-card__poster';
  1816. var posterUrl = String(row.performancePoster || '').trim();
  1817. if (posterUrl) {
  1818. var img = document.createElement('img');
  1819. img.src = posterUrl;
  1820. img.alt = String(row.performanceName || '');
  1821. img.decoding = 'async';
  1822. img.loading = 'lazy';
  1823. posterWrap.appendChild(img);
  1824. }
  1825. var body = document.createElement('div');
  1826. body.className = 'performance-card__body';
  1827. var nameEl = document.createElement('div');
  1828. nameEl.className = 'performance-card__name';
  1829. nameEl.textContent = String(row.performanceName != null ? row.performanceName : '').trim() || '—';
  1830. body.appendChild(nameEl);
  1831. var dr = String(row.dateRange || '').trim();
  1832. if (dr) {
  1833. var line1 = document.createElement('div');
  1834. line1.className = 'performance-card__meta';
  1835. line1.textContent = dr;
  1836. body.appendChild(line1);
  1837. }
  1838. var si = String(row.scheduleInfo || '').trim();
  1839. if (si) {
  1840. var line2 = document.createElement('div');
  1841. line2.className = 'performance-card__meta';
  1842. line2.textContent = si;
  1843. line2.title = si;
  1844. body.appendChild(line2);
  1845. }
  1846. card.appendChild(posterWrap);
  1847. card.appendChild(body);
  1848. return card;
  1849. }
  1850. function renderPerformanceList() {
  1851. var section = document.getElementById('sharePerformanceSection');
  1852. var titleEl = document.getElementById('performanceSectionTitle');
  1853. var strip = document.getElementById('performanceStripEl');
  1854. if (!section || !titleEl || !strip) return;
  1855. strip.innerHTML = '';
  1856. if (!shouldShowPerformanceSection()) {
  1857. section.style.display = 'none';
  1858. section.setAttribute('aria-hidden', 'true');
  1859. return;
  1860. }
  1861. if (closedMerchantFlag) {
  1862. section.style.display = 'none';
  1863. section.setAttribute('aria-hidden', 'true');
  1864. return;
  1865. }
  1866. var records = performanceListCache.records;
  1867. var total = performanceListCache.total;
  1868. if (isNaN(total)) total = records.length;
  1869. titleEl.textContent = '演出安排(' + total + ')';
  1870. if (!records.length) {
  1871. section.style.display = 'none';
  1872. section.setAttribute('aria-hidden', 'true');
  1873. return;
  1874. }
  1875. section.style.display = 'block';
  1876. section.setAttribute('aria-hidden', 'false');
  1877. records.forEach(function (row) {
  1878. if (!row) return;
  1879. strip.appendChild(createPerformanceCardElement(row));
  1880. });
  1881. }
  1882. function renderStaffGroups(raw) {
  1883. staffGroupsCache = Array.isArray(raw) ? raw.slice() : [];
  1884. var section = document.getElementById('shareStaffSection');
  1885. var mount = document.getElementById('staffGroupsMount');
  1886. if (!section || !mount) return;
  1887. var totalStaff = 0;
  1888. staffGroupsCache.forEach(function (g) {
  1889. if (g && Array.isArray(g.staffList)) totalStaff += g.staffList.length;
  1890. });
  1891. var countEl = document.getElementById('staffSectionCountEl');
  1892. if (countEl) countEl.textContent = String(totalStaff);
  1893. mount.innerHTML = '';
  1894. if (closedMerchantFlag) {
  1895. section.style.display = 'none';
  1896. section.setAttribute('aria-hidden', 'true');
  1897. return;
  1898. }
  1899. var groups = staffGroupsCache.filter(function (g) {
  1900. return g && Array.isArray(g.staffList) && g.staffList.length;
  1901. });
  1902. if (!groups.length) {
  1903. section.style.display = 'none';
  1904. section.setAttribute('aria-hidden', 'true');
  1905. return;
  1906. }
  1907. section.style.display = 'block';
  1908. section.setAttribute('aria-hidden', 'false');
  1909. groups.forEach(function (group) {
  1910. var wrap = document.createElement('div');
  1911. wrap.className = 'staff-group';
  1912. if (group.titleId != null) wrap.dataset.titleId = String(group.titleId);
  1913. var strip = document.createElement('div');
  1914. strip.className = 'staff-strip';
  1915. group.staffList.forEach(function (staff) {
  1916. if (!staff) return;
  1917. strip.appendChild(createStaffCardElement(staff));
  1918. });
  1919. wrap.appendChild(strip);
  1920. mount.appendChild(wrap);
  1921. });
  1922. }
  1923. function bindStaffSection() {
  1924. var btn = document.getElementById('staffSectionAllBtn');
  1925. if (!btn || btn.dataset.bound) return;
  1926. btn.dataset.bound = '1';
  1927. btn.addEventListener('click', function (e) {
  1928. e.preventDefault();
  1929. tryOpenHBuilderApp();
  1930. });
  1931. }
  1932. function buildHeroSlides(urls) {
  1933. var track = document.getElementById('heroTrack');
  1934. var dotsWrap = document.getElementById('heroDots');
  1935. track.innerHTML = '';
  1936. dotsWrap.innerHTML = '';
  1937. var list = (urls || []).filter(Boolean);
  1938. if (!list.length) {
  1939. var slide = document.createElement('div');
  1940. slide.className = 'hero__slide';
  1941. var img = document.createElement('img');
  1942. img.src = 'images/hero.png';
  1943. img.alt = '店铺';
  1944. slide.appendChild(img);
  1945. track.appendChild(slide);
  1946. var dot = document.createElement('span');
  1947. dot.className = 'hero__dot is-active';
  1948. dotsWrap.appendChild(dot);
  1949. return initHeroCarousel(1);
  1950. }
  1951. list.forEach(function (url, d) {
  1952. var slide = document.createElement('div');
  1953. slide.className = 'hero__slide';
  1954. var img = document.createElement('img');
  1955. img.src = url;
  1956. img.alt = '店铺图';
  1957. slide.appendChild(img);
  1958. track.appendChild(slide);
  1959. var dot = document.createElement('span');
  1960. dot.className = 'hero__dot' + (d === 0 ? ' is-active' : '');
  1961. dotsWrap.appendChild(dot);
  1962. });
  1963. initHeroCarousel(list.length);
  1964. }
  1965. var heroI = 0;
  1966. var heroTimer = null;
  1967. function initHeroCarousel(slides) {
  1968. var track = document.getElementById('heroTrack');
  1969. var dotsWrap = document.getElementById('heroDots');
  1970. var dots = dotsWrap.querySelectorAll('.hero__dot');
  1971. if (slides < 2) return;
  1972. function go(n) {
  1973. heroI = (n + slides) % slides;
  1974. track.style.transform = 'translateX(' + (-heroI * 100) + '%)';
  1975. dots.forEach(function (el, idx) {
  1976. el.classList.toggle('is-active', idx === heroI);
  1977. });
  1978. }
  1979. if (heroTimer) clearInterval(heroTimer);
  1980. heroTimer = setInterval(function () { go(heroI + 1); }, 4000);
  1981. var hero = document.getElementById('hero');
  1982. var startX = 0;
  1983. hero.addEventListener('touchstart', function (e) {
  1984. startX = e.changedTouches[0].clientX;
  1985. }, { passive: true });
  1986. hero.addEventListener('touchend', function (e) {
  1987. var dx = e.changedTouches[0].clientX - startX;
  1988. if (Math.abs(dx) > 40) go(dx < 0 ? heroI + 1 : heroI - 1);
  1989. }, { passive: true });
  1990. }
  1991. function timeToMinutes(t) {
  1992. var parts = String(t || '').trim().split(':');
  1993. var h = parseInt(parts[0], 10) || 0;
  1994. var m = parseInt(parts[1], 10) || 0;
  1995. return h * 60 + m;
  1996. }
  1997. function isTimeInRange(startTime, endTime) {
  1998. var s = String(startTime || '').trim();
  1999. var e = String(endTime || '').trim();
  2000. if (s === '00:00' && e === '00:00') return true;
  2001. if (s === '00:00' && e === '23:59') return true;
  2002. var cur = new Date().getHours() * 60 + new Date().getMinutes();
  2003. var sm = timeToMinutes(s);
  2004. var em = timeToMinutes(e);
  2005. if (em < sm) {
  2006. return cur >= sm || cur <= em;
  2007. }
  2008. return cur >= sm && cur <= em;
  2009. }
  2010. function parseHolidayDate(str) {
  2011. if (!str) return null;
  2012. var d = new Date(String(str).trim().replace(/-/g, '/'));
  2013. return isNaN(d.getTime()) ? null : d;
  2014. }
  2015. function isTodayInHolidayRange(holidayInfo) {
  2016. if (!holidayInfo) return false;
  2017. var hi = holidayInfo;
  2018. if (typeof hi === 'string') {
  2019. try {
  2020. hi = JSON.parse(hi);
  2021. } catch (err) {
  2022. return false;
  2023. }
  2024. }
  2025. var start = hi.startDate || hi.holidayStartDate || hi.beginDate || hi.start || hi.holidayStart;
  2026. var end = hi.endDate || hi.holidayEndDate || hi.finishDate || hi.end || hi.holidayEnd;
  2027. if (!start || !end) return false;
  2028. var startD = parseHolidayDate(start);
  2029. var endD = parseHolidayDate(end);
  2030. if (!startD || !endD) return false;
  2031. var today = new Date();
  2032. today.setHours(0, 0, 0, 0);
  2033. startD.setHours(0, 0, 0, 0);
  2034. endD.setHours(0, 0, 0, 0);
  2035. return today >= startD && today <= endD;
  2036. }
  2037. function findNormalBusinessInfo(list) {
  2038. var wdJs = new Date().getDay();
  2039. var i;
  2040. var x;
  2041. var w;
  2042. for (i = 0; i < list.length; i++) {
  2043. x = list[i];
  2044. if (!x || x.holidayInfo) continue;
  2045. w = x.weekDay != null ? x.weekDay : x.week;
  2046. if (w === undefined || w === null) continue;
  2047. if (Number(w) === wdJs) return x;
  2048. }
  2049. var wdMap = wdJs === 0 ? 7 : wdJs;
  2050. for (i = 0; i < list.length; i++) {
  2051. x = list[i];
  2052. if (!x || x.holidayInfo) continue;
  2053. w = x.weekDay != null ? x.weekDay : x.week;
  2054. if (w === undefined || w === null) continue;
  2055. if (Number(w) === wdMap) return x;
  2056. }
  2057. for (i = 0; i < list.length; i++) {
  2058. x = list[i];
  2059. if (x && !x.holidayInfo && (x.startTime || x.endTime)) return x;
  2060. }
  2061. return null;
  2062. }
  2063. /** 营业状态:暂停营业 | 商家暂未配置营业时间 | 休息中 | 营业中 xx:xx至xx:xx | 营业中 全天营业 */
  2064. function computeBusinessStatusDisplay(d) {
  2065. if (!d) return { text: '—', isOpen: false };
  2066. if (Number(d.businessStatus) === 99) {
  2067. return { text: '商户已关闭', isOpen: false };
  2068. }
  2069. if (Number(d.businessStatus) === 1) {
  2070. return { text: '暂停营业', isOpen: false };
  2071. }
  2072. var list = d.storeBusinessInfoVos || d.storeBusinessInfos || [];
  2073. if (!list.length) {
  2074. return { text: '商家暂未配置营业时间', isOpen: false };
  2075. }
  2076. var holidayList = Array.isArray(d.holidayBusinessInfoList) && d.holidayBusinessInfoList.length
  2077. ? d.holidayBusinessInfoList
  2078. : list.filter(function (item) { return item && item.holidayInfo; });
  2079. var todayHolidayItem = holidayList.find(function (item) {
  2080. return isTodayInHolidayRange(item.holidayInfo);
  2081. });
  2082. var normal = d.normalBusinessInfo || d.normalBusinessInfoVo || findNormalBusinessInfo(list);
  2083. var isOpen = false;
  2084. var currentItem = null;
  2085. if (todayHolidayItem) {
  2086. isOpen = isTimeInRange(todayHolidayItem.startTime, todayHolidayItem.endTime);
  2087. currentItem = todayHolidayItem;
  2088. } else if (normal) {
  2089. isOpen = isTimeInRange(normal.startTime, normal.endTime);
  2090. currentItem = normal;
  2091. }
  2092. if (!currentItem) return { text: '休息中', isOpen: false };
  2093. if (!isOpen) return { text: '休息中', isOpen: false };
  2094. var st = String(currentItem.startTime || '').trim();
  2095. var et = String(currentItem.endTime || '').trim();
  2096. if (st === '00:00' && et === '00:00') return { text: '营业中 全天营业', isOpen: true };
  2097. if (st === '00:00' && et === '23:59') return { text: '营业中 全天营业', isOpen: true };
  2098. var needNextDay = timeToMinutes(et) < timeToMinutes(st);
  2099. var suffix = (needNextDay ? '次日' : '') + et;
  2100. return { text: ('营业中 ' + st + ' 至 ' + suffix).trim(), isOpen: true };
  2101. }
  2102. /**
  2103. * 分项评分:可能在 storeEvaluate 对象内,或为 JSON 字符串;部分接口把字段放在详情根上。
  2104. */
  2105. function parseStoreEvaluateRaw(raw) {
  2106. if (raw == null || raw === '') return null;
  2107. if (typeof raw === 'string') {
  2108. var t = raw.trim();
  2109. if (!t) return null;
  2110. try {
  2111. raw = JSON.parse(t);
  2112. } catch (e) {
  2113. return null;
  2114. }
  2115. }
  2116. if (Array.isArray(raw) && raw.length && raw[0] && typeof raw[0] === 'object') {
  2117. raw = raw[0];
  2118. }
  2119. if (raw && typeof raw === 'object' && !Array.isArray(raw)) return raw;
  2120. return null;
  2121. }
  2122. function getStoreEvaluateScores(d) {
  2123. var ev = parseStoreEvaluateRaw(d.storeEvaluate)
  2124. || parseStoreEvaluateRaw(d.evaluate)
  2125. || parseStoreEvaluateRaw(d.evaluateInfo);
  2126. function lane(key, snake) {
  2127. var v;
  2128. if (ev && ev[key] != null && ev[key] !== '') v = ev[key];
  2129. else if (d[key] != null && d[key] !== '') v = d[key];
  2130. else if (snake && d[snake] != null && d[snake] !== '') v = d[snake];
  2131. else return null;
  2132. var n = Number(v);
  2133. return !isNaN(n) ? n : null;
  2134. }
  2135. return {
  2136. scoreOne: lane('scoreOne', 'score_one'),
  2137. scoreTwo: lane('scoreTwo', 'score_two'),
  2138. scoreThree: lane('scoreThree', 'score_three')
  2139. };
  2140. }
  2141. function fmtEvalScore(n) {
  2142. return n != null && !isNaN(n) ? Number(n).toFixed(1) : null;
  2143. }
  2144. var CLOSED_REC_STAR_PATH =
  2145. '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';
  2146. function closedRecEscHtml(s) {
  2147. return String(s == null ? '' : s)
  2148. .replace(/&/g, '&amp;')
  2149. .replace(/</g, '&lt;')
  2150. .replace(/>/g, '&gt;')
  2151. .replace(/"/g, '&quot;');
  2152. }
  2153. function closedRecStarsHtml(score) {
  2154. var s = Number(score);
  2155. if (isNaN(s)) s = 0;
  2156. s = Math.max(0, Math.min(5, s));
  2157. var rounded = Math.round(s);
  2158. var parts = [];
  2159. var i;
  2160. for (i = 1; i <= 5; i++) {
  2161. var fill = i <= rounded ? '#F58220' : '#E5E5E5';
  2162. parts.push(
  2163. '<svg class="closed-rec-star" width="11" height="11" viewBox="0 0 24 24" aria-hidden="true">' +
  2164. '<path fill="' + fill + '" d="' + CLOSED_REC_STAR_PATH + '"/></svg>'
  2165. );
  2166. }
  2167. return '<span class="closed-rec-stars">' + parts.join('') + '</span>';
  2168. }
  2169. function closedRecFormatDistance(item) {
  2170. if (item.distance != null && item.distance !== '') {
  2171. var km = Number(item.distance);
  2172. if (!isNaN(km) && km >= 0) {
  2173. return Math.round(km * 1000) + '米';
  2174. }
  2175. return String(item.distance).trim();
  2176. }
  2177. if (item.position != null && String(item.position).trim() !== '') {
  2178. return String(item.position).trim();
  2179. }
  2180. if (item.dist != null && item.dist !== '') {
  2181. var dn = Number(item.dist);
  2182. if (!isNaN(dn)) {
  2183. return dn >= 1 ? dn.toFixed(dn % 1 === 0 ? 0 : 1) + 'km' : Math.round(dn * 1000) + '米';
  2184. }
  2185. }
  2186. return '';
  2187. }
  2188. function closedRecPickScore(item) {
  2189. var x =
  2190. item.scoreAvg != null ? Number(item.scoreAvg)
  2191. : item.score != null ? Number(item.score)
  2192. : item.rating != null ? Number(item.rating)
  2193. : item.starScore != null ? Number(item.starScore)
  2194. : NaN;
  2195. return isNaN(x) ? null : x;
  2196. }
  2197. function closedRecPickReviewCount(item) {
  2198. var n =
  2199. item.commitCount != null ? Number(item.commitCount)
  2200. : item.commentCount != null ? Number(item.commentCount)
  2201. : item.reviewCount != null ? Number(item.reviewCount)
  2202. : item.evaluateCount != null ? Number(item.evaluateCount)
  2203. : NaN;
  2204. return isNaN(n) ? 0 : Math.max(0, Math.floor(n));
  2205. }
  2206. function normalizeClosedStoreRecommendList(res) {
  2207. if (!res || typeof res !== 'object') return [];
  2208. var raw = res.data != null ? res.data : res.result;
  2209. if (Array.isArray(raw)) return raw;
  2210. if (raw && typeof raw === 'object') {
  2211. if (Array.isArray(raw.list)) return raw.list;
  2212. if (Array.isArray(raw.records)) return raw.records;
  2213. if (Array.isArray(raw.rows)) return raw.rows;
  2214. if (Array.isArray(raw.content)) return raw.content;
  2215. if (Array.isArray(raw.stores)) return raw.stores;
  2216. if (Array.isArray(raw.storeList)) return raw.storeList;
  2217. if (Array.isArray(raw.storeVos)) return raw.storeVos;
  2218. if (Array.isArray(raw.items)) return raw.items;
  2219. }
  2220. if (Array.isArray(res.list)) return res.list;
  2221. if (Array.isArray(res.records)) return res.records;
  2222. return [];
  2223. }
  2224. function fetchShareClosedStoreRecommend(storeIdStr) {
  2225. var loc = getClosedRecommendUserLocation();
  2226. var page = parseInt(q('page') || '1', 10);
  2227. var pageSize = parseInt(q('pageSize') || '10', 10);
  2228. if (isNaN(page) || page < 1) page = 1;
  2229. if (isNaN(pageSize) || pageSize < 1) pageSize = 10;
  2230. var body = {
  2231. page: page,
  2232. pageSize: pageSize,
  2233. storeId: String(storeIdStr || ''),
  2234. userCity: loc.userCity,
  2235. userLat: loc.userLat,
  2236. userLng: loc.userLng
  2237. };
  2238. return fetch(API_LIFE_AI_BASE + STORE_GLOBAL_RECOMMEND_PATH, {
  2239. method: 'POST',
  2240. mode: 'cors',
  2241. credentials: 'omit',
  2242. headers: {
  2243. Accept: 'application/json',
  2244. 'Content-Type': 'application/json;charset=UTF-8'
  2245. },
  2246. body: JSON.stringify(body)
  2247. }).then(function (res) {
  2248. if (!res.ok) throw new Error('HTTP ' + res.status);
  2249. return res.json();
  2250. });
  2251. }
  2252. function renderShareClosedRecommended(list) {
  2253. var wrap = document.getElementById('shareClosedRecList');
  2254. var empty = document.getElementById('shareClosedRecEmpty');
  2255. if (!wrap || !empty) return;
  2256. wrap.querySelectorAll('.closed-rec-card').forEach(function (n) {
  2257. n.remove();
  2258. });
  2259. if (!list || !list.length) {
  2260. empty.style.display = 'block';
  2261. return;
  2262. }
  2263. empty.style.display = 'none';
  2264. list.forEach(function (item) {
  2265. if (!item || typeof item !== 'object') return;
  2266. var imgUrlField = item.imgUrl != null ? String(item.imgUrl).trim() : '';
  2267. var home = item.homeImage != null ? String(item.homeImage).trim() : '';
  2268. if (home && /\.mp4(\?|#|$)/i.test(home)) {
  2269. var vf = item.videoFirstFrame != null ? String(item.videoFirstFrame).trim() : '';
  2270. if (vf) home = vf;
  2271. }
  2272. var imgUrl =
  2273. imgUrlField ||
  2274. home ||
  2275. (item.coverUrl != null ? String(item.coverUrl).trim() : '') ||
  2276. (item.mainImage != null ? String(item.mainImage).trim() : '') ||
  2277. (item.goodsImage != null ? String(item.goodsImage).trim() : '') ||
  2278. (item.entranceImage != null ? String(item.entranceImage).trim() : '') ||
  2279. (Array.isArray(item.goodsImageList) && item.goodsImageList[0]) ||
  2280. (Array.isArray(item.imageList) && item.imageList[0]) ||
  2281. (Array.isArray(item.storeAlbumUrlList) && item.storeAlbumUrlList[0]) ||
  2282. '';
  2283. var name = item.title != null && String(item.title).trim() !== ''
  2284. ? String(item.title).replace(/\r?\n/g, ' ').replace(/\s+/g, ' ').trim()
  2285. : (item.storeName || item.goodsName || item.secondGoodsTitle || item.name || '推荐');
  2286. var dist = closedRecFormatDistance(item);
  2287. var scoreVal = closedRecPickScore(item);
  2288. var displayScore = scoreVal != null ? scoreVal.toFixed(1) : '—';
  2289. var starScore = scoreVal != null ? scoreVal : 0;
  2290. var rc = closedRecPickReviewCount(item);
  2291. var reviewLabel = rc > 0 ? rc + '条评价' : '';
  2292. var seller =
  2293. item.userName != null && String(item.userName).trim() !== ''
  2294. ? String(item.userName).trim()
  2295. : (item.nickName != null && String(item.nickName).trim() !== ''
  2296. ? String(item.nickName).trim()
  2297. : '');
  2298. var card = document.createElement('article');
  2299. card.className = 'closed-rec-card';
  2300. card.innerHTML =
  2301. '<div class="closed-rec-card__img"><img class="closed-rec-card__cover" src="" alt="" decoding="async"></div>' +
  2302. '<div class="closed-rec-card__body">' +
  2303. '<div class="closed-rec-card__top">' +
  2304. '<span class="closed-rec-card__name">' + closedRecEscHtml(name) + '</span>' +
  2305. (dist ? '<span class="closed-rec-card__dist">' + closedRecEscHtml(dist) + '</span>' : '') +
  2306. '</div>' +
  2307. '<div class="closed-rec-card__rating">' +
  2308. closedRecStarsHtml(starScore) +
  2309. '<span class="closed-rec-rating-num">' + closedRecEscHtml(displayScore) + '</span>' +
  2310. (reviewLabel ? '<span class="closed-rec-meta">' + closedRecEscHtml(reviewLabel) + '</span>' : '') +
  2311. '</div>' +
  2312. (seller ? '<div class="closed-rec-card__footer">' + closedRecEscHtml(seller) + '</div>' : '') +
  2313. '</div>';
  2314. var coverIm = card.querySelector('img.closed-rec-card__cover');
  2315. if (coverIm) {
  2316. coverIm.src = imgUrl;
  2317. coverIm.onerror = function () {
  2318. this.onerror = null;
  2319. this.src = '';
  2320. };
  2321. }
  2322. wrap.appendChild(card);
  2323. });
  2324. }
  2325. function loadShareClosedRecommendations() {
  2326. var sid = getStoreId();
  2327. if (!sid) {
  2328. renderShareClosedRecommended([]);
  2329. return;
  2330. }
  2331. fetchShareClosedStoreRecommend(sid)
  2332. .then(function (res) {
  2333. var list = normalizeClosedStoreRecommendList(res);
  2334. if (!list.length && res && res.msg) {
  2335. console.warn('[store-recommend]', res.msg);
  2336. }
  2337. renderShareClosedRecommended(list);
  2338. })
  2339. .catch(function (e) {
  2340. console.error(e);
  2341. renderShareClosedRecommended([]);
  2342. });
  2343. }
  2344. function applyShareIndexClosedMerchantUi(closed) {
  2345. var wasClosed = closedMerchantFlag;
  2346. closedMerchantFlag = closed;
  2347. var banner = document.getElementById('shareClosedBanner');
  2348. var contentEl = document.getElementById('shareContentEl');
  2349. var belowEl = document.getElementById('shareBelowContentEl');
  2350. var recWrap = document.getElementById('shareClosedRecommendWrap');
  2351. if (banner) {
  2352. banner.style.display = closed ? 'block' : 'none';
  2353. banner.setAttribute('aria-hidden', closed ? 'false' : 'true');
  2354. }
  2355. if (contentEl) {
  2356. contentEl.style.display = closed ? 'none' : '';
  2357. contentEl.setAttribute('aria-hidden', closed ? 'true' : 'false');
  2358. }
  2359. if (belowEl) {
  2360. belowEl.style.display = '';
  2361. belowEl.setAttribute('aria-hidden', 'false');
  2362. }
  2363. if (recWrap) {
  2364. if (closed) {
  2365. recWrap.style.display = 'block';
  2366. recWrap.setAttribute('aria-hidden', 'false');
  2367. if (!wasClosed) {
  2368. loadShareClosedRecommendations();
  2369. }
  2370. } else {
  2371. recWrap.style.display = 'none';
  2372. recWrap.setAttribute('aria-hidden', 'true');
  2373. renderShareClosedRecommended([]);
  2374. }
  2375. }
  2376. }
  2377. function renderDetail(d) {
  2378. if (!d) return;
  2379. document.getElementById('storeName').textContent = d.storeName || '—';
  2380. var score = d.scoreAvg != null ? Number(d.scoreAvg) : NaN;
  2381. document.getElementById('scoreAvg').textContent = !isNaN(score) ? score.toFixed(1) : '—';
  2382. document.getElementById('commitCount').textContent = d.commitCount != null ? String(d.commitCount)+'条' : '0';
  2383. var evRow = document.getElementById('storeEvaluateRow');
  2384. var evOne = document.getElementById('storeEvaluateScoreOne');
  2385. var evTwo = document.getElementById('storeEvaluateScoreTwo');
  2386. var evThree = document.getElementById('storeEvaluateScoreThree');
  2387. if (evRow && evOne && evTwo && evThree) {
  2388. evRow.classList.remove('is-visible');
  2389. evRow.setAttribute('aria-hidden', 'true');
  2390. var es = getStoreEvaluateScores(d);
  2391. var a = fmtEvalScore(es.scoreOne);
  2392. var b = fmtEvalScore(es.scoreTwo);
  2393. var c = fmtEvalScore(es.scoreThree);
  2394. if (a !== null || b !== null || c !== null) {
  2395. evOne.textContent = a !== null ? a : '—';
  2396. evTwo.textContent = b !== null ? b : '—';
  2397. evThree.textContent = c !== null ? c : '—';
  2398. evRow.classList.add('is-visible');
  2399. evRow.setAttribute('aria-hidden', 'false');
  2400. }
  2401. }
  2402. var bizDisp = computeBusinessStatusDisplay(d);
  2403. var bizEl = document.getElementById('bizStatus');
  2404. bizEl.textContent = bizDisp.text;
  2405. bizEl.className = 'status' + (bizDisp.isOpen ? ' is-open' : '');
  2406. document.getElementById('hoursText').textContent = '';
  2407. document.getElementById('storeAddr').textContent = d.queryAddress || d.storeAddress || '—';
  2408. if (d.distance != null) {
  2409. document.getElementById('metaDistance').style.display = 'flex';
  2410. document.getElementById('distanceText').textContent =
  2411. '距您' + (Number(d.distance) > 1 ? d.distance + '千米' : Math.round(Number(d.distance) * 1000) + '米');
  2412. }
  2413. if (d.subwayName && d.distance2 != null) {
  2414. document.getElementById('metaSubway').style.display = 'flex';
  2415. document.getElementById('subwayText').textContent =
  2416. '距' + d.subwayName + '步行' + (Number(d.distance2) >= 1000
  2417. ? (Number(d.distance2) / 1000).toFixed(1) + 'km'
  2418. : Math.round(Number(d.distance2)) + 'm');
  2419. }
  2420. var imgs = [];
  2421. if (Array.isArray(d.storeAlbumUrlList) && d.storeAlbumUrlList.length) imgs = d.storeAlbumUrlList.slice();
  2422. else if (d.entranceImage) imgs = [d.entranceImage];
  2423. buildHeroSlides(imgs);
  2424. var closedMerchant = Number(d.businessStatus) === 99;
  2425. applyShareIndexClosedMerchantUi(closedMerchant);
  2426. renderMarketingList(marketingListCache);
  2427. renderPerformanceList();
  2428. renderStaffGroups(staffGroupsCache);
  2429. }
  2430. function getLngForApi() {
  2431. var v = q('jingdu');
  2432. if (v) return v;
  2433. return q('lon') || q('lng') || q('longitude');
  2434. }
  2435. function getLatForApi() {
  2436. var v = q('weidu');
  2437. if (v) return v;
  2438. return q('lat') || q('latitude');
  2439. }
  2440. function mergeSearchAndHashParamsForRedirect() {
  2441. var params = new URLSearchParams();
  2442. function ingest(slice) {
  2443. if (!slice) return;
  2444. var p = new URLSearchParams(slice);
  2445. p.forEach(function (val, key) {
  2446. params.set(key, val);
  2447. });
  2448. }
  2449. if (location.search && location.search.length > 1) {
  2450. ingest(location.search.slice(1));
  2451. }
  2452. var hash = location.hash || '';
  2453. var qi = hash.indexOf('?');
  2454. if (qi >= 0) {
  2455. ingest(hash.slice(qi + 1));
  2456. }
  2457. return params;
  2458. }
  2459. /** getClientStoreDetail 无承载数据时进 shareCheckInUndefined(businessStatus=99 与落地页约定一致) */
  2460. function buildShareCheckInUndefinedRedirectHref() {
  2461. var p = mergeSearchAndHashParamsForRedirect();
  2462. p.set('businessStatus', '99');
  2463. var sid = getStoreId();
  2464. if (sid && !p.has('storeId')) {
  2465. p.set('storeId', sid);
  2466. }
  2467. var j = getLngForApi();
  2468. var w = getLatForApi();
  2469. if (j && !p.has('userLng')) {
  2470. p.set('userLng', j);
  2471. }
  2472. if (w && !p.has('userLat')) {
  2473. p.set('userLat', w);
  2474. }
  2475. var qs = p.toString();
  2476. return 'shareCheckInUndefined.html' + (qs ? ('?' + qs) : '?businessStatus=99');
  2477. }
  2478. function run() {
  2479. var sid = getStoreId();
  2480. var userId = q('userId');
  2481. var jingdu = getLngForApi();
  2482. var weidu = getLatForApi();
  2483. if (!sid) {
  2484. showErr('缺少店铺 id(请从 App 分享链接打开,URL 需带 id 或 storeId)');
  2485. document.getElementById('storeName').textContent = '参数错误';
  2486. return;
  2487. }
  2488. var detailPath = '/store/info/getClientStoreDetail?' +
  2489. 'id=' + encodeURIComponent(sid) +
  2490. '&userId=' + encodeURIComponent(userId) +
  2491. '&jingdu=' + encodeURIComponent(jingdu) +
  2492. '&weidu=' + encodeURIComponent(weidu);
  2493. fetchStoreInfoGetOne(sid).then(function (getOneRes) {
  2494. if (isGetOneBusinessStatus99(getOneRes)) {
  2495. applyShareIndexClosedMerchantUi(true);
  2496. }
  2497. apiFetch(detailPath)
  2498. .then(function (res) {
  2499. var tip = res && res.msg != null ? String(res.msg).trim() : '';
  2500. if (tip === '暂无承载数据') {
  2501. if (closedMerchantFlag) {
  2502. return;
  2503. }
  2504. window.location.replace(buildShareCheckInUndefinedRedirectHref());
  2505. return;
  2506. }
  2507. if (res.code !== 200 || !res.data) {
  2508. showErr(res.msg || '店铺详情加载失败');
  2509. return;
  2510. }
  2511. renderDetail(res.data);
  2512. })
  2513. .catch(function (e) {
  2514. console.error(e);
  2515. showErr('店铺详情请求失败(若为 file:// 打开,请检查 CORS 或改用 http 访问本页)');
  2516. });
  2517. var couponPath = '/store/info/getStoreCouponList?storeId=' + encodeURIComponent(sid);
  2518. marketingCouponLoaded = false;
  2519. apiFetch(couponPath)
  2520. .then(function (res) {
  2521. marketingCouponLoaded = true;
  2522. var list = (res && res.code === 200 && res.data && res.data.marketingList) || [];
  2523. if (!Array.isArray(list)) list = [];
  2524. renderMarketingList(list);
  2525. })
  2526. .catch(function (e) {
  2527. marketingCouponLoaded = true;
  2528. console.warn('[getStoreCouponList]', e);
  2529. renderMarketingList([]);
  2530. });
  2531. if (shouldShowPerformanceSection()) {
  2532. var perfPath = '/performance/list/query?storeId=' + encodeURIComponent(sid) + '&page=1&size=100';
  2533. apiFetch(perfPath)
  2534. .then(function (res) {
  2535. var d = (res && res.code === 200 && res.data) || null;
  2536. if (!d || typeof d !== 'object') {
  2537. performanceListCache.records = [];
  2538. performanceListCache.total = 0;
  2539. } else {
  2540. performanceListCache.records = Array.isArray(d.records) ? d.records.slice() : [];
  2541. var pt = d.total;
  2542. performanceListCache.total = pt != null && !isNaN(Number(pt))
  2543. ? Number(pt)
  2544. : performanceListCache.records.length;
  2545. }
  2546. renderPerformanceList();
  2547. })
  2548. .catch(function (e) {
  2549. console.warn('[performance/list/query]', e);
  2550. performanceListCache.records = [];
  2551. performanceListCache.total = 0;
  2552. renderPerformanceList();
  2553. });
  2554. } else {
  2555. performanceListCache.records = [];
  2556. performanceListCache.total = 0;
  2557. renderPerformanceList();
  2558. }
  2559. var staffPath = '/storeStaffConfig/queryStaffListByTitle?storeId=' + encodeURIComponent(sid);
  2560. apiFetch(staffPath)
  2561. .then(function (res) {
  2562. var arr = (res && res.code === 200 && res.data) || [];
  2563. if (!Array.isArray(arr)) arr = [];
  2564. renderStaffGroups(arr);
  2565. })
  2566. .catch(function (e) {
  2567. console.warn('[queryStaffListByTitle]', e);
  2568. renderStaffGroups([]);
  2569. });
  2570. });
  2571. }
  2572. function boot() {
  2573. var launchTag = document.getElementById('launch-btn');
  2574. if (launchTag) launchTag.setAttribute('appid', WECHAT_OPEN_APP_ID);
  2575. bindWeChatLaunchTagEvents();
  2576. if (shouldInitWeChatJssdkOnLoad()) {
  2577. if (isWeChatInAppBrowser()) document.body.classList.add('is-wechat');
  2578. if (isWxPcBrowser() && (isWxForceDebug() || isWxPcAutoDebugHost())) {
  2579. document.body.classList.add('wx-pc-debug');
  2580. }
  2581. scheduleWeChatJssdkBootstrap();
  2582. }
  2583. if (isWeChatInAppBrowser()) {
  2584. var openBtnWx = document.getElementById('openApp');
  2585. if (openBtnWx) {
  2586. openBtnWx.addEventListener('click', function () {
  2587. if (!weChatJssdkConfigured) {
  2588. showFabToast(
  2589. wxInitLastError || '微信 SDK 初始化中,请稍候再点底部按钮'
  2590. );
  2591. }
  2592. });
  2593. }
  2594. } else {
  2595. var openBtn = document.getElementById('openApp');
  2596. if (openBtn) openBtn.addEventListener('click', tryOpenHBuilderApp);
  2597. }
  2598. run();
  2599. bindMarketingMore();
  2600. bindStaffSection();
  2601. }
  2602. if (document.readyState === 'complete') {
  2603. boot();
  2604. } else {
  2605. window.onload = boot;
  2606. }
  2607. })();
  2608. </script>
  2609. </body>
  2610. </html>