shareIndex.html 87 KB

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