shareUndefined.html 52 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923
  1. <!DOCTYPE html>
  2. <html lang="zh-CN">
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, viewport-fit=cover">
  6. <meta name="format-detection" content="telephone=no">
  7. <title>U店在哪</title>
  8. <style>
  9. :root {
  10. --orange: #F58220;
  11. --orange-light: #FFF4E8;
  12. --red: #FF4D4F;
  13. --text: #333333;
  14. --text-secondary: #999999;
  15. --border: #EEEEEE;
  16. --bg: #FFFFFF;
  17. --safe-bottom: env(safe-area-inset-bottom, 0px);
  18. }
  19. * {
  20. margin: 0;
  21. padding: 0;
  22. box-sizing: border-box;
  23. }
  24. html {
  25. font-size: 16px;
  26. -webkit-tap-highlight-color: transparent;
  27. overflow-x: hidden;
  28. }
  29. body {
  30. font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", sans-serif;
  31. background: var(--bg);
  32. color: var(--text);
  33. padding-bottom: calc(88px + var(--safe-bottom));
  34. min-height: 100vh;
  35. overflow-x: hidden;
  36. }
  37. /* Header */
  38. .header {
  39. position: sticky;
  40. top: 0;
  41. z-index: 100;
  42. display: flex;
  43. align-items: center;
  44. justify-content: center;
  45. height: 44px;
  46. padding: 0 15px;
  47. background: var(--bg);
  48. border-bottom: 1px solid var(--border);
  49. }
  50. .header__back {
  51. position: absolute;
  52. left: 15px;
  53. width: 24px;
  54. height: 24px;
  55. display: flex;
  56. align-items: center;
  57. justify-content: center;
  58. color: var(--text);
  59. text-decoration: none;
  60. }
  61. .header__title {
  62. font-size: 17px;
  63. font-weight: 600;
  64. color: var(--text);
  65. }
  66. /* Hero carousel */
  67. .hero {
  68. position: relative;
  69. margin: 0 15px;
  70. margin-top: 10px;
  71. border-radius: 0 0 12px 12px;
  72. overflow: hidden;
  73. }
  74. /* 内容不存在 / 已删除:居中插图 + 说明文案 */
  75. .hero.hero--empty {
  76. display: flex;
  77. flex-direction: column;
  78. align-items: center;
  79. justify-content: center;
  80. padding: 48px 24px 56px;
  81. min-height: min(52vh, 440px);
  82. background: var(--bg);
  83. overflow: visible;
  84. }
  85. .hero--empty__illustration {
  86. display: block;
  87. width: 100%;
  88. max-width: 280px;
  89. height: auto;
  90. object-fit: contain;
  91. }
  92. .hero--empty__tip {
  93. padding: 0 16px;
  94. font-size: 15px;
  95. line-height: 1.5;
  96. color: var(--text-secondary);
  97. text-align: center;
  98. font-weight: 400;
  99. }
  100. .hero__track {
  101. display: flex;
  102. transition: transform 0.35s ease;
  103. }
  104. .hero__slide {
  105. flex: 0 0 100%;
  106. aspect-ratio: 16 / 10;
  107. background: #f0f0f0;
  108. }
  109. .hero__slide img {
  110. width: 100%;
  111. height: 100%;
  112. object-fit: cover;
  113. display: block;
  114. vertical-align: middle;
  115. }
  116. .hero__dots {
  117. position: absolute;
  118. bottom: 12px;
  119. left: 0;
  120. right: 0;
  121. display: flex;
  122. justify-content: center;
  123. align-items: center;
  124. gap: 6px;
  125. }
  126. .hero__dot {
  127. width: 6px;
  128. height: 6px;
  129. border-radius: 3px;
  130. background: rgba(255, 255, 255, 0.45);
  131. transition: width 0.25s ease, background 0.25s ease;
  132. }
  133. .hero__dot.is-active {
  134. width: 16px;
  135. background: #fff;
  136. }
  137. /* Store block */
  138. .section {
  139. padding: 16px 15px 0;
  140. }
  141. .store-name {
  142. font-size: 20px;
  143. font-weight: 700;
  144. line-height: 1.35;
  145. margin-bottom: 12px;
  146. }
  147. .row {
  148. display: flex;
  149. align-items: center;
  150. justify-content: space-between;
  151. gap: 10px;
  152. }
  153. .rating-row {
  154. margin-bottom: 12px;
  155. }
  156. .stars {
  157. display: inline-flex;
  158. align-items: center;
  159. gap: 2px;
  160. }
  161. .star {
  162. width: 14px;
  163. height: 14px;
  164. color: var(--orange);
  165. }
  166. .rating-num {
  167. margin-left: 6px;
  168. font-size: 14px;
  169. font-weight: 600;
  170. color: var(--orange);
  171. }
  172. .link-muted {
  173. display: inline-flex;
  174. align-items: center;
  175. gap: 2px;
  176. font-size: 13px;
  177. color: var(--text-secondary);
  178. text-decoration: none;
  179. }
  180. .chevron {
  181. width: 14px;
  182. height: 14px;
  183. opacity: 0.6;
  184. }
  185. .hours-row {
  186. margin-bottom: 16px;
  187. align-items: flex-start;
  188. }
  189. .hours-left {
  190. flex: 1;
  191. min-width: 0;
  192. }
  193. .status {
  194. font-size: 14px;
  195. color: var(--red);
  196. margin-right: 8px;
  197. }
  198. .status.is-open {
  199. color: var(--orange);
  200. }
  201. .hours-text {
  202. font-size: 14px;
  203. color: var(--text-secondary);
  204. }
  205. .divider {
  206. height: 8px;
  207. background: #F7F7F7;
  208. margin: 0;
  209. }
  210. /* Location */
  211. .loc-wrap {
  212. display: flex;
  213. padding: 16px 15px;
  214. gap: 12px;
  215. }
  216. .loc-main {
  217. flex: 1;
  218. min-width: 0;
  219. padding-right: 12px;
  220. }
  221. .addr {
  222. font-size: 15px;
  223. font-weight: 600;
  224. line-height: 1.45;
  225. margin-bottom: 10px;
  226. }
  227. .meta-line {
  228. display: flex;
  229. align-items: flex-start;
  230. gap: 6px;
  231. font-size: 13px;
  232. color: var(--text-secondary);
  233. line-height: 1.45;
  234. margin-top: 6px;
  235. }
  236. .meta-line svg {
  237. flex-shrink: 0;
  238. margin-top: 2px;
  239. opacity: 0.75;
  240. }
  241. .loc-actions {
  242. display: flex;
  243. flex-direction: row;
  244. align-items: center;
  245. justify-content: center;
  246. gap: 18px;
  247. flex-shrink: 0;
  248. }
  249. .act-btn {
  250. display: flex;
  251. flex-direction: column;
  252. align-items: center;
  253. gap: 4px;
  254. background: none;
  255. border: none;
  256. padding: 0;
  257. cursor: pointer;
  258. font-size: 12px;
  259. color: var(--text);
  260. }
  261. .act-btn__icon {
  262. width: 44px;
  263. height: 44px;
  264. border-radius: 50%;
  265. background: #F5F5F5;
  266. display: flex;
  267. align-items: center;
  268. justify-content: center;
  269. color: var(--orange);
  270. }
  271. /* More */
  272. .more-title {
  273. padding: 8px 15px 12px;
  274. font-size: 16px;
  275. font-weight: 700;
  276. }
  277. .more-scroll {
  278. display: grid;
  279. grid-template-columns: repeat(2, 1fr);
  280. gap: 10px;
  281. padding: 0 15px 20px;
  282. }
  283. #recEmpty {
  284. grid-column: 1 / -1;
  285. }
  286. .rec-card {
  287. min-width: 0;
  288. background: #fff;
  289. border-radius: 8px;
  290. overflow: hidden;
  291. box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
  292. }
  293. .rec-card__img {
  294. aspect-ratio: 4 / 3;
  295. background: #eee;
  296. }
  297. .rec-card__img img {
  298. width: 100%;
  299. height: 100%;
  300. object-fit: cover;
  301. }
  302. .rec-card__body {
  303. padding: 10px;
  304. }
  305. .rec-card__top {
  306. display: flex;
  307. justify-content: space-between;
  308. align-items: baseline;
  309. gap: 8px;
  310. margin-bottom: 6px;
  311. }
  312. .rec-card__name {
  313. font-size: 15px;
  314. font-weight: 700;
  315. flex: 1;
  316. min-width: 0;
  317. overflow: hidden;
  318. text-overflow: ellipsis;
  319. white-space: nowrap;
  320. }
  321. .rec-card__dist {
  322. font-size: 12px;
  323. color: var(--text-secondary);
  324. flex-shrink: 0;
  325. }
  326. .rec-card__rating {
  327. display: flex;
  328. align-items: center;
  329. flex-wrap: wrap;
  330. gap: 4px 8px;
  331. }
  332. .rec-card__rating .stars .star {
  333. width: 11px;
  334. height: 11px;
  335. }
  336. .rec-card__rating .rating-num {
  337. font-size: 12px;
  338. }
  339. .rec-meta {
  340. font-size: 12px;
  341. color: var(--text-secondary);
  342. }
  343. .rec-card__seller {
  344. display: flex;
  345. align-items: center;
  346. gap: 8px;
  347. margin-top: 8px;
  348. min-width: 0;
  349. }
  350. .rec-card__avatar {
  351. width: 22px;
  352. height: 22px;
  353. border-radius: 50%;
  354. object-fit: cover;
  355. flex-shrink: 0;
  356. background: #eee;
  357. }
  358. .rec-card__seller-name {
  359. font-size: 12px;
  360. color: var(--text-secondary);
  361. overflow: hidden;
  362. text-overflow: ellipsis;
  363. white-space: nowrap;
  364. }
  365. /* FAB */
  366. .fab-wrap {
  367. position: fixed;
  368. left: 0;
  369. right: 0;
  370. bottom: 0;
  371. z-index: 200;
  372. padding: 12px 24px calc(12px + var(--safe-bottom));
  373. background: linear-gradient(to top, rgba(255, 255, 255, 0.98) 70%, transparent);
  374. pointer-events: none;
  375. }
  376. .fab-dock__slot {
  377. width: 100%;
  378. max-width: 198px;
  379. height: 48px;
  380. margin: 0 auto;
  381. pointer-events: auto;
  382. }
  383. #openApp img {
  384. display: block;
  385. width: 100%;
  386. height: 48px;
  387. object-fit: contain;
  388. pointer-events: none;
  389. }
  390. #launch-btn {
  391. display: none;
  392. width: 100%;
  393. height: 48px;
  394. min-height: 48px;
  395. border-radius: 24px;
  396. overflow: hidden;
  397. opacity: 1;
  398. }
  399. body.is-wechat.wx-jssdk-ready #launch-btn {
  400. display: block;
  401. }
  402. body.is-wechat.wx-jssdk-ready #openApp {
  403. display: none !important;
  404. }
  405. #openAppToast {
  406. display: none;
  407. position: fixed;
  408. left: 16px;
  409. right: 16px;
  410. bottom: calc(72px + var(--safe-bottom));
  411. z-index: 10001;
  412. padding: 10px 14px;
  413. font-size: 13px;
  414. line-height: 1.45;
  415. color: #fff;
  416. text-align: center;
  417. background: rgba(0, 0, 0, 0.78);
  418. border-radius: 8px;
  419. pointer-events: none;
  420. word-break: break-all;
  421. }
  422. #openApp {
  423. touch-action: manipulation;
  424. }
  425. .fab-wrap .fab {
  426. pointer-events: auto;
  427. }
  428. .fab {
  429. display: flex;
  430. align-items: center;
  431. justify-content: center;
  432. gap: 10px;
  433. width: 100%;
  434. max-width: 198px;
  435. margin: 0 auto;
  436. height: 48px;
  437. border: none;
  438. border-radius: 24px;
  439. background: var(--orange);
  440. color: #fff;
  441. font-size: 16px;
  442. font-weight: 600;
  443. box-shadow: 0 4px 16px rgba(245, 130, 32, 0.45);
  444. cursor: pointer;
  445. }
  446. .fab__logo {
  447. width: 28px;
  448. height: 28px;
  449. flex-shrink: 0;
  450. }
  451. .home-indicator {
  452. height: 5px;
  453. background: #000;
  454. border-radius: 3px;
  455. width: 134px;
  456. margin: 8px auto 4px;
  457. opacity: 0.2;
  458. }
  459. </style>
  460. </head>
  461. <body>
  462. <div class="hero hero--empty" id="hero" role="status" aria-live="polite">
  463. <img class="hero--empty__illustration" src="images/empty.png" alt="" decoding="async">
  464. <p class="hero--empty__tip">商品已删除/下架/卖出</p>
  465. </div>
  466. <div class="divider"></div>
  467. <h3 class="more-title">更多推荐</h3>
  468. <div class="more-scroll" id="recList">
  469. <p id="recEmpty" style="padding:12px;color:#999;font-size:14px;display:none;">暂无推荐</p>
  470. </div>
  471. <div id="openAppToast" role="status" aria-live="polite"></div>
  472. <div class="fab-wrap">
  473. <div class="fab-dock__slot">
  474. <!-- 非微信 / 微信 JSSDK 未就绪:scheme 唤起 -->
  475. <button type="button" class="fab" id="openApp">
  476. <img src="images/ubtn.png" alt="APP内打开" decoding="async">
  477. </button>
  478. <!-- 微信内 wx.config 成功后:仅此按钮可唤起 App(须用户直接点击) -->
  479. <wx-open-launch-app id="launch-btn" appid="wxf5f1efe3a9f5012e" extinfo="">
  480. <script type="text/wxtag-template">
  481. <style>
  482. .wx-open-app-btn {
  483. display: block;
  484. width: 100%;
  485. height: 48px;
  486. margin: 0;
  487. padding: 0;
  488. border: none;
  489. border-radius: 24px;
  490. background: #F47D1F;
  491. box-shadow: 0 4px 16px rgba(245, 130, 32, 0.45);
  492. cursor: pointer;
  493. overflow: hidden;
  494. -webkit-tap-highlight-color: transparent;
  495. }
  496. .wx-open-app-btn img {
  497. display: block;
  498. width: 100%;
  499. height: 48px;
  500. object-fit: contain;
  501. opacity: 1;
  502. pointer-events: none;
  503. -webkit-user-drag: none;
  504. }
  505. </style>
  506. <button class="wx-open-app-btn" aria-label="APP内打开">
  507. <img src="https://test.ailien.shop/h5/HBuilderProjects/images/uBtn.png" alt="APP内打开" width="198" height="48" />
  508. </button>
  509. </script>
  510. </wx-open-launch-app>
  511. </div>
  512. <div class="home-indicator" aria-hidden="true"></div>
  513. </div>
  514. <script src="https://res.wx.qq.com/open/js/jweixin-1.6.0.js"></script>
  515. <script>
  516. (function () {
  517. 'use strict';
  518. /**
  519. * 更多推荐:POST http://124.93.18.180:9100/ai/life-manager/api/v1/second_hand/global-recommend
  520. * 常用 query:userId、userLat/userLng 或 lat/weidu、lon/jingdu、radiusKm、page、pageSize、categoryOneId、categoryTwoId
  521. *
  522. * 本页仅展示「已卖出 / 下架 / 删除」占位与推荐,无有效商品详情:点「APP内打开」一律进 App 登录页
  523. * shopro://pages/index/login?…(与 shareIndex.html 关店唤起一致)。在 App 内嵌 H5 且存在 uni 时优先 uni.navigateTo。
  524. *
  525. * 注意:用 file:// 打开本页时,浏览器可能因 CORS 拦截跨域请求。
  526. */
  527. var API_BASE = 'https://test.ailien.shop/alienStore';
  528. var API_LIFE_AI_BASE = 'http://183.252.196.135:9100';
  529. var SECOND_GLOBAL_RECOMMEND_PATH = '/ai/life-manager/api/v1/second_hand/global-recommend';
  530. var DEFAULT_REC_RADIUS_KM = 195.69;
  531. /**
  532. * 微信 JSSDK — 与 shareIndex.html 一致
  533. * POST {API_BASE}/wx/getWxConfig,body 传 url(当前页完整地址,不含 #)
  534. */
  535. var WECHAT_MP_APP_ID = 'wx412792c77f47babd';
  536. var WECHAT_OPEN_APP_ID = 'wxf5f1efe3a9f5012e';
  537. var WECHAT_GET_WX_CONFIG_PATH = '/wx/getWxConfig';
  538. var H5_PAGE_BASE_FALLBACK = 'https://test.ailien.shop/h5/HBuilderProjects/';
  539. var WX_GET_CONFIG_SIGN_URL = H5_PAGE_BASE_FALLBACK + 'shareUndefined.html';
  540. var WECHAT_JS_SAFE_HOSTS = ['uat.ailien.shop', 'test.ailien.shop'];
  541. var weChatJssdkConfigured = false;
  542. var wxConfigSignRetriedBaseUrl = false;
  543. var wxInitLastError = '';
  544. var wxJssdkInitPromise = null;
  545. /**
  546. * 与 secondShareGoods.html 一致:唤起 App 打开二手商品详情页(合并 search + hash 内 query)
  547. */
  548. var APP_ANDROID_PACKAGE = 'com.alien.Udianzaizhe';
  549. var APP_IOS_URL_SCHEME = 'shopro://';
  550. var APP_UNI_STORE_PATH = 'pages/secondHandTransactions/pages/detail/index';
  551. function showDownloadTip() {
  552. var msg = '请到应用商店下载';
  553. if (typeof uni !== 'undefined' && typeof uni.showToast === 'function') {
  554. uni.showToast({ title: msg, icon: 'none', duration: 2500 });
  555. } else {
  556. window.alert(msg);
  557. }
  558. }
  559. function mergeSearchAndHashParams() {
  560. var params = new URLSearchParams();
  561. function ingestAppend(querySlice) {
  562. if (!querySlice) return;
  563. var p = new URLSearchParams(querySlice);
  564. p.forEach(function (val, key) {
  565. params.append(key, val);
  566. });
  567. }
  568. function ingestSet(querySlice) {
  569. if (!querySlice) return;
  570. var p = new URLSearchParams(querySlice);
  571. p.forEach(function (val, key) {
  572. params.set(key, val);
  573. });
  574. }
  575. if (location.search && location.search.length > 1) {
  576. ingestAppend(location.search.slice(1));
  577. }
  578. var hash = location.hash || '';
  579. var qi = hash.indexOf('?');
  580. if (qi >= 0) {
  581. ingestSet(hash.slice(qi + 1));
  582. }
  583. return params;
  584. }
  585. function q(name) {
  586. var v = mergeSearchAndHashParams().get(name);
  587. return v == null ? '' : String(v);
  588. }
  589. /** 推荐用户位置:优先 URL 的 longitude/latitude,未带时用默认坐标 */
  590. var DEFAULT_REC_USER_LAT = (function () {
  591. var raw = (q('latitude') || q('lat') || q('weidu') || '').trim();
  592. var n = raw !== '' ? Number(raw) : NaN;
  593. return !isNaN(n) ? n : 38.925756;
  594. })();
  595. var DEFAULT_REC_USER_LNG = (function () {
  596. var raw = (q('longitude') || q('lon') || q('jingdu') || '').trim();
  597. var n = raw !== '' ? Number(raw) : NaN;
  598. return !isNaN(n) ? n : 121.662543;
  599. })();
  600. function rawQueryHasGoodsId(qs) {
  601. return /(?:^|&)(goodsId|id)=/i.test('&' + String(qs || '') + '&');
  602. }
  603. function getRawMergedQueryForAppOpen() {
  604. var rawSearch =
  605. location.search && location.search.length > 1 ? location.search.slice(1) : '';
  606. var hash0 = location.hash || '';
  607. var hqi0 = hash0.indexOf('?');
  608. var rawHashQ = hqi0 >= 0 ? hash0.slice(hqi0 + 1) : '';
  609. if (!rawSearch && !rawHashQ) return '';
  610. if (rawHashQ && rawSearch) {
  611. if (rawQueryHasGoodsId(rawHashQ)) return rawHashQ;
  612. if (rawQueryHasGoodsId(rawSearch)) return rawSearch;
  613. return rawHashQ;
  614. }
  615. return rawHashQ || rawSearch;
  616. }
  617. /** 本 HTML 仅为不可用商品落地页,唤起路径固定为登录(不依赖 URL 是否带 goodsUnavailable,避免旧链/丢参) */
  618. function getAppUniPathForShareUndefined() {
  619. return 'pages/index/login';
  620. }
  621. function buildAppOpenQueryStringMerged() {
  622. var rawQs = getRawMergedQueryForAppOpen();
  623. if (rawQs) {
  624. return '?' + rawQs;
  625. }
  626. var params = mergeSearchAndHashParams();
  627. var gid = params.get('goodsId') || params.get('id') || '';
  628. if (gid && !params.has('goodsId')) {
  629. params.set('goodsId', gid);
  630. }
  631. if (gid && !params.has('id')) {
  632. params.set('id', gid);
  633. }
  634. var sid = params.get('storeId') || '';
  635. if (sid && !params.has('storeId')) {
  636. params.set('storeId', sid);
  637. }
  638. var qsOut = params.toString();
  639. return qsOut ? ('?' + qsOut) : '';
  640. }
  641. /**
  642. * 微信 extinfo 专用 query:禁止透传整段原始 query(易超 1024 或含封面/描述等大字段导致 launch:fail)。
  643. * 与 secondShareGoods / shareDynamic 一致,仅保留 App 登录页解析所需字段。
  644. */
  645. function buildWxLaunchQueryParams() {
  646. var params = mergeSearchAndHashParams();
  647. var mini = new URLSearchParams();
  648. mini.set('goodsUnavailable', '1');
  649. var gs = params.get('goodsStatus');
  650. if (gs != null && String(gs).trim() !== '') {
  651. mini.set('goodsStatus', String(gs).trim());
  652. }
  653. var goodsId = params.get('goodsId') || params.get('id') || '';
  654. if (goodsId) {
  655. mini.set('goodsId', String(goodsId).trim());
  656. mini.set('id', String(goodsId).trim());
  657. }
  658. var userId = params.get('userId');
  659. if (userId != null && String(userId).trim() !== '') {
  660. mini.set('userId', String(userId).trim());
  661. }
  662. var sid = params.get('storeId');
  663. if (sid != null && String(sid).trim() !== '') {
  664. mini.set('storeId', String(sid).trim());
  665. }
  666. var lon =
  667. params.get('longitude') ||
  668. params.get('lon') ||
  669. params.get('lng') ||
  670. params.get('jingdu') ||
  671. '';
  672. if (lon !== '' && !isNaN(Number(lon))) {
  673. mini.set('longitude', String(lon));
  674. }
  675. var lat =
  676. params.get('latitude') ||
  677. params.get('lat') ||
  678. params.get('weidu') ||
  679. '';
  680. if (lat !== '' && !isNaN(Number(lat))) {
  681. mini.set('latitude', String(lat));
  682. }
  683. var city = params.get('userCity') || params.get('city');
  684. if (city != null && String(city).trim() !== '') {
  685. mini.set('userCity', String(city).trim());
  686. }
  687. return mini;
  688. }
  689. /** Uni 路由串(无 shopro://),供 wx-open-launch-app extinfo */
  690. function buildAppUniPageLaunchUrl() {
  691. var path = getAppUniPathForShareUndefined().replace(/^\//, '');
  692. var qs = buildWxLaunchQueryParams().toString();
  693. return qs ? path + '?' + qs : path;
  694. }
  695. /**
  696. * wx-open-launch-app extinfo:pages/index/login?…(与 shareIndex 关店唤起一致)
  697. */
  698. function buildWeChatLaunchExtinfo(useBarePathOnly) {
  699. var path = getAppUniPathForShareUndefined().replace(/^\//, '');
  700. if (useBarePathOnly) return path;
  701. var mini = buildWxLaunchQueryParams();
  702. var goodsId = mini.get('goodsId') || mini.get('id') || '';
  703. if (goodsId) {
  704. mini.set('goodsId', goodsId);
  705. mini.set('id', goodsId);
  706. }
  707. var qs = mini.toString();
  708. var uniPage = qs ? path + '?' + qs : path;
  709. if (uniPage.length <= 1024) return uniPage;
  710. var shortKeys = ['goodsUnavailable', 'goodsStatus', 'goodsId', 'id', 'userId'];
  711. var shortMini = new URLSearchParams();
  712. shortKeys.forEach(function (key) {
  713. var val = mini.get(key);
  714. if (val != null && String(val).trim() !== '') {
  715. shortMini.set(key, String(val).trim());
  716. }
  717. });
  718. var shortPage = shortMini.toString() ? path + '?' + shortMini.toString() : path;
  719. return shortPage.length <= 1024 ? shortPage : path;
  720. }
  721. /** 供 App 内嵌 WebView:uni 路由到登录页,query 与深链一致 */
  722. function buildUniLoginPageUrl() {
  723. var tail = buildAppOpenQueryStringMerged();
  724. var u = '/pages/index/login' + (tail || '');
  725. return u.length > 1800 ? '/pages/index/login' : u;
  726. }
  727. function buildAppDeepLink() {
  728. var path = getAppUniPathForShareUndefined().replace(/^\//, '');
  729. var s = buildAppOpenQueryStringMerged();
  730. var root = APP_IOS_URL_SCHEME.replace(/\/$/, '');
  731. if (!s) {
  732. return root + '/' + path;
  733. }
  734. return root + '/' + path + s;
  735. }
  736. function isWeChatInAppBrowser() {
  737. return /MicroMessenger/i.test(navigator.userAgent || '');
  738. }
  739. function ensureWxShareFromQueryBeforeConfig() {
  740. if (!isWeChatInAppBrowser()) return;
  741. var from = String(q('from') || '').trim();
  742. if (from) return;
  743. try {
  744. var u = new URL(location.href);
  745. u.searchParams.set('from', 'singlemessage');
  746. history.replaceState(null, '', u.pathname + u.search + (location.hash || ''));
  747. } catch (eFrom) {
  748. var sep = location.search && location.search.length > 1 ? '&' : '?';
  749. history.replaceState(
  750. null,
  751. '',
  752. location.pathname +
  753. (location.search || '') +
  754. sep +
  755. 'from=singlemessage' +
  756. (location.hash || '')
  757. );
  758. }
  759. }
  760. function logWxEntryDiagnostics() {
  761. if (!isWeChatInAppBrowser()) return;
  762. console.log('[wx-entry]', {
  763. entryFrom: q('from') || '(无)',
  764. signUrl: getWxConfigSignUrl()
  765. });
  766. }
  767. function readQueryParam(name) {
  768. return q(name);
  769. }
  770. function isWxDebugOn() {
  771. return readQueryParam('wxDebug') === '1';
  772. }
  773. function isWxForceDebug() {
  774. return readQueryParam('wxForce') === '1';
  775. }
  776. function isWxConfigOnClickDebug() {
  777. return readQueryParam('wxConfigOnClick') === '1';
  778. }
  779. function isWxPcAutoDebugHost() {
  780. var h = (location.hostname || '').toLowerCase();
  781. if (h === 'localhost' || h === '127.0.0.1') return true;
  782. for (var i = 0; i < WECHAT_JS_SAFE_HOSTS.length; i++) {
  783. if (WECHAT_JS_SAFE_HOSTS[i] === h) return true;
  784. }
  785. return false;
  786. }
  787. function isWxPcBrowser() {
  788. return !isWeChatInAppBrowser();
  789. }
  790. function shouldInitWeChatJssdkOnLoad() {
  791. if (isWeChatInAppBrowser()) return true;
  792. return isWxForceDebug() || isWxPcAutoDebugHost();
  793. }
  794. function shouldFetchWxConfig(fromUserClick) {
  795. if (isWeChatInAppBrowser()) return true;
  796. if (fromUserClick) return true;
  797. return isWxForceDebug() || isWxPcAutoDebugHost();
  798. }
  799. function getWxHtmlUrl() {
  800. var forced = String(q('wxSignUrl') || '').trim();
  801. if (forced) return forced.split('#')[0];
  802. return String(location.href || '').split('#')[0];
  803. }
  804. function getWxSignPageUrlForApi() {
  805. var htmlUrl = getWxHtmlUrl();
  806. if (htmlUrl && /^https?:\/\//i.test(htmlUrl)) return htmlUrl;
  807. return WX_GET_CONFIG_SIGN_URL;
  808. }
  809. function getWxHtmlUrlBase() {
  810. var htmlUrl = getWxSignPageUrlForApi();
  811. try {
  812. var u = new URL(htmlUrl);
  813. return u.origin + u.pathname;
  814. } catch (eU) {
  815. return WX_GET_CONFIG_SIGN_URL;
  816. }
  817. }
  818. function getWxConfigSignUrl() {
  819. if (String(q('wxSignBaseOnly') || '') === '1') return getWxHtmlUrlBase();
  820. return getWxSignPageUrlForApi();
  821. }
  822. function getWxGetConfigApiUrl() {
  823. return API_BASE.replace(/\/$/, '') + WECHAT_GET_WX_CONFIG_PATH;
  824. }
  825. function buildWxGetConfigRequestBody(htmlUrl) {
  826. return {
  827. url: String(htmlUrl || '').split('#')[0].trim()
  828. };
  829. }
  830. function resolveWxConfigAppIdFromSignData(d) {
  831. if (!d || typeof d !== 'object') return '';
  832. var mp =
  833. d.mpAppId ||
  834. d.mpAppid ||
  835. d.officialAppId ||
  836. d.gzhAppId ||
  837. d.serviceAppId;
  838. if (mp != null && String(mp).trim() !== '') return String(mp).trim();
  839. var fromQuery = String(q('wxMpAppId') || WECHAT_MP_APP_ID || '').trim();
  840. if (fromQuery) return fromQuery;
  841. var raw = d.appId || d.appid || d.wxAppId;
  842. return raw != null && String(raw).trim() !== '' ? String(raw).trim() : '';
  843. }
  844. function normalizeWxJssdkSignPayload(res, signUrlUsed) {
  845. if (!res || typeof res !== 'object') return null;
  846. var d = res.data != null && typeof res.data === 'object' ? res.data : res;
  847. if (!d || typeof d !== 'object') return null;
  848. var appId = resolveWxConfigAppIdFromSignData(d);
  849. var timestamp = d.timestamp != null ? d.timestamp : d.timeStamp;
  850. var nonceStr =
  851. d.nonceStr != null && String(d.nonceStr) !== ''
  852. ? d.nonceStr
  853. : d.noncestr != null && String(d.noncestr) !== ''
  854. ? d.noncestr
  855. : d.nonce;
  856. var signature = d.signature || d.sign;
  857. if (!appId || timestamp == null || nonceStr == null || nonceStr === '' || !signature) {
  858. return null;
  859. }
  860. return {
  861. appId: String(appId),
  862. timestamp: Number(timestamp),
  863. nonceStr: String(nonceStr),
  864. signature: String(signature),
  865. signUrl: String(signUrlUsed || '')
  866. .split('#')[0]
  867. .trim()
  868. };
  869. }
  870. function getWxErrMsg(err) {
  871. if (!err) return '';
  872. if (err.errMsg) return String(err.errMsg);
  873. if (typeof err === 'string') return err;
  874. try {
  875. return JSON.stringify(err);
  876. } catch (e) {
  877. return String(err);
  878. }
  879. }
  880. function formatWxConfigErrorTip(err, signPageUrl) {
  881. var errMsg = getWxErrMsg(err);
  882. var tip = '微信 JSSDK 配置失败';
  883. if (/invalid signature/i.test(errMsg)) {
  884. return (
  885. tip +
  886. ':签名无效。请核对:①后端用与前端相同的 url 签名;②url=' +
  887. (signPageUrl || getWxHtmlUrl()) +
  888. ';③nonceStr/timestamp 与接口返回一致;④appId=' +
  889. WECHAT_MP_APP_ID
  890. );
  891. }
  892. if (/require\s*subscribe/i.test(errMsg)) {
  893. return tip + ':' + errMsg + '(服务号需用户已关注)';
  894. }
  895. return errMsg ? tip + ':' + errMsg : tip;
  896. }
  897. function setWxInitError(msg) {
  898. wxInitLastError = String(msg || '').trim();
  899. if (wxInitLastError) console.warn('[wx]', wxInitLastError);
  900. }
  901. function requestWeChatJssdkSignAndConfig(htmlUrlOptional) {
  902. var htmlUrl = String(
  903. htmlUrlOptional != null ? htmlUrlOptional : getWxConfigSignUrl()
  904. )
  905. .split('#')[0]
  906. .trim();
  907. if (!htmlUrl || !/^https?:\/\//i.test(htmlUrl)) {
  908. htmlUrl = WX_GET_CONFIG_SIGN_URL;
  909. }
  910. if (isWxDebugOn()) {
  911. try {
  912. window.alert('htmlUrl(签名用):\n' + htmlUrl);
  913. } catch (eDbg) {}
  914. }
  915. var requestUrl = getWxGetConfigApiUrl();
  916. var requestBody = buildWxGetConfigRequestBody(htmlUrl);
  917. console.log('[wx] htmlUrl=', htmlUrl);
  918. console.log('[wx] POST getWxConfig →', requestUrl, requestBody);
  919. return fetch(requestUrl, {
  920. method: 'POST',
  921. mode: 'cors',
  922. credentials: 'omit',
  923. headers: {
  924. Accept: 'application/json',
  925. 'Content-Type': 'application/json;charset=UTF-8'
  926. },
  927. body: JSON.stringify(requestBody)
  928. })
  929. .then(function (r) {
  930. if (r.ok) return r.json();
  931. return r
  932. .text()
  933. .catch(function () {
  934. return '';
  935. })
  936. .then(function (text) {
  937. var hint = '';
  938. try {
  939. var j = JSON.parse(text);
  940. hint = j.msg || j.message || '';
  941. } catch (eP) {
  942. if (text) hint = text.slice(0, 120);
  943. }
  944. throw new Error('getWxConfig HTTP ' + r.status + (hint ? ':' + hint : ''));
  945. });
  946. })
  947. .then(function (res) {
  948. if (res && res.code != null) {
  949. var c = Number(res.code);
  950. if (c !== 200 && c !== 0 && res.success !== true) {
  951. throw new Error(res.msg || res.message || 'getWxConfig code ' + c);
  952. }
  953. }
  954. var sign = normalizeWxJssdkSignPayload(res, htmlUrl);
  955. if (!sign) {
  956. console.warn('[wx] getWxConfig 响应字段不全', res, 'htmlUrl=', htmlUrl);
  957. throw new Error(
  958. 'getWxConfig 缺少 appId/timestamp/nonceStr/signature(见控制台)'
  959. );
  960. }
  961. if (sign.appId !== WECHAT_MP_APP_ID) {
  962. console.warn(
  963. '[wx] 后端 appId=' + sign.appId + ',期望服务号 ' + WECHAT_MP_APP_ID
  964. );
  965. }
  966. if (typeof wx === 'undefined') {
  967. if (isWxPcBrowser()) {
  968. console.log('[wx] PC getWxConfig 成功(无 jweixin)', sign);
  969. return true;
  970. }
  971. setWxInitError('jweixin.js 未加载');
  972. return false;
  973. }
  974. return applyWxConfigFromSign(sign, htmlUrl);
  975. });
  976. }
  977. function applyWxConfigFromSign(sign, htmlUrl) {
  978. var wxConfigParams = {
  979. debug: isWxDebugOn(),
  980. appId: String(sign.appId),
  981. timestamp: sign.timestamp,
  982. nonceStr: String(sign.nonceStr),
  983. signature: String(sign.signature),
  984. jsApiList: [],
  985. openTagList: ['wx-open-launch-app']
  986. };
  987. return new Promise(function (resolve) {
  988. wx.config(wxConfigParams);
  989. wx.ready(function () {
  990. weChatJssdkConfigured = true;
  991. document.body.classList.add('wx-jssdk-ready');
  992. refreshWxLaunchTagAttrs(false);
  993. console.log('[wx.config] ready, htmlUrl=', htmlUrl);
  994. resolve(true);
  995. });
  996. wx.error(function (err) {
  997. weChatJssdkConfigured = false;
  998. document.body.classList.remove('wx-jssdk-ready');
  999. wxJssdkInitPromise = null;
  1000. var errMsg = getWxErrMsg(err);
  1001. setWxInitError(formatWxConfigErrorTip(err, htmlUrl));
  1002. if (isWxDebugOn()) window.alert(wxInitLastError);
  1003. console.warn('[wx.config]', errMsg, 'htmlUrl=', htmlUrl);
  1004. var baseUrl = getWxHtmlUrlBase();
  1005. var fullUrl = getWxSignPageUrlForApi();
  1006. if (
  1007. !/invalid signature/i.test(errMsg) ||
  1008. wxConfigSignRetriedBaseUrl ||
  1009. baseUrl === fullUrl ||
  1010. htmlUrl === baseUrl
  1011. ) {
  1012. resolve(false);
  1013. return;
  1014. }
  1015. wxConfigSignRetriedBaseUrl = true;
  1016. requestWeChatJssdkSignAndConfig(baseUrl).then(resolve);
  1017. });
  1018. });
  1019. }
  1020. function refreshWxLaunchTagAttrs(useBarePathOnly) {
  1021. var tag = document.getElementById('launch-btn');
  1022. if (!tag) return;
  1023. try {
  1024. tag.setAttribute('appid', WECHAT_OPEN_APP_ID);
  1025. tag.setAttribute('extinfo', buildWeChatLaunchExtinfo(!!useBarePathOnly));
  1026. console.log('[wx-open-launch-app] extinfo=', tag.getAttribute('extinfo'));
  1027. } catch (eA) {}
  1028. }
  1029. function bindWeChatLaunchTagEvents() {
  1030. var tag = document.getElementById('launch-btn');
  1031. if (!tag || tag._wxLaunchBound) return;
  1032. tag._wxLaunchBound = true;
  1033. tag._wxLaunchBareRetried = false;
  1034. refreshWxLaunchTagAttrs(false);
  1035. tag.addEventListener('launch', function () {
  1036. tag._wxLaunchBareRetried = false;
  1037. console.log('[wx-open-launch-app] launch ok');
  1038. showFabToast('正在打开 U店在哪…');
  1039. });
  1040. tag.addEventListener('error', function (e) {
  1041. var detail = e && e.detail;
  1042. var errMsg =
  1043. detail && detail.errMsg
  1044. ? String(detail.errMsg)
  1045. : detail && detail.errmsg
  1046. ? String(detail.errmsg)
  1047. : '';
  1048. console.warn('[wx-open-launch-app]', detail, 'extinfo=', tag.getAttribute('extinfo'));
  1049. if (/launch:fail_check/i.test(errMsg)) {
  1050. showAppOpenFailTip(
  1051. '请确复制链接进入U店在哪'
  1052. );
  1053. return;
  1054. }
  1055. if (
  1056. /launch:fail/i.test(errMsg) &&
  1057. !tag._wxLaunchBareRetried &&
  1058. tag.getAttribute('extinfo') !== buildWeChatLaunchExtinfo(true)
  1059. ) {
  1060. tag._wxLaunchBareRetried = true;
  1061. refreshWxLaunchTagAttrs(true);
  1062. showFabToast('请再点一次「APP内打开」');
  1063. return;
  1064. }
  1065. showAppOpenFailTip(
  1066. '请确复制链接进入U店在哪'
  1067. );
  1068. });
  1069. }
  1070. function initWeChatOpenLaunchApp(fromUserClick) {
  1071. if (!shouldFetchWxConfig(!!fromUserClick)) {
  1072. console.log('[wx] 未调用 getWxConfig');
  1073. return Promise.resolve(false);
  1074. }
  1075. ensureWxShareFromQueryBeforeConfig();
  1076. if (isWxPcBrowser()) {
  1077. console.warn(
  1078. '[wx] PC:请求 getWxConfig' + (fromUserClick ? '(按钮)' : '(进页)')
  1079. );
  1080. }
  1081. if (wxJssdkInitPromise && !fromUserClick) return wxJssdkInitPromise;
  1082. wxConfigSignRetriedBaseUrl = false;
  1083. wxInitLastError = '';
  1084. var htmlUrl = getWxConfigSignUrl();
  1085. bindWeChatLaunchTagEvents();
  1086. wxJssdkInitPromise = requestWeChatJssdkSignAndConfig(htmlUrl)
  1087. .then(function (ok) {
  1088. if (ok === true) return true;
  1089. if (!wxInitLastError) {
  1090. setWxInitError('wx.config 失败,可加 ?wxDebug=1 查看 htmlUrl');
  1091. }
  1092. return false;
  1093. })
  1094. .catch(function (e) {
  1095. var msg = e && e.message ? e.message : 'getWxConfig 请求失败';
  1096. setWxInitError(msg);
  1097. console.warn('[wx] requestWeChatJssdkSignAndConfig failed', msg, 'htmlUrl=', htmlUrl);
  1098. if (isWeChatInAppBrowser() && isWxDebugOn()) window.alert(msg);
  1099. return false;
  1100. })
  1101. .finally(function () {
  1102. if (!weChatJssdkConfigured) wxJssdkInitPromise = null;
  1103. });
  1104. return wxJssdkInitPromise;
  1105. }
  1106. /** 进页即尝试拉签名;jweixin 晚到时自动重试 */
  1107. function scheduleWeChatJssdkBootstrap() {
  1108. if (!shouldInitWeChatJssdkOnLoad()) return;
  1109. var attempts = 0;
  1110. function tick() {
  1111. attempts += 1;
  1112. if (weChatJssdkConfigured) return;
  1113. initWeChatOpenLaunchApp();
  1114. if (!weChatJssdkConfigured && attempts < 8 && typeof wx === 'undefined') {
  1115. setTimeout(tick, 400);
  1116. }
  1117. }
  1118. tick();
  1119. }
  1120. function showFabToast(msg, ms) {
  1121. var tip = String(msg || '').trim();
  1122. if (!tip) return;
  1123. var el = document.getElementById('openAppToast');
  1124. if (el) {
  1125. el.textContent = tip;
  1126. el.style.display = 'block';
  1127. if (showFabToast._t) clearTimeout(showFabToast._t);
  1128. showFabToast._t = setTimeout(function () {
  1129. el.style.display = 'none';
  1130. }, ms || 2800);
  1131. }
  1132. console.log('[openApp]', tip);
  1133. }
  1134. function showAppOpenFailTip(msg) {
  1135. var tip = msg || '未能打开 App,请确认已安装最新版「U店在哪」。';
  1136. if (typeof uni !== 'undefined' && typeof uni.showToast === 'function') {
  1137. uni.showToast({ title: tip, icon: 'none', duration: 2800 });
  1138. } else if (isWeChatInAppBrowser()) {
  1139. window.alert(tip);
  1140. } else {
  1141. console.warn('[openApp]', tip);
  1142. }
  1143. }
  1144. function tryFetchWxConfigOnPcClick() {
  1145. if (!isWxPcBrowser()) return Promise.resolve(false);
  1146. showFabToast('正在请求 getWxConfig…');
  1147. wxJssdkInitPromise = null;
  1148. return initWeChatOpenLaunchApp(true).then(function (ok) {
  1149. if (ok) {
  1150. showFabToast(
  1151. weChatJssdkConfigured
  1152. ? 'getWxConfig 成功,wx.config 已就绪'
  1153. : 'getWxConfig 成功'
  1154. );
  1155. } else {
  1156. showFabToast(wxInitLastError || 'getWxConfig 失败');
  1157. }
  1158. return ok;
  1159. });
  1160. }
  1161. function launchAppDeepLink(deepLink) {
  1162. try {
  1163. var a = document.createElement('a');
  1164. a.href = deepLink;
  1165. a.setAttribute('target', '_self');
  1166. document.body.appendChild(a);
  1167. a.click();
  1168. document.body.removeChild(a);
  1169. } catch (e1) {}
  1170. try {
  1171. window.location.href = deepLink;
  1172. } catch (e2) {}
  1173. }
  1174. function tryOpenUShopApp() {
  1175. /* 微信内须直接点击 wx-open-launch-app,scheme 会被拦截 */
  1176. if (isWeChatInAppBrowser()) return;
  1177. tryFetchWxConfigOnPcClick().then(function () {
  1178. if (isWxConfigOnClickDebug() && !isWxForceDebug() && !isWxPcAutoDebugHost()) {
  1179. return;
  1180. }
  1181. tryOpenUShopAppViaScheme();
  1182. });
  1183. }
  1184. function tryOpenUShopAppViaScheme() {
  1185. function openBySchemeOrPlus() {
  1186. showFabToast('正在打开 U店在哪…');
  1187. var deepLink = buildAppDeepLink();
  1188. if (typeof plus !== 'undefined' && plus.runtime) {
  1189. var installed = null;
  1190. try {
  1191. if (typeof plus.runtime.isApplicationExist === 'function') {
  1192. installed = plus.runtime.isApplicationExist({
  1193. pname: APP_ANDROID_PACKAGE,
  1194. action: APP_IOS_URL_SCHEME
  1195. });
  1196. }
  1197. } catch (e) {
  1198. console.warn(e);
  1199. }
  1200. if (installed === false) {
  1201. showDownloadTip();
  1202. return;
  1203. }
  1204. try {
  1205. plus.runtime.openURL(deepLink);
  1206. } catch (e2) {
  1207. console.warn(e2);
  1208. showDownloadTip();
  1209. }
  1210. return;
  1211. }
  1212. var done = false;
  1213. function finish() {
  1214. if (done) return;
  1215. done = true;
  1216. document.removeEventListener('visibilitychange', onVis);
  1217. window.removeEventListener('pagehide', onHide);
  1218. }
  1219. function onVis() {
  1220. if (document.visibilityState === 'hidden') finish();
  1221. }
  1222. function onHide() {
  1223. finish();
  1224. }
  1225. document.addEventListener('visibilitychange', onVis);
  1226. window.addEventListener('pagehide', onHide);
  1227. try {
  1228. launchAppDeepLink(deepLink);
  1229. } catch (e3) {
  1230. finish();
  1231. showDownloadTip();
  1232. return;
  1233. }
  1234. window.setTimeout(function () {
  1235. finish();
  1236. }, 2600);
  1237. }
  1238. if (typeof uni !== 'undefined' && typeof uni.navigateTo === 'function') {
  1239. var loginUrl = buildUniLoginPageUrl();
  1240. try {
  1241. uni.navigateTo({
  1242. url: loginUrl,
  1243. fail: function () {
  1244. if (typeof uni.reLaunch === 'function') {
  1245. try {
  1246. uni.reLaunch({
  1247. url: loginUrl.length > 1800 ? '/pages/index/login' : loginUrl,
  1248. fail: function () {
  1249. openBySchemeOrPlus();
  1250. }
  1251. });
  1252. return;
  1253. } catch (eRl) {}
  1254. }
  1255. openBySchemeOrPlus();
  1256. }
  1257. });
  1258. return;
  1259. } catch (eUni) {
  1260. openBySchemeOrPlus();
  1261. return;
  1262. }
  1263. }
  1264. openBySchemeOrPlus();
  1265. }
  1266. function showErr(msg) {
  1267. var el = document.getElementById('pageError');
  1268. el.textContent = msg;
  1269. el.style.display = 'block';
  1270. }
  1271. function getStoreId() {
  1272. return q('id') || q('storeId');
  1273. }
  1274. function apiFetch(path) {
  1275. return fetch(API_BASE + path, {
  1276. method: 'GET',
  1277. mode: 'cors',
  1278. credentials: 'omit',
  1279. headers: { Accept: 'application/json' }
  1280. }).then(function (res) {
  1281. if (!res.ok) throw new Error('HTTP ' + res.status);
  1282. return res.json();
  1283. });
  1284. }
  1285. function isApiOk(res) {
  1286. if (!res || typeof res !== 'object') return false;
  1287. if (res.success === false) return false;
  1288. var c = res.code;
  1289. return c === 200 || c === '200' || Number(c) === 200;
  1290. }
  1291. function fetchSecondGlobalRecommend() {
  1292. var userIdRaw = q('userId').trim();
  1293. var userId =
  1294. userIdRaw !== '' && !isNaN(Number(userIdRaw)) ? Number(userIdRaw) : null;
  1295. var latRaw = (q('userLat') || q('latitude') || q('lat') || q('weidu')).trim();
  1296. var lngRaw = (q('userLng') || q('longitude') || q('lon') || q('jingdu')).trim();
  1297. var userLat =
  1298. latRaw !== '' && !isNaN(Number(latRaw)) ? Number(latRaw) : DEFAULT_REC_USER_LAT;
  1299. var userLng =
  1300. lngRaw !== '' && !isNaN(Number(lngRaw)) ? Number(lngRaw) : DEFAULT_REC_USER_LNG;
  1301. var rkRaw = q('radiusKm').trim();
  1302. var radiusKm =
  1303. rkRaw !== '' && !isNaN(Number(rkRaw)) ? Number(rkRaw) : DEFAULT_REC_RADIUS_KM;
  1304. var page = parseInt(q('page') || '1', 10);
  1305. var pageSize = parseInt(q('pageSize') || '20', 10);
  1306. if (isNaN(page) || page < 1) page = 1;
  1307. if (isNaN(pageSize) || pageSize < 1) pageSize = 20;
  1308. var c1Raw = q('categoryOneId').trim();
  1309. var c2Raw = q('categoryTwoId').trim();
  1310. var categoryOneId =
  1311. c1Raw === '' || c1Raw.toLowerCase() === 'null'
  1312. ? null
  1313. : isNaN(Number(c1Raw))
  1314. ? null
  1315. : Number(c1Raw);
  1316. var categoryTwoId =
  1317. c2Raw === '' || c2Raw.toLowerCase() === 'null'
  1318. ? null
  1319. : isNaN(Number(c2Raw))
  1320. ? null
  1321. : Number(c2Raw);
  1322. var body = {
  1323. categoryOneId: categoryOneId,
  1324. categoryTwoId: categoryTwoId,
  1325. page: page,
  1326. pageSize: pageSize,
  1327. radiusKm: radiusKm,
  1328. userLat: userLat,
  1329. userLng: userLng,
  1330. userId: userId
  1331. };
  1332. return fetch(API_LIFE_AI_BASE + SECOND_GLOBAL_RECOMMEND_PATH, {
  1333. method: 'POST',
  1334. mode: 'cors',
  1335. credentials: 'omit',
  1336. headers: {
  1337. Accept: 'application/json',
  1338. 'Content-Type': 'application/json;charset=UTF-8'
  1339. },
  1340. body: JSON.stringify(body)
  1341. }).then(function (res) {
  1342. if (!res.ok) throw new Error('HTTP ' + res.status);
  1343. return res.json();
  1344. });
  1345. }
  1346. function normalizeGlobalRecommendList(res) {
  1347. if (!res || typeof res !== 'object') return [];
  1348. var raw = null;
  1349. if (isApiOk(res)) {
  1350. raw = res.data != null ? res.data : res.result;
  1351. }
  1352. if (Array.isArray(raw)) return raw;
  1353. if (raw && typeof raw === 'object') {
  1354. if (Array.isArray(raw.list)) return raw.list;
  1355. if (Array.isArray(raw.records)) return raw.records;
  1356. if (Array.isArray(raw.rows)) return raw.rows;
  1357. if (Array.isArray(raw.content)) return raw.content;
  1358. }
  1359. return [];
  1360. }
  1361. function buildHeroSlides(urls) {
  1362. var track = document.getElementById('heroTrack');
  1363. var dotsWrap = document.getElementById('heroDots');
  1364. track.innerHTML = '';
  1365. dotsWrap.innerHTML = '';
  1366. var list = (urls || []).filter(Boolean);
  1367. if (!list.length) {
  1368. var slide = document.createElement('div');
  1369. slide.className = 'hero__slide';
  1370. var img = document.createElement('img');
  1371. img.src = 'images/hero.png';
  1372. img.alt = '店铺';
  1373. slide.appendChild(img);
  1374. track.appendChild(slide);
  1375. var dot = document.createElement('span');
  1376. dot.className = 'hero__dot is-active';
  1377. dotsWrap.appendChild(dot);
  1378. return initHeroCarousel(1);
  1379. }
  1380. list.forEach(function (url, d) {
  1381. var slide = document.createElement('div');
  1382. slide.className = 'hero__slide';
  1383. var img = document.createElement('img');
  1384. img.src = url;
  1385. img.alt = '店铺图';
  1386. slide.appendChild(img);
  1387. track.appendChild(slide);
  1388. var dot = document.createElement('span');
  1389. dot.className = 'hero__dot' + (d === 0 ? ' is-active' : '');
  1390. dotsWrap.appendChild(dot);
  1391. });
  1392. initHeroCarousel(list.length);
  1393. }
  1394. var heroI = 0;
  1395. var heroTimer = null;
  1396. function initHeroCarousel(slides) {
  1397. var track = document.getElementById('heroTrack');
  1398. var dotsWrap = document.getElementById('heroDots');
  1399. var dots = dotsWrap.querySelectorAll('.hero__dot');
  1400. if (slides < 2) return;
  1401. function go(n) {
  1402. heroI = (n + slides) % slides;
  1403. track.style.transform = 'translateX(' + (-heroI * 100) + '%)';
  1404. dots.forEach(function (el, idx) {
  1405. el.classList.toggle('is-active', idx === heroI);
  1406. });
  1407. }
  1408. if (heroTimer) clearInterval(heroTimer);
  1409. heroTimer = setInterval(function () { go(heroI + 1); }, 4000);
  1410. var hero = document.getElementById('hero');
  1411. var startX = 0;
  1412. hero.addEventListener('touchstart', function (e) {
  1413. startX = e.changedTouches[0].clientX;
  1414. }, { passive: true });
  1415. hero.addEventListener('touchend', function (e) {
  1416. var dx = e.changedTouches[0].clientX - startX;
  1417. if (Math.abs(dx) > 40) go(dx < 0 ? heroI + 1 : heroI - 1);
  1418. }, { passive: true });
  1419. }
  1420. function timeToMinutes(t) {
  1421. var parts = String(t || '').trim().split(':');
  1422. var h = parseInt(parts[0], 10) || 0;
  1423. var m = parseInt(parts[1], 10) || 0;
  1424. return h * 60 + m;
  1425. }
  1426. function isTimeInRange(startTime, endTime) {
  1427. var s = String(startTime || '').trim();
  1428. var e = String(endTime || '').trim();
  1429. if (s === '00:00' && e === '00:00') return true;
  1430. if (s === '00:00' && e === '23:59') return true;
  1431. var cur = new Date().getHours() * 60 + new Date().getMinutes();
  1432. var sm = timeToMinutes(s);
  1433. var em = timeToMinutes(e);
  1434. if (em < sm) {
  1435. return cur >= sm || cur <= em;
  1436. }
  1437. return cur >= sm && cur <= em;
  1438. }
  1439. function parseHolidayDate(str) {
  1440. if (!str) return null;
  1441. var d = new Date(String(str).trim().replace(/-/g, '/'));
  1442. return isNaN(d.getTime()) ? null : d;
  1443. }
  1444. function isTodayInHolidayRange(holidayInfo) {
  1445. if (!holidayInfo) return false;
  1446. var hi = holidayInfo;
  1447. if (typeof hi === 'string') {
  1448. try {
  1449. hi = JSON.parse(hi);
  1450. } catch (err) {
  1451. return false;
  1452. }
  1453. }
  1454. var start = hi.startDate || hi.holidayStartDate || hi.beginDate || hi.start || hi.holidayStart;
  1455. var end = hi.endDate || hi.holidayEndDate || hi.finishDate || hi.end || hi.holidayEnd;
  1456. if (!start || !end) return false;
  1457. var startD = parseHolidayDate(start);
  1458. var endD = parseHolidayDate(end);
  1459. if (!startD || !endD) return false;
  1460. var today = new Date();
  1461. today.setHours(0, 0, 0, 0);
  1462. startD.setHours(0, 0, 0, 0);
  1463. endD.setHours(0, 0, 0, 0);
  1464. return today >= startD && today <= endD;
  1465. }
  1466. function findNormalBusinessInfo(list) {
  1467. var wdJs = new Date().getDay();
  1468. var i;
  1469. var x;
  1470. var w;
  1471. for (i = 0; i < list.length; i++) {
  1472. x = list[i];
  1473. if (!x || x.holidayInfo) continue;
  1474. w = x.weekDay != null ? x.weekDay : x.week;
  1475. if (w === undefined || w === null) continue;
  1476. if (Number(w) === wdJs) return x;
  1477. }
  1478. var wdMap = wdJs === 0 ? 7 : wdJs;
  1479. for (i = 0; i < list.length; i++) {
  1480. x = list[i];
  1481. if (!x || x.holidayInfo) continue;
  1482. w = x.weekDay != null ? x.weekDay : x.week;
  1483. if (w === undefined || w === null) continue;
  1484. if (Number(w) === wdMap) return x;
  1485. }
  1486. for (i = 0; i < list.length; i++) {
  1487. x = list[i];
  1488. if (x && !x.holidayInfo && (x.startTime || x.endTime)) return x;
  1489. }
  1490. return null;
  1491. }
  1492. /** 营业状态:暂停营业 | 商家暂未配置营业时间 | 休息中 | 营业中 xx:xx至xx:xx | 营业中 全天营业 */
  1493. function computeBusinessStatusDisplay(d) {
  1494. if (!d) return { text: '—', isOpen: false };
  1495. if (Number(d.businessStatus) === 1) {
  1496. return { text: '暂停营业', isOpen: false };
  1497. }
  1498. var list = d.storeBusinessInfoVos || d.storeBusinessInfos || [];
  1499. if (!list.length) {
  1500. return { text: '商家暂未配置营业时间', isOpen: false };
  1501. }
  1502. var holidayList = Array.isArray(d.holidayBusinessInfoList) && d.holidayBusinessInfoList.length
  1503. ? d.holidayBusinessInfoList
  1504. : list.filter(function (item) { return item && item.holidayInfo; });
  1505. var todayHolidayItem = holidayList.find(function (item) {
  1506. return isTodayInHolidayRange(item.holidayInfo);
  1507. });
  1508. var normal = d.normalBusinessInfo || d.normalBusinessInfoVo || findNormalBusinessInfo(list);
  1509. var isOpen = false;
  1510. var currentItem = null;
  1511. if (todayHolidayItem) {
  1512. isOpen = isTimeInRange(todayHolidayItem.startTime, todayHolidayItem.endTime);
  1513. currentItem = todayHolidayItem;
  1514. } else if (normal) {
  1515. isOpen = isTimeInRange(normal.startTime, normal.endTime);
  1516. currentItem = normal;
  1517. }
  1518. if (!currentItem) return { text: '休息中', isOpen: false };
  1519. if (!isOpen) return { text: '休息中', isOpen: false };
  1520. var st = String(currentItem.startTime || '').trim();
  1521. var et = String(currentItem.endTime || '').trim();
  1522. if (st === '00:00' && et === '00:00') return { text: '营业中 全天营业', isOpen: true };
  1523. if (st === '00:00' && et === '23:59') return { text: '营业中 全天营业', isOpen: true };
  1524. var needNextDay = timeToMinutes(et) < timeToMinutes(st);
  1525. var suffix = (needNextDay ? '次日' : '') + et;
  1526. return { text: ('营业中 ' + st + ' 至 ' + suffix).trim(), isOpen: true };
  1527. }
  1528. function renderDetail(d) {
  1529. if (!d) return;
  1530. document.getElementById('storeName').textContent = d.storeName || '—';
  1531. var score = d.scoreAvg != null ? Number(d.scoreAvg) : NaN;
  1532. document.getElementById('scoreAvg').textContent = !isNaN(score) ? score.toFixed(1) : '—';
  1533. document.getElementById('commitCount').textContent = d.commitCount != null ? String(d.commitCount) : '0';
  1534. var bizDisp = computeBusinessStatusDisplay(d);
  1535. var bizEl = document.getElementById('bizStatus');
  1536. bizEl.textContent = bizDisp.text;
  1537. bizEl.className = 'status' + (bizDisp.isOpen ? ' is-open' : '');
  1538. document.getElementById('hoursText').textContent = '';
  1539. document.getElementById('storeAddr').textContent = d.queryAddress || d.storeAddress || '—';
  1540. if (d.distance != null) {
  1541. document.getElementById('metaDistance').style.display = 'flex';
  1542. document.getElementById('distanceText').textContent =
  1543. '距您' + (Number(d.distance) > 1 ? d.distance + '千米' : Math.round(Number(d.distance) * 1000) + '米');
  1544. }
  1545. if (d.subwayName && d.distance2 != null) {
  1546. document.getElementById('metaSubway').style.display = 'flex';
  1547. document.getElementById('subwayText').textContent =
  1548. '距' + d.subwayName + '步行' + (Number(d.distance2) >= 1000
  1549. ? (Number(d.distance2) / 1000).toFixed(1) + 'km'
  1550. : Math.round(Number(d.distance2)) + 'm');
  1551. }
  1552. var imgs = [];
  1553. if (Array.isArray(d.storeAlbumUrlList) && d.storeAlbumUrlList.length) imgs = d.storeAlbumUrlList.slice();
  1554. else if (d.entranceImage) imgs = [d.entranceImage];
  1555. buildHeroSlides(imgs);
  1556. }
  1557. function formatRecDist(m) {
  1558. if (m == null || m === '') return '';
  1559. var n = Number(m);
  1560. if (isNaN(n)) return String(m);
  1561. return n >= 1000 ? (n / 1000).toFixed(1) + 'km' : Math.round(n) + 'm';
  1562. }
  1563. function escHtml(s) {
  1564. return String(s == null ? '' : s)
  1565. .replace(/&/g, '&amp;')
  1566. .replace(/</g, '&lt;')
  1567. .replace(/>/g, '&gt;')
  1568. .replace(/"/g, '&quot;');
  1569. }
  1570. /** global-recommend records:homeImage、title、position、dist、price、amount、likeCount、collectCount、userName、userImage */
  1571. function renderRecommended(list) {
  1572. var wrap = document.getElementById('recList');
  1573. var empty = document.getElementById('recEmpty');
  1574. wrap.querySelectorAll('.rec-card').forEach(function (n) {
  1575. n.remove();
  1576. });
  1577. if (!list || !list.length) {
  1578. empty.style.display = 'block';
  1579. return;
  1580. }
  1581. empty.style.display = 'none';
  1582. list.forEach(function (item) {
  1583. if (!item || typeof item !== 'object') return;
  1584. var card = document.createElement('article');
  1585. card.className = 'rec-card';
  1586. var home = item.homeImage != null ? String(item.homeImage).trim() : '';
  1587. if (home && /\.mp4(\?|#|$)/i.test(home)) {
  1588. var vf = item.videoFirstFrame != null ? String(item.videoFirstFrame).trim() : '';
  1589. if (vf) home = vf;
  1590. }
  1591. var imgUrl =
  1592. home ||
  1593. (item.coverUrl != null ? String(item.coverUrl).trim() : '') ||
  1594. (item.mainImage != null ? String(item.mainImage).trim() : '') ||
  1595. (item.goodsImage != null ? String(item.goodsImage).trim() : '') ||
  1596. (Array.isArray(item.goodsImageList) && item.goodsImageList[0]) ||
  1597. (Array.isArray(item.imageList) && item.imageList[0]) ||
  1598. 'images/hero.png';
  1599. var name = item.title != null && String(item.title).trim() !== ''
  1600. ? String(item.title).replace(/\r?\n/g, ' ').replace(/\s+/g, ' ').trim()
  1601. : (item.goodsName ||
  1602. item.secondGoodsTitle ||
  1603. item.name ||
  1604. '商品');
  1605. var dist = '';
  1606. if (item.position != null && String(item.position).trim() !== '') {
  1607. dist = String(item.position).trim();
  1608. } else if (item.dist != null && item.dist !== '') {
  1609. var dn = Number(item.dist);
  1610. if (!isNaN(dn)) {
  1611. dist = dn.toFixed(dn % 1 === 0 ? 0 : 2) + 'km';
  1612. }
  1613. } else if (item.distance != null && item.distance !== '') {
  1614. var d2 = Number(item.distance);
  1615. dist = !isNaN(d2) ? d2.toFixed(d2 % 1 === 0 ? 0 : 2) + 'km' : String(item.distance);
  1616. }
  1617. var priceStr = '';
  1618. if (item.price != null && String(item.price).trim() !== '') {
  1619. var ps = String(item.price).trim();
  1620. var pNum = parseFloat(ps.replace(/[^\d.]/g, ''));
  1621. priceStr = !isNaN(pNum) ? pNum.toFixed(2) : ps;
  1622. } else if (item.amount != null && item.amount !== '') {
  1623. var an = Number(item.amount);
  1624. priceStr = !isNaN(an) ? an.toFixed(2) : String(item.amount);
  1625. } else {
  1626. priceStr = '—';
  1627. }
  1628. var seller =
  1629. item.userName != null && String(item.userName).trim() !== ''
  1630. ? String(item.userName).trim()
  1631. : '';
  1632. var userImg =
  1633. item.userImage != null && String(item.userImage).trim() !== ''
  1634. ? String(item.userImage).trim()
  1635. : '';
  1636. var likeN = item.likeCount != null ? Number(item.likeCount) : NaN;
  1637. var colN = item.collectCount != null ? Number(item.collectCount) : NaN;
  1638. var metaBits = [];
  1639. // if (!isNaN(likeN)) metaBits.push(likeN + '赞');
  1640. // if (!isNaN(colN)) metaBits.push(colN + '想要');
  1641. var metaRight = metaBits.join(' · ');
  1642. var showSellerRow = !!(seller || userImg);
  1643. card.innerHTML =
  1644. '<div class="rec-card__img"><img class="rec-card__cover" src="" alt=""></div>' +
  1645. '<div class="rec-card__body">' +
  1646. '<div class="rec-card__top">' +
  1647. '<span class="rec-card__name">' + escHtml(name) + '</span>' +
  1648. (dist ? '<span class="rec-card__dist">' + escHtml(dist) + '</span>' : '') +
  1649. '</div>' +
  1650. '<div class="rec-card__rating">' +
  1651. '<span class="rec-meta" style="color:#E62E2E;font-weight:600;">¥' + escHtml(priceStr) + '</span>' +
  1652. (metaRight
  1653. ? '<span class="rec-meta">' + escHtml(metaRight) + '</span>'
  1654. : '') +
  1655. '</div>' +
  1656. (showSellerRow
  1657. ? '<div class="rec-card__seller">' +
  1658. '<img class="rec-card__avatar" src="" alt="" width="22" height="22" decoding="async">' +
  1659. (seller ? '<span class="rec-card__seller-name">' + escHtml(seller) + '</span>' : '') +
  1660. '</div>'
  1661. : '') +
  1662. '</div>';
  1663. var coverIm = card.querySelector('img.rec-card__cover');
  1664. if (coverIm) {
  1665. coverIm.src = imgUrl;
  1666. coverIm.onerror = function () {
  1667. this.onerror = null;
  1668. this.src = 'images/hero.png';
  1669. };
  1670. }
  1671. var avIm = card.querySelector('img.rec-card__avatar');
  1672. if (avIm) {
  1673. avIm.src = userImg || 'images/demouser.png';
  1674. avIm.onerror = function () {
  1675. this.onerror = null;
  1676. this.src = 'images/demouser.png';
  1677. };
  1678. }
  1679. wrap.appendChild(card);
  1680. });
  1681. }
  1682. function run() {
  1683. fetchSecondGlobalRecommend()
  1684. .then(function (res) {
  1685. var list = normalizeGlobalRecommendList(res);
  1686. if (!list.length && res && res.msg) {
  1687. console.warn('[global-recommend]', res.msg);
  1688. }
  1689. renderRecommended(list);
  1690. })
  1691. .catch(function (e) {
  1692. console.error(e);
  1693. renderRecommended([]);
  1694. });
  1695. }
  1696. function boot() {
  1697. var launchTag = document.getElementById('launch-btn');
  1698. if (launchTag) launchTag.setAttribute('appid', WECHAT_OPEN_APP_ID);
  1699. bindWeChatLaunchTagEvents();
  1700. if (isWeChatInAppBrowser()) {
  1701. document.body.classList.add('is-wechat');
  1702. ensureWxShareFromQueryBeforeConfig();
  1703. logWxEntryDiagnostics();
  1704. }
  1705. if (shouldInitWeChatJssdkOnLoad()) {
  1706. if (isWxPcBrowser() && (isWxForceDebug() || isWxPcAutoDebugHost())) {
  1707. document.body.classList.add('wx-pc-debug');
  1708. }
  1709. scheduleWeChatJssdkBootstrap();
  1710. }
  1711. document.addEventListener('WeixinOpenTagsError', function (e) {
  1712. console.warn('[WeixinOpenTagsError]', e && e.detail);
  1713. });
  1714. run();
  1715. if (isWeChatInAppBrowser()) {
  1716. var openBtnWx = document.getElementById('openApp');
  1717. if (openBtnWx) {
  1718. openBtnWx.addEventListener('click', function () {
  1719. if (!weChatJssdkConfigured) {
  1720. showFabToast(
  1721. wxInitLastError || '微信 SDK 初始化中,请稍候再点底部按钮'
  1722. );
  1723. return;
  1724. }
  1725. });
  1726. }
  1727. } else {
  1728. var openBtn = document.getElementById('openApp');
  1729. if (openBtn) {
  1730. openBtn.addEventListener('click', tryOpenUShopApp);
  1731. }
  1732. }
  1733. }
  1734. if (document.readyState === 'complete') {
  1735. boot();
  1736. } else {
  1737. window.onload = boot;
  1738. }
  1739. })();
  1740. </script>
  1741. </body>
  1742. </html>