secondShareGoods.html 62 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214
  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>商品分享</title>
  8. <style>
  9. :root {
  10. --orange: #F58220;
  11. --price-red: #E62E2E;
  12. --tag-bg: #fff5e9;
  13. --tag-text: #b05b28;
  14. --text: #1a1a1a;
  15. --text-secondary: #999999;
  16. --safe-bottom: env(safe-area-inset-bottom, 0px);
  17. }
  18. * {
  19. margin: 0;
  20. padding: 0;
  21. box-sizing: border-box;
  22. }
  23. html {
  24. font-size: 16px;
  25. -webkit-tap-highlight-color: transparent;
  26. overflow-x: hidden;
  27. }
  28. body {
  29. font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", sans-serif;
  30. background: #fff;
  31. color: var(--text);
  32. min-height: 100vh;
  33. padding-bottom: calc(100px + var(--safe-bottom));
  34. }
  35. .fab-wrap {
  36. position: fixed;
  37. left: 0;
  38. right: 0;
  39. bottom: 0;
  40. z-index: 200;
  41. padding: 12px 24px calc(12px + var(--safe-bottom));
  42. background: linear-gradient(to top, rgba(255, 255, 255, 0.98) 70%, transparent);
  43. pointer-events: none;
  44. }
  45. .fab-dock__slot {
  46. width: 100%;
  47. max-width: 198px;
  48. height: 48px;
  49. margin: 0 auto;
  50. pointer-events: auto;
  51. }
  52. #openApp.fab {
  53. padding: 0 10px;
  54. -webkit-font-smoothing: antialiased;
  55. text-rendering: optimizeLegibility;
  56. }
  57. .fab__brand-clip {
  58. display: block;
  59. flex-shrink: 0;
  60. line-height: 0;
  61. }
  62. .fab__brand-img {
  63. display: block;
  64. height: 26px;
  65. width: auto;
  66. max-width: none;
  67. pointer-events: none;
  68. -webkit-user-drag: none;
  69. }
  70. .fab__label {
  71. font-size: 15px;
  72. line-height: 1;
  73. letter-spacing: 0.04em;
  74. white-space: nowrap;
  75. }
  76. #launch-btn {
  77. display: none;
  78. width: 100%;
  79. height: 48px;
  80. min-height: 48px;
  81. border-radius: 24px;
  82. overflow: hidden;
  83. opacity: 1;
  84. }
  85. body.is-wechat.wx-jssdk-ready #launch-btn {
  86. display: block;
  87. }
  88. body.is-wechat.wx-jssdk-ready #openApp {
  89. display: none !important;
  90. }
  91. .fab-wrap .fab {
  92. pointer-events: auto;
  93. }
  94. #openAppToast {
  95. display: none;
  96. position: fixed;
  97. left: 16px;
  98. right: 16px;
  99. bottom: calc(72px + var(--safe-bottom));
  100. z-index: 10001;
  101. padding: 10px 14px;
  102. font-size: 13px;
  103. line-height: 1.45;
  104. color: #fff;
  105. text-align: center;
  106. background: rgba(0, 0, 0, 0.78);
  107. border-radius: 8px;
  108. pointer-events: none;
  109. word-break: break-all;
  110. }
  111. #openApp {
  112. touch-action: manipulation;
  113. }
  114. .fab {
  115. display: flex;
  116. align-items: center;
  117. justify-content: center;
  118. gap: 4px;
  119. width: 100%;
  120. max-width: 198px;
  121. margin: 0 auto;
  122. height: 48px;
  123. border: none;
  124. border-radius: 24px;
  125. background: #F47D1F;
  126. color: #fff;
  127. font-size: 16px;
  128. font-weight: 600;
  129. box-shadow: 0 4px 16px rgba(245, 130, 32, 0.45);
  130. cursor: pointer;
  131. }
  132. .fab__logo {
  133. width: 28px;
  134. height: 28px;
  135. flex-shrink: 0;
  136. }
  137. .home-indicator {
  138. height: 5px;
  139. background: #000;
  140. border-radius: 3px;
  141. width: 134px;
  142. margin: 8px auto 4px;
  143. opacity: 0.2;
  144. }
  145. /* 顶部大图 + 叠字 */
  146. .goods-hero {
  147. position: relative;
  148. width: 100%;
  149. min-height: 58vh;
  150. max-height: 520px;
  151. background: #e8e8e8 center / cover no-repeat;
  152. overflow: hidden;
  153. }
  154. .goods-hero__img {
  155. position: absolute;
  156. inset: 0;
  157. width: 100%;
  158. height: 100%;
  159. object-fit: cover;
  160. display: block;
  161. }
  162. .goods-hero__shade {
  163. position: absolute;
  164. inset: 0;
  165. background: linear-gradient(
  166. 180deg,
  167. rgba(0, 0, 0, 0.35) 0%,
  168. rgba(0, 0, 0, 0.1) 38%,
  169. rgba(0, 0, 0, 0.45) 100%
  170. );
  171. pointer-events: none;
  172. }
  173. .goods-hero__inner {
  174. position: relative;
  175. z-index: 1;
  176. min-height: 58vh;
  177. max-height: 520px;
  178. padding: calc(12px + env(safe-area-inset-top, 0px)) 16px 28px;
  179. display: flex;
  180. flex-direction: column;
  181. justify-content: space-between;
  182. align-items: flex-start;
  183. }
  184. .goods-hero__user {
  185. display: flex;
  186. align-items: center;
  187. gap: 10px;
  188. }
  189. .goods-hero__avatar {
  190. width: 40px;
  191. height: 40px;
  192. border-radius: 50%;
  193. object-fit: cover;
  194. flex-shrink: 0;
  195. background: rgba(255, 255, 255, 0.3);
  196. }
  197. .goods-hero__user-meta {
  198. display: flex;
  199. flex-direction: column;
  200. gap: 2px;
  201. }
  202. .goods-hero__name {
  203. font-size: 15px;
  204. font-weight: 600;
  205. color: #fff;
  206. text-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
  207. }
  208. .goods-hero__time {
  209. font-size: 12px;
  210. color: rgba(255, 255, 255, 0.82);
  211. text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  212. }
  213. .goods-hero__slogan {
  214. margin-top: auto;
  215. padding-bottom: 4px;
  216. }
  217. .goods-hero__slogan-line {
  218. font-size: 26px;
  219. font-weight: 800;
  220. line-height: 1.25;
  221. color: #fff;
  222. letter-spacing: 0.02em;
  223. text-shadow: 0 2px 12px rgba(0, 0, 0, 0.45);
  224. }
  225. /* 白色内容区 */
  226. .goods-panel {
  227. background: #fff;
  228. border-radius: 16px 16px 0 0;
  229. margin-top: -16px;
  230. position: relative;
  231. z-index: 2;
  232. padding: 20px 16px 24px;
  233. box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.06);
  234. }
  235. .goods-panel__row-price {
  236. display: flex;
  237. align-items: flex-end;
  238. justify-content: space-between;
  239. gap: 12px;
  240. margin-bottom: 14px;
  241. }
  242. .goods-panel__price {
  243. display: flex;
  244. align-items: baseline;
  245. gap: 2px;
  246. color: var(--price-red);
  247. font-weight: 800;
  248. line-height: 1;
  249. }
  250. .goods-panel__price-yen {
  251. font-size: 18px;
  252. }
  253. .goods-panel__price-num {
  254. font-size: 28px;
  255. letter-spacing: -0.02em;
  256. }
  257. .goods-panel__dist {
  258. display: inline-flex;
  259. align-items: center;
  260. gap: 4px;
  261. font-size: 12px;
  262. color: var(--text-secondary);
  263. flex-shrink: 0;
  264. padding-bottom: 2px;
  265. }
  266. .goods-panel__dist svg,
  267. .goods-panel__dist img {
  268. width: 14px;
  269. height: 14px;
  270. opacity: 0.85;
  271. display: block;
  272. flex-shrink: 0;
  273. object-fit: contain;
  274. }
  275. .goods-panel__title {
  276. font-size: 17px;
  277. font-weight: 700;
  278. line-height: 1.45;
  279. color: var(--text);
  280. margin-bottom: 16px;
  281. }
  282. .goods-panel__row-stats {
  283. display: flex;
  284. align-items: center;
  285. justify-content: space-between;
  286. gap: 12px;
  287. margin-bottom: 16px;
  288. }
  289. .goods-panel__stats {
  290. display: flex;
  291. align-items: center;
  292. gap: 18px;
  293. }
  294. .goods-panel__stat {
  295. display: inline-flex;
  296. align-items: center;
  297. gap: 5px;
  298. font-size: 14px;
  299. color: var(--text-secondary);
  300. }
  301. .goods-panel__stat svg {
  302. width: 16px;
  303. height: 16px;
  304. flex-shrink: 0;
  305. }
  306. .goods-panel__stat img {
  307. width: 16px;
  308. height: 16px;
  309. flex-shrink: 0;
  310. display: block;
  311. object-fit: contain;
  312. }
  313. .goods-panel__share {
  314. display: inline-flex;
  315. align-items: center;
  316. gap: 4px;
  317. padding: 0;
  318. border: none;
  319. background: none;
  320. font-size: 14px;
  321. color: var(--text-secondary);
  322. cursor: pointer;
  323. -webkit-tap-highlight-color: transparent;
  324. }
  325. .goods-panel__share svg {
  326. width: 18px;
  327. height: 18px;
  328. }
  329. .goods-panel__tags {
  330. display: flex;
  331. flex-wrap: wrap;
  332. align-items: center;
  333. gap: 8px;
  334. }
  335. .goods-tag {
  336. display: inline-block;
  337. padding: 2px 8px;
  338. border-radius: 4px;
  339. font-size: 12px;
  340. font-weight: 400;
  341. line-height: 1.35;
  342. background: #fff5e9;
  343. }
  344. .goods-tag--topic {
  345. color: #b05b28;
  346. }
  347. .goods-tag--label {
  348. color: #333333;
  349. }
  350. /* 留言 */
  351. .goods-comments {
  352. margin-top: 20px;
  353. padding-top: 20px;
  354. border-top: 1px solid #eee;
  355. }
  356. .goods-comments__head {
  357. display: flex;
  358. align-items: center;
  359. justify-content: space-between;
  360. margin-bottom: 18px;
  361. }
  362. .goods-comments__title {
  363. font-size: 17px;
  364. font-weight: 700;
  365. color: var(--text);
  366. }
  367. .goods-comments__total {
  368. display: inline-flex;
  369. align-items: center;
  370. gap: 4px;
  371. font-size: 14px;
  372. color: #151515;
  373. }
  374. .goods-comments__total svg {
  375. width: 18px;
  376. height: 18px;
  377. opacity: 0.85;
  378. }
  379. .goods-comments__list {
  380. list-style: none;
  381. }
  382. .goods-comments__empty {
  383. list-style: none;
  384. padding: 24px 12px;
  385. text-align: center;
  386. font-size: 14px;
  387. color: var(--text-secondary);
  388. }
  389. .goods-cmt {
  390. padding-bottom: 18px;
  391. margin-bottom: 18px;
  392. border-bottom: 1px solid #eee;
  393. }
  394. .goods-cmt:last-child {
  395. margin-bottom: 0;
  396. padding-bottom: 0;
  397. border-bottom: none;
  398. }
  399. .goods-cmt__row {
  400. display: flex;
  401. align-items: flex-start;
  402. gap: 12px;
  403. }
  404. .goods-cmt__avatar {
  405. width: 40px;
  406. height: 40px;
  407. border-radius: 50%;
  408. object-fit: cover;
  409. background: #e8e8e8;
  410. flex-shrink: 0;
  411. }
  412. .goods-cmt--nested .goods-cmt__avatar {
  413. width: 32px;
  414. height: 32px;
  415. }
  416. .goods-cmt__body {
  417. flex: 1;
  418. min-width: 0;
  419. }
  420. .goods-cmt__name {
  421. font-size: 15px;
  422. font-weight: 700;
  423. color: var(--text);
  424. line-height: 1.3;
  425. }
  426. .goods-cmt__time {
  427. display: block;
  428. margin-top: 2px;
  429. font-size: 12px;
  430. color: var(--text-secondary);
  431. line-height: 1.35;
  432. }
  433. .goods-cmt__text {
  434. margin-top: 10px;
  435. font-size: 15px;
  436. line-height: 1.5;
  437. color: var(--text);
  438. word-break: break-word;
  439. }
  440. .goods-cmt__actions {
  441. display: flex;
  442. align-items: center;
  443. gap: 20px;
  444. margin-top: 12px;
  445. }
  446. .goods-cmt__action {
  447. display: inline-flex;
  448. align-items: center;
  449. gap: 4px;
  450. padding: 0;
  451. border: none;
  452. background: none;
  453. font-size: 13px;
  454. color: var(--text-secondary);
  455. cursor: pointer;
  456. -webkit-tap-highlight-color: transparent;
  457. }
  458. .goods-cmt__action svg {
  459. width: 16px;
  460. height: 16px;
  461. flex-shrink: 0;
  462. opacity: 0.88;
  463. }
  464. .goods-cmt__thread {
  465. margin-top: 14px;
  466. padding-left: 52px;
  467. }
  468. .goods-cmt__replies-inner.is-collapsed {
  469. display: none;
  470. }
  471. .goods-cmt__thread-bar {
  472. display: flex;
  473. align-items: center;
  474. justify-content: space-between;
  475. width: 100%;
  476. margin-top: 10px;
  477. padding: 10px 12px;
  478. border: none;
  479. border-radius: 8px;
  480. background: #f5f5f5;
  481. font-size: 13px;
  482. color: #888;
  483. cursor: pointer;
  484. -webkit-tap-highlight-color: transparent;
  485. }
  486. .goods-cmt__thread-bar-right {
  487. display: inline-flex;
  488. align-items: center;
  489. gap: 4px;
  490. color: var(--text-secondary);
  491. }
  492. .goods-cmt__thread-chevron {
  493. width: 14px;
  494. height: 14px;
  495. transition: transform 0.2s ease;
  496. flex-shrink: 0;
  497. }
  498. .goods-cmt__thread-bar.is-collapsed .goods-cmt__thread-chevron {
  499. transform: rotate(180deg);
  500. }
  501. .goods-cmt--nested {
  502. padding-bottom: 0;
  503. margin-bottom: 0;
  504. border-bottom: none;
  505. }
  506. .goods-cmt--nested .goods-cmt__text {
  507. margin-top: 8px;
  508. }
  509. </style>
  510. </head>
  511. <body>
  512. <section class="goods-hero" id="goodsHero" aria-label="商品配图">
  513. <img class="goods-hero__img" id="goodsHeroImg" src="" alt="">
  514. <div class="goods-hero__shade" aria-hidden="true"></div>
  515. <div class="goods-hero__inner">
  516. <div class="goods-hero__user">
  517. <img class="goods-hero__avatar" id="goodsUserAvatar" src="images/demouser.png" alt="">
  518. <div class="goods-hero__user-meta">
  519. <span class="goods-hero__name" id="goodsUserName">维尼</span>
  520. <span class="goods-hero__time" id="goodsTimeAgo">11小时前</span>
  521. </div>
  522. </div>
  523. <div class="goods-hero__slogan" id="goodsHeroSloganWrap" style="display:none;">
  524. <div class="goods-hero__slogan-line" id="goodsSlogan1"></div>
  525. <div class="goods-hero__slogan-line" id="goodsSlogan2"></div>
  526. </div>
  527. </div>
  528. </section>
  529. <div class="goods-panel">
  530. <div class="goods-panel__row-price">
  531. <div class="goods-panel__price">
  532. <span class="goods-panel__price-yen">¥</span>
  533. <span class="goods-panel__price-num" id="goodsPrice">690.00</span>
  534. </div>
  535. <div class="goods-panel__dist">
  536. <img src="images/juli.svg" alt="" width="14" height="14" decoding="async" aria-hidden="true">
  537. <span id="goodsDistance">距离 2.5km</span>
  538. </div>
  539. </div>
  540. <h1 class="goods-panel__title" id="goodsTitle">HCK哈士奇BC-330RDE烤漆复古冰箱家用大容量单门冰柜高颜值网红</h1>
  541. <div class="goods-panel__row-stats">
  542. <div class="goods-panel__stats">
  543. <span class="goods-panel__stat goods-panel__stat--hot" id="goodsHotStat">
  544. <img src="images/huo.svg" alt="" width="16" height="16" decoding="async" aria-hidden="true">
  545. <span id="goodsHotCount" style="color:#151515;">510</span>
  546. </span>
  547. <span class="goods-panel__stat">
  548. <img src="images/xing.svg" alt="" width="16" height="16" decoding="async" aria-hidden="true">
  549. <span id="goodsFavCount" style="color:#151515;">260</span>
  550. </span>
  551. </div>
  552. </div>
  553. <div class="goods-panel__tags" id="goodsTags"></div>
  554. <section class="goods-comments" id="goodsComments" aria-label="留言">
  555. <div class="goods-comments__head">
  556. <h2 class="goods-comments__title">留言</h2>
  557. <div class="goods-comments__total">
  558. <img src="images/liuyan.svg" alt="" width="16" height="16" decoding="async" aria-hidden="true">
  559. <span id="goodsCommentTotal">24</span>
  560. </div>
  561. </div>
  562. <ul class="goods-comments__list" id="goodsCommentList"></ul>
  563. </section>
  564. </div>
  565. <div id="openAppToast" role="status" aria-live="polite"></div>
  566. <div class="fab-wrap">
  567. <div class="fab-dock__slot">
  568. <button type="button" class="fab" id="openApp" aria-label="APP内打开">
  569. <span class="fab__brand-clip" aria-hidden="true">
  570. <img class="fab__brand-img" src="images/uBtn.svg" alt="" decoding="async">
  571. </span>
  572. <span class="fab__label">APP内打开</span>
  573. </button>
  574. <wx-open-launch-app id="launch-btn" appid="wxf5f1efe3a9f5012e" extinfo="">
  575. <script type="text/wxtag-template">
  576. <style>
  577. .wx-open-app-btn {
  578. display: flex;
  579. align-items: center;
  580. justify-content: center;
  581. gap: 4px;
  582. width: 100%;
  583. height: 48px;
  584. margin: 0;
  585. padding: 0 10px;
  586. border: none;
  587. border-radius: 24px;
  588. background: #F47D1F;
  589. box-shadow: 0 4px 16px rgba(245, 130, 32, 0.45);
  590. color: #fff;
  591. font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", sans-serif;
  592. -webkit-font-smoothing: antialiased;
  593. cursor: pointer;
  594. overflow: hidden;
  595. -webkit-tap-highlight-color: transparent;
  596. box-sizing: border-box;
  597. }
  598. .wx-open-app-btn .fab__brand-clip {
  599. display: block;
  600. flex-shrink: 0;
  601. line-height: 0;
  602. }
  603. .wx-open-app-btn .fab__brand-img {
  604. display: block;
  605. height: 26px;
  606. width: auto;
  607. max-width: none;
  608. pointer-events: none;
  609. -webkit-user-drag: none;
  610. }
  611. .wx-open-app-btn .fab__label {
  612. font-size: 15px;
  613. line-height: 1;
  614. letter-spacing: 0.04em;
  615. white-space: nowrap;
  616. }
  617. </style>
  618. <button class="wx-open-app-btn" aria-label="APP内打开">
  619. <span class="fab__brand-clip" aria-hidden="true">
  620. <img class="fab__brand-img" src="https://prod.ailien.shop/h5/HBuilderProjects/images/uBtn.svg" alt="" decoding="async">
  621. </span>
  622. <span class="fab__label">APP内打开</span>
  623. </button>
  624. </script>
  625. </wx-open-launch-app>
  626. </div>
  627. <div class="home-indicator" aria-hidden="true"></div>
  628. </div>
  629. <script src="https://res.wx.qq.com/open/js/jweixin-1.6.0.js"></script>
  630. <script>
  631. (function () {
  632. 'use strict';
  633. /**
  634. * 进入页仅用 querySecondGoodsDetailWithOutJWT 判断商品是否存在(不用其 data 渲染页面):
  635. * POST {API_BASE_SECOND}/recommend/querySecondGoodsDetailWithOutJWT
  636. * body:goodsId、longitude、latitude、phoneId
  637. * goodsStatus 不为 3 → shareUndefined;goodsStatus 为 3 → applyFromUrl + 留言
  638. */
  639. /**
  640. * 唤起 App 落地:二手商品详情(与 pages.json 路径一致)
  641. */
  642. var APP_ANDROID_PACKAGE = 'com.alien.Udianzaizhe';
  643. var APP_DOWNLOAD_URL = 'https://a.app.qq.com/o/simple.jsp?pkgname=com.alien.Udianzaina';
  644. var APP_IOS_URL_SCHEME = 'shopro://';
  645. var APP_UNI_STORE_PATH = 'pages/secondHandTransactions/pages/detail/index';
  646. var API_BASE = 'https://prod.ailien.shop/alienStore';
  647. /**
  648. * 微信 JSSDK — 与 shareIndex.html 一致
  649. * POST {API_BASE}/wx/getWxConfig,body 传 url(当前页完整地址,不含 #)
  650. */
  651. var WECHAT_MP_APP_ID = 'wx412792c77f47babd';
  652. var WECHAT_OPEN_APP_ID = 'wxf5f1efe3a9f5012e';
  653. var WECHAT_GET_WX_CONFIG_PATH = '/wx/getWxConfig';
  654. var H5_PAGE_BASE_FALLBACK = 'https://prod.ailien.shop/h5/HBuilderProjects/';
  655. var WX_GET_CONFIG_SIGN_URL = H5_PAGE_BASE_FALLBACK + 'secondShareGoods.html';
  656. var WECHAT_JS_SAFE_HOSTS = ['uat.ailien.shop', 'prod.ailien.shop'];
  657. var weChatJssdkConfigured = false;
  658. var wxConfigSignRetriedBaseUrl = false;
  659. var wxInitLastError = '';
  660. var wxJssdkInitPromise = null;
  661. function showDownloadTip() {
  662. window.location.href = APP_DOWNLOAD_URL;
  663. }
  664. function mergeSearchAndHashParams() {
  665. var params = new URLSearchParams();
  666. function ingestAppend(querySlice) {
  667. if (!querySlice) return;
  668. var p = new URLSearchParams(querySlice);
  669. p.forEach(function (val, key) {
  670. params.append(key, val);
  671. });
  672. }
  673. function ingestSet(querySlice) {
  674. if (!querySlice) return;
  675. var p = new URLSearchParams(querySlice);
  676. p.forEach(function (val, key) {
  677. params.set(key, val);
  678. });
  679. }
  680. if (location.search && location.search.length > 1) {
  681. ingestAppend(location.search.slice(1));
  682. }
  683. var hash = location.hash || '';
  684. var qi = hash.indexOf('?');
  685. if (qi >= 0) {
  686. ingestSet(hash.slice(qi + 1));
  687. }
  688. return params;
  689. }
  690. function q(name) {
  691. var v = mergeSearchAndHashParams().get(name);
  692. return v == null ? '' : String(v);
  693. }
  694. function buildAppOpenQueryStringMerged() {
  695. var params = mergeSearchAndHashParams();
  696. var gid = params.get('goodsId') || params.get('id') || '';
  697. if (gid && !params.has('goodsId')) {
  698. params.set('goodsId', gid);
  699. }
  700. var sid = params.get('storeId') || params.get('id') || '';
  701. if (sid && !params.has('storeId')) {
  702. params.set('storeId', sid);
  703. }
  704. var qsOut = params.toString();
  705. return qsOut ? ('?' + qsOut) : '';
  706. }
  707. function getSecondGoodsAppUniPath() {
  708. return String(APP_UNI_STORE_PATH || 'pages/secondHandTransactions/pages/detail/index').replace(
  709. /^\//,
  710. ''
  711. );
  712. }
  713. function buildAppDeepLink() {
  714. var path = getSecondGoodsAppUniPath();
  715. var s = buildAppOpenQueryStringMerged();
  716. var root = APP_IOS_URL_SCHEME.replace(/\/$/, '');
  717. if (!s) {
  718. return root + '/' + path;
  719. }
  720. return root + '/' + path + s;
  721. }
  722. /** Uni 路由串(无 shopro://),供 wx-open-launch-app extinfo */
  723. function buildAppUniPageLaunchUrl() {
  724. var path = getSecondGoodsAppUniPath();
  725. var qs = buildAppOpenQueryStringMerged().replace(/^\?/, '');
  726. return qs ? path + '?' + qs : path;
  727. }
  728. /**
  729. * wx-open-launch-app extinfo:pages/secondHandTransactions/pages/detail/index?goodsId=…
  730. */
  731. function buildWeChatLaunchExtinfo() {
  732. var uniPage = buildAppUniPageLaunchUrl();
  733. if (uniPage.length <= 1024) return uniPage;
  734. var params = mergeSearchAndHashParams();
  735. var mini = new URLSearchParams();
  736. var goodsId = params.get('goodsId') || params.get('id') || '';
  737. if (goodsId) mini.set('goodsId', goodsId);
  738. var path = getSecondGoodsAppUniPath();
  739. var shortPage = path + '?' + mini.toString();
  740. if (shortPage.length <= 1024) return shortPage;
  741. return shortPage.slice(0, 1024);
  742. }
  743. function isWeChatInAppBrowser() {
  744. return /MicroMessenger/i.test(navigator.userAgent || '');
  745. }
  746. function getWxShareEntryFrom() {
  747. var from = q('from');
  748. if (from) return String(from).trim().toLowerCase();
  749. try {
  750. var h = location.hash || '';
  751. var qi = h.indexOf('?');
  752. if (qi >= 0) {
  753. var hf = new URLSearchParams(h.slice(qi + 1)).get('from');
  754. if (hf) return String(hf).trim().toLowerCase();
  755. }
  756. } catch (eH) {}
  757. try {
  758. var sf = new URLSearchParams(location.search || '').get('from');
  759. if (sf) return String(sf).trim().toLowerCase();
  760. } catch (eS) {}
  761. return '';
  762. }
  763. function logWxEntryDiagnostics() {
  764. if (!isWeChatInAppBrowser()) return;
  765. console.log('[wx-entry]', {
  766. entryFrom: getWxShareEntryFrom() || '(无)',
  767. wxJssdkReady: weChatJssdkConfigured,
  768. signUrl: getWxConfigSignUrl()
  769. });
  770. }
  771. function isIOSWeChatBrowser() {
  772. var ua = navigator.userAgent || '';
  773. return /MicroMessenger/i.test(ua) && /iPhone|iPad|iPod/i.test(ua);
  774. }
  775. function readQueryParam(name) {
  776. return q(name);
  777. }
  778. function isWxDebugOn() {
  779. return readQueryParam('wxDebug') === '1';
  780. }
  781. function isWxForceDebug() {
  782. return readQueryParam('wxForce') === '1';
  783. }
  784. function isWxConfigOnClickDebug() {
  785. return readQueryParam('wxConfigOnClick') === '1';
  786. }
  787. function isWxPcAutoDebugHost() {
  788. var h = (location.hostname || '').toLowerCase();
  789. if (h === 'localhost' || h === '127.0.0.1') return true;
  790. for (var i = 0; i < WECHAT_JS_SAFE_HOSTS.length; i++) {
  791. if (WECHAT_JS_SAFE_HOSTS[i] === h) return true;
  792. }
  793. return false;
  794. }
  795. function isWxPcBrowser() {
  796. return !isWeChatInAppBrowser();
  797. }
  798. function shouldInitWeChatJssdkOnLoad() {
  799. if (isWeChatInAppBrowser()) return true;
  800. return isWxForceDebug() || isWxPcAutoDebugHost();
  801. }
  802. function shouldFetchWxConfig(fromUserClick) {
  803. if (isWeChatInAppBrowser()) return true;
  804. if (fromUserClick) return true;
  805. return isWxForceDebug() || isWxPcAutoDebugHost();
  806. }
  807. function getWxHtmlUrl() {
  808. var forced = String(q('wxSignUrl') || '').trim();
  809. if (forced) return forced.split('#')[0];
  810. return String(location.href || '').split('#')[0];
  811. }
  812. function getWxSignPageUrlForApi() {
  813. var htmlUrl = getWxHtmlUrl();
  814. if (htmlUrl && /^https?:\/\//i.test(htmlUrl)) return htmlUrl;
  815. return WX_GET_CONFIG_SIGN_URL;
  816. }
  817. function getWxHtmlUrlBase() {
  818. var htmlUrl = getWxSignPageUrlForApi();
  819. try {
  820. var u = new URL(htmlUrl);
  821. return u.origin + u.pathname;
  822. } catch (eU) {
  823. return WX_GET_CONFIG_SIGN_URL;
  824. }
  825. }
  826. function getWxConfigSignUrl() {
  827. if (String(q('wxSignBaseOnly') || '') === '1') return getWxHtmlUrlBase();
  828. return getWxSignPageUrlForApi();
  829. }
  830. function getWxGetConfigApiUrl() {
  831. return API_BASE.replace(/\/$/, '') + WECHAT_GET_WX_CONFIG_PATH;
  832. }
  833. function buildWxGetConfigRequestBody(htmlUrl) {
  834. return {
  835. url: String(htmlUrl || '').split('#')[0].trim()
  836. };
  837. }
  838. function resolveWxConfigAppIdFromSignData(d) {
  839. if (!d || typeof d !== 'object') return '';
  840. var mp =
  841. d.mpAppId ||
  842. d.mpAppid ||
  843. d.officialAppId ||
  844. d.gzhAppId ||
  845. d.serviceAppId;
  846. if (mp != null && String(mp).trim() !== '') return String(mp).trim();
  847. var fromQuery = String(q('wxMpAppId') || WECHAT_MP_APP_ID || '').trim();
  848. if (fromQuery) return fromQuery;
  849. var raw = d.appId || d.appid || d.wxAppId;
  850. return raw != null && String(raw).trim() !== '' ? String(raw).trim() : '';
  851. }
  852. function normalizeWxJssdkSignPayload(res, signUrlUsed) {
  853. if (!res || typeof res !== 'object') return null;
  854. var d = res.data != null && typeof res.data === 'object' ? res.data : res;
  855. if (!d || typeof d !== 'object') return null;
  856. var appId = resolveWxConfigAppIdFromSignData(d);
  857. var timestamp = d.timestamp != null ? d.timestamp : d.timeStamp;
  858. var nonceStr =
  859. d.nonceStr != null && String(d.nonceStr) !== ''
  860. ? d.nonceStr
  861. : d.noncestr != null && String(d.noncestr) !== ''
  862. ? d.noncestr
  863. : d.nonce;
  864. var signature = d.signature || d.sign;
  865. if (!appId || timestamp == null || nonceStr == null || nonceStr === '' || !signature) {
  866. return null;
  867. }
  868. return {
  869. appId: String(appId),
  870. timestamp: Number(timestamp),
  871. nonceStr: String(nonceStr),
  872. signature: String(signature),
  873. signUrl: String(signUrlUsed || '')
  874. .split('#')[0]
  875. .trim()
  876. };
  877. }
  878. function getWxErrMsg(err) {
  879. if (!err) return '';
  880. if (err.errMsg) return String(err.errMsg);
  881. if (typeof err === 'string') return err;
  882. try {
  883. return JSON.stringify(err);
  884. } catch (e) {
  885. return String(err);
  886. }
  887. }
  888. function formatWxConfigErrorTip(err, signPageUrl) {
  889. var errMsg = getWxErrMsg(err);
  890. var tip = '微信 JSSDK 配置失败';
  891. if (/invalid signature/i.test(errMsg)) {
  892. return (
  893. tip +
  894. ':签名无效。url=' +
  895. (signPageUrl || getWxHtmlUrl()) +
  896. ';appId=' +
  897. WECHAT_MP_APP_ID
  898. );
  899. }
  900. if (/require\s*subscribe/i.test(errMsg)) {
  901. return tip + ':' + errMsg + '(服务号需用户已关注)';
  902. }
  903. return errMsg ? tip + ':' + errMsg : tip;
  904. }
  905. function setWxInitError(msg) {
  906. wxInitLastError = String(msg || '').trim();
  907. if (wxInitLastError) console.warn('[wx]', wxInitLastError);
  908. }
  909. function requestWeChatJssdkSignAndConfig(htmlUrlOptional) {
  910. var htmlUrl = String(
  911. htmlUrlOptional != null ? htmlUrlOptional : getWxConfigSignUrl()
  912. )
  913. .split('#')[0]
  914. .trim();
  915. if (!htmlUrl || !/^https?:\/\//i.test(htmlUrl)) {
  916. htmlUrl = WX_GET_CONFIG_SIGN_URL;
  917. }
  918. if (isWxDebugOn()) {
  919. try {
  920. window.alert('htmlUrl(签名用):\n' + htmlUrl);
  921. } catch (eDbg) {}
  922. }
  923. var requestUrl = getWxGetConfigApiUrl();
  924. var requestBody = buildWxGetConfigRequestBody(htmlUrl);
  925. console.log('[wx] htmlUrl=', htmlUrl);
  926. console.log('[wx] POST getWxConfig →', requestUrl, requestBody);
  927. return fetch(requestUrl, {
  928. method: 'POST',
  929. mode: 'cors',
  930. credentials: 'omit',
  931. headers: {
  932. Accept: 'application/json',
  933. 'Content-Type': 'application/json;charset=UTF-8'
  934. },
  935. body: JSON.stringify(requestBody)
  936. })
  937. .then(function (r) {
  938. if (r.ok) return r.json();
  939. return r
  940. .text()
  941. .catch(function () {
  942. return '';
  943. })
  944. .then(function (text) {
  945. var hint = '';
  946. try {
  947. var j = JSON.parse(text);
  948. hint = j.msg || j.message || '';
  949. } catch (eP) {
  950. if (text) hint = text.slice(0, 120);
  951. }
  952. throw new Error('getWxConfig HTTP ' + r.status + (hint ? ':' + hint : ''));
  953. });
  954. })
  955. .then(function (res) {
  956. if (res && res.code != null) {
  957. var c = Number(res.code);
  958. if (c !== 200 && c !== 0 && res.success !== true) {
  959. throw new Error(res.msg || res.message || 'getWxConfig code ' + c);
  960. }
  961. }
  962. var sign = normalizeWxJssdkSignPayload(res, htmlUrl);
  963. if (!sign) {
  964. console.warn('[wx] getWxConfig 响应字段不全', res, 'htmlUrl=', htmlUrl);
  965. throw new Error(
  966. 'getWxConfig 缺少 appId/timestamp/nonceStr/signature(见控制台)'
  967. );
  968. }
  969. if (sign.appId !== WECHAT_MP_APP_ID) {
  970. console.warn(
  971. '[wx] 后端 appId=' + sign.appId + ',期望服务号 ' + WECHAT_MP_APP_ID
  972. );
  973. }
  974. if (typeof wx === 'undefined') {
  975. if (isWxPcBrowser()) {
  976. console.log('[wx] PC getWxConfig 成功(无 jweixin)', sign);
  977. return true;
  978. }
  979. setWxInitError('jweixin.js 未加载');
  980. return false;
  981. }
  982. return applyWxConfigFromSign(sign, htmlUrl);
  983. });
  984. }
  985. function applyWxConfigFromSign(sign, htmlUrl) {
  986. var wxConfigParams = {
  987. debug: isWxDebugOn(),
  988. appId: String(sign.appId),
  989. timestamp: sign.timestamp,
  990. nonceStr: String(sign.nonceStr),
  991. signature: String(sign.signature),
  992. jsApiList: [],
  993. openTagList: ['wx-open-launch-app']
  994. };
  995. return new Promise(function (resolve) {
  996. wx.config(wxConfigParams);
  997. wx.ready(function () {
  998. weChatJssdkConfigured = true;
  999. document.body.classList.add('wx-jssdk-ready');
  1000. refreshWxLaunchTagAttrs();
  1001. console.log('[wx.config] ready, htmlUrl=', htmlUrl);
  1002. resolve(true);
  1003. });
  1004. wx.error(function (err) {
  1005. weChatJssdkConfigured = false;
  1006. document.body.classList.remove('wx-jssdk-ready');
  1007. wxJssdkInitPromise = null;
  1008. var errMsg = getWxErrMsg(err);
  1009. setWxInitError(formatWxConfigErrorTip(err, htmlUrl));
  1010. if (isWxDebugOn()) window.alert(wxInitLastError);
  1011. console.warn('[wx.config]', errMsg, 'htmlUrl=', htmlUrl);
  1012. var baseUrl = getWxHtmlUrlBase();
  1013. var fullUrl = getWxSignPageUrlForApi();
  1014. if (
  1015. !/invalid signature/i.test(errMsg) ||
  1016. wxConfigSignRetriedBaseUrl ||
  1017. baseUrl === fullUrl ||
  1018. htmlUrl === baseUrl
  1019. ) {
  1020. resolve(false);
  1021. return;
  1022. }
  1023. wxConfigSignRetriedBaseUrl = true;
  1024. requestWeChatJssdkSignAndConfig(baseUrl).then(resolve);
  1025. });
  1026. });
  1027. }
  1028. function refreshWxLaunchTagAttrs() {
  1029. var tag = document.getElementById('launch-btn');
  1030. if (!tag) return;
  1031. try {
  1032. tag.setAttribute('appid', WECHAT_OPEN_APP_ID);
  1033. tag.setAttribute('extinfo', buildWeChatLaunchExtinfo());
  1034. } catch (eA) {}
  1035. }
  1036. function bindWeChatLaunchTagEvents() {
  1037. var tag = document.getElementById('launch-btn');
  1038. if (!tag || tag._wxLaunchBound) return;
  1039. tag._wxLaunchBound = true;
  1040. refreshWxLaunchTagAttrs();
  1041. tag.addEventListener('launch', function () {
  1042. console.log('[wx-open-launch-app] launch ok');
  1043. // showFabToast('正在打开 U店在哪…');
  1044. });
  1045. tag.addEventListener('error', function (e) {
  1046. var detail = e && e.detail;
  1047. var errMsg =
  1048. detail && detail.errMsg
  1049. ? String(detail.errMsg)
  1050. : detail && detail.errmsg
  1051. ? String(detail.errmsg)
  1052. : '';
  1053. console.warn('[wx-open-launch-app]', detail);
  1054. if (/launch:fail/i.test(errMsg) && !getWxShareEntryFrom()) {
  1055. showDownloadTip();
  1056. } else {
  1057. showAppOpenFailTip(
  1058. errMsg
  1059. ? '未能打开 App:' + errMsg
  1060. : '未能打开 App,请确认已安装最新版「U店在哪」'
  1061. );
  1062. }
  1063. });
  1064. }
  1065. function initWeChatOpenLaunchApp(fromUserClick) {
  1066. if (!shouldFetchWxConfig(!!fromUserClick)) {
  1067. return Promise.resolve(false);
  1068. }
  1069. if (wxJssdkInitPromise && !fromUserClick) return wxJssdkInitPromise;
  1070. wxConfigSignRetriedBaseUrl = false;
  1071. wxInitLastError = '';
  1072. var htmlUrl = getWxConfigSignUrl();
  1073. bindWeChatLaunchTagEvents();
  1074. wxJssdkInitPromise = requestWeChatJssdkSignAndConfig(htmlUrl)
  1075. .then(function (ok) {
  1076. if (ok === true) return true;
  1077. if (!wxInitLastError) {
  1078. setWxInitError('wx.config 失败,可加 ?wxDebug=1');
  1079. }
  1080. return false;
  1081. })
  1082. .catch(function (e) {
  1083. var msg = e && e.message ? e.message : 'getWxConfig 请求失败';
  1084. setWxInitError(msg);
  1085. console.warn('[wx] init failed', msg, 'htmlUrl=', htmlUrl);
  1086. if (isWeChatInAppBrowser() && isWxDebugOn()) window.alert(msg);
  1087. return false;
  1088. })
  1089. .finally(function () {
  1090. if (!weChatJssdkConfigured) wxJssdkInitPromise = null;
  1091. });
  1092. return wxJssdkInitPromise;
  1093. }
  1094. function scheduleWeChatJssdkBootstrap() {
  1095. if (!shouldInitWeChatJssdkOnLoad()) return;
  1096. var attempts = 0;
  1097. function tick() {
  1098. attempts += 1;
  1099. if (weChatJssdkConfigured) return;
  1100. initWeChatOpenLaunchApp();
  1101. if (!weChatJssdkConfigured && attempts < 8 && typeof wx === 'undefined') {
  1102. setTimeout(tick, 400);
  1103. }
  1104. }
  1105. /* iOS 微信分享卡片可能稍后才写入 from 等参数,过早验签会 invalid signature */
  1106. if (isIOSWeChatBrowser()) {
  1107. setTimeout(tick, 350);
  1108. } else {
  1109. tick();
  1110. }
  1111. }
  1112. function showFabToast(msg, ms) {
  1113. var tip = String(msg || '').trim();
  1114. if (!tip) return;
  1115. var el = document.getElementById('openAppToast');
  1116. if (el) {
  1117. el.textContent = tip;
  1118. el.style.display = 'block';
  1119. if (showFabToast._t) clearTimeout(showFabToast._t);
  1120. showFabToast._t = setTimeout(function () {
  1121. el.style.display = 'none';
  1122. }, ms || 2800);
  1123. }
  1124. console.log('[openApp]', tip);
  1125. }
  1126. function showAppOpenFailTip(msg) {
  1127. var tip = msg || '未能打开 App,请确认已安装最新版「U店在哪」。';
  1128. if (typeof uni !== 'undefined' && typeof uni.showToast === 'function') {
  1129. uni.showToast({ title: tip, icon: 'none', duration: 2800 });
  1130. } else if (isWeChatInAppBrowser()) {
  1131. window.alert(tip);
  1132. } else {
  1133. console.warn('[openApp]', tip);
  1134. }
  1135. }
  1136. function tryFetchWxConfigOnPcClick() {
  1137. if (!isWxPcBrowser()) return Promise.resolve(false);
  1138. showFabToast('正在请求 getWxConfig…');
  1139. wxJssdkInitPromise = null;
  1140. return initWeChatOpenLaunchApp(true).then(function (ok) {
  1141. if (ok) {
  1142. showFabToast(
  1143. weChatJssdkConfigured
  1144. ? 'getWxConfig 成功,wx.config 已就绪'
  1145. : 'getWxConfig 成功'
  1146. );
  1147. } else {
  1148. showFabToast(wxInitLastError || 'getWxConfig 失败');
  1149. }
  1150. return ok;
  1151. });
  1152. }
  1153. function launchAppDeepLink(deepLink) {
  1154. try {
  1155. var a = document.createElement('a');
  1156. a.href = deepLink;
  1157. a.setAttribute('target', '_self');
  1158. document.body.appendChild(a);
  1159. a.click();
  1160. document.body.removeChild(a);
  1161. } catch (e1) {}
  1162. try {
  1163. window.location.href = deepLink;
  1164. } catch (e2) {}
  1165. }
  1166. function tryOpenHBuilderApp() {
  1167. if (isWeChatInAppBrowser()) return;
  1168. tryFetchWxConfigOnPcClick().then(function () {
  1169. if (isWxConfigOnClickDebug() && !isWxForceDebug() && !isWxPcAutoDebugHost()) {
  1170. return;
  1171. }
  1172. tryOpenHBuilderAppViaScheme();
  1173. });
  1174. }
  1175. function tryOpenHBuilderAppViaScheme() {
  1176. // showFabToast('正在打开 U店在哪…');
  1177. var deepLink = buildAppDeepLink();
  1178. if (typeof plus !== 'undefined' && plus.runtime) {
  1179. var installed = null;
  1180. try {
  1181. if (typeof plus.runtime.isApplicationExist === 'function') {
  1182. installed = plus.runtime.isApplicationExist({
  1183. pname: APP_ANDROID_PACKAGE,
  1184. action: APP_IOS_URL_SCHEME
  1185. });
  1186. }
  1187. } catch (e) {
  1188. console.warn(e);
  1189. }
  1190. if (installed === false) {
  1191. showDownloadTip();
  1192. return;
  1193. }
  1194. try {
  1195. plus.runtime.openURL(deepLink);
  1196. } catch (e2) {
  1197. console.warn(e2);
  1198. showDownloadTip();
  1199. }
  1200. return;
  1201. }
  1202. var t0 = Date.now();
  1203. var done = false;
  1204. function finish() {
  1205. if (done) return;
  1206. done = true;
  1207. document.removeEventListener('visibilitychange', onVis);
  1208. window.removeEventListener('pagehide', onHide);
  1209. }
  1210. function onVis() {
  1211. if (document.visibilityState === 'hidden') finish();
  1212. }
  1213. function onHide() {
  1214. finish();
  1215. }
  1216. document.addEventListener('visibilitychange', onVis);
  1217. window.addEventListener('pagehide', onHide);
  1218. try {
  1219. launchAppDeepLink(deepLink);
  1220. } catch (e3) {
  1221. finish();
  1222. showDownloadTip();
  1223. return;
  1224. }
  1225. window.setTimeout(function () {
  1226. if (done) return;
  1227. finish();
  1228. showDownloadTip();
  1229. }, 2600);
  1230. }
  1231. function tryDecode(s) {
  1232. s = String(s || '');
  1233. if (!s) return '';
  1234. try {
  1235. return decodeURIComponent(s.replace(/\+/g, ' '));
  1236. } catch (e) {
  1237. return s;
  1238. }
  1239. }
  1240. var DEFAULT_HERO = '';
  1241. /** 二手商品接口前缀;可用 URL 参数 alienSecondBase / secondApiBase 覆盖 */
  1242. function resolveSecondApiBase() {
  1243. var custom = (q('alienSecondBase') || q('secondApiBase') || '').trim();
  1244. if (custom) {
  1245. return custom.replace(/\/+$/, '');
  1246. }
  1247. var host = (location.hostname || '').toLowerCase();
  1248. if (host === 'prod.ailien.shop' || host === 'uat.ailien.shop') {
  1249. return 'https://prod.ailien.shop/alienSecond';
  1250. }
  1251. return 'http://120.26.186.130:8000/alienSecond';
  1252. }
  1253. var API_BASE_SECOND = resolveSecondApiBase();
  1254. /** 与 querySecondGoodsDetailWithOutJWT 表单一致;优先地址栏,否则默认坐标 */
  1255. var DEFAULT_REQUEST_LONGITUDE =
  1256. (q('longitude') || q('lon') || q('jingdu') || '').trim() || '121.662527';
  1257. var DEFAULT_REQUEST_LATITUDE =
  1258. (q('latitude') || q('lat') || q('weidu') || '').trim() || '38.925754';
  1259. var COMMENT_SOURCE_TYPE = 4;
  1260. function apiGet(path) {
  1261. return fetch(API_BASE + path, {
  1262. method: 'GET',
  1263. mode: 'cors',
  1264. credentials: 'omit',
  1265. headers: { Accept: 'application/json' }
  1266. }).then(function (res) {
  1267. if (!res.ok) throw new Error('HTTP ' + res.status);
  1268. return res.json();
  1269. });
  1270. }
  1271. function apiPostJson(path, body) {
  1272. return fetch(API_BASE + path, {
  1273. method: 'POST',
  1274. mode: 'cors',
  1275. credentials: 'omit',
  1276. headers: {
  1277. Accept: 'application/json',
  1278. 'Content-Type': 'application/json'
  1279. },
  1280. body: JSON.stringify(body || {})
  1281. }).then(function (res) {
  1282. if (!res.ok) throw new Error('HTTP ' + res.status);
  1283. return res.json();
  1284. });
  1285. }
  1286. function pick(d, keys) {
  1287. if (!d || typeof d !== 'object') return null;
  1288. for (var i = 0; i < keys.length; i++) {
  1289. var k = keys[i];
  1290. if (d[k] != null && d[k] !== '') return d[k];
  1291. }
  1292. return null;
  1293. }
  1294. function isApiOk(res) {
  1295. if (!res || typeof res !== 'object') return false;
  1296. if (res.success === false) return false;
  1297. var c = res.code;
  1298. return c === 200 || c === '200' || Number(c) === 200;
  1299. }
  1300. /** 二手详情存在性接口:兼容 code 0 / success:true(与 alienSecond 常见返回一致) */
  1301. function isSecondGoodsExistOk(res) {
  1302. if (!res || typeof res !== 'object') return false;
  1303. if (res.success === false) return false;
  1304. if (res.success === true) return true;
  1305. var c = res.code;
  1306. if (c === 200 || c === '200' || Number(c) === 200) return true;
  1307. if (c === 0 || c === '0' || Number(c) === 0) return true;
  1308. return false;
  1309. }
  1310. function pickSecondGoodsDetailData(res) {
  1311. if (!res || typeof res !== 'object') return null;
  1312. var d = res.data != null ? res.data : res.result;
  1313. if (d == null) return null;
  1314. if (Array.isArray(d)) {
  1315. return d.length && typeof d[0] === 'object' ? d[0] : null;
  1316. }
  1317. if (typeof d !== 'object') return null;
  1318. var inner =
  1319. d.secondGoodsDetail ||
  1320. d.goodsDetail ||
  1321. d.goodsInfo ||
  1322. d.detail ||
  1323. d.record;
  1324. if (inner && typeof inner === 'object' && !Array.isArray(inner)) {
  1325. return inner;
  1326. }
  1327. return d;
  1328. }
  1329. /** 详情里是否有可识别的商品实体(有则视为存在,不依赖 goodsStatus 数值) */
  1330. function hasSecondGoodsDetailPayload(d) {
  1331. if (!d || typeof d !== 'object') return false;
  1332. var id = d.goodsId != null ? d.goodsId : d.id;
  1333. if (id != null && String(id).trim() !== '' && String(id).trim() !== '0') {
  1334. return true;
  1335. }
  1336. var name = d.goodsName || d.title || d.secondGoodsTitle || d.name;
  1337. if (name != null && String(name).trim() !== '') return true;
  1338. var img =
  1339. d.coverUrl ||
  1340. d.mainImage ||
  1341. d.goodsImage ||
  1342. d.firstImage ||
  1343. (Array.isArray(d.goodsImageList) && d.goodsImageList[0]);
  1344. if (img != null && String(img).trim() !== '') return true;
  1345. return Object.keys(d).length > 0;
  1346. }
  1347. function isDetailDataExplicitlyDeleted(d) {
  1348. if (!d || typeof d !== 'object') return false;
  1349. if (d.deleteFlag === 1 || d.deleteFlag === '1' || Number(d.deleteFlag) === 1) {
  1350. return true;
  1351. }
  1352. if (d.deleted === true || d.isDelete === 1 || d.isDelete === '1') {
  1353. return true;
  1354. }
  1355. return false;
  1356. }
  1357. /** 与店铺 getClientStoreDetail 一致:无商品时 code 仍可能为 200 */
  1358. function isNoCarryingDataMsg(res) {
  1359. if (!res || typeof res !== 'object') return false;
  1360. var msg = res.msg != null ? String(res.msg).trim() : '';
  1361. return msg === '暂无承载数据';
  1362. }
  1363. function isMsgIndicateGoodsGone(msg) {
  1364. msg = String(msg || '').trim();
  1365. if (!msg) return false;
  1366. if (msg === '暂无承载数据') return true;
  1367. return /已删除|已下架|已卖出|商品不存在|不存在该|查无此商品|找不到该商品|商品不可用/.test(
  1368. msg
  1369. );
  1370. }
  1371. function fmtPriceNum(v) {
  1372. var n = v != null ? Number(v) : NaN;
  1373. return !isNaN(n) ? n.toFixed(2) : String(v != null ? v : '');
  1374. }
  1375. /** kind: topic(#话题 棕橙)| label(分类名 深灰,不带 #) */
  1376. function appendGoodsTag(mount, raw, kind) {
  1377. if (!mount || raw == null) return;
  1378. var s = String(raw).trim();
  1379. if (!s) return;
  1380. var span = document.createElement('span');
  1381. span.className =
  1382. 'goods-tag ' + (kind === 'label' ? 'goods-tag--label' : 'goods-tag--topic');
  1383. if (kind === 'label') {
  1384. span.textContent = s.replace(/^#+/, '');
  1385. } else {
  1386. span.textContent = s.indexOf('#') === 0 ? s : '#' + s;
  1387. }
  1388. mount.appendChild(span);
  1389. }
  1390. function renderGoodsDetail(d) {
  1391. if (!d || typeof d !== 'object') return;
  1392. var title = pick(d, ['goodsName', 'title', 'secondGoodsTitle', 'name']);
  1393. if (title) {
  1394. var el = document.getElementById('goodsTitle');
  1395. if (el) el.textContent = String(title);
  1396. }
  1397. var price = pick(d, ['price', 'goodsPrice', 'salePrice', 'currentPrice', 'amount']);
  1398. if (price != null) {
  1399. var pe = document.getElementById('goodsPrice');
  1400. if (pe) pe.textContent = fmtPriceNum(price);
  1401. }
  1402. var dist = pick(d, ['dist', 'distance', 'distanceText', 'distanceDesc', 'distanceDescription', 'distanceKm']);
  1403. if (dist != null) {
  1404. var dt = String(dist).trim();
  1405. if (dt) {
  1406. if (!/^距离/.test(dt)) dt = '距离 ' + dt;
  1407. if (!/km$/i.test(dt) && !/千米/.test(dt) && !/米/.test(dt) && !/\s*m\s*$/i.test(dt)) {
  1408. dt = dt.replace(/\s+$/, '') + 'km';
  1409. }
  1410. var de = document.getElementById('goodsDistance');
  1411. if (de) de.textContent = dt;
  1412. }
  1413. }
  1414. var img =
  1415. pick(d, ['coverUrl', 'mainImage', 'goodsImage', 'firstImage', 'bannerUrl']) ||
  1416. (Array.isArray(d.goodsImageList) && d.goodsImageList[0]) ||
  1417. (Array.isArray(d.imageList) && d.imageList[0]);
  1418. if (img) {
  1419. var hi = document.getElementById('goodsHeroImg');
  1420. if (hi) {
  1421. hi.src = String(img);
  1422. hi.alt = '商品图';
  1423. }
  1424. }
  1425. var nick = pick(d, ['publishUserNick', 'userNickName', 'nickName', 'userName', 'publisherName']);
  1426. if (nick) {
  1427. var ne = document.getElementById('goodsUserName');
  1428. if (ne) ne.textContent = String(nick);
  1429. }
  1430. var av = pick(d, ['publishUserAvatar', 'userAvatar', 'userHead', 'avatar', 'headImg']);
  1431. if (av) {
  1432. var ae = document.getElementById('goodsUserAvatar');
  1433. if (ae) ae.src = String(av);
  1434. }
  1435. var tm = pick(d, ['timeAgo', 'releaseTime', 'publishTime', 'createTime', 'publishTimeStr']);
  1436. if (tm) {
  1437. var te = document.getElementById('goodsTimeAgo');
  1438. if (te) te.textContent = String(tm);
  1439. }
  1440. var s1 = pick(d, ['promotionLineOne', 'promotionTitle', 'subtitle', 'slogan1', 'line1']);
  1441. var s2 = pick(d, ['promotionLineTwo', 'subTitle', 'slogan2', 'line2']);
  1442. var wrap = document.getElementById('goodsHeroSloganWrap');
  1443. var e1 = document.getElementById('goodsSlogan1');
  1444. var e2 = document.getElementById('goodsSlogan2');
  1445. if (wrap && e1 && e2) {
  1446. if (s1 || s2) {
  1447. if (s1) e1.textContent = String(s1);
  1448. if (s2) e2.textContent = String(s2);
  1449. wrap.style.display = '';
  1450. } else {
  1451. wrap.style.display = 'none';
  1452. }
  1453. }
  1454. var hotStat = document.getElementById('goodsHotStat');
  1455. var cs = pick(d, ['collectStatus']);
  1456. if (hotStat) {
  1457. var hideHot =
  1458. cs != null &&
  1459. (Number(cs) === 0 || String(cs).trim() === '0');
  1460. hotStat.style.display = hideHot ? 'none' : '';
  1461. }
  1462. var hot = pick(d, ['browseCount', 'viewCount', 'hotCount', 'readCount']);
  1463. if (hot != null) {
  1464. var he = document.getElementById('goodsHotCount');
  1465. if (he) he.textContent = String(hot);
  1466. }
  1467. var fav = pick(d, ['collectCount', 'wantCount', 'favCount', 'favoriteCount']);
  1468. if (fav != null) {
  1469. var fe = document.getElementById('goodsFavCount');
  1470. if (fe) fe.textContent = String(fav);
  1471. }
  1472. var topicStr = d.topic != null ? String(d.topic).trim() : '';
  1473. var labelStr = d.label != null ? String(d.label).trim() : '';
  1474. var hasApiTags = topicStr !== '' || labelStr !== '';
  1475. var mount = document.getElementById('goodsTags');
  1476. if (mount) {
  1477. if (hasApiTags) {
  1478. mount.innerHTML = '';
  1479. if (topicStr) appendGoodsTag(mount, topicStr, 'topic');
  1480. if (labelStr) appendGoodsTag(mount, labelStr, 'label');
  1481. } else {
  1482. var tags = d.tagList || d.tags || d.labelList || d.goodsTags;
  1483. if (tags) {
  1484. mount.innerHTML = '';
  1485. var arr = Array.isArray(tags) ? tags : String(tags).split(/[,,]/);
  1486. arr.forEach(function (t) {
  1487. if (t == null || t === '') return;
  1488. var label =
  1489. typeof t === 'object'
  1490. ? (t.tagName || t.name || t.label || '')
  1491. : String(t);
  1492. label = String(label).trim();
  1493. if (!label) return;
  1494. var isTopic = label.indexOf('#') === 0;
  1495. appendGoodsTag(mount, label, isTopic ? 'topic' : 'label');
  1496. });
  1497. }
  1498. }
  1499. }
  1500. }
  1501. var SVG_LIKE = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M14 9V5a3 3 0 0 0-3-3l-4 9v11h11.28a2 2 0 0 0 2-1.7l1.38-9a2 2 0 0 0-2-2.3zM7 22H4a2 2 0 0 1-2-2v-7a2 2 0 0 1 2-2h3"/></svg>';
  1502. var SVG_REPLY = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"/></svg>';
  1503. var SVG_CHEV = '<svg class="goods-cmt__thread-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>';
  1504. function cmtAvatarUrl(c) {
  1505. return String(
  1506. pick(c, ['headImg', 'userAvatar', 'userHead', 'avatar', 'avatarUrl']) || ''
  1507. ).trim();
  1508. }
  1509. function cmtUserName(c) {
  1510. var s = String(pick(c, ['headName', 'userName', 'nickName', 'userNickName', 'commentUserName', 'headPhone']) || '—').trim();
  1511. return s || '—';
  1512. }
  1513. function cmtTime(c) {
  1514. return String(pick(c, ['createTime', 'createdTime', 'commentTime']) || '');
  1515. }
  1516. function cmtContent(c) {
  1517. return String(pick(c, ['content', 'commentContent', 'text']) || '');
  1518. }
  1519. function cmtLikeCount(c) {
  1520. var v = pick(c, ['likeCount', 'likeNum', 'praiseCount']);
  1521. return v != null ? String(v) : '0';
  1522. }
  1523. function cmtReplies(c) {
  1524. if (!c || typeof c !== 'object') return [];
  1525. var sub =
  1526. c.childCommonComments ||
  1527. c.replyList ||
  1528. c.replyVOList ||
  1529. c.children ||
  1530. c.subComments ||
  1531. c.replies;
  1532. if (sub == null) return [];
  1533. return Array.isArray(sub) ? sub.filter(Boolean) : [];
  1534. }
  1535. function appendCmtRow(parentBody, c, showReply) {
  1536. var row = document.createElement('div');
  1537. row.className = 'goods-cmt__row';
  1538. var img = document.createElement('img');
  1539. img.className = 'goods-cmt__avatar';
  1540. img.alt = '';
  1541. var au = cmtAvatarUrl(c);
  1542. img.src = au || 'images/demouser.png';
  1543. var body = document.createElement('div');
  1544. body.className = 'goods-cmt__body';
  1545. var name = document.createElement('span');
  1546. name.className = 'goods-cmt__name';
  1547. name.textContent = cmtUserName(c);
  1548. var time = document.createElement('span');
  1549. time.className = 'goods-cmt__time';
  1550. time.textContent = cmtTime(c);
  1551. var text = document.createElement('p');
  1552. text.className = 'goods-cmt__text';
  1553. text.textContent = cmtContent(c);
  1554. var actions = document.createElement('div');
  1555. actions.className = 'goods-cmt__actions';
  1556. var likeBtn = document.createElement('button');
  1557. likeBtn.type = 'button';
  1558. likeBtn.className = 'goods-cmt__action';
  1559. likeBtn.setAttribute('aria-label', '点赞');
  1560. likeBtn.innerHTML = SVG_LIKE + '<span>' + cmtLikeCount(c) + '</span>';
  1561. actions.appendChild(likeBtn);
  1562. if (showReply) {
  1563. var repBtn = document.createElement('button');
  1564. repBtn.type = 'button';
  1565. repBtn.className = 'goods-cmt__action';
  1566. repBtn.setAttribute('aria-label', '回复');
  1567. repBtn.innerHTML = SVG_REPLY + '<span>回复</span>';
  1568. actions.appendChild(repBtn);
  1569. }
  1570. body.appendChild(name);
  1571. body.appendChild(time);
  1572. body.appendChild(text);
  1573. body.appendChild(actions);
  1574. row.appendChild(img);
  1575. row.appendChild(body);
  1576. parentBody.appendChild(row);
  1577. return body;
  1578. }
  1579. function buildNestedCmt(c) {
  1580. var wrap = document.createElement('div');
  1581. wrap.className = 'goods-cmt goods-cmt--nested';
  1582. appendCmtRow(wrap, c, false);
  1583. return wrap;
  1584. }
  1585. function filterTopLevelComments(list) {
  1586. if (!Array.isArray(list) || !list.length) return [];
  1587. var top = list.filter(function (c) {
  1588. if (!c) return false;
  1589. var pid = c.parentId != null ? c.parentId : c.pid;
  1590. if (typeof pid === 'string') pid = pid.trim();
  1591. return pid == null || pid === '' || Number(pid) === 0;
  1592. });
  1593. return top.length ? top : list.slice();
  1594. }
  1595. function countCommentsInApiList(records) {
  1596. if (!Array.isArray(records)) return 0;
  1597. var tops = filterTopLevelComments(records);
  1598. var n = 0;
  1599. for (var i = 0; i < tops.length; i++) {
  1600. var c = tops[i];
  1601. if (!c) continue;
  1602. n += 1 + cmtReplies(c).length;
  1603. }
  1604. return n;
  1605. }
  1606. function normalizeCommentListPayload(d) {
  1607. if (typeof d === 'string') {
  1608. try {
  1609. d = JSON.parse(d);
  1610. } catch (e) {
  1611. return { records: [], total: 0 };
  1612. }
  1613. }
  1614. if (Array.isArray(d)) {
  1615. return { records: d, total: countCommentsInApiList(d) };
  1616. }
  1617. if (d && typeof d === 'object') {
  1618. var arr = d.records || d.list || d.rows;
  1619. if (!Array.isArray(arr) && Array.isArray(d.data)) arr = d.data;
  1620. if (!Array.isArray(arr)) arr = [];
  1621. var total =
  1622. d.total != null && !isNaN(Number(d.total))
  1623. ? Number(d.total)
  1624. : countCommentsInApiList(arr);
  1625. return { records: arr, total: total };
  1626. }
  1627. return { records: [], total: 0 };
  1628. }
  1629. function renderCommentsList(rows, total) {
  1630. var mount = document.getElementById('goodsCommentList');
  1631. var totEl = document.getElementById('goodsCommentTotal');
  1632. if (!mount) return;
  1633. mount.innerHTML = '';
  1634. var list = filterTopLevelComments(Array.isArray(rows) ? rows : []);
  1635. var n = total != null && !isNaN(Number(total)) ? Number(total) : countCommentsInApiList(Array.isArray(rows) ? rows : []);
  1636. if (totEl) totEl.textContent = String(n);
  1637. if (!list.length) {
  1638. var empty = document.createElement('li');
  1639. empty.className = 'goods-comments__empty';
  1640. empty.setAttribute('role', 'status');
  1641. empty.textContent = '暂无留言';
  1642. mount.appendChild(empty);
  1643. return;
  1644. }
  1645. list.forEach(function (c) {
  1646. if (!c) return;
  1647. var li = document.createElement('li');
  1648. li.className = 'goods-cmt';
  1649. appendCmtRow(li, c, true);
  1650. var replies = cmtReplies(c);
  1651. if (replies.length) {
  1652. var thread = document.createElement('div');
  1653. thread.className = 'goods-cmt__thread';
  1654. var inner = document.createElement('div');
  1655. inner.className = 'goods-cmt__replies-inner';
  1656. replies.forEach(function (r) {
  1657. if (r) inner.appendChild(buildNestedCmt(r));
  1658. });
  1659. var bar = document.createElement('button');
  1660. bar.type = 'button';
  1661. bar.className = 'goods-cmt__thread-bar';
  1662. bar.setAttribute('aria-expanded', 'true');
  1663. bar.innerHTML =
  1664. '<span>共<span class="js-reply-count">' + replies.length + '</span>条回复</span>' +
  1665. '<span class="goods-cmt__thread-bar-right">' +
  1666. '<span class="js-thread-label">收起</span>' + SVG_CHEV + '</span>';
  1667. thread.appendChild(inner);
  1668. thread.appendChild(bar);
  1669. li.appendChild(thread);
  1670. }
  1671. mount.appendChild(li);
  1672. });
  1673. }
  1674. function bindCommentThreadDelegation() {
  1675. var list = document.getElementById('goodsCommentList');
  1676. if (!list || list.dataset.threadDeleg) return;
  1677. list.dataset.threadDeleg = '1';
  1678. list.addEventListener('click', function (e) {
  1679. var bar = e.target.closest('.goods-cmt__thread-bar');
  1680. if (!bar) return;
  1681. var inner = bar.previousElementSibling;
  1682. if (!inner || !inner.classList.contains('goods-cmt__replies-inner')) return;
  1683. var collapsed = inner.classList.toggle('is-collapsed');
  1684. bar.classList.toggle('is-collapsed', collapsed);
  1685. bar.setAttribute('aria-expanded', collapsed ? 'false' : 'true');
  1686. var lab = bar.querySelector('.js-thread-label');
  1687. if (lab) lab.textContent = collapsed ? '展开' : '收起';
  1688. });
  1689. }
  1690. function buildShareUndefinedRedirectQuery(gs, ctx) {
  1691. ctx = ctx || {};
  1692. var uq = new URLSearchParams();
  1693. uq.set('goodsUnavailable', '1');
  1694. if (gs != null && String(gs).trim() !== '') {
  1695. uq.set('goodsStatus', String(gs).trim());
  1696. }
  1697. if (ctx.userId) uq.set('userId', String(ctx.userId));
  1698. if (ctx.longitude) uq.set('longitude', String(ctx.longitude));
  1699. if (ctx.latitude) uq.set('latitude', String(ctx.latitude));
  1700. if (ctx.userCity) uq.set('userCity', String(ctx.userCity));
  1701. var gid = ctx.goodsId || '';
  1702. if (gid) {
  1703. uq.set('goodsId', String(gid));
  1704. uq.set('id', String(gid));
  1705. }
  1706. return uq;
  1707. }
  1708. function redirectToShareUndefined(gs, ctx) {
  1709. window.location.replace(
  1710. 'shareUndefined.html?' + buildShareUndefinedRedirectQuery(gs, ctx).toString()
  1711. );
  1712. }
  1713. /** 从 querySecondGoodsDetailWithOutJWT 返回中解析 goodsStatus(兼容 data 嵌套) */
  1714. function pickGoodsStatusFromDetailResponse(res) {
  1715. if (!res || typeof res !== 'object') return null;
  1716. var d = pickSecondGoodsDetailData(res);
  1717. var candidates = [];
  1718. if (d && d.goodsStatus != null) candidates.push(d.goodsStatus);
  1719. if (res.goodsStatus != null) candidates.push(res.goodsStatus);
  1720. var raw = res.data != null ? res.data : res.result;
  1721. if (raw && typeof raw === 'object' && !Array.isArray(raw) && raw.goodsStatus != null) {
  1722. candidates.push(raw.goodsStatus);
  1723. }
  1724. var i;
  1725. for (i = 0; i < candidates.length; i++) {
  1726. var v = candidates[i];
  1727. if (v != null && String(v).trim() !== '') return v;
  1728. }
  1729. return null;
  1730. }
  1731. /** 仅 goodsStatus === 3 视为可展示;缺省或其它值均进不可用页 */
  1732. function isGoodsStatusAvailable(gs) {
  1733. if (gs == null || String(gs).trim() === '') return false;
  1734. return Number(gs) === 3 || String(gs).trim() === '3';
  1735. }
  1736. /**
  1737. * 存在性接口:以 goodsStatus 为准,不为 3(含缺失)→ 跳转 shareUndefined。
  1738. */
  1739. function isDetailResponseGoodsUnavailable(res) {
  1740. if (!res || typeof res !== 'object') return true;
  1741. if (!isSecondGoodsExistOk(res)) return true;
  1742. return !isGoodsStatusAvailable(pickGoodsStatusFromDetailResponse(res));
  1743. }
  1744. /**
  1745. * 仅用 querySecondGoodsDetailWithOutJWT 判断商品是否存在,不渲染接口返回的详情字段
  1746. * @returns {Promise<{redirected:boolean, exists:boolean}>}
  1747. */
  1748. function checkSecondGoodsExists(goodsId, lon, lat, phoneId, redirectCtx) {
  1749. var lonStr =
  1750. lon != null && String(lon).trim() !== ''
  1751. ? String(lon).trim()
  1752. : String(DEFAULT_REQUEST_LONGITUDE);
  1753. var latStr =
  1754. lat != null && String(lat).trim() !== ''
  1755. ? String(lat).trim()
  1756. : String(DEFAULT_REQUEST_LATITUDE);
  1757. var pid =
  1758. phoneId != null && String(phoneId).trim() !== ''
  1759. ? String(phoneId).trim()
  1760. : '';
  1761. /** 表单字段:键为 string,值一律 string(x-www-form-urlencoded) */
  1762. var formBody = {
  1763. goodsId: String(goodsId != null ? goodsId : '').trim(),
  1764. longitude: String(lonStr),
  1765. latitude: String(latStr),
  1766. phoneId: pid
  1767. };
  1768. var form = new URLSearchParams();
  1769. form.set('goodsId', formBody.goodsId);
  1770. form.set('longitude', formBody.longitude);
  1771. form.set('latitude', formBody.latitude);
  1772. form.set('phoneId', formBody.phoneId);
  1773. var detailUrl =
  1774. API_BASE_SECOND + '/recommend/querySecondGoodsDetailWithOutJWT';
  1775. var formStr = form.toString();
  1776. return fetch(detailUrl, {
  1777. method: 'POST',
  1778. mode: 'cors',
  1779. credentials: 'omit',
  1780. headers: {
  1781. Accept: 'application/json',
  1782. 'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8'
  1783. },
  1784. body: formStr
  1785. })
  1786. .then(function (res) {
  1787. if (!res.ok) throw new Error('HTTP ' + res.status);
  1788. return res.json();
  1789. })
  1790. .then(function (res) {
  1791. redirectCtx = redirectCtx || {};
  1792. var d = pickSecondGoodsDetailData(res);
  1793. if (isDetailResponseGoodsUnavailable(res)) {
  1794. var gs = pickGoodsStatusFromDetailResponse(res);
  1795. console.warn(
  1796. '[querySecondGoodsDetailWithOutJWT] unavailable goodsStatus=',
  1797. gs,
  1798. res && res.code,
  1799. res && res.msg,
  1800. d
  1801. );
  1802. redirectToShareUndefined(gs, redirectCtx);
  1803. return { redirected: true, exists: false };
  1804. }
  1805. return { redirected: false, exists: true };
  1806. });
  1807. }
  1808. function fetchCommentList(goodsId, userId, pageNum, pageSize) {
  1809. var st = (q('sourceType') || '').trim();
  1810. var sourceType = st && !isNaN(Number(st)) ? Number(st) : COMMENT_SOURCE_TYPE;
  1811. var path = '/commonComment/getListBySourceType?' +
  1812. 'sourceType=' + encodeURIComponent(String(sourceType)) +
  1813. '&sourceId=' + encodeURIComponent(String(goodsId)) +
  1814. '&pageNum=' + encodeURIComponent(String(pageNum || 1)) +
  1815. '&pageSize=' + encodeURIComponent(String(pageSize || 10)) +
  1816. '&userId=' + encodeURIComponent(userId != null ? String(userId) : '');
  1817. return apiGet(path).then(function (res) {
  1818. if (!isApiOk(res)) {
  1819. if (res && res.msg) console.warn('[getListBySourceType]', res.msg);
  1820. renderCommentsList([], 0);
  1821. return;
  1822. }
  1823. var raw = res.data != null ? res.data : res.result;
  1824. var pack = normalizeCommentListPayload(raw);
  1825. renderCommentsList(pack.records, pack.total);
  1826. });
  1827. }
  1828. /** 分享卡片常用 sourceId;与留言 sourceId 一致 */
  1829. function getShareGoodsId() {
  1830. return (q('goodsId') || q('id') || q('sourceId') || '').trim();
  1831. }
  1832. function run() {
  1833. var goodsId = getShareGoodsId();
  1834. var userId = (q('userId') || '').trim();
  1835. var phoneId = (q('phoneId') || q('phone_id') || '').trim();
  1836. var lon = (q('longitude') || q('lon') || q('jingdu') || '').trim();
  1837. var lat = (q('latitude') || q('lat') || q('weidu') || '').trim();
  1838. var userCity = (q('userCity') || q('city') || '').trim();
  1839. var lonResolved = lon || DEFAULT_REQUEST_LONGITUDE;
  1840. var latResolved = lat || DEFAULT_REQUEST_LATITUDE;
  1841. var pageNum = (q('pageNum') || '1').trim();
  1842. var pageSize = (q('pageSize') || '10').trim();
  1843. var redirectCtx = {
  1844. goodsId: goodsId,
  1845. userId: userId,
  1846. longitude: lonResolved,
  1847. latitude: latResolved,
  1848. userCity: userCity
  1849. };
  1850. bindCommentThreadDelegation();
  1851. /* 分享卡片应带 goodsId;勿因 URL 残留 goodsUnavailable=1 跳过存在性校验直接进不可用页 */
  1852. if (
  1853. !goodsId &&
  1854. String(q('goodsUnavailable') || '').trim() === '1'
  1855. ) {
  1856. redirectToShareUndefined(q('goodsStatus'), redirectCtx);
  1857. return;
  1858. }
  1859. if (!goodsId) {
  1860. applyFromUrl();
  1861. return;
  1862. }
  1863. checkSecondGoodsExists(goodsId, lon, lat, phoneId, redirectCtx)
  1864. .catch(function (e) {
  1865. console.warn('[querySecondGoodsDetailWithOutJWT]', e);
  1866. return { redirected: false, exists: null, checkFailed: true };
  1867. })
  1868. .then(function (checkResult) {
  1869. if (checkResult && checkResult.redirected) {
  1870. return;
  1871. }
  1872. applyFromUrl();
  1873. return fetchCommentList(goodsId, userId, pageNum, pageSize).catch(function (e) {
  1874. console.warn('[getListBySourceType]', e);
  1875. renderCommentsList([], 0);
  1876. });
  1877. });
  1878. }
  1879. function applyFromUrl() {
  1880. var heroImg = document.getElementById('goodsHeroImg');
  1881. var imgUrl = q('image') || q('goodsImage') || q('coverUrl') || q('img');
  1882. imgUrl = tryDecode(imgUrl).trim();
  1883. if (imgUrl) {
  1884. heroImg.src = imgUrl;
  1885. heroImg.alt = '商品图';
  1886. } else {
  1887. heroImg.src = DEFAULT_HERO;
  1888. heroImg.alt = '';
  1889. }
  1890. var av = tryDecode(q('userImage') || q('avatar')).trim();
  1891. document.getElementById('goodsUserAvatar').src = av || 'images/demouser.png';
  1892. var uname = tryDecode(q('userName') || q('nickname')).trim();
  1893. if (uname) document.getElementById('goodsUserName').textContent = uname;
  1894. var ago = tryDecode(q('timeAgo') || q('publishTime')).trim();
  1895. if (ago) document.getElementById('goodsTimeAgo').textContent = ago;
  1896. var s1 = tryDecode(q('slogan1') || q('line1')).trim();
  1897. var s2 = tryDecode(q('slogan2') || q('line2')).trim();
  1898. var elS1 = document.getElementById('goodsSlogan1');
  1899. var elS2 = document.getElementById('goodsSlogan2');
  1900. var elWrap = document.getElementById('goodsHeroSloganWrap');
  1901. if (s1 && elS1) elS1.textContent = s1;
  1902. if (s2 && elS2) elS2.textContent = s2;
  1903. if (elWrap && (s1 || s2)) elWrap.style.display = '';
  1904. var price = tryDecode(q('price')).trim();
  1905. if (price) {
  1906. var pn = parseFloat(price.replace(/[^\d.]/g, ''));
  1907. document.getElementById('goodsPrice').textContent =
  1908. !isNaN(pn) ? pn.toFixed(2) : price;
  1909. }
  1910. var dist = tryDecode(q('distance') || q('distanceKm') || q('dist')).trim();
  1911. if (dist) {
  1912. if (!/^距离/.test(dist)) dist = '距离 ' + dist;
  1913. if (!/km$/i.test(dist) && !/千米/.test(dist) && !/米/.test(dist) && !/\s*m\s*$/i.test(dist)) {
  1914. dist = dist.replace(/\s+$/, '') + 'km';
  1915. }
  1916. document.getElementById('goodsDistance').textContent = dist;
  1917. }
  1918. var title = tryDecode(q('title') || q('goodsTitle')).trim();
  1919. if (title) document.getElementById('goodsTitle').textContent = title;
  1920. var hot = tryDecode(q('hotCount') || q('hot')).trim();
  1921. if (hot) document.getElementById('goodsHotCount').textContent = hot;
  1922. var fav = tryDecode(q('favCount') || q('fav') || q('collectCount')).trim();
  1923. if (fav) document.getElementById('goodsFavCount').textContent = fav;
  1924. var cc = tryDecode(q('commentCount') || q('comments')).trim();
  1925. if (cc) {
  1926. var elTot = document.getElementById('goodsCommentTotal');
  1927. if (elTot) elTot.textContent = cc;
  1928. }
  1929. var tagsRaw = tryDecode(q('tags') || q('tag')).trim();
  1930. var mount = document.getElementById('goodsTags');
  1931. var hasGoodsId = (q('goodsId') || q('id') || '').trim();
  1932. if (mount) {
  1933. if (tagsRaw) {
  1934. mount.innerHTML = '';
  1935. tagsRaw.split(/[,,]/).map(function (t) { return t.trim(); }).filter(Boolean).forEach(function (t) {
  1936. appendGoodsTag(mount, t, t.indexOf('#') === 0 ? 'topic' : 'label');
  1937. });
  1938. } else if (!hasGoodsId) {
  1939. mount.innerHTML = '';
  1940. ['复古冰箱', '网红冰箱', '复古烤漆', '冰箱'].forEach(function (t) {
  1941. appendGoodsTag(mount, t, 'label');
  1942. });
  1943. }
  1944. }
  1945. }
  1946. function sharePage() {
  1947. var title = document.getElementById('goodsTitle').textContent || '商品分享';
  1948. var url = location.href;
  1949. if (navigator.share) {
  1950. navigator.share({ title: title, text: title, url: url }).catch(function () {});
  1951. return;
  1952. }
  1953. if (navigator.clipboard && navigator.clipboard.writeText) {
  1954. navigator.clipboard.writeText(url).then(function () {
  1955. window.alert('链接已复制');
  1956. }).catch(function () {
  1957. window.prompt('复制链接', url);
  1958. });
  1959. } else {
  1960. window.prompt('复制链接', url);
  1961. }
  1962. }
  1963. var shareBtn = document.getElementById('goodsShareBtn');
  1964. if (shareBtn) shareBtn.addEventListener('click', sharePage);
  1965. function boot() {
  1966. var launchTag = document.getElementById('launch-btn');
  1967. if (launchTag) launchTag.setAttribute('appid', WECHAT_OPEN_APP_ID);
  1968. bindWeChatLaunchTagEvents();
  1969. if (isWeChatInAppBrowser()) {
  1970. document.body.classList.add('is-wechat');
  1971. logWxEntryDiagnostics();
  1972. }
  1973. if (shouldInitWeChatJssdkOnLoad()) {
  1974. if (isWxPcBrowser() && (isWxForceDebug() || isWxPcAutoDebugHost())) {
  1975. document.body.classList.add('wx-pc-debug');
  1976. }
  1977. scheduleWeChatJssdkBootstrap();
  1978. }
  1979. document.addEventListener('WeixinOpenTagsError', function (e) {
  1980. console.warn('[WeixinOpenTagsError]', e && e.detail);
  1981. });
  1982. if (isWeChatInAppBrowser()) {
  1983. var openBtnWx = document.getElementById('openApp');
  1984. if (openBtnWx) {
  1985. openBtnWx.addEventListener('click', function () {
  1986. if (!weChatJssdkConfigured) {
  1987. showFabToast(
  1988. wxInitLastError || '微信 SDK 初始化中,请稍候再点底部按钮'
  1989. );
  1990. }
  1991. });
  1992. }
  1993. } else {
  1994. var openAppBtn = document.getElementById('openApp');
  1995. if (openAppBtn) {
  1996. openAppBtn.addEventListener('click', tryOpenHBuilderApp);
  1997. }
  1998. }
  1999. run();
  2000. }
  2001. if (document.readyState === 'complete') {
  2002. boot();
  2003. } else {
  2004. window.onload = boot;
  2005. }
  2006. })();
  2007. </script>
  2008. </body>
  2009. </html>