detail.vue 107 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366
  1. <template>
  2. <view class="page">
  3. <view class="pageDecor">
  4. <view class="pageGlow glowA" />
  5. <view class="pageGlow glowB" />
  6. <view class="pageGlow glowC" />
  7. <view class="pageGrain" />
  8. </view>
  9. <!-- 顶部留白:兼容 iOS 刘海 -->
  10. <view class="safeTop" />
  11. <!-- 品牌页头:任何状态下均显示 -->
  12. <view class="brandPageHeader">
  13. <view class="brandPageHeaderInner">
  14. <text class="brandPageHeaderName">佳友厚苑</text>
  15. <view class="brandPageHeaderDot" />
  16. <text class="brandPageHeaderLabel">官方溯源 品质可验</text>
  17. </view>
  18. </view>
  19. <!-- ===== 加载中状态 ===== -->
  20. <view v-if="!traceLoaded" class="loadingState">
  21. <text class="loadingText">溯源信息加载中…</text>
  22. </view>
  23. <!-- ===== 数据加载完成后:正常态 / 异常态 ===== -->
  24. <view v-else class="mainContent">
  25. <!-- 正常态:已发布 -->
  26. <view v-if="canShowTraceContent">
  27. <!-- Hero 首屏:商品图 + 品牌氛围 + 商品信息面板 -->
  28. <view class="hero">
  29. <view class="heroCard">
  30. <!-- Hero 视觉区:商品图 + 品牌氛围 -->
  31. <view class="heroBg">
  32. <image
  33. class="heroImage"
  34. :src="traceDetail.product?.image || traceDetail.farm?.image"
  35. mode="aspectFill"
  36. />
  37. <!-- 底部大字号水印,营造品牌氛围 -->
  38. <view class="heroBrandAnchor">
  39. <text class="heroBrandAnchorText">JIAYOU</text>
  40. </view>
  41. <!-- 光感层:多层次渐变 + 景深 + 底部暗化 -->
  42. <view class="heroMask" />
  43. </view>
  44. <!-- 商品信息面板:嵌入 Hero 底部,与 Hero 自然过渡 -->
  45. <view class="heroInfoPanel">
  46. <view class="infoPanelInner">
  47. <view class="sectionHeader">
  48. <view class="sectionHeaderLeft">
  49. <text class="sectionEn">Product</text>
  50. <text class="sectionTitle">商品信息</text>
  51. </view>
  52. <view v-if="traceDetail.batch?.statusBadge" class="trustBadge" :class="traceDetail.batch.statusBadge.type">
  53. <!-- 认证徽章 SVG:双圆环 + 对勾,图标主视觉,文字辅助 -->
  54. <svg class="trustBadgeIcon" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
  55. <circle cx="10" cy="10" r="9" stroke="rgba(27,71,42,0.38)" stroke-width="0.9" />
  56. <circle cx="10" cy="10" r="5.5" stroke="rgba(27,71,42,0.22)" stroke-width="0.7" />
  57. <path d="M6.6 10.4L9.1 12.9L13.8 8" stroke="rgba(27,71,42,0.8)" stroke-width="1.15" stroke-linecap="round" stroke-linejoin="round" />
  58. </svg>
  59. <text class="trustBadgeText">{{ traceDetail.batch.statusBadge.text }}</text>
  60. </view>
  61. </view>
  62. <view class="infoPanelBody">
  63. <text class="infoPanelName">{{ traceDetail.product.name }}</text>
  64. <view v-if="traceDetail.product.spec" class="infoPanelSpec">
  65. <view class="specDot" />
  66. <text class="specText">{{ traceDetail.product.spec }}</text>
  67. </view>
  68. <view v-if="traceDetail.product?.intro" class="infoPanelIntro">
  69. <text>{{ traceDetail.product.intro }}</text>
  70. </view>
  71. </view>
  72. </view>
  73. </view>
  74. </view>
  75. </view>
  76. <scroll-view class="content" scroll-y>
  77. <!-- 溯源信息卡:融合溯源结论 + 批次核心信息 -->
  78. <view v-if="traceDetail.batch?.exists && traceDetail.traceConclusionCard" class="card cardLevel1 cardConclusion">
  79. <view class="sectionHeader">
  80. <view class="sectionHeaderLeft">
  81. <text class="sectionEn">Conclusion</text>
  82. <text class="sectionTitle">溯源信息</text>
  83. </view>
  84. </view>
  85. <!-- 溯源信息卡片主体:三层竖向结构 -->
  86. <view class="conclusionIdentity">
  87. <!-- 第一层:批次号主信息区 -->
  88. <view class="conclusionBatchWrap">
  89. <text class="conclusionBatchLabel">批次编号</text>
  90. <text class="conclusionBatchNo">{{ traceDetail.batch.no }}</text>
  91. </view>
  92. <!-- 第二层:时间摘要区 -->
  93. <view v-if="traceDetail.batch?.harvestTime || traceDetail.batch?.packTime" class="conclusionSummary">
  94. <template v-if="traceDetail.batch?.harvestTime && traceDetail.batch?.packTime">
  95. <text class="summaryLabel">生产/采收日期:</text>
  96. <text class="summaryText">{{ traceDetail.batch.harvestTime }}</text>
  97. <text class="summaryDivider">|</text>
  98. <text class="summaryLabel">包装日期:</text>
  99. <text class="summaryText">{{ traceDetail.batch.packTime }}</text>
  100. </template>
  101. <template v-else-if="traceDetail.batch?.harvestTime">
  102. <text class="summaryLabel">生产/采收日期:</text>
  103. <text class="summaryText">{{ traceDetail.batch.harvestTime }}</text>
  104. </template>
  105. <template v-else-if="traceDetail.batch?.packTime">
  106. <text class="summaryLabel">包装日期:</text>
  107. <text class="summaryText">{{ traceDetail.batch.packTime }}</text>
  108. </template>
  109. </view>
  110. <!-- 第三层:结论标签区 -->
  111. <view class="conclusionTags">
  112. <view class="conclusionTag">
  113. <text>全程可追溯</text>
  114. </view>
  115. <view class="conclusionTag">
  116. <text>已通过安全检测</text>
  117. </view>
  118. </view>
  119. </view>
  120. </view>
  121. <!-- 农场信息(合并为单卡:图片+名称+地区+介绍连续表达) -->
  122. <view v-if="traceDetail.farm?.name" class="card cardLevel2 cardFarm">
  123. <view class="sectionHeader">
  124. <view class="sectionHeaderLeft">
  125. <text class="sectionEn">Origin</text>
  126. <text class="sectionTitle">源头农场</text>
  127. </view>
  128. </view>
  129. <!-- 农场主体:左图右文结构,融入主体内容 -->
  130. <view class="farmBody">
  131. <view class="farmImageWrap">
  132. <image class="farmImage" :src="traceDetail.farm.image" mode="aspectFill" />
  133. <view class="farmImageVignette" />
  134. </view>
  135. <view class="farmMeta">
  136. <text class="farmName">{{ traceDetail.farm.name }}</text>
  137. <view class="farmTags">
  138. <text class="farmTag">真实种植</text>
  139. <text class="farmTag">可追溯来源</text>
  140. </view>
  141. <view v-if="traceDetail.farm.location" class="farmLocation">
  142. <svg class="locationIcon" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
  143. <path d="M10 2C7.24 2 5 4.24 5 7c0 4 5 11 5 11s5-7 5-11c0-2.76-2.24-5-5-5zm0 6.5c-1.38 0-2.5-1.12-2.5-2.5s1.12-2.5 2.5-2.5 2.5 1.12 2.5 2.5-1.12 2.5-2.5 2.5z" fill="rgba(39,113,76,0.6)"/>
  144. </svg>
  145. <text class="locationText">产地:{{ traceDetail.farm.location }}</text>
  146. </view>
  147. </view>
  148. </view>
  149. <view v-if="traceDetail.farm?.intro" class="farmIntro">
  150. <text class="farmIntroOrigin">{{ traceDetail.farm.intro }}</text>
  151. </view>
  152. </view>
  153. <!-- 农事时间轴:关键种植过程 -->
  154. <view v-if="traceDetail.batch?.exists && traceDetail.farmTimeline?.length" class="card cardLevel1 cardTimeline">
  155. <view class="sectionHeader">
  156. <view class="sectionHeaderLeft">
  157. <text class="sectionEn">Process</text>
  158. <text class="sectionTitle">种植过程记录</text>
  159. </view>
  160. </view>
  161. <view class="timelineList">
  162. <view
  163. v-for="(item, index) in traceDetail.farmTimeline"
  164. :key="`timeline-${index}`"
  165. :class="{
  166. 'timelineItem': true,
  167. 'is-key': item.stage === 'test',
  168. 'is-current': item.stage === 'pack'
  169. }"
  170. >
  171. <view class="timelineLeft">
  172. <view class="timelineDot" />
  173. <view v-if="index !== traceDetail.farmTimeline.length - 1" class="timelineLine" />
  174. </view>
  175. <view class="timelineRight">
  176. <text v-if="item.time" class="timelineTime">{{ item.time }}</text>
  177. <text class="timelineTitle">{{ item.title }}</text>
  178. <text class="timelineDesc">{{ item.desc }}</text>
  179. </view>
  180. </view>
  181. </view>
  182. <view class="timelineFootnote">
  183. <text>以上信息真实有效,可追溯验证</text>
  184. </view>
  185. </view>
  186. <!-- 种植现场实时画面 -->
  187. <view v-if="traceDetail.batch?.exists && traceDetail.camera" class="card cardLevel1 cardLive">
  188. <view class="sectionHeader">
  189. <view class="sectionHeaderLeft">
  190. <text class="sectionEn">Live Scene</text>
  191. <text class="sectionTitle">种植现场</text>
  192. </view>
  193. </view>
  194. <!-- <image
  195. v-if="traceDetail.camera.coverImage"
  196. class="liveCover"
  197. :src="traceDetail.camera.coverImage"
  198. mode="aspectFill"
  199. />
  200. <view v-else class="livePlaceholder">
  201. <view class="livePlayIcon">
  202. <view class="livePlayDot" />
  203. <view class="livePlayDot dot2" />
  204. <view class="livePlayDot dot3" />
  205. </view>
  206. <text class="livePlaceholderMain">实时画面接入中</text>
  207. <text class="livePlaceholderSub">请稍候查看现场情况</text>
  208. </view> -->
  209. <!-- 视频预览区域 -->
  210. <view class="video-section">
  211. <view class="video-container" :class="{'fullscreen-mode': isFullscreen}">
  212. <!-- 默认未播放态背景:深灰绿 + 柔和层次感 -->
  213. <view v-if="!isPlaying" class="video-placeholder-bg">
  214. <image :src="deviceInfo.imageUrl" mode="aspectFill" style="width:100%;height:100%"></image>
  215. </view>
  216. <!-- 使用跨平台视频播放组件 -->
  217. <!-- #ifdef H5 -->
  218. <!-- iOS H5:使用 video 直接播放 HLS(绕过 Jessibuca + wss_flv) -->
  219. <video
  220. v-if="isPlaying && isH5IOS"
  221. id="h5IosVideo"
  222. class="video-player"
  223. :src="getIOSH5StreamUrl"
  224. :autoplay="true"
  225. :controls="true"
  226. :show-center-play-btn="true"
  227. :enable-progress-gesture="false"
  228. :object-fit="'contain'"
  229. @error="onVideoError"
  230. @play="onVideoPlay"
  231. @pause="onVideoPause"
  232. @ended="onVideoEnded"
  233. @timeupdate="onTimeUpdate"
  234. @fullscreenchange="onFullscreenChange"
  235. ></video>
  236. <!-- 非 iOS H5:使用 Jessibuca + wss_flv(保持安卓/PC 原有逻辑) -->
  237. <view v-else-if="isPlaying && !isH5IOS" class="h5-video-wrapper">
  238. <Jessibuca ref="jessibucaRef" :videoUrl="getH5StreamUrl" :hasAudio="true" @error="onVideoError" />
  239. </view>
  240. <!-- #endif -->
  241. <!-- 微信小程序视频播放 -->
  242. <!-- #ifdef MP-WEIXIN -->
  243. <video
  244. v-if="isPlaying"
  245. id="myVideo"
  246. class="video-player"
  247. :src="getAppStreamUrl"
  248. :autoplay="true"
  249. :controls="true"
  250. :show-center-play-btn="true"
  251. :enable-progress-gesture="false"
  252. :object-fit="'contain'"
  253. @error="onVideoError"
  254. @play="onVideoPlay"
  255. @pause="onVideoPause"
  256. @ended="onVideoEnded"
  257. @timeupdate="onTimeUpdate"
  258. @fullscreenchange="onFullscreenChange"
  259. ></video>
  260. <!-- #endif -->
  261. <!-- App端视频播放 -->
  262. <!-- #ifdef APP-PLUS || APP-HARMONY -->
  263. <video
  264. v-if="isPlaying"
  265. id="appVideo"
  266. class="video-player"
  267. :src="getAppStreamUrl"
  268. :autoplay="true"
  269. :controls="true"
  270. :show-center-play-btn="true"
  271. @error="onVideoError"
  272. ></video>
  273. <!-- #endif -->
  274. <!-- 视频控制层 -->
  275. <view class="video-controls">
  276. <view class="control-row top-controls">
  277. <!-- 左上角留空,保持简洁 -->
  278. <!-- 右上角:全屏按钮(仅播放态显示) -->
  279. <view v-if="isPlaying" class="fullscreen-button" @click="toggleFullscreen">
  280. <image src="/static/icons/resize_icon.png" mode="aspectFit"
  281. style="width: 18px; height: 18px;"></image>
  282. </view>
  283. </view>
  284. <view class="control-row center-controls">
  285. <!-- 默认未播放态:圆形播放按钮 -->
  286. <view v-if="!isPlaying" class="play-button" @click="togglePlayState">
  287. <view class="play-btn-circle">
  288. <view class="play-btn-icon"></view>
  289. </view>
  290. </view>
  291. <!-- 播放态:暂停按钮 -->
  292. <view v-else class="center-button-container" @click="togglePlayState">
  293. <view class="pause-icon">
  294. <image src="/static/icons/pause_icon.png" mode="aspectFit"
  295. style="width: 24px; height: 24px;"></image>
  296. </view>
  297. </view>
  298. </view>
  299. <view class="control-row bottom-controls">
  300. <!-- 只在播放时显示时间码 -->
  301. <view v-if="isPlaying && !isH5IOS" class="video-time">{{ currentTime }}</view>
  302. </view>
  303. </view>
  304. <!-- 实时在线状态标签(固定在右上角,不受其他元素影响) -->
  305. <view class="video-fixed-status">
  306. <view class="liveStatusPill" :class="cameraStatus.value">
  307. <view class="liveStatusDot" />
  308. <text class="liveStatusText">实时在线</text>
  309. </view>
  310. </view>
  311. </view>
  312. </view>
  313. <view class="liveDesc">
  314. <text>现场画面可见,种植状态真实呈现</text>
  315. </view>
  316. </view>
  317. <!-- 种植环境记录 -->
  318. <view v-if="traceDetail.batch?.exists && traceDetail.environment" class="card cardLevel1 cardEnvironment">
  319. <view class="sectionHeader">
  320. <view class="sectionHeaderLeft">
  321. <text class="sectionEn">Environment</text>
  322. <text class="sectionTitle">种植环境记录</text>
  323. </view>
  324. </view>
  325. <view class="environmentSummary">
  326. <text>{{ traceDetail.environment.summary }}</text>
  327. </view>
  328. <!-- 土壤养分趋势图 -->
  329. <view v-if="traceDetail.environment.chart" class="environmentChart">
  330. <view class="environmentChartHead">
  331. <text class="environmentChartTitle">土壤养分变化趋势</text>
  332. <text class="environmentChartSub">氮 / 磷 / 钾 种植期记录</text>
  333. </view>
  334. <view class="environmentChartCanvas">
  335. <!-- SVG 绘图区 -->
  336. <view class="chartPlotArea">
  337. <svg class="chartSvg" viewBox="0 0 700 200" preserveAspectRatio="none">
  338. <!-- 网格线 -->
  339. <line v-for="(line, idx) in svgGridLines" :key="`grid-${idx}`"
  340. class="chartGridLineSvg"
  341. :x1="0" :y1="line" :x2="700" :y2="line"
  342. />
  343. <!-- 定义渐变和发光滤镜 -->
  344. <defs>
  345. <linearGradient id="gradN" x1="0%" y1="0%" x2="100%" y2="0%">
  346. <stop offset="0%" stop-color="rgba(47, 125, 85, 0.3)" />
  347. <stop offset="50%" stop-color="rgba(47, 125, 85, 0.7)" />
  348. <stop offset="100%" stop-color="rgba(47, 125, 85, 0.3)" />
  349. </linearGradient>
  350. <linearGradient id="gradP" x1="0%" y1="0%" x2="100%" y2="0%">
  351. <stop offset="0%" stop-color="rgba(180, 140, 70, 0.3)" />
  352. <stop offset="50%" stop-color="rgba(180, 140, 70, 0.7)" />
  353. <stop offset="100%" stop-color="rgba(180, 140, 70, 0.3)" />
  354. </linearGradient>
  355. <linearGradient id="gradK" x1="0%" y1="0%" x2="100%" y2="0%">
  356. <stop offset="0%" stop-color="rgba(84, 130, 110, 0.3)" />
  357. <stop offset="50%" stop-color="rgba(84, 130, 110, 0.7)" />
  358. <stop offset="100%" stop-color="rgba(84, 130, 110, 0.3)" />
  359. </linearGradient>
  360. <filter id="glow" x="-50%" y="-50%" width="200%" height="200%">
  361. <feGaussianBlur stdDeviation="3" result="blur" />
  362. <feMerge>
  363. <feMergeNode in="blur" />
  364. <feMergeNode in="SourceGraphic" />
  365. </feMerge>
  366. </filter>
  367. </defs>
  368. <!-- 面积渐变层(先绘制,在线下方) -->
  369. <path class="chartAreaN" :d="chartAreas.n" />
  370. <path class="chartAreaP" :d="chartAreas.p" />
  371. <path class="chartAreaK" :d="chartAreas.k" />
  372. <!-- 曲线层(带渐变和发光) -->
  373. <path class="chartPathN" :d="chartPaths.n" stroke="url(#gradN)" />
  374. <path class="chartPathP" :d="chartPaths.p" stroke="url(#gradP)" />
  375. <path class="chartPathK" :d="chartPaths.k" stroke="url(#gradK)" />
  376. <!-- 数据点 -->
  377. <circle v-for="(pt, idx) in chartPoints.n" :key="`n-${idx}`"
  378. class="chartDotN"
  379. cx="0" cy="0" r="3"
  380. :transform="`translate(${pt.x}, ${pt.y})`"
  381. />
  382. <circle v-for="(pt, idx) in chartPoints.p" :key="`p-${idx}`"
  383. class="chartDotP"
  384. cx="0" cy="0" r="3"
  385. :transform="`translate(${pt.x}, ${pt.y})`"
  386. />
  387. <circle v-for="(pt, idx) in chartPoints.k" :key="`k-${idx}`"
  388. class="chartDotK"
  389. cx="0" cy="0" r="3"
  390. :transform="`translate(${pt.x}, ${pt.y})`"
  391. />
  392. </svg>
  393. </view>
  394. <!-- 日期标签:独立于绘图区 -->
  395. <view class="chartLabels">
  396. <text v-for="(label, idx) in traceDetail.environment.chart.labels" :key="`label-${idx}`">{{ label }}</text>
  397. </view>
  398. </view>
  399. <view class="environmentChartLegend">
  400. <view class="legendItem">
  401. <view class="legendDot legendN" />
  402. <text>氮</text>
  403. </view>
  404. <view class="legendItem">
  405. <view class="legendDot legendP" />
  406. <text>磷</text>
  407. </view>
  408. <view class="legendItem">
  409. <view class="legendDot legendK" />
  410. <text>钾</text>
  411. </view>
  412. </view>
  413. </view>
  414. <!-- 环境摘要项 -->
  415. <view class="environmentGrid">
  416. <view
  417. v-for="(item, index) in traceDetail.environment.items"
  418. :key="`env-${index}`"
  419. class="environmentItem"
  420. >
  421. <text class="environmentLabel">{{ item.label }}</text>
  422. <text class="environmentValue">{{ item.value }}</text>
  423. <text class="environmentStatus">{{ item.status }}</text>
  424. </view>
  425. </view>
  426. </view>
  427. <!-- 检测报告:横向卡片列表 -->
  428. <view v-if="traceDetail.batch?.exists" class="card cardLevel2 cardCredential">
  429. <view class="sectionHeader">
  430. <view class="sectionHeaderLeft">
  431. <text class="sectionEn">Report</text>
  432. <text class="sectionTitle">检测报告</text>
  433. </view>
  434. </view>
  435. <!-- 横向滑动卡片列表 -->
  436. <scroll-view
  437. v-if="reportItems.length"
  438. class="reportCardList"
  439. scroll-x
  440. :show-scrollbar="false"
  441. enhanced
  442. >
  443. <view class="reportCardTrack">
  444. <view
  445. v-for="(item, itemIdx) in reportItems"
  446. :key="`report-card-${itemIdx}`"
  447. class="reportCard"
  448. @click="previewDoc('report', getReportGlobalIndex(itemIdx, 0))"
  449. >
  450. <!-- 报告缩略图(带页数角标) -->
  451. <view class="reportCardThumb">
  452. <image
  453. v-if="item.images && item.images.length"
  454. class="reportCardThumbImg"
  455. :src="item.images[0]"
  456. mode="aspectFit"
  457. />
  458. <view v-else class="reportCardThumbEmpty">
  459. <text class="reportCardThumbEmptyText">暂无图片</text>
  460. </view>
  461. <view v-if="item.images && item.images.length > 1" class="reportCardPages">
  462. 共{{ item.images.length }}页
  463. </view>
  464. </view>
  465. <!-- 报告信息 -->
  466. <view class="reportCardMeta">
  467. <view v-if="item.detectDate" class="reportCardRow">
  468. <text class="reportCardLabel">检测日期</text>
  469. <text class="reportCardValue">{{ item.detectDate }}</text>
  470. </view>
  471. <view v-if="item.no" class="reportCardRow">
  472. <text class="reportCardLabel">报告编号</text>
  473. <text class="reportCardValue reportCardValueNo">{{ item.no }}</text>
  474. </view>
  475. </view>
  476. <!-- 点击提示 -->
  477. <text class="reportCardHint">点击查看大图</text>
  478. </view>
  479. </view>
  480. </scroll-view>
  481. <!-- 待补充状态 -->
  482. <view v-else class="docPlaceholder">
  483. <text class="docPlaceholderTitle">检测报告待补充</text>
  484. <text class="docPlaceholderText">
  485. {{ traceDetail.report?.emptyMessage || '检测报告待补充,请耐心等待。' }}
  486. </text>
  487. </view>
  488. </view>
  489. <!-- 合格证:信息摘要 + 缩略图一体化布局 -->
  490. <view v-if="traceDetail.batch?.exists" class="card cardLevel1 cardCredential">
  491. <view class="sectionHeader">
  492. <view class="sectionHeaderLeft">
  493. <text class="sectionEn">Certificate</text>
  494. <text class="sectionTitle">合格证</text>
  495. </view>
  496. </view>
  497. <!-- 信息与缩略图一体化区域 -->
  498. <view class="certSummary">
  499. <!-- 左侧:信息摘要 -->
  500. <view class="certSummaryInfo">
  501. <view v-if="traceDetail.certificate?.issueDate" class="certSummaryRow">
  502. <text class="certSummaryLabel">开具日期</text>
  503. <text class="certSummaryValue">{{ traceDetail.certificate.issueDate }}</text>
  504. </view>
  505. <view v-if="traceDetail.certificate?.no" class="certSummaryRow">
  506. <text class="certSummaryLabel">合格证编号</text>
  507. <text class="certSummaryValue">{{ traceDetail.certificate.no }}</text>
  508. </view>
  509. </view>
  510. <!-- 右侧:缩略图 -->
  511. <view
  512. v-if="traceDetail.certificate?.status === 'uploaded' && certificateImages.length"
  513. class="certThumbContainer"
  514. @click="previewDoc('certificate', 0)"
  515. >
  516. <view class="certThumbWrap">
  517. <image class="certThumbImage" :src="certificateImages[0]" mode="aspectFit" />
  518. </view>
  519. <text class="certPreviewHint">点击查看</text>
  520. </view>
  521. <!-- 待补充状态:仅显示提示 -->
  522. <view v-else class="certPendingHint">
  523. <text class="certPendingText">
  524. {{ traceDetail.certificate?.emptyMessage || '合格证待补充,请耐心等待。' }}
  525. </text>
  526. </view>
  527. </view>
  528. </view>
  529. <!-- 安心收口文案 -->
  530. <view class="pageEndHint">
  531. <text>本产品已完成全流程溯源记录,信息真实可查,请放心食用。</text>
  532. </view>
  533. <view class="footerDivider" />
  534. <!-- 微信小店复购引导 -->
  535. <view class="rebuyGuide">
  536. <view class="rebuyGuideLeft">
  537. <view class="rebuyGuideBrandRow">
  538. <image class="rebuyGuideLogo" src="/static/jyhy-logo.png" mode="aspectFit" />
  539. <text class="rebuyGuideTitle">佳友厚苑</text>
  540. </view>
  541. <text class="rebuyGuideText">喜欢这款产品?微信小店可查看同款</text>
  542. </view>
  543. <view class="rebuyGuideBtn" @click="goToWechatStore">
  544. <text>去看看</text>
  545. </view>
  546. </view>
  547. <!-- 轻量页脚 -->
  548. <view class="traceFooter">
  549. <view class="traceFooterHint">如需帮助,联系客服</view>
  550. <view class="traceFooterPhone" @click="contactCustomer">
  551. <image class="traceFooterPhoneIcon" src="/static/icons/phone.svg" mode="aspectFit" />
  552. <text class="traceFooterPhoneNum">13379508760</text>
  553. </view>
  554. <view class="traceFooterBrand">佳友厚苑 · 安心之选</view>
  555. </view>
  556. </scroll-view>
  557. </view>
  558. <!-- ===== 异常态:待发布 / 已下线 / 无效批次 ===== -->
  559. <view v-if="!canShowTraceContent">
  560. <view class="abnormalStateCard">
  561. <view class="sectionHeader">
  562. <view class="sectionHeaderLeft">
  563. <text class="sectionEn">Status</text>
  564. <text class="sectionTitle">暂无相关溯源码信息</text>
  565. </view>
  566. </view>
  567. <view class="emptyText">{{ traceDetail.batch?.emptyMessage || '未找到对应溯源码信息,请确认二维码是否正确。' }}</view>
  568. </view>
  569. </view>
  570. </view>
  571. </view>
  572. </template>
  573. <script setup>
  574. import { computed, ref, reactive } from 'vue'
  575. import { onLoad } from '@dcloudio/uni-app'
  576. import {getTraceDetail } from '@/api/base/index.js'
  577. import {
  578. getDeviceCollectorDetail,
  579. getChannels,
  580. playStart,
  581. pause ,
  582. querySnap
  583. } from '@/api/device.js'
  584. import Jessibuca from '@/components/common/jessibuca.vue'
  585. // 页面状态选择(H5 演示用):通过路由参数传入 state 即可切换 mock 场景
  586. // 例如:/pages/trace/detail?state=reportPending
  587. // 加载状态
  588. const loading = ref(false)
  589. // 数据首次加载完成标记(用于区分"加载中"与"加载后异常态")
  590. const traceLoaded = ref(false)
  591. // 数据存储
  592. const traceInfo = ref(null)
  593. const routeOptions = ref({})
  594. const mockStateKey = ref('normal')
  595. const isFullscreen = ref(false)
  596. const isPlaying = ref(false)
  597. const livePlayerContext = ref(null) // 小程序视频上下文
  598. const appLivePlayerContext = ref(null) // App端视频上下文
  599. const h5IosVideoContext = ref(null) // H5 iOS video 上下文
  600. const jessibucaRef = ref(null)
  601. const isMuted = ref(false)
  602. const isRecording = ref(false)
  603. const isVoiceActive = ref(false)
  604. const isGridView = ref(false)
  605. const isZoomMode = ref(false)
  606. const currentTime = ref('14:30:25')
  607. // ===== 平台识别:iPhone / iOS 设备判断 =====
  608. const isIOSDevice = computed(() => {
  609. // #ifdef H5
  610. const ua = navigator.userAgent.toLowerCase()
  611. return /iphone|ipad|ipod/.test(ua)
  612. // #endif
  613. // #ifdef APP-PLUS
  614. const platform = uni.getSystemInfoSync().platform
  615. return platform === 'ios'
  616. // #endif
  617. return false
  618. })
  619. const isIPhoneH5 = computed(() => {
  620. // #ifdef H5
  621. const ua = navigator.userAgent.toLowerCase()
  622. return /iphone/.test(ua) && !/ipad|ipod/.test(ua)
  623. // #endif
  624. return false
  625. })
  626. const isIPadH5 = computed(() => {
  627. // #ifdef H5
  628. const ua = navigator.userAgent.toLowerCase()
  629. return /ipad/.test(ua)
  630. // #endif
  631. return false
  632. })
  633. // H5 iOS 设备(包括 iPhone 和 iPad)
  634. const isH5IOS = computed(() => {
  635. // #ifdef H5
  636. const ua = navigator.userAgent.toLowerCase()
  637. return /iphone|ipad|ipod/.test(ua)
  638. // #endif
  639. return false
  640. })
  641. // 响应式数据
  642. const deviceInfo = reactive({
  643. deviceId: '34020000001110000001',
  644. name: '设备加载中...',
  645. status: 'off',
  646. location: '正在获取位置...',
  647. lastUpdate: '',
  648. deviceType: 'weather', // 默认类型,会根据API返回更新
  649. deviceTypeId: null,
  650. streamUrl: '',
  651. channelId: null, // 当前通道ID
  652. // ===== 流地址:分格式保存,不再互相覆盖 =====
  653. originalStreamUrl: '', // 兼容旧逻辑
  654. wsFlvStreamUrl: '', // wss_flv 流地址(安卓 H5 用)
  655. hlsStreamUrl: '', // hls 流地址(iOS H5 / 小程序 / App iOS 用)
  656. fmp4StreamUrl: '', // fmp4 流地址(App Android 用)
  657. imageUrl: '' // 设备图片(如果有)
  658. })
  659. const MOCK_TRACE_DETAILS = {
  660. normal: {
  661. product: {
  662. name: '',
  663. spec: '',
  664. image: '',
  665. intro: ''
  666. },
  667. farm: {
  668. name: '',
  669. location: '',
  670. image: '',
  671. intro: ''
  672. },
  673. batch: {
  674. status: '',
  675. statusText: '',
  676. exists: false,
  677. statusBadge: { text: '', type: '' },
  678. no: '',
  679. plantStartTime: '2026-03-01',
  680. harvestTime: '',
  681. packTime: '',
  682. emptyTitle: '暂无相关溯源码信息',
  683. emptyMessage: '未找到对应溯源码信息,请确认二维码是否正确。'
  684. },
  685. report: {
  686. status: '',
  687. statusBadge: { text: '', type: '' },
  688. // 每份报告独立 detectDate / no / images
  689. items: [
  690. {
  691. detectDate: '',
  692. no: '',
  693. images: ['']
  694. },
  695. {
  696. detectDate: '',
  697. no: '',
  698. images: ['']
  699. },
  700. {
  701. detectDate: '',
  702. no: '',
  703. images: ['']
  704. }
  705. ]
  706. },
  707. certificate: {
  708. status: '',
  709. statusBadge: { text: '', type: '' },
  710. issueDate: '',
  711. no: '',
  712. fileUrl: '',
  713. images: ['']
  714. },
  715. traceConclusionCard: {
  716. title: '溯源结论',
  717. conclusion: '本批次产品来源清晰,已完成安全检测,过程可查',
  718. desc: '检测材料与溯源数据已展示,可继续查看',
  719. passed: true
  720. },
  721. farmTimeline: [
  722. {
  723. time: '2026-03-01',
  724. stage: 'planting',
  725. title: '开始种植',
  726. desc: '本批次产品进入种植管理阶段'
  727. },
  728. {
  729. time: '2026-03-12',
  730. stage: 'care',
  731. title: '生长期养护',
  732. desc: '种植期间已持续开展灌溉、施肥等日常养护'
  733. },
  734. {
  735. time: '2026-03-20',
  736. stage: 'inspection',
  737. title: '田间巡检',
  738. desc: '种植期间已持续开展长势检查与环境巡检'
  739. },
  740. {
  741. time: '2026-03-30',
  742. stage: 'harvest',
  743. title: '成熟采收',
  744. desc: '本批次产品进入成熟采收阶段'
  745. },
  746. {
  747. time: '2026-03-31',
  748. stage: 'test',
  749. title: '安全检测',
  750. desc: '已完成安全检测,相关结果可查'
  751. },
  752. {
  753. time: '2026-04-01',
  754. stage: 'pack',
  755. title: '包装日期:出库',
  756. desc: '已完成包装日期:整理,进入销售流通环节'
  757. }
  758. ],
  759. camera: {
  760. liveUrl: '',
  761. coverImage: '',
  762. status: 'online',
  763. desc: '来自农场实景画面,种植环境真实呈现'
  764. },
  765. environment: {
  766. summary: '本批次种植期环境稳定,整体处于适宜生长区间',
  767. chart: {
  768. type: 'npk_trend',
  769. labels: ['03-01', '03-06', '03-10', '03-15', '03-21', '03-27', '04-01'],
  770. values: {
  771. n: [26.2, 25.8, 26.4, 25.9, 26.6, 26.1, 26.4],
  772. p: [20.5, 20.1, 20.4, 20.0, 20.3, 20.2, 20.4],
  773. k: [14.2, 14.6, 14.3, 14.7, 14.4, 14.8, 14.5]
  774. }
  775. },
  776. items: [
  777. { label: '气温', value: '22.3℃', status: '种植期平均' },
  778. { label: '湿度', value: '45%', status: '种植期平均' },
  779. { label: '降雨量', value: '118mm', status: '种植期累计' },
  780. { label: '光照', value: '充足', status: '表现稳定' }
  781. ],
  782. current: {
  783. temperature: '24.5℃',
  784. humidity: '42.2%'
  785. }
  786. }
  787. },
  788. reportPending: {
  789. product: {
  790. name: '',
  791. spec: '',
  792. image: '',
  793. intro: ''
  794. },
  795. farm: {
  796. name: '',
  797. location: '',
  798. image: null,
  799. intro: ''
  800. },
  801. batch: {
  802. status: '',
  803. statusText: '',
  804. exists: false,
  805. statusBadge: { text: '', type: '' },
  806. no: '',
  807. plantStartTime: '',
  808. harvestTime: '',
  809. packTime: '',
  810. emptyTitle: '暂无相关溯源码信息',
  811. emptyMessage: '未找到对应溯源码信息,请确认二维码是否正确。'
  812. },
  813. report: {
  814. status: '',
  815. statusBadge: { text: '', type: '' },
  816. emptyMessage: '',
  817. items: []
  818. },
  819. certificate: {
  820. status: '',
  821. statusBadge: { text: '', type: '' },
  822. issueDate: '',
  823. no: '',
  824. fileUrl: '',
  825. images: []
  826. },
  827. traceConclusionCard: {
  828. title: '溯源结论',
  829. conclusion: '本批次产品来源清晰,已完成安全检测,过程可查',
  830. desc: '检测材料与溯源数据已展示,可继续查看',
  831. passed: true
  832. },
  833. farmTimeline: []
  834. },
  835. certificatePending: {
  836. product: {
  837. name: '',
  838. spec: '',
  839. image: '',
  840. intro: ''
  841. },
  842. farm: {
  843. name: '',
  844. location: '',
  845. image: null,
  846. intro: ''
  847. },
  848. batch: {
  849. status: '',
  850. statusText: '',
  851. exists: false,
  852. statusBadge: { text: '', type: '' },
  853. no: '',
  854. plantStartTime: '',
  855. harvestTime: '',
  856. packTime: '',
  857. emptyTitle: '暂无相关溯源码信息',
  858. emptyMessage: '未找到对应溯源码信息,请确认二维码是否正确。'
  859. },
  860. report: {
  861. status: '',
  862. statusBadge: { text: '', type: '' },
  863. items: [
  864. {
  865. detectDate: '',
  866. no: '',
  867. images: []
  868. }
  869. ]
  870. },
  871. certificate: {
  872. status: '',
  873. statusBadge: { text: '', type: '' },
  874. emptyMessage: ''
  875. },
  876. traceConclusionCard: {
  877. title: '溯源结论',
  878. conclusion: '本批次产品来源清晰,已完成安全检测,过程可查',
  879. desc: '检测材料与溯源数据已展示,可继续查看',
  880. passed: true
  881. },
  882. farmTimeline: []
  883. },
  884. batchNotFound: {
  885. product: {
  886. name:'',
  887. spec: '',
  888. image: '',
  889. intro: ''
  890. },
  891. farm: {
  892. name: '',
  893. location: '',
  894. image: null,
  895. intro: ''
  896. },
  897. batch: {
  898. status: '',
  899. statusText: '',
  900. exists: false,
  901. statusBadge: { text: '', type: '' },
  902. no: '',
  903. plantStartTime: '',
  904. harvestTime: '',
  905. packTime: '',
  906. emptyTitle: '暂无相关溯源码信息',
  907. emptyMessage: '未找到对应溯源码信息,请确认二维码是否正确。'
  908. },
  909. report: null,
  910. certificate: null,
  911. traceConclusionCard: {
  912. title: '溯源结论',
  913. conclusion: '本批次产品来源清晰,已完成安全检测,过程可查',
  914. desc: '检测材料与溯源数据已展示,可继续查看',
  915. passed: true
  916. },
  917. farmTimeline: []
  918. },
  919. batchOfflined: {
  920. product: {
  921. name: '',
  922. spec: '',
  923. image: '',
  924. intro: ''
  925. },
  926. farm: {
  927. name: '',
  928. location: '',
  929. image: null,
  930. intro: ''
  931. },
  932. batch: {
  933. status: '',
  934. statusText: '',
  935. exists: false,
  936. statusBadge: { text: '', type: '' },
  937. no: '',
  938. plantStartTime: '',
  939. harvestTime: '',
  940. packTime: '',
  941. emptyTitle: '暂无相关溯源码信息',
  942. emptyMessage: '未找到对应溯源码信息,请确认二维码是否正确。'
  943. },
  944. report: null,
  945. certificate: null,
  946. traceConclusionCard: {
  947. title: '溯源结论',
  948. conclusion: '本批次产品来源清晰,已完成安全检测,过程可查',
  949. desc: '检测材料与溯源数据已展示,可继续查看',
  950. passed: true
  951. },
  952. farmTimeline: []
  953. }
  954. }
  955. // 加载Jessibuca脚本
  956. const loadJessibucaScript = () => {
  957. // #ifdef H5
  958. const script = document.createElement('script')
  959. script.src = '/static/js/jessibuca/jessibuca.js'
  960. script.onload = () => {
  961. console.log('Jessibuca 脚本加载成功')
  962. }
  963. script.onerror = (error) => {
  964. console.error('Jessibuca 脚本加载失败:', error)
  965. }
  966. document.head.appendChild(script)
  967. // #endif
  968. }
  969. // 获取H5环境使用的流地址(非 iOS H5 用 wss_flv)
  970. const getH5StreamUrl = computed(() => {
  971. // 确保使用安全的 WSS 协议
  972. let url = deviceInfo.wsFlvStreamUrl
  973. if (url && url.startsWith('ws://')) {
  974. console.warn('检测到不安全的 ws:// 协议,自动转换为 wss://')
  975. url = url.replace('ws://', 'wss://')
  976. }
  977. return url
  978. })
  979. // ===== iOS H5 专用流地址(直接用 HLS,不走 Jessibuca) =====
  980. const getIOSH5StreamUrl = computed(() => {
  981. // iOS H5 优先使用 HLS 地址
  982. const hlsUrl = deviceInfo.hlsStreamUrl
  983. console.log('========== [诊断] iOS H5 流地址 ==========')
  984. console.log('hlsStreamUrl:', hlsUrl)
  985. return hlsUrl || ''
  986. })
  987. // 当前 H5 实际使用的流地址(根据设备类型选择)
  988. const getCurrentH5StreamUrl = computed(() => {
  989. if (isH5IOS.value) {
  990. return getIOSH5StreamUrl.value
  991. } else {
  992. return getH5StreamUrl.value
  993. }
  994. })
  995. function resolveStateKey(opts) {
  996. const raw = (opts?.state || opts?.batchState || opts?.scene || '').toString().trim()
  997. if (!raw) return 'normal'
  998. const allowed = ['normal', 'reportPending', 'certificatePending', 'batchNotFound', 'batchOfflined']
  999. return allowed.includes(raw) ? raw : 'normal'
  1000. }
  1001. onLoad((opts) => {
  1002. // 拿到浏览器路径参数
  1003. const fullPath = window.location.pathname
  1004. const batchId = fullPath.split('/').filter(Boolean).pop()
  1005. // 优先使用路由参数中的 id,其次使用 URL 路径中的 id
  1006. const finalId = batchId || 1
  1007. loadData(finalId)
  1008. queryChannels()
  1009. routeOptions.value = opts || {}
  1010. mockStateKey.value = resolveStateKey(opts || {})
  1011. startTimeUpdate()
  1012. // #ifdef MP-WEIXIN
  1013. setTimeout(() => {
  1014. livePlayerContext.value = uni.createVideoContext('myVideo')
  1015. console.log('微信小程序视频上下文已创建')
  1016. }, 500)
  1017. // #endif
  1018. // #ifdef APP-PLUS || APP-HARMONY
  1019. setTimeout(() => {
  1020. appLivePlayerContext.value = uni.createVideoContext('appVideo')
  1021. console.log('App视频上下文已创建')
  1022. }, 500)
  1023. // #endif
  1024. // #ifdef H5
  1025. loadJessibucaScript()
  1026. setTimeout(() => {
  1027. h5IosVideoContext.value = uni.createVideoContext('h5IosVideo')
  1028. console.log('H5 iOS 视频上下文已创建')
  1029. }, 500)
  1030. // #endif
  1031. })
  1032. // 根据设备id获取通道列表
  1033. const queryChannels = () => {
  1034. console.log('========== [诊断] queryChannels 被调用 ==========')
  1035. getChannels(deviceInfo.deviceId)
  1036. .then(response => {
  1037. console.log('获取通道列表:', response)
  1038. const res = response.data
  1039. if (res.code === 0 && res.data.total > 0) {
  1040. const channels = res.data.list
  1041. deviceInfo.channelId = channels[0].deviceId
  1042. deviceInfo.status = channels[0].status
  1043. console.log('通道信息:', { channelId: deviceInfo.channelId, status: deviceInfo.status })
  1044. // ===== 诊断日志:调用 playStart 前 =====
  1045. console.log('========== [诊断] 准备调用 playStart ==========')
  1046. console.log('deviceId:', deviceInfo.deviceId)
  1047. console.log('channelId:', deviceInfo.channelId)
  1048. console.log('isH5IOS:', isH5IOS.value)
  1049. console.log('isIPhoneH5:', isIPhoneH5.value)
  1050. querySnap(deviceInfo.deviceId, deviceInfo.channelId).then(url => {
  1051. deviceInfo.imageUrl = url
  1052. })
  1053. playStart(deviceInfo.deviceId, deviceInfo.channelId).then(res => {
  1054. if (res.data.code !== 0) {
  1055. console.error('播放开始失败:', res.message)
  1056. uni.showToast({
  1057. title: '播放失败: ' + res.message,
  1058. icon: 'none'
  1059. })
  1060. return
  1061. }
  1062. console.log('playStart 返回数据:', res.data.data)
  1063. console.log('playStart 可用流地址:', Object.keys(res.data.data || {}))
  1064. // ===== 诊断日志:playStart 成功,保存各格式流地址 =====
  1065. console.log('========== [诊断] 保存各格式流地址 ==========')
  1066. // #ifdef H5
  1067. // H5 环境:分别保存 wss_flv 和 hls
  1068. const rawWsFlv = res.data.data.wss_flv
  1069. const rawHls = res.data.data.hls
  1070. // 非 iOS H5:走 wss_flv + Jessibuca,保留 URL 替换逻辑
  1071. if (!isH5IOS.value && rawWsFlv) {
  1072. const urlObj = new URL(rawWsFlv)
  1073. urlObj.hostname = 'nxy.gbdfarm.com'
  1074. urlObj.port = '9000'
  1075. deviceInfo.wsFlvStreamUrl = urlObj.toString()
  1076. console.log('H5 非iOS - wsFlvStreamUrl:', deviceInfo.wsFlvStreamUrl)
  1077. } else if (!isH5IOS.value) {
  1078. console.warn('H5 非iOS - 未获取到 wss_flv')
  1079. }
  1080. // iOS H5:直接用 HLS,不做 URL 替换
  1081. if (isH5IOS.value && rawHls) {
  1082. deviceInfo.hlsStreamUrl = rawHls // 直接使用原始 HLS 地址,不替换域名
  1083. console.log('H5 iOS - hlsStreamUrl (不替换域名):', deviceInfo.hlsStreamUrl)
  1084. } else if (isH5IOS.value) {
  1085. console.warn('H5 iOS - 未获取到 hls,使用 wss_flv 兜底')
  1086. // iOS 没有 HLS 时,尝试用 wss_flv(可能也会黑屏,但至少有尝试)
  1087. deviceInfo.hlsStreamUrl = rawWsFlv || ''
  1088. }
  1089. // 兼容旧逻辑
  1090. deviceInfo.originalStreamUrl = isH5IOS.value
  1091. ? deviceInfo.hlsStreamUrl
  1092. : deviceInfo.wsFlvStreamUrl
  1093. console.log('H5 - originalStreamUrl (兼容):', deviceInfo.originalStreamUrl)
  1094. // #endif
  1095. // #ifdef MP-WEIXIN
  1096. deviceInfo.hlsStreamUrl = res.data.data.hls || deviceInfo.hlsStreamUrl
  1097. deviceInfo.originalStreamUrl = deviceInfo.hlsStreamUrl
  1098. console.log("queryChannels - 小程序 hlsStreamUrl:", deviceInfo.hlsStreamUrl)
  1099. // #endif
  1100. // #ifdef APP-PLUS || APP-HARMONY
  1101. deviceInfo.fmp4StreamUrl = res.data.data.fmp4 || deviceInfo.fmp4StreamUrl
  1102. deviceInfo.hlsStreamUrl = res.data.data.hls || deviceInfo.hlsStreamUrl
  1103. deviceInfo.originalStreamUrl = deviceInfo.fmp4StreamUrl
  1104. console.log("queryChannels - App fmp4StreamUrl:", deviceInfo.fmp4StreamUrl)
  1105. console.log("queryChannels - App hlsStreamUrl:", deviceInfo.hlsStreamUrl)
  1106. // #endif
  1107. // ===== 最终诊断日志 =====
  1108. console.log('========== [诊断] 流地址保存完成 ==========')
  1109. console.log('wsFlvStreamUrl:', deviceInfo.wsFlvStreamUrl)
  1110. console.log('hlsStreamUrl:', deviceInfo.hlsStreamUrl)
  1111. console.log('fmp4StreamUrl:', deviceInfo.fmp4StreamUrl)
  1112. console.log('originalStreamUrl (兼容):', deviceInfo.originalStreamUrl)
  1113. }).catch(err => {
  1114. console.error('播放开始失败:', err)
  1115. })
  1116. } else {
  1117. uni.showToast({
  1118. title: '获取通道列表失败: ' + res.data.message,
  1119. icon: 'none'
  1120. })
  1121. return
  1122. }
  1123. })
  1124. .catch(err => {
  1125. console.error('获取通道列表错误:', err)
  1126. })
  1127. }
  1128. const loadData = async (batchId) => {
  1129. // 重置首次加载标记,确保请求开始时不会误判为"已加载"
  1130. traceLoaded.value = false
  1131. loading.value = true
  1132. try {
  1133. // 调用接口
  1134. const res = await getTraceDetail(batchId)
  1135. traceInfo.value = res.data.data
  1136. console.log('接口返回数据:', res)
  1137. } catch (error) {
  1138. console.error('加载失败', error)
  1139. // 错误提示已在拦截器中自动处理
  1140. } finally {
  1141. // 无论成功失败都关闭 loading
  1142. loading.value = false
  1143. // 标记数据已完成首次加载
  1144. traceLoaded.value = true
  1145. }
  1146. }
  1147. // 视频播放错误处理
  1148. const onVideoError = (e) => {
  1149. console.error('========== [诊断] 视频播放错误 ==========')
  1150. console.error('视频播放错误:', e)
  1151. let errorMsg = '视频加载失败'
  1152. // 微信小程序video组件错误码
  1153. if (e && e.detail) {
  1154. const errCode = e.detail.errCode
  1155. console.error('微信错误码:', errCode)
  1156. console.error('微信错误信息:', e.detail.errMsg)
  1157. switch(errCode) {
  1158. case 10001:
  1159. errorMsg = '网络错误,请检查网络连接'
  1160. break
  1161. case 10002:
  1162. errorMsg = '视频格式不支持'
  1163. break
  1164. case 10003:
  1165. errorMsg = '视频解码失败'
  1166. break
  1167. case 10004:
  1168. errorMsg = '视频地址无效'
  1169. break
  1170. default:
  1171. errorMsg = `播放失败(错误码:${errCode})`
  1172. }
  1173. }
  1174. // ===== 诊断日志:当前环境信息 =====
  1175. // #ifdef H5
  1176. console.log('========== [诊断] H5 错误上下文 ==========')
  1177. console.log('isH5IOS:', isH5IOS.value)
  1178. console.log('getH5StreamUrl (非iOS):', getH5StreamUrl.value)
  1179. console.log('getIOSH5StreamUrl (iOS):', getIOSH5StreamUrl.value)
  1180. // #endif
  1181. uni.showToast({
  1182. title: errorMsg,
  1183. icon: 'none',
  1184. duration: 3000
  1185. })
  1186. isPlaying.value = false
  1187. // #ifdef H5
  1188. // 只对非 iOS H5 做 Jessibuca 重试
  1189. setTimeout(() => {
  1190. if (isPlaying.value && !isH5IOS.value && jessibucaRef.value) {
  1191. console.log('尝试重新加载视频流')
  1192. } else if (isH5IOS.value) {
  1193. console.log('【诊断】iOS H5 播放失败,hlsStreamUrl:', deviceInfo.hlsStreamUrl)
  1194. }
  1195. }, 3000)
  1196. // #endif
  1197. }
  1198. // 更新时间
  1199. const startTimeUpdate = () => {
  1200. setInterval(() => {
  1201. const now = new Date()
  1202. const hours = String(now.getHours()).padStart(2, '0')
  1203. const minutes = String(now.getMinutes()).padStart(2, '0')
  1204. const seconds = String(now.getSeconds()).padStart(2, '0')
  1205. currentTime.value = `${hours}:${minutes}:${seconds}`
  1206. }, 1000)
  1207. }
  1208. // 播放/暂停切换
  1209. const togglePlayState = () => {
  1210. console.log('========== [诊断] togglePlayState 被调用 ==========')
  1211. console.log('当前 isPlaying:', isPlaying.value)
  1212. console.log('isH5IOS:', isH5IOS.value)
  1213. if (!isPlaying.value) {
  1214. // 开始播放
  1215. isPlaying.value = true
  1216. // ===== 诊断日志:播放链路选择 =====
  1217. // #ifdef H5
  1218. if (isH5IOS.value) {
  1219. console.log('========== [诊断] H5 iOS 播放链路 ==========')
  1220. console.log('使用 iOS H5 专用流地址')
  1221. console.log('getIOSH5StreamUrl:', getIOSH5StreamUrl.value)
  1222. } else {
  1223. console.log('========== [诊断] H5 非iOS 播放链路 ==========')
  1224. console.log('使用 Jessibuca + wss_flv')
  1225. console.log('getH5StreamUrl:', getH5StreamUrl.value)
  1226. }
  1227. // #endif
  1228. // #ifdef MP-WEIXIN
  1229. console.log('========== [诊断] 微信小程序播放链路 ==========')
  1230. console.log('使用 video + hls')
  1231. console.log('getAppStreamUrl:', getAppStreamUrl.value)
  1232. setTimeout(() => {
  1233. if (livePlayerContext.value) {
  1234. livePlayerContext.value.play()
  1235. console.log('微信小程序开始播放')
  1236. }
  1237. }, 300)
  1238. // #endif
  1239. // #ifdef APP-PLUS || APP-HARMONY
  1240. console.log('========== [诊断] App 播放链路 ==========')
  1241. console.log('使用 video + fmp4/hls')
  1242. console.log('getAppStreamUrl:', getAppStreamUrl.value)
  1243. setTimeout(() => {
  1244. if (appLivePlayerContext.value) {
  1245. appLivePlayerContext.value.play()
  1246. console.log('App开始播放')
  1247. }
  1248. }, 300)
  1249. // #endif
  1250. // #ifdef H5
  1251. // 【最小修复】不再重复调用 playStart,直接使用 queryChannels 中已保存的流地址
  1252. console.log('【修复】togglePlayState 不再调用 playStart,使用已保存的流地址')
  1253. console.log('H5 实际播放 URL:', getCurrentH5StreamUrl.value)
  1254. // iOS H5 需要手动调用 video.play()
  1255. if (isH5IOS.value) {
  1256. setTimeout(() => {
  1257. if (h5IosVideoContext.value) {
  1258. h5IosVideoContext.value.play()
  1259. console.log('H5 iOS video.play() 已调用')
  1260. }
  1261. }, 300)
  1262. }
  1263. uni.vibrateShort()
  1264. // #endif
  1265. } else {
  1266. // #ifdef H5
  1267. // iOS H5 的 video 暂停
  1268. if (isH5IOS.value && h5IosVideoContext.value) {
  1269. h5IosVideoContext.value.pause()
  1270. console.log('H5 iOS video.pause() 已调用')
  1271. }
  1272. // 非 iOS H5 的 Jessibuca 暂停
  1273. if (!isH5IOS.value && jessibucaRef.value) {
  1274. jessibucaRef.value.pause()
  1275. }
  1276. // #endif
  1277. // #ifdef MP-WEIXIN
  1278. if (livePlayerContext.value) {
  1279. livePlayerContext.value.pause()
  1280. }
  1281. // #endif
  1282. // #ifdef APP-PLUS || APP-HARMONY
  1283. if (appLivePlayerContext.value) {
  1284. appLivePlayerContext.value.pause()
  1285. }
  1286. // #endif
  1287. isPlaying.value = false
  1288. uni.showToast({
  1289. title: '视频已暂停',
  1290. icon: 'none',
  1291. duration: 1500
  1292. })
  1293. }
  1294. }
  1295. // 静音切换
  1296. const toggleMute = () => {
  1297. isMuted.value = !isMuted.value
  1298. // #ifdef H5
  1299. if (jessibucaRef.value) {
  1300. if (isMuted.value) {
  1301. jessibucaRef.value.mute()
  1302. } else {
  1303. jessibucaRef.value.cancelMute()
  1304. }
  1305. }
  1306. // #endif
  1307. // #ifndef H5
  1308. // App端的静音通过 live-player 的 muted 属性控制,会自动响应
  1309. uni.showToast({
  1310. title: isMuted.value ? '已静音' : '已取消静音',
  1311. icon: 'none'
  1312. })
  1313. // #endif
  1314. }
  1315. // 全屏切换
  1316. const toggleFullscreen = () => {
  1317. if (!isPlaying.value) {
  1318. togglePlayState()
  1319. setTimeout(() => {
  1320. setFullscreen(true)
  1321. }, 500)
  1322. } else {
  1323. setFullscreen(!isFullscreen.value)
  1324. }
  1325. }
  1326. // 设置全屏状态
  1327. const setFullscreen = (fullscreen) => {
  1328. isFullscreen.value = fullscreen
  1329. // #ifdef H5
  1330. if (isFullscreen.value) {
  1331. const ua = navigator.userAgent.toLowerCase()
  1332. const isMobile = /mobile|android|iphone|ipad/.test(ua)
  1333. if (isMobile && jessibucaRef.value) {
  1334. jessibucaRef.value.fullscreenSwich()
  1335. } else {
  1336. setTimeout(() => {
  1337. if (jessibucaRef.value) {
  1338. jessibucaRef.value.resize()
  1339. }
  1340. }, 300)
  1341. }
  1342. if (window.screen && window.screen.orientation && window.screen.orientation.lock) {
  1343. window.screen.orientation.lock('landscape').catch(err => {
  1344. console.error('无法锁定屏幕方向:', err)
  1345. })
  1346. }
  1347. } else {
  1348. if (jessibucaRef.value) {
  1349. if (jessibucaRef.value.isFullscreen()) {
  1350. jessibucaRef.value.fullscreenSwich()
  1351. }
  1352. setTimeout(() => {
  1353. if (jessibucaRef.value) {
  1354. jessibucaRef.value.resize()
  1355. }
  1356. }, 300)
  1357. }
  1358. if (window.screen && window.screen.orientation && window.screen.orientation.unlock) {
  1359. window.screen.orientation.unlock()
  1360. }
  1361. }
  1362. // #endif
  1363. // #ifdef MP-WEIXIN
  1364. if (livePlayerContext.value) {
  1365. if (isFullscreen.value) {
  1366. livePlayerContext.value.requestFullScreen({
  1367. direction: 90
  1368. })
  1369. } else {
  1370. livePlayerContext.value.exitFullScreen()
  1371. }
  1372. }
  1373. // #endif
  1374. // #ifdef APP-PLUS || APP-HARMONY
  1375. if (appLivePlayerContext.value) {
  1376. if (isFullscreen.value) {
  1377. appLivePlayerContext.value.requestFullScreen({
  1378. direction: 90
  1379. })
  1380. } else {
  1381. appLivePlayerContext.value.exitFullScreen()
  1382. }
  1383. }
  1384. // #endif
  1385. }
  1386. // 截图
  1387. const takeScreenshot = () => {
  1388. // #ifdef H5
  1389. if (jessibucaRef.value && isPlaying.value) {
  1390. jessibucaRef.value.screenshot()
  1391. uni.showToast({
  1392. title: '截图已保存',
  1393. icon: 'success'
  1394. })
  1395. } else {
  1396. uni.showToast({
  1397. title: '请先播放视频',
  1398. icon: 'none'
  1399. })
  1400. }
  1401. // #endif
  1402. // if (livePlayerContext.value && isPlaying.value) {
  1403. // livePlayerContext.value.snapshot({
  1404. // success: (res) => {
  1405. // console.log('截图成功:', res.tempImagePath)
  1406. // uni.saveImageToPhotosAlbum({
  1407. // filePath: res.tempImagePath,
  1408. // success: () => {
  1409. // uni.showToast({
  1410. // title: '截图已保存到相册',
  1411. // icon: 'success'
  1412. // })
  1413. // },
  1414. // fail: (err) => {
  1415. // console.error('保存截图失败:', err)
  1416. // uni.showToast({
  1417. // title: '保存截图失败',
  1418. // icon: 'none'
  1419. // })
  1420. // }
  1421. // })
  1422. // },
  1423. // fail: (err) => {
  1424. // console.error('截图失败:', err)
  1425. // uni.showToast({
  1426. // title: '截图失败',
  1427. // icon: 'none'
  1428. // })
  1429. // }
  1430. // })
  1431. // } else {
  1432. // uni.showToast({
  1433. // title: '请先播放视频',
  1434. // icon: 'none'
  1435. // })
  1436. // }
  1437. // #ifndef H5
  1438. if (appLivePlayerContext.value && isPlaying.value) {
  1439. appLivePlayerContext.value.snapshot({
  1440. success: (res) => {
  1441. console.log('App截图成功:', res.tempImagePath)
  1442. uni.saveImageToPhotosAlbum({
  1443. filePath: res.tempImagePath,
  1444. success: () => {
  1445. uni.showToast({
  1446. title: '截图已保存到相册',
  1447. icon: 'success'
  1448. })
  1449. },
  1450. fail: (err) => {
  1451. console.error('App保存截图失败:', err)
  1452. uni.showToast({
  1453. title: '保存截图失败',
  1454. icon: 'none'
  1455. })
  1456. }
  1457. })
  1458. },
  1459. fail: (err) => {
  1460. console.error('App截图失败:', err)
  1461. uni.showToast({
  1462. title: '截图失败',
  1463. icon: 'none'
  1464. })
  1465. }
  1466. })
  1467. } else {
  1468. uni.showToast({
  1469. title: '请先播放视频',
  1470. icon: 'none'
  1471. })
  1472. }
  1473. // #endif
  1474. }
  1475. // 小程序播放器状态变化处理
  1476. const onVideoPlay = () => {
  1477. console.log('视频开始播放')
  1478. isPlaying.value = true
  1479. }
  1480. const onVideoPause = () => {
  1481. console.log('视频暂停')
  1482. }
  1483. const onVideoEnded = () => {
  1484. console.log('视频播放结束')
  1485. isPlaying.value = false
  1486. }
  1487. const onTimeUpdate = (e) => {
  1488. // 更新播放时间
  1489. if (e && e.detail) {
  1490. const currentSeconds = Math.floor(e.detail.currentTime)
  1491. const hours = String(Math.floor(currentSeconds / 3600)).padStart(2, '0')
  1492. const minutes = String(Math.floor((currentSeconds % 3600) / 60)).padStart(2, '0')
  1493. const seconds = String(currentSeconds % 60).padStart(2, '0')
  1494. currentTime.value = `${hours}:${minutes}:${seconds}`
  1495. }
  1496. }
  1497. const onStateChange = (e) => {
  1498. console.log('播放器状态变化:', e.detail)
  1499. const state = e.detail.code
  1500. switch (state) {
  1501. case 2001:
  1502. console.log('已连接服务器')
  1503. break
  1504. case 2002:
  1505. console.log('开始拉流')
  1506. break
  1507. case 2003:
  1508. console.log('网络接收到首个视频帧')
  1509. break
  1510. case 2004:
  1511. console.log('视频播放开始')
  1512. break
  1513. case 2005:
  1514. console.log('视频播放进度')
  1515. break
  1516. case 2006:
  1517. console.log('视频播放结束')
  1518. isPlaying.value = false
  1519. break
  1520. case 2007:
  1521. console.log('视频播放Loading')
  1522. break
  1523. case 2008:
  1524. console.log('解码器启动')
  1525. break
  1526. case 2009:
  1527. console.log('视频分辨率改变')
  1528. break
  1529. case -2301:
  1530. console.error('网络断连,且重新连接亦不能恢复,播放器已停止')
  1531. isPlaying.value = false
  1532. uni.showToast({
  1533. title: '网络断连,请重试',
  1534. icon: 'none'
  1535. })
  1536. break
  1537. case -2302:
  1538. console.error('获取加速拉流地址失败')
  1539. break
  1540. case 2101:
  1541. console.error('当前视频帧解码失败')
  1542. break
  1543. case 2102:
  1544. console.error('当前音频帧解码失败')
  1545. break
  1546. case 2103:
  1547. console.warn('网络断连, 已启动自动重连')
  1548. break
  1549. case 2104:
  1550. console.warn('网络断连, 重连中...')
  1551. break
  1552. case 2105:
  1553. console.log('网络断连, 重连成功')
  1554. break
  1555. case 2106:
  1556. console.error('网络断连, 重连失败')
  1557. break
  1558. case 2107:
  1559. console.error('播放器连接超时')
  1560. break
  1561. case 2108:
  1562. console.error('获取点播文件信息失败')
  1563. break
  1564. default:
  1565. console.log('其他状态:', state)
  1566. }
  1567. }
  1568. // 小程序全屏状态变化
  1569. const onFullscreenChange = (e) => {
  1570. isFullscreen.value = e.detail.fullScreen
  1571. console.log('全屏状态变化:', isFullscreen.value)
  1572. }
  1573. // 获取App(安卓/鸿蒙)环境使用的流地址
  1574. const getAppStreamUrl = computed(() => {
  1575. // ===== 诊断日志 =====
  1576. console.log('========== [诊断] getAppStreamUrl ==========')
  1577. console.log('fmp4StreamUrl:', deviceInfo.fmp4StreamUrl)
  1578. console.log('hlsStreamUrl:', deviceInfo.hlsStreamUrl)
  1579. // App iOS 优先使用 HLS
  1580. // #ifdef APP-PLUS
  1581. const platform = uni.getSystemInfoSync().platform
  1582. console.log('App 平台:', platform)
  1583. if (platform === 'ios') {
  1584. if (deviceInfo.hlsStreamUrl) {
  1585. console.log('App iOS 优先使用 hlsStreamUrl')
  1586. return deviceInfo.hlsStreamUrl
  1587. } else if (deviceInfo.fmp4StreamUrl) {
  1588. console.log('App iOS 无 hls,使用 fmp4 兜底')
  1589. return deviceInfo.fmp4StreamUrl
  1590. }
  1591. }
  1592. // #endif
  1593. // App Android / 鸿蒙:优先使用 fmp4
  1594. if (deviceInfo.fmp4StreamUrl) {
  1595. console.log('App 使用 fmp4StreamUrl')
  1596. return deviceInfo.fmp4StreamUrl
  1597. }
  1598. // 如果没有流地址,返回空字符串
  1599. console.warn('未获取到视频流地址')
  1600. return ''
  1601. })
  1602. // ===== 批次状态判断 =====
  1603. // 爱智农后台状态:1=待发布, 2=已发布, 3=已下线
  1604. const BATCH_STATUS_PENDING = '1'
  1605. const BATCH_STATUS_PUBLISHED = '2'
  1606. const BATCH_STATUS_OFFLINED = '3'
  1607. // 获取当前批次状态值
  1608. const batchStatus = computed(() => {
  1609. const data = traceInfo.value
  1610. if (!data) return ''
  1611. const s = String(data.status)
  1612. if ([BATCH_STATUS_PENDING, BATCH_STATUS_PUBLISHED, BATCH_STATUS_OFFLINED].includes(s)) {
  1613. return s
  1614. }
  1615. return ''
  1616. })
  1617. // 是否可展示完整溯源内容(仅已发布状态)
  1618. const canShowTraceContent = computed(() => batchStatus.value === BATCH_STATUS_PUBLISHED)
  1619. // 各状态布尔值
  1620. const isBatchPending = computed(() => batchStatus.value === BATCH_STATUS_PENDING)
  1621. const isBatchPublished = computed(() => batchStatus.value === BATCH_STATUS_PUBLISHED)
  1622. const isBatchOfflined = computed(() => batchStatus.value === BATCH_STATUS_OFFLINED)
  1623. const isBatchUnavailable = computed(() => !canShowTraceContent.value)
  1624. // 各状态文案映射
  1625. const batchStatusTextMap = {
  1626. [BATCH_STATUS_PENDING]: '待发布',
  1627. [BATCH_STATUS_PUBLISHED]: '已发布',
  1628. [BATCH_STATUS_OFFLINED]: '已下线'
  1629. }
  1630. // 各状态 badge 映射
  1631. const batchStatusBadgeMap = {
  1632. [BATCH_STATUS_PENDING]: { text: '待发布', type: 'wait' },
  1633. [BATCH_STATUS_PUBLISHED]: { text: '检验合格', type: 'ok' },
  1634. [BATCH_STATUS_OFFLINED]: { text: '已下线', type: 'muted' },
  1635. _invalid: { text: '未找到', type: 'muted' }
  1636. }
  1637. // 各状态异常态文案
  1638. const batchEmptyMessageMap = {
  1639. [BATCH_STATUS_PENDING]: '当前批次暂未开放查询,相关溯源内容暂不对外展示。',
  1640. [BATCH_STATUS_OFFLINED]: '当前批次已下线,相关溯源内容暂不对外展示。',
  1641. _invalid: '未找到对应溯源码信息,请确认二维码是否正确。'
  1642. }
  1643. // 获取当前状态对应的 badge
  1644. const getCurrentStatusBadge = () => {
  1645. const s = batchStatus.value
  1646. if (!s) return batchStatusBadgeMap._invalid
  1647. return batchStatusBadgeMap[s] || batchStatusBadgeMap._invalid
  1648. }
  1649. // 获取当前状态对应的异常态文案
  1650. const getCurrentEmptyMessage = () => {
  1651. const s = batchStatus.value
  1652. if (!s) return batchEmptyMessageMap._invalid
  1653. return batchEmptyMessageMap[s] || batchEmptyMessageMap._invalid
  1654. }
  1655. const traceDetail = computed(() => {
  1656. // 如果没有真实数据,返回 mock 数据
  1657. if (!traceInfo.value) {
  1658. return MOCK_TRACE_DETAILS[mockStateKey.value] || MOCK_TRACE_DETAILS.normal
  1659. }
  1660. const data = traceInfo.value
  1661. // 解析 certFiles 和 reportFiles(JSON 字符串转数组)
  1662. let certFiles = []
  1663. let reportFiles = []
  1664. // 查找 farmTimeline 中 stage === 'planting' 的节点,用于兜底种植时间
  1665. const plantingNode = Array.isArray(data.farmTimeline)
  1666. ? data.farmTimeline.find(item => item.stage === 'planting')
  1667. : null
  1668. try {
  1669. if (data.certificate?.certFiles) {
  1670. certFiles = JSON.parse(data.certificate.certFiles)
  1671. }
  1672. } catch (e) {
  1673. console.error('解析 certFiles 失败', e)
  1674. }
  1675. // 构建返回数据结构
  1676. return {
  1677. product: {
  1678. name: data.productName || '',
  1679. spec: data.productSpec || '',
  1680. image: data.productImage || '',
  1681. intro: data.productDesc || ''
  1682. },
  1683. farm: {
  1684. name: data.farmName || '',
  1685. location: data.farmRegion || '',
  1686. image: data.farmImage || '',
  1687. intro: data.farmIntro || ''
  1688. },
  1689. batch: {
  1690. status: batchStatus.value,
  1691. statusText: batchStatusTextMap[batchStatus.value] || '未找到',
  1692. exists: canShowTraceContent.value,
  1693. statusBadge: getCurrentStatusBadge(),
  1694. no: data.batchNo || '',
  1695. plantStartTime: '2026-03-01',
  1696. harvestTime: data.produceDate || '',
  1697. packTime: data.packageDate || '',
  1698. emptyTitle: '暂无相关溯源码信息',
  1699. emptyMessage: getCurrentEmptyMessage()
  1700. },
  1701. report: {
  1702. status: data.reports && data.reports.length > 0 ? 'uploaded' : 'pending',
  1703. statusBadge: data.reports && data.reports.length > 0
  1704. ? { text: '已上传', type: 'ok' }
  1705. : { text: '待补充', type: 'wait' },
  1706. emptyMessage: '检测报告待补充,上传完成后可查看大图。',
  1707. items: (data.reports || []).map(report => {
  1708. let images = []
  1709. // 处理 reportFiles:可能是字符串 URL、JSON 字符串数组、或已解析的数组
  1710. if (report.reportFiles) {
  1711. if (typeof report.reportFiles === 'string') {
  1712. // 尝试解析 JSON 字符串
  1713. try {
  1714. const parsed = JSON.parse(report.reportFiles)
  1715. // 如果解析成功且是数组,提取 url 字段
  1716. if (Array.isArray(parsed)) {
  1717. images = parsed.map(item =>
  1718. typeof item === 'string' ? item : (item.url || item)
  1719. ).filter(Boolean)
  1720. } else {
  1721. // 解析后不是数组,可能是单个对象
  1722. images = [parsed.url || parsed].filter(Boolean)
  1723. }
  1724. } catch (e) {
  1725. // 解析失败,当作普通 URL 字符串处理
  1726. images = [report.reportFiles]
  1727. }
  1728. } else if (Array.isArray(report.reportFiles)) {
  1729. // 已经是数组,提取 url 字段
  1730. images = report.reportFiles.map(item =>
  1731. typeof item === 'string' ? item : (item.url || item)
  1732. ).filter(Boolean)
  1733. } else if (typeof report.reportFiles === 'object') {
  1734. // 单个对象
  1735. images = [report.reportFiles.url || report.reportFiles].filter(Boolean)
  1736. }
  1737. }
  1738. return {
  1739. detectDate: report.reportDate || '',
  1740. no: report.reportNo || '',
  1741. images: images
  1742. }
  1743. })
  1744. },
  1745. certificate: {
  1746. status: data.certificate && certFiles.length > 0 ? 'uploaded' : 'pending',
  1747. statusBadge: data.certificate && certFiles.length > 0
  1748. ? { text: '已上传', type: 'ok' }
  1749. : { text: '待补充', type: 'wait' },
  1750. issueDate: data.certificate?.certIssueDate || '',
  1751. no: data.certificate?.certNo || '',
  1752. fileUrl: certFiles.length > 0 ? certFiles[0].url : '',
  1753. images: certFiles.map(f => f.url),
  1754. emptyMessage: '合格证待补充,上传完成后可查看大图。'
  1755. },
  1756. traceConclusionCard: {
  1757. title: '溯源结论',
  1758. conclusion: '本批次产品来源清晰,已完成安全检测,过程可查',
  1759. desc: '检测材料与溯源数据已展示,可继续查看',
  1760. passed: true
  1761. },
  1762. // 时间轴逻辑:演示态使用 mock + 真实态使用真实数据
  1763. farmTimeline: (() => {
  1764. // 判断是否有真实时间轴数据
  1765. const hasRealTimeline = Array.isArray(data.farmTimeline) && data.farmTimeline.length > 0
  1766. let timeline = []
  1767. if (!hasRealTimeline) {
  1768. // 演示态:使用完整 mock 时间轴(用于页面展示验证)
  1769. timeline = [
  1770. { time: '2026-03-01', stage: 'planting', title: '开始种植', desc: '本批次产品进入种植管理阶段' },
  1771. { time: '2026-03-12', stage: 'care', title: '生长期养护', desc: '种植期间已持续开展灌溉、施肥等日常养护' },
  1772. { time: '2026-03-20', stage: 'inspection', title: '田间巡检', desc: '种植期间已持续开展长势检查与环境巡检' },
  1773. { time: data.produceDate || '', stage: 'harvest', title: '成熟采收', desc: '本批次产品进入成熟采收阶段' },
  1774. { time: (data.reports?.[0]?.reportDate) || '', stage: 'test', title: '安全检测', desc: '已完成安全检测,相关结果可查' },
  1775. { time: data.packageDate || '', stage: 'pack', title: '包装日期:出库', desc: '已完成包装日期:整理,进入销售流通环节' }
  1776. ]
  1777. } else {
  1778. // 真实态:使用真实数据 + 补充系统节点
  1779. timeline = [...data.farmTimeline]
  1780. const stageSet = new Set(timeline.map(n => n.stage))
  1781. // 成熟采收
  1782. if (data.produceDate && !stageSet.has('harvest')) {
  1783. timeline.push({
  1784. time: data.produceDate,
  1785. stage: 'harvest',
  1786. title: '成熟采收',
  1787. desc: '本批次产品进入成熟采收阶段'
  1788. })
  1789. }
  1790. // 安全检测
  1791. if (data.reports && data.reports.length > 0 && !stageSet.has('test')) {
  1792. const validDates = data.reports
  1793. .map(r => r.reportDate)
  1794. .filter(d => d && /^\d{4}-\d{2}-\d{2}/.test(d))
  1795. .sort()
  1796. if (validDates.length > 0) {
  1797. timeline.push({
  1798. time: validDates[0],
  1799. stage: 'test',
  1800. title: '安全检测',
  1801. desc: '已完成安全检测,相关结果可查'
  1802. })
  1803. }
  1804. }
  1805. // 包装日期:出库
  1806. if (data.packageDate && !stageSet.has('pack')) {
  1807. timeline.push({
  1808. time: data.packageDate,
  1809. stage: 'pack',
  1810. title: '包装日期:出库',
  1811. desc: '已完成包装日期:整理,进入销售流通环节'
  1812. })
  1813. }
  1814. }
  1815. // stage 顺序权重
  1816. const stageOrder = {
  1817. planting: 1,
  1818. care: 2,
  1819. inspection: 3,
  1820. harvest: 4,
  1821. test: 5,
  1822. pack: 6
  1823. }
  1824. // 按业务阶段排序,同 stage 内再按时间
  1825. timeline.sort((a, b) => {
  1826. const orderA = stageOrder[a.stage] || 99
  1827. const orderB = stageOrder[b.stage] || 99
  1828. // 先按 stage 排序
  1829. if (orderA !== orderB) {
  1830. return orderA - orderB
  1831. }
  1832. // 同 stage 再按时间
  1833. if (!a.time) return -1
  1834. if (!b.time) return 1
  1835. return a.time > b.time ? 1 : -1
  1836. })
  1837. return timeline.slice(0, 6)
  1838. })(),
  1839. camera: {
  1840. liveUrl: data.camera?.liveUrl || '',
  1841. coverImage: data.camera?.coverImage || '',
  1842. status: data.camera?.status || 'online',
  1843. desc: data.camera?.liveUrl
  1844. ? '当前为种植现场实时画面,现场环境与种植状态可见'
  1845. : '来自农场实景画面,种植环境真实呈现'
  1846. },
  1847. environment: {
  1848. summary: '本批次种植期环境稳定,整体处于适宜生长区间',
  1849. chart: {
  1850. type: 'npk_trend',
  1851. labels: ['03-01', '03-06', '03-10', '03-15', '03-21', '03-27', '04-01'],
  1852. values: {
  1853. n: [26.2, 25.8, 26.4, 25.9, 26.6, 26.1, 26.4],
  1854. p: [20.5, 20.1, 20.4, 20.0, 20.3, 20.2, 20.4],
  1855. k: [14.2, 14.6, 14.3, 14.7, 14.4, 14.8, 14.5]
  1856. }
  1857. },
  1858. items: [
  1859. { label: '气温', value: '22.3℃', status: '种植期平均' },
  1860. { label: '湿度', value: '45%', status: '种植期平均' },
  1861. { label: '降雨量', value: '118mm', status: '种植期累计' },
  1862. { label: '光照', value: '充足', status: '表现稳定' }
  1863. ],
  1864. current: {
  1865. temperature: '24.5℃',
  1866. humidity: '42.2%'
  1867. }
  1868. }
  1869. }
  1870. })
  1871. // 种植现场状态:三态逻辑
  1872. const cameraStatus = computed(() => {
  1873. const camera = deviceInfo?.status
  1874. if (!camera) return 'off'
  1875. // const hasLiveUrl = !!camera.liveUrl
  1876. // 有 liveUrl 但无封面图 → loading(信号接入中)
  1877. // 有 liveUrl 且有封面图 → online(可播放)
  1878. // 无 liveUrl → offline
  1879. if (camera && camera == 'off') {
  1880. return 'loading'
  1881. }
  1882. if (camera && camera == 'ON') {
  1883. return 'online'
  1884. }
  1885. return 'offline'
  1886. })
  1887. const cameraStatusText = computed(() => {
  1888. const map = {
  1889. loading: '连接中',
  1890. online: '实时在线',
  1891. offline: '暂未连接'
  1892. }
  1893. return map[cameraStatus.value] || '暂未连接'
  1894. })
  1895. // 种植环境记录图表配置
  1896. const CHART_SVG_WIDTH = 700
  1897. const CHART_SVG_HEIGHT = 200
  1898. const CHART_PADDING = 24 // SVG 内边距
  1899. // 动态计算数据范围(从真实数据中获取,并留上下边距)
  1900. const chartValueRange = computed(() => {
  1901. const chart = traceDetail.value?.environment?.chart
  1902. if (!chart?.values) {
  1903. return { min: 0, max: 1 }
  1904. }
  1905. const allValues = [
  1906. ...(chart.values.n || []),
  1907. ...(chart.values.p || []),
  1908. ...(chart.values.k || [])
  1909. ].filter(v => typeof v === 'number' && !Number.isNaN(v))
  1910. if (!allValues.length) {
  1911. return { min: 0, max: 1 }
  1912. }
  1913. const min = Math.min(...allValues)
  1914. const max = Math.max(...allValues)
  1915. // 增加上下留白,避免点贴边
  1916. const padding = (max - min) * 0.18 || 1
  1917. return {
  1918. min: min - padding,
  1919. max: max + padding
  1920. }
  1921. })
  1922. // 计算单个数据点在 SVG 坐标中的 y 值(使用动态范围)
  1923. const getSvgY = (value) => {
  1924. const { min, max } = chartValueRange.value
  1925. const range = max - min
  1926. if (range === 0) return CHART_SVG_HEIGHT / 2
  1927. const normalized = (value - min) / range
  1928. const innerHeight = CHART_SVG_HEIGHT - CHART_PADDING * 2
  1929. const y = CHART_PADDING + innerHeight * (1 - normalized)
  1930. return y
  1931. }
  1932. // 计算单个数据点在 SVG 坐标中的 x 值
  1933. const getSvgX = (idx, dataLength) => {
  1934. if (dataLength <= 1) return CHART_SVG_WIDTH / 2
  1935. const innerWidth = CHART_SVG_WIDTH - CHART_PADDING * 2
  1936. return CHART_PADDING + (idx / (dataLength - 1)) * innerWidth
  1937. }
  1938. // 获取某组数据的所有点位(过滤无效数据)
  1939. const getSvgPoints = (data) => {
  1940. if (!Array.isArray(data) || data.length === 0) return []
  1941. return data
  1942. .filter(v => typeof v === 'number' && !Number.isNaN(v))
  1943. .map((val, idx, arr) => ({
  1944. x: getSvgX(idx, arr.length),
  1945. y: getSvgY(val),
  1946. value: val
  1947. }))
  1948. }
  1949. // Catmull-Rom 转 Bezier 生成平滑曲线路径
  1950. const buildSmoothPath = (points) => {
  1951. if (points.length < 2) return ''
  1952. if (points.length === 2) {
  1953. return `M ${points[0].x} ${points[0].y} L ${points[1].x} ${points[1].y}`
  1954. }
  1955. // 起点
  1956. let d = `M ${points[0].x} ${points[0].y}`
  1957. // 中间点使用 Catmull-Rom 转 Bezier
  1958. for (let i = 0; i < points.length - 1; i++) {
  1959. const p0 = points[Math.max(0, i - 1)]
  1960. const p1 = points[i]
  1961. const p2 = points[i + 1]
  1962. const p3 = points[Math.min(points.length - 1, i + 2)]
  1963. // 控制点计算(张力系数 0.5)
  1964. const cp1x = p1.x + (p2.x - p0.x) / 6
  1965. const cp1y = p1.y + (p2.y - p0.y) / 6
  1966. const cp2x = p2.x - (p3.x - p1.x) / 6
  1967. const cp2y = p2.y - (p3.y - p1.y) / 6
  1968. d += ` C ${cp1x} ${cp1y}, ${cp2x} ${cp2y}, ${p2.x} ${p2.y}`
  1969. }
  1970. return d
  1971. }
  1972. // SVG 网格线 y 坐标
  1973. const svgGridLines = [24, 56, 88, 120, 152, 176]
  1974. // 平滑曲线配置
  1975. const CURVE_TENSION = 0.35 // 张力系数,越小越平滑
  1976. // 统一的图表计算 computed(确保所有依赖正确响应式)
  1977. const chartData = computed(() => {
  1978. const chart = traceDetail.value?.environment?.chart
  1979. if (!chart || !chart.values) {
  1980. return { n: [], p: [], k: [], paths: { n: '', p: '', k: '' }, areas: { n: '', p: '', k: '' } }
  1981. }
  1982. const valuesN = chart.values.n || []
  1983. const valuesP = chart.values.p || []
  1984. const valuesK = chart.values.k || []
  1985. // 收集所有有效数值,计算全局范围
  1986. const allValues = [...valuesN, ...valuesP, ...valuesK]
  1987. .filter(v => typeof v === 'number' && !Number.isNaN(v))
  1988. if (!allValues.length) {
  1989. return { n: [], p: [], k: [], paths: { n: '', p: '', k: '' }, areas: { n: '', p: '', k: '' } }
  1990. }
  1991. const dataMin = Math.min(...allValues)
  1992. const dataMax = Math.max(...allValues)
  1993. const padding = (dataMax - dataMin) * 0.25 || 1 // 增加边距空间
  1994. const minVal = dataMin - padding
  1995. const maxVal = dataMax + padding
  1996. const range = maxVal - minVal || 1
  1997. // 计算坐标的辅助函数
  1998. const calcY = (val) => {
  1999. const normalized = (val - minVal) / range
  2000. const innerHeight = CHART_SVG_HEIGHT - CHART_PADDING * 2
  2001. return CHART_PADDING + innerHeight * (1 - normalized)
  2002. }
  2003. const calcX = (idx, length) => {
  2004. if (length <= 1) return CHART_SVG_WIDTH / 2
  2005. const innerWidth = CHART_SVG_WIDTH - CHART_PADDING * 2
  2006. return CHART_PADDING + (idx / (length - 1)) * innerWidth
  2007. }
  2008. // 异常点平滑处理(简单移动平均)
  2009. const smoothValues = (data) => {
  2010. if (data.length < 3) return data
  2011. return data.map((v, i, arr) => {
  2012. if (i === 0 || i === arr.length - 1) return v
  2013. const prev = arr[i - 1]
  2014. const next = arr[i + 1]
  2015. // 如果与前后差值过大,做轻微平滑
  2016. if (Math.abs(v - prev) > range * 0.3 && Math.abs(v - next) > range * 0.3) {
  2017. return (prev + v + next) / 3
  2018. }
  2019. return v
  2020. })
  2021. }
  2022. // 计算点坐标(带平滑)
  2023. const calcPoints = (data) => {
  2024. if (!data.length) return []
  2025. const smoothed = smoothValues(data.filter(v => typeof v === 'number' && !Number.isNaN(v)))
  2026. return smoothed.map((val, idx, arr) => ({
  2027. x: calcX(idx, arr.length),
  2028. y: calcY(val),
  2029. value: val
  2030. }))
  2031. }
  2032. // 生成平滑曲线路径(使用优化的张力系数)
  2033. const buildPath = (points) => {
  2034. if (points.length < 2) return ''
  2035. if (points.length === 2) {
  2036. return `M ${points[0].x} ${points[0].y} L ${points[1].x} ${points[1].y}`
  2037. }
  2038. let d = `M ${points[0].x} ${points[0].y}`
  2039. for (let i = 0; i < points.length - 1; i++) {
  2040. const p0 = points[Math.max(0, i - 1)]
  2041. const p1 = points[i]
  2042. const p2 = points[i + 1]
  2043. const p3 = points[Math.min(points.length - 1, i + 2)]
  2044. // 使用可配置的张力系数
  2045. const cp1x = p1.x + (p2.x - p0.x) * CURVE_TENSION
  2046. const cp1y = p1.y + (p2.y - p0.y) * CURVE_TENSION
  2047. const cp2x = p2.x - (p3.x - p1.x) * CURVE_TENSION
  2048. const cp2y = p2.y - (p3.y - p1.y) * CURVE_TENSION
  2049. d += ` C ${cp1x} ${cp1y}, ${cp2x} ${cp2y}, ${p2.x} ${p2.y}`
  2050. }
  2051. return d
  2052. }
  2053. // 生成面积渐变路径(曲线下方填充)
  2054. const buildArea = (points) => {
  2055. if (points.length < 2) return ''
  2056. const linePath = buildPath(points)
  2057. const bottomY = CHART_SVG_HEIGHT - CHART_PADDING
  2058. const firstX = points[0].x
  2059. const lastX = points[points.length - 1].x
  2060. return `${linePath} L ${lastX} ${bottomY} L ${firstX} ${bottomY} Z`
  2061. }
  2062. const nPoints = calcPoints(valuesN)
  2063. const pPoints = calcPoints(valuesP)
  2064. const kPoints = calcPoints(valuesK)
  2065. return {
  2066. n: nPoints,
  2067. p: pPoints,
  2068. k: kPoints,
  2069. paths: {
  2070. n: buildPath(nPoints),
  2071. p: buildPath(pPoints),
  2072. k: buildPath(kPoints)
  2073. },
  2074. areas: {
  2075. n: buildArea(nPoints),
  2076. p: buildArea(pPoints),
  2077. k: buildArea(kPoints)
  2078. }
  2079. }
  2080. })
  2081. // 兼容旧接口
  2082. const chartPoints = computed(() => ({
  2083. n: chartData.value.n,
  2084. p: chartData.value.p,
  2085. k: chartData.value.k
  2086. }))
  2087. const chartPaths = computed(() => chartData.value.paths)
  2088. const chartAreas = computed(() => chartData.value.areas)
  2089. const reportImages = computed(() => {
  2090. const items = traceDetail.value?.report?.items
  2091. if (Array.isArray(items)) {
  2092. return items.flatMap(item => Array.isArray(item.images) ? item.images : [])
  2093. }
  2094. return []
  2095. })
  2096. const reportItems = computed(() => {
  2097. return traceDetail.value?.report?.items || []
  2098. })
  2099. // 计算某份报告内某张图在全局 reportImages 扁平数组中的索引
  2100. function getReportGlobalIndex(itemIndex, imgIndex) {
  2101. const items = reportItems.value
  2102. let offset = 0
  2103. for (let i = 0; i < itemIndex; i++) {
  2104. const imgArr = items[i]?.images
  2105. offset += Array.isArray(imgArr) ? imgArr.length : 0
  2106. }
  2107. return offset + imgIndex
  2108. }
  2109. const certificateImages = computed(() => {
  2110. const c = traceDetail.value?.certificate
  2111. if (!c) return []
  2112. if (Array.isArray(c.images) && c.images.length) return c.images
  2113. return c.fileUrl ? [c.fileUrl] : []
  2114. })
  2115. function contactCustomer() {
  2116. uni.makePhoneCall({
  2117. phoneNumber: '13379508760'
  2118. })
  2119. }
  2120. function goToWechatStore() {
  2121. const url = 'https://store.weixin.qq.com/shop/a/MfixzaIsuMchTDd'
  2122. // #ifdef H5
  2123. window.location.href = url
  2124. // #endif
  2125. // #ifndef H5
  2126. uni.setClipboardData({
  2127. data: url,
  2128. success: () => {
  2129. uni.showToast({ title: '链接已复制,请在浏览器打开', icon: 'none' })
  2130. }
  2131. })
  2132. // #endif
  2133. }
  2134. function goBackToPurchase() {
  2135. uni.showModal({
  2136. title: '返回购买渠道',
  2137. content: 'mock 模式:后续可跳转到直播间/小店页面。',
  2138. showCancel: true,
  2139. confirmText: '确认返回'
  2140. })
  2141. }
  2142. function previewDoc(kind, index) {
  2143. const urls = kind === 'report' ? reportImages.value : certificateImages.value
  2144. if (!urls.length) {
  2145. uni.showToast({ title: '该文件暂未上传', icon: 'none' })
  2146. return
  2147. }
  2148. uni.previewImage({
  2149. urls,
  2150. current: urls[index] || urls[0]
  2151. })
  2152. }
  2153. </script>
  2154. <style scoped>
  2155. .page {
  2156. position: relative;
  2157. min-height: 100vh;
  2158. --bg-cream-1: #f8f2e8;
  2159. --bg-cream-2: #f3ebdd;
  2160. --bg-cream-3: #ece1ce;
  2161. --forest-900: #143a2b;
  2162. --forest-800: #1f513b;
  2163. --forest-700: #2d6849;
  2164. --sage-500: #708f7d;
  2165. --gold-320: #ccb086;
  2166. --gold-260: #dcc4a0;
  2167. --text-900: #233126;
  2168. --text-700: #3c4d41;
  2169. --text-500: #6b776d;
  2170. background: linear-gradient(172deg,
  2171. #FAF6EF 0%,
  2172. #F4EEE3 38%,
  2173. #EDF0EC 68%,
  2174. #E8EFE9 100%
  2175. );
  2176. overflow: hidden;
  2177. }
  2178. /* 背景氛围层:三层光感(前景/中景/背景)+ grain */
  2179. .pageDecor {
  2180. position: fixed;
  2181. inset: 0;
  2182. pointer-events: none;
  2183. z-index: 0;
  2184. }
  2185. .pageGlow {
  2186. position: absolute;
  2187. border-radius: 50%;
  2188. filter: blur(14rpx);
  2189. }
  2190. /* 背景层:左上森林绿微光 */
  2191. .glowA {
  2192. width: 780rpx;
  2193. height: 780rpx;
  2194. top: -280rpx;
  2195. left: -300rpx;
  2196. background: radial-gradient(circle, rgba(26, 84, 58, 0.18) 0%, rgba(20, 72, 50, 0) 70%);
  2197. opacity: 0.85;
  2198. }
  2199. /* 中景层:右下金色暖光 */
  2200. .glowB {
  2201. width: 720rpx;
  2202. height: 720rpx;
  2203. right: -280rpx;
  2204. top: 480rpx;
  2205. background: radial-gradient(circle, rgba(200, 170, 120, 0.2) 0%, rgba(200, 170, 120, 0) 72%);
  2206. opacity: 0.9;
  2207. }
  2208. /* 前景层:顶部柔和高光,塑造空间感 */
  2209. .glowC {
  2210. width: 600rpx;
  2211. height: 360rpx;
  2212. top: -60rpx;
  2213. left: 50%;
  2214. transform: translateX(-50%);
  2215. background: radial-gradient(ellipse at 50% 0%, rgba(255, 252, 246, 0.38), transparent 70%);
  2216. filter: blur(20rpx);
  2217. opacity: 0.7;
  2218. }
  2219. /* 纹理叠加层 */
  2220. .pageGrain {
  2221. position: absolute;
  2222. inset: 0;
  2223. opacity: 0.55;
  2224. background:
  2225. radial-gradient(900rpx 380rpx at 48% -4%, rgba(255, 255, 255, 0.55), rgba(255, 255, 255, 0)),
  2226. radial-gradient(640rpx 400rpx at 104% 48%, rgba(68, 112, 86, 0.09), rgba(68, 112, 86, 0)),
  2227. radial-gradient(700rpx 320rpx at -4% 76%, rgba(210, 180, 130, 0.12), rgba(210, 180, 130, 0)),
  2228. linear-gradient(180deg, rgba(248, 244, 236, 0.16) 0%, rgba(228, 242, 232, 0.08) 100%);
  2229. }
  2230. .safeTop {
  2231. height: calc(env(safe-area-inset-top));
  2232. position: relative;
  2233. z-index: 1;
  2234. }
  2235. /* 轻品牌页头:透明底,不叠在 Hero 上产生「白雾」;层级低于首屏卡 */
  2236. .brandPageHeader {
  2237. position: relative;
  2238. z-index: 2;
  2239. display: flex;
  2240. align-items: center;
  2241. min-height: 72rpx;
  2242. padding: 0 40rpx;
  2243. box-sizing: border-box;
  2244. border-bottom: 1rpx solid rgba(39, 75, 57, 0.05);
  2245. background: transparent;
  2246. }
  2247. .brandPageHeaderInner {
  2248. display: flex;
  2249. align-items: center;
  2250. gap: 10rpx;
  2251. width: 100%;
  2252. }
  2253. .brandPageHeaderName {
  2254. font-size: 22rpx;
  2255. font-weight: 600;
  2256. line-height: 1.15;
  2257. letter-spacing: 0.1em;
  2258. color: rgba(27, 41, 33, 0.65);
  2259. }
  2260. .brandPageHeaderDot {
  2261. flex-shrink: 0;
  2262. width: 4rpx;
  2263. height: 4rpx;
  2264. border-radius: 50%;
  2265. background: rgba(39, 113, 76, 0.4);
  2266. }
  2267. .brandPageHeaderLabel {
  2268. font-size: 20rpx;
  2269. font-weight: 400;
  2270. line-height: 1.15;
  2271. letter-spacing: 0.06em;
  2272. color: rgba(112, 143, 125, 0.7);
  2273. }
  2274. .hero,
  2275. .content {
  2276. position: relative;
  2277. z-index: 1;
  2278. }
  2279. .hero {
  2280. padding: 0 24rpx;
  2281. }
  2282. /* 完整首屏大卡:与品牌页头分离,避免负 margin 上提后被页头遮盖 */
  2283. .heroCard {
  2284. border-radius: 42rpx;
  2285. overflow: hidden;
  2286. margin-top: 20rpx;
  2287. position: relative;
  2288. z-index: 4;
  2289. box-shadow:
  2290. 0 48rpx 120rpx rgba(10, 36, 24, 0.2),
  2291. 0 16rpx 48rpx rgba(10, 36, 24, 0.1),
  2292. 0 2rpx 0 rgba(255, 255, 255, 0.6) inset;
  2293. backdrop-filter: blur(4px);
  2294. }
  2295. /* Hero 视觉区:多层次光感空间,顶部高光 + 景深 + 底部暗化 */
  2296. .heroBg {
  2297. position: relative;
  2298. width: 100%;
  2299. height: 0;
  2300. padding-bottom: 56.25%;
  2301. overflow: hidden;
  2302. background: linear-gradient(160deg, rgba(20, 74, 52, 0.72), rgba(205, 177, 129, 0.3) 70%, rgba(243, 232, 214, 0.36));
  2303. }
  2304. /* 前景层光晕:右下淡金色微光(提升质感) */
  2305. .heroBg::before {
  2306. content: '';
  2307. position: absolute;
  2308. right: -100rpx;
  2309. bottom: -72rpx;
  2310. width: 520rpx;
  2311. height: 280rpx;
  2312. border-radius: 50%;
  2313. background: radial-gradient(ellipse at 42% 38%, rgba(252, 244, 228, 0.18), transparent 68%);
  2314. pointer-events: none;
  2315. z-index: 2;
  2316. }
  2317. .heroImage {
  2318. position: absolute;
  2319. inset: 0;
  2320. width: 100%;
  2321. height: 100%;
  2322. display: block;
  2323. z-index: 1;
  2324. }
  2325. .heroBrandAnchor {
  2326. position: absolute;
  2327. right: -48rpx;
  2328. bottom: -14rpx;
  2329. z-index: 2;
  2330. pointer-events: none;
  2331. }
  2332. .heroBrandAnchorText {
  2333. font-size: 164rpx;
  2334. font-weight: 700;
  2335. letter-spacing: 0.1em;
  2336. line-height: 1;
  2337. color: rgba(248, 241, 227, 0.045);
  2338. transform: rotate(-8deg);
  2339. }
  2340. /* Hero 遮罩层:提亮后仍保留轻微底部过渡,避免压住真实商品图 */
  2341. .heroMask {
  2342. position: absolute;
  2343. inset: 0;
  2344. z-index: 3;
  2345. background:
  2346. radial-gradient(ellipse 180% 60% at 50% 0%, rgba(255, 252, 248, 0.26), transparent 68%),
  2347. radial-gradient(480rpx 240rpx at 90% 8%, rgba(252, 248, 240, 0.2), transparent 62%),
  2348. radial-gradient(700rpx 360rpx at 8% 65%, rgba(6, 24, 16, 0.12), transparent 58%),
  2349. radial-gradient(560rpx 300rpx at 88% 80%, rgba(205, 177, 129, 0.06), transparent 62%),
  2350. linear-gradient(180deg,
  2351. rgba(8, 28, 18, 0) 0%,
  2352. rgba(8, 28, 18, 0) 62%,
  2353. rgba(10, 36, 24, 0.05) 80%,
  2354. rgba(8, 26, 18, 0.1) 92%,
  2355. rgba(248, 244, 238, 0.12) 100%
  2356. );
  2357. }
  2358. /* 商品信息面板:玻璃浮层效果,负margin上浮 + backdrop-filter */
  2359. .heroInfoPanel {
  2360. background: rgba(252, 248, 242, 0.88);
  2361. backdrop-filter: blur(14px);
  2362. -webkit-backdrop-filter: blur(14px);
  2363. position: relative;
  2364. }
  2365. /* 与 Hero 底部自然过渡 */
  2366. .heroInfoPanel::before {
  2367. content: '';
  2368. position: absolute;
  2369. top: -56rpx;
  2370. left: 0;
  2371. right: 0;
  2372. height: 56rpx;
  2373. background: linear-gradient(180deg,
  2374. rgba(252, 248, 242, 0) 0%,
  2375. rgba(252, 248, 242, 0.88) 100%
  2376. );
  2377. pointer-events: none;
  2378. z-index: 1;
  2379. }
  2380. .infoPanelInner {
  2381. position: relative;
  2382. z-index: 2;
  2383. padding: 32rpx 30rpx 30rpx;
  2384. }
  2385. /* 与下方农场/批次等卡片共用 .sectionHeader / .sectionHeaderLeft 样式 */
  2386. .infoPanelBody {
  2387. padding-top: 0;
  2388. }
  2389. .infoPanelName {
  2390. display: block;
  2391. font-size: 30rpx;
  2392. font-weight: 600;
  2393. line-height: 1.4;
  2394. letter-spacing: 0.01em;
  2395. color: rgba(27, 41, 33, 0.92);
  2396. }
  2397. .infoPanelSpec {
  2398. display: inline-flex;
  2399. align-items: center;
  2400. gap: 10rpx;
  2401. margin-top: 14rpx;
  2402. padding: 8rpx 16rpx;
  2403. border-radius: 20rpx;
  2404. background: rgba(39, 113, 76, 0.06);
  2405. border: 1rpx solid rgba(39, 113, 76, 0.08);
  2406. }
  2407. .specDot {
  2408. width: 6rpx;
  2409. height: 6rpx;
  2410. border-radius: 50%;
  2411. background: rgba(39, 113, 76, 0.5);
  2412. }
  2413. .specText {
  2414. font-size: 20rpx;
  2415. font-weight: 400;
  2416. color: rgba(54, 66, 57, 0.85);
  2417. }
  2418. .infoPanelIntro {
  2419. margin-top: 16rpx;
  2420. padding-top: 16rpx;
  2421. border-top: 1rpx solid rgba(39, 75, 57, 0.06);
  2422. font-size: 23rpx;
  2423. line-height: 1.8;
  2424. color: rgba(54, 66, 57, 0.75);
  2425. }
  2426. .purchaseBanner {
  2427. margin-top: 20rpx;
  2428. padding: 20rpx 24rpx;
  2429. background: linear-gradient(135deg, rgba(39, 75, 57, 0.04) 0%, rgba(39, 75, 57, 0.08) 100%);
  2430. border-radius: 20rpx;
  2431. border: 1rpx solid rgba(39, 75, 57, 0.08);
  2432. }
  2433. .purchaseBannerInner {
  2434. display: flex;
  2435. flex-direction: column;
  2436. align-items: flex-start;
  2437. gap: 8rpx;
  2438. }
  2439. .purchaseBannerTitle {
  2440. font-size: 24rpx;
  2441. font-weight: 600;
  2442. color: rgba(39, 75, 57, 0.9);
  2443. }
  2444. .purchaseBannerText {
  2445. font-size: 22rpx;
  2446. color: rgba(54, 66, 57, 0.65);
  2447. }
  2448. .purchaseBannerBtn {
  2449. margin-top: 6rpx;
  2450. padding: 10rpx 20rpx;
  2451. background: rgba(39, 75, 57, 0.08);
  2452. border-radius: 40rpx;
  2453. border: 1rpx solid rgba(39, 75, 57, 0.15);
  2454. }
  2455. .purchaseBannerBtn text {
  2456. font-size: 22rpx;
  2457. color: rgba(39, 75, 57, 0.85);
  2458. }
  2459. .content {
  2460. padding: 20rpx 0 40rpx;
  2461. }
  2462. /* 加载中状态:轻量提示,不闪异常态 */
  2463. .loadingState {
  2464. margin: 40rpx 24rpx;
  2465. padding: 60rpx 32rpx;
  2466. border-radius: 36rpx;
  2467. background: rgba(252, 250, 244, 0.76);
  2468. display: flex;
  2469. justify-content: center;
  2470. align-items: center;
  2471. }
  2472. .loadingText {
  2473. font-size: 24rpx;
  2474. font-weight: 400;
  2475. color: rgba(84, 106, 93, 0.65);
  2476. letter-spacing: 0.02em;
  2477. }
  2478. /* 异常态空状态卡:与页面整体风格一致的轻量提示 */
  2479. .abnormalStateCard {
  2480. margin: 40rpx 24rpx;
  2481. padding: 40rpx 32rpx;
  2482. border-radius: 36rpx;
  2483. background: rgba(252, 250, 244, 0.76);
  2484. box-shadow:
  2485. 0 16rpx 40rpx rgba(38, 41, 32, 0.07),
  2486. 0 1rpx 0 rgba(255, 255, 255, 0.5) inset;
  2487. }
  2488. .abnormalStateCard .sectionHeader {
  2489. margin-bottom: 20rpx;
  2490. }
  2491. .abnormalStateCard .emptyText {
  2492. font-size: 24rpx;
  2493. line-height: 1.8;
  2494. color: rgba(54, 66, 57, 0.7);
  2495. margin-top: 16rpx;
  2496. }
  2497. /* 基础卡片:半透明玻璃质感 */
  2498. .card {
  2499. margin: 0 24rpx 22rpx;
  2500. padding: 30rpx 28rpx;
  2501. border-radius: 36rpx;
  2502. background: rgba(252, 250, 244, 0.76);
  2503. box-shadow:
  2504. 0 16rpx 40rpx rgba(38, 41, 32, 0.07),
  2505. 0 1rpx 0 rgba(255, 255, 255, 0.5) inset;
  2506. backdrop-filter: blur(8px);
  2507. -webkit-backdrop-filter: blur(8px);
  2508. }
  2509. .card.soft {
  2510. background: rgba(252, 248, 244, 0.6);
  2511. }
  2512. /* Hero 之后第一张卡:适度上浮 */
  2513. .cardHeroFirst {
  2514. margin-top: -28rpx;
  2515. position: relative;
  2516. z-index: 3;
  2517. }
  2518. /* 层级 0:与 Hero 同级,主卡(商品面板) */
  2519. .cardLevel0 {
  2520. box-shadow:
  2521. 0 48rpx 120rpx rgba(10, 36, 24, 0.16),
  2522. 0 16rpx 48rpx rgba(10, 36, 24, 0.08),
  2523. 0 1rpx 0 rgba(255, 255, 255, 0.6) inset;
  2524. }
  2525. /* 层级 1:次要信息卡,阴影中等 */
  2526. .cardLevel1 {
  2527. box-shadow:
  2528. 0 20rpx 50rpx rgba(30, 34, 24, 0.09),
  2529. 0 8rpx 24rpx rgba(30, 34, 24, 0.05),
  2530. 0 1rpx 0 rgba(255, 255, 255, 0.55) inset;
  2531. }
  2532. /* 层级 2:次次要信息卡,阴影更轻 */
  2533. .cardLevel2 {
  2534. box-shadow:
  2535. 0 14rpx 36rpx rgba(36, 38, 28, 0.065),
  2536. 0 1rpx 0 rgba(255, 255, 255, 0.5) inset;
  2537. }
  2538. /* 层级 3:底部辅助信息卡,最轻 */
  2539. .cardLevel3 {
  2540. box-shadow:
  2541. 0 8rpx 22rpx rgba(42, 44, 30, 0.04),
  2542. 0 1rpx 0 rgba(255, 255, 255, 0.44) inset;
  2543. }
  2544. .cardFarm {
  2545. background: rgba(250, 248, 242, 0.82);
  2546. }
  2547. .cardCredential {
  2548. background: rgba(252, 248, 240, 0.84);
  2549. }
  2550. .cardBatchState {
  2551. background: rgba(252, 248, 244, 0.74);
  2552. }
  2553. /* 检测结论卡:融合溯源信息,与农场卡视觉统一 */
  2554. .cardConclusion {
  2555. background: rgba(250, 248, 242, 0.82);
  2556. padding-top: 20rpx;
  2557. }
  2558. /* 溯源信息卡主体:三层竖向结构 */
  2559. .conclusionIdentity {
  2560. display: flex;
  2561. flex-direction: column;
  2562. gap: 16rpx;
  2563. }
  2564. /* 第一层:批次号主信息区 */
  2565. .conclusionBatchWrap {
  2566. display: flex;
  2567. flex-direction: column;
  2568. gap: 4rpx;
  2569. }
  2570. .conclusionBatchLabel {
  2571. display: block;
  2572. font-size: 20rpx;
  2573. font-weight: 500;
  2574. line-height: 1.4;
  2575. color: rgba(84, 106, 93, 0.6);
  2576. letter-spacing: 0.02em;
  2577. }
  2578. .conclusionBatchNo {
  2579. display: block;
  2580. font-size: 26rpx;
  2581. font-weight: 500;
  2582. line-height: 1.4;
  2583. color: rgba(27, 41, 33, 0.78);
  2584. letter-spacing: 0.02em;
  2585. }
  2586. /* 第二层:时间摘要区,一行式表达 */
  2587. .conclusionSummary {
  2588. display: flex;
  2589. align-items: baseline;
  2590. flex-wrap: wrap;
  2591. gap: 6rpx 0;
  2592. }
  2593. .summaryLabel {
  2594. font-size: 20rpx;
  2595. font-weight: 500;
  2596. color: rgba(84, 106, 93, 0.6);
  2597. letter-spacing: 0.01em;
  2598. margin-right: 6rpx;
  2599. }
  2600. .summaryText {
  2601. font-size: 21rpx;
  2602. font-weight: 400;
  2603. color: rgba(27, 41, 33, 0.78);
  2604. letter-spacing: 0.01em;
  2605. }
  2606. .summaryDivider {
  2607. font-size: 20rpx;
  2608. font-weight: 400;
  2609. color: rgba(84, 106, 93, 0.4);
  2610. margin: 0 16rpx;
  2611. }
  2612. /* 第三层:结论标签区,独立横向排列 */
  2613. .conclusionTags {
  2614. display: flex;
  2615. flex-direction: row;
  2616. gap: 12rpx;
  2617. }
  2618. .conclusionTag {
  2619. display: inline-flex;
  2620. align-items: center;
  2621. padding: 6rpx 16rpx;
  2622. border-radius: 999rpx;
  2623. background: rgba(39, 113, 76, 0.08);
  2624. }
  2625. .conclusionTag text {
  2626. font-size: 19rpx;
  2627. font-weight: 500;
  2628. letter-spacing: 0.02em;
  2629. color: rgba(39, 113, 76, 0.8);
  2630. }
  2631. /* 农事时间轴:关键种植过程 */
  2632. .cardTimeline {
  2633. background: rgba(252, 250, 244, 0.82);
  2634. }
  2635. .timelineList {
  2636. padding-top: 4rpx;
  2637. }
  2638. .timelineItem {
  2639. display: flex;
  2640. padding-bottom: 24rpx;
  2641. }
  2642. .timelineItem:last-child {
  2643. padding-bottom: 0;
  2644. }
  2645. .timelineLeft {
  2646. display: flex;
  2647. flex-direction: column;
  2648. align-items: center;
  2649. width: 40rpx;
  2650. flex-shrink: 0;
  2651. }
  2652. .timelineDot {
  2653. width: 12rpx;
  2654. height: 12rpx;
  2655. border-radius: 50%;
  2656. background: rgba(39, 113, 76, 0.5);
  2657. flex-shrink: 0;
  2658. }
  2659. .timelineLine {
  2660. width: 1rpx;
  2661. flex: 1;
  2662. background: rgba(39, 113, 76, 0.2);
  2663. margin-top: 8rpx;
  2664. }
  2665. .timelineRight {
  2666. flex: 1;
  2667. padding-left: 24rpx;
  2668. }
  2669. .timelineTime {
  2670. display: block;
  2671. font-size: 19rpx;
  2672. font-weight: 400;
  2673. color: rgba(84, 106, 93, 0.5);
  2674. margin-bottom: 6rpx;
  2675. letter-spacing: 0.02em;
  2676. }
  2677. .timelineTitle {
  2678. display: block;
  2679. font-size: 25rpx;
  2680. font-weight: 500;
  2681. color: rgba(27, 41, 33, 0.88);
  2682. margin-bottom: 6rpx;
  2683. line-height: 1.35;
  2684. }
  2685. .timelineDesc {
  2686. display: block;
  2687. font-size: 21rpx;
  2688. font-weight: 400;
  2689. line-height: 1.7;
  2690. color: rgba(84, 106, 93, 0.75);
  2691. }
  2692. /* 关键节点(安全检测):轻强调 */
  2693. .timelineItem.is-key .timelineDot {
  2694. background: rgba(39, 113, 76, 0.7);
  2695. }
  2696. .timelineItem.is-key .timelineTitle {
  2697. font-weight: 600;
  2698. color: rgba(27, 41, 33, 0.9);
  2699. }
  2700. /* 当前节点(包装日期:出库):主高亮 */
  2701. .timelineItem.is-current .timelineDot {
  2702. background: #2f7d55;
  2703. box-shadow: 0 0 0 6rpx rgba(47, 125, 85, 0.12);
  2704. }
  2705. .timelineItem.is-current .timelineTitle {
  2706. font-weight: 600;
  2707. color: rgba(20, 60, 40, 0.95);
  2708. }
  2709. /* 底部可信来源说明 */
  2710. .timelineFootnote {
  2711. margin-top: 20rpx;
  2712. font-size: 20rpx;
  2713. color: rgba(84, 106, 93, 0.45);
  2714. line-height: 1.6;
  2715. }
  2716. /* 种植现场实时画面模块 */
  2717. .cardLive {
  2718. background: rgba(252, 250, 244, 0.82);
  2719. }
  2720. .liveMediaWrap {
  2721. position: relative;
  2722. width: 100%;
  2723. height: 380rpx;
  2724. border-radius: 20rpx;
  2725. overflow: hidden;
  2726. background: linear-gradient(
  2727. 160deg,
  2728. rgba(39, 113, 76, 0.04) 0%,
  2729. rgba(39, 113, 76, 0.015) 50%,
  2730. rgba(39, 113, 76, 0.05) 100%
  2731. );
  2732. border: 1rpx solid rgba(39, 75, 57, 0.08);
  2733. box-shadow: inset 0 2rpx 12rpx rgba(39, 113, 76, 0.04);
  2734. }
  2735. .liveCover {
  2736. width: 100%;
  2737. height: 100%;
  2738. }
  2739. /* 默认未播放态背景:深灰绿 + 墨绿色层次感 */
  2740. .video-placeholder-bg {
  2741. position: absolute;
  2742. top: 0;
  2743. left: 0;
  2744. width: 100%;
  2745. height: 100%;
  2746. background: linear-gradient(
  2747. 165deg,
  2748. rgba(45, 70, 55, 0.78) 0%,
  2749. rgba(35, 55, 45, 0.82) 50%,
  2750. rgba(28, 45, 38, 0.88) 100%
  2751. );
  2752. box-shadow: inset 0 0 100rpx rgba(55, 90, 68, 0.12);
  2753. }
  2754. .livePlaceholder {
  2755. width: 100%;
  2756. height: 100%;
  2757. display: flex;
  2758. flex-direction: column;
  2759. align-items: center;
  2760. justify-content: center;
  2761. background: transparent;
  2762. }
  2763. .livePlayIcon {
  2764. display: flex;
  2765. align-items: center;
  2766. gap: 8rpx;
  2767. margin-bottom: 20rpx;
  2768. }
  2769. .livePlayDot {
  2770. width: 8rpx;
  2771. height: 8rpx;
  2772. border-radius: 50%;
  2773. background: rgba(39, 113, 76, 0.35);
  2774. animation: livePulse 1.4s ease-in-out infinite;
  2775. }
  2776. .livePlayDot.dot2 {
  2777. animation-delay: 0.2s;
  2778. }
  2779. .livePlayDot.dot3 {
  2780. animation-delay: 0.4s;
  2781. }
  2782. @keyframes livePulse {
  2783. 0%, 100% {
  2784. opacity: 0.3;
  2785. transform: scale(0.8);
  2786. }
  2787. 50% {
  2788. opacity: 1;
  2789. transform: scale(1.1);
  2790. }
  2791. }
  2792. .livePlaceholderMain {
  2793. font-size: 26rpx;
  2794. font-weight: 500;
  2795. color: rgba(39, 113, 76, 0.5);
  2796. margin-bottom: 10rpx;
  2797. }
  2798. .livePlaceholderSub {
  2799. font-size: 20rpx;
  2800. color: rgba(84, 106, 93, 0.35);
  2801. }
  2802. /* 实时在线状态标签(视频区内部轻量风格) */
  2803. .liveStatusPill {
  2804. display: flex;
  2805. align-items: center;
  2806. gap: 5rpx;
  2807. padding: 0;
  2808. background: transparent;
  2809. border: none;
  2810. }
  2811. .liveStatusDot {
  2812. width: 6rpx;
  2813. height: 6rpx;
  2814. border-radius: 50%;
  2815. flex-shrink: 0;
  2816. background: #6EDFA3;
  2817. box-shadow: 0 0 6rpx rgba(110, 223, 163, 0.6);
  2818. }
  2819. .liveStatusPill.online .liveStatusDot {
  2820. animation: statusPulse 2s ease-in-out infinite;
  2821. }
  2822. .liveStatusText {
  2823. font-size: 18rpx;
  2824. font-weight: 600;
  2825. color: rgba(235, 245, 240, 0.88);
  2826. letter-spacing: 0.02em;
  2827. text-shadow: 0 1rpx 4rpx rgba(0, 0, 0, 0.25);
  2828. }
  2829. @keyframes statusPulse {
  2830. 0%, 100% {
  2831. opacity: 1;
  2832. box-shadow: 0 0 6rpx rgba(110, 223, 163, 0.6);
  2833. }
  2834. 50% {
  2835. opacity: 0.7;
  2836. box-shadow: 0 0 3rpx rgba(110, 223, 163, 0.3);
  2837. }
  2838. }
  2839. .liveStatusPill.offline .liveStatusDot {
  2840. background: rgba(150, 160, 155, 0.6);
  2841. box-shadow: none;
  2842. }
  2843. .liveDesc {
  2844. margin-top: 14rpx;
  2845. font-size: 18rpx;
  2846. color: rgba(84, 106, 93, 0.45);
  2847. line-height: 1.6;
  2848. }
  2849. /* 种植环境记录模块 */
  2850. .cardEnvironment {
  2851. background: rgba(252, 250, 244, 0.82);
  2852. }
  2853. .environmentSummary {
  2854. font-size: 26rpx;
  2855. font-weight: 500;
  2856. color: rgba(27, 41, 33, 0.8);
  2857. line-height: 1.6;
  2858. margin-bottom: 24rpx;
  2859. }
  2860. /* 土壤养分趋势图 */
  2861. .environmentChart {
  2862. background: rgba(39, 113, 76, 0.03);
  2863. border: 1rpx solid rgba(39, 113, 76, 0.08);
  2864. border-radius: 16rpx;
  2865. padding: 24rpx;
  2866. margin-bottom: 24rpx;
  2867. }
  2868. .environmentChartHead {
  2869. margin-bottom: 20rpx;
  2870. }
  2871. .environmentChartTitle {
  2872. display: block;
  2873. font-size: 24rpx;
  2874. font-weight: 500;
  2875. color: rgba(27, 41, 33, 0.75);
  2876. }
  2877. .environmentChartSub {
  2878. display: block;
  2879. font-size: 20rpx;
  2880. color: rgba(84, 106, 93, 0.45);
  2881. margin-top: 4rpx;
  2882. }
  2883. .environmentChartCanvas {
  2884. position: relative;
  2885. height: 200rpx;
  2886. margin-bottom: 16rpx;
  2887. }
  2888. .chartPlotArea {
  2889. position: absolute;
  2890. top: 0;
  2891. left: 0;
  2892. right: 0;
  2893. bottom: 30rpx;
  2894. }
  2895. /* SVG 图表样式 */
  2896. .chartSvg {
  2897. width: 100%;
  2898. height: 100%;
  2899. }
  2900. /* 网格线(弱化,避免抢视觉) */
  2901. .chartGridLineSvg {
  2902. stroke: rgba(39, 113, 76, 0.05);
  2903. stroke-width: 1;
  2904. }
  2905. /* 面积渐变层(趋势带效果) */
  2906. .chartAreaN {
  2907. fill: rgba(47, 125, 85, 0.08);
  2908. }
  2909. .chartAreaP {
  2910. fill: rgba(180, 140, 70, 0.08);
  2911. }
  2912. .chartAreaK {
  2913. fill: rgba(84, 130, 110, 0.08);
  2914. }
  2915. /* 曲线样式(柔和趋势线) */
  2916. .chartPathN {
  2917. fill: none;
  2918. stroke-width: 2.5;
  2919. stroke-opacity: 0.7;
  2920. stroke-linecap: round;
  2921. stroke-linejoin: round;
  2922. }
  2923. .chartPathP {
  2924. fill: none;
  2925. stroke-width: 2.5;
  2926. stroke-opacity: 0.7;
  2927. stroke-linecap: round;
  2928. stroke-linejoin: round;
  2929. }
  2930. .chartPathK {
  2931. fill: none;
  2932. stroke-width: 2.5;
  2933. stroke-opacity: 0.7;
  2934. stroke-linecap: round;
  2935. stroke-linejoin: round;
  2936. }
  2937. /* 数据点样式(小而柔和) */
  2938. .chartDotN {
  2939. fill: rgba(47, 125, 85, 0.85);
  2940. }
  2941. .chartDotP {
  2942. fill: rgba(180, 140, 70, 0.85);
  2943. }
  2944. .chartDotK {
  2945. fill: rgba(84, 130, 110, 0.85);
  2946. }
  2947. .chartLabels {
  2948. position: absolute;
  2949. bottom: 0;
  2950. left: 0;
  2951. right: 0;
  2952. display: flex;
  2953. justify-content: space-between;
  2954. }
  2955. .chartLabels text {
  2956. font-size: 18rpx;
  2957. color: rgba(84, 106, 93, 0.4);
  2958. }
  2959. .environmentChartLegend {
  2960. display: flex;
  2961. justify-content: center;
  2962. gap: 40rpx;
  2963. }
  2964. .legendItem {
  2965. display: flex;
  2966. align-items: center;
  2967. gap: 10rpx;
  2968. }
  2969. .legendDot {
  2970. width: 8rpx;
  2971. height: 8rpx;
  2972. border-radius: 50%;
  2973. }
  2974. .legendN {
  2975. background: rgba(47, 125, 85, 0.65);
  2976. }
  2977. .legendP {
  2978. background: rgba(180, 140, 70, 0.65);
  2979. }
  2980. .legendK {
  2981. background: rgba(84, 130, 110, 0.65);
  2982. }
  2983. .legendItem text {
  2984. font-size: 22rpx;
  2985. color: rgba(84, 106, 93, 0.55);
  2986. }
  2987. /* 环境摘要项 */
  2988. .environmentGrid {
  2989. display: grid;
  2990. grid-template-columns: repeat(2, minmax(0, 1fr));
  2991. gap: 16rpx;
  2992. }
  2993. .environmentItem {
  2994. display: flex;
  2995. flex-direction: column;
  2996. gap: 6rpx;
  2997. padding: 20rpx;
  2998. border-radius: 14rpx;
  2999. background: rgba(39, 113, 76, 0.04);
  3000. border: 1rpx solid rgba(39, 113, 76, 0.08);
  3001. }
  3002. .environmentLabel {
  3003. font-size: 18rpx;
  3004. color: rgba(84, 106, 93, 0.45);
  3005. }
  3006. .environmentValue {
  3007. font-size: 26rpx;
  3008. font-weight: 500;
  3009. color: rgba(27, 41, 33, 0.8);
  3010. line-height: 1.2;
  3011. }
  3012. .environmentStatus {
  3013. font-size: 18rpx;
  3014. color: rgba(47, 125, 85, 0.55);
  3015. }
  3016. /* ================================================
  3017. 微动效:让页面"活起来"
  3018. ================================================ */
  3019. /* Hero 进入:上浮 + 淡入 */
  3020. @keyframes heroEnter {
  3021. 0% {
  3022. opacity: 0;
  3023. transform: translateY(28rpx);
  3024. }
  3025. 100% {
  3026. opacity: 1;
  3027. transform: translateY(0);
  3028. }
  3029. }
  3030. .heroCard {
  3031. animation: heroEnter 0.6s cubic-bezier(0.22, 0.78, 0.35, 1) both;
  3032. }
  3033. /* 卡片依次入场:延迟递增,制造节奏感 */
  3034. @keyframes cardEnter {
  3035. 0% {
  3036. opacity: 0;
  3037. transform: translateY(20rpx);
  3038. }
  3039. 100% {
  3040. opacity: 1;
  3041. transform: translateY(0);
  3042. }
  3043. }
  3044. /* 商品面板:稍晚于 Hero */
  3045. .heroInfoPanel {
  3046. animation: cardEnter 0.5s cubic-bezier(0.22, 0.78, 0.35, 1) 0.15s both;
  3047. }
  3048. /* 检测结论卡 */
  3049. .cardConclusion {
  3050. animation: cardEnter 0.5s cubic-bezier(0.22, 0.78, 0.35, 1) 0.2s both;
  3051. }
  3052. /* 农场卡 */
  3053. .cardFarm {
  3054. animation: cardEnter 0.5s cubic-bezier(0.22, 0.78, 0.35, 1) 0.25s both;
  3055. }
  3056. /* 批次状态卡(不存在/已下线) */
  3057. .cardBatchState {
  3058. animation: cardEnter 0.5s cubic-bezier(0.22, 0.78, 0.35, 1) 0.2s both;
  3059. }
  3060. /* 凭证卡 */
  3061. .cardCredential {
  3062. animation: cardEnter 0.5s cubic-bezier(0.22, 0.78, 0.35, 1) 0.45s both;
  3063. }
  3064. /* ============================
  3065. 检测报告横向卡片列表
  3066. ============================ */
  3067. .reportCardList {
  3068. width: 100%;
  3069. overflow-x: auto;
  3070. overflow-y: hidden;
  3071. -webkit-overflow-scrolling: touch;
  3072. white-space: nowrap;
  3073. }
  3074. .reportCardList::-webkit-scrollbar {
  3075. display: none;
  3076. }
  3077. .reportCardTrack {
  3078. display: inline-flex;
  3079. flex-wrap: nowrap;
  3080. align-items: stretch;
  3081. gap: 16rpx;
  3082. padding: 6rpx 4rpx 10rpx;
  3083. /* 关键:让子项不受 flex 压缩,自然撑开形成横向溢出 */
  3084. width: max-content;
  3085. }
  3086. /* 单张报告卡片 */
  3087. .reportCard {
  3088. flex-shrink: 0;
  3089. width: 220rpx;
  3090. background: #FAFBF9;
  3091. border: 1rpx solid rgba(39, 75, 57, 0.09);
  3092. border-radius: 14rpx;
  3093. padding: 12rpx 12rpx 10rpx;
  3094. display: flex;
  3095. flex-direction: column;
  3096. align-items: stretch;
  3097. box-shadow: 0 2rpx 8rpx rgba(39, 75, 57, 0.04);
  3098. }
  3099. /* 缩略图(带页数角标覆盖层) */
  3100. .reportCardThumb {
  3101. position: relative;
  3102. width: 100%;
  3103. height: 196rpx;
  3104. background: rgba(39, 75, 57, 0.03);
  3105. border-radius: 10rpx;
  3106. overflow: hidden;
  3107. display: flex;
  3108. align-items: center;
  3109. justify-content: center;
  3110. margin-bottom: 10rpx;
  3111. }
  3112. .reportCardThumbImg {
  3113. width: 100%;
  3114. height: 100%;
  3115. }
  3116. .reportCardThumbEmpty {
  3117. width: 100%;
  3118. height: 100%;
  3119. display: flex;
  3120. align-items: center;
  3121. justify-content: center;
  3122. }
  3123. .reportCardThumbEmptyText {
  3124. font-size: 18rpx;
  3125. color: rgba(39, 75, 57, 0.3);
  3126. }
  3127. /* 页数角标:绝对定位在缩略图右下角 */
  3128. .reportCardPages {
  3129. position: absolute;
  3130. bottom: 8rpx;
  3131. right: 8rpx;
  3132. font-size: 15rpx;
  3133. color: rgba(39, 75, 57, 0.65);
  3134. background: rgba(250, 251, 249, 0.88);
  3135. border: 1rpx solid rgba(39, 75, 57, 0.1);
  3136. border-radius: 6rpx;
  3137. padding: 2rpx 8rpx;
  3138. line-height: 1.4;
  3139. }
  3140. /* 报告元信息 */
  3141. .reportCardMeta {
  3142. flex: 1;
  3143. margin-bottom: 6rpx;
  3144. }
  3145. .reportCardRow {
  3146. display: flex;
  3147. justify-content: space-between;
  3148. align-items: baseline;
  3149. gap: 4rpx;
  3150. margin-bottom: 4rpx;
  3151. }
  3152. .reportCardLabel {
  3153. font-size: 16rpx;
  3154. color: rgba(84, 106, 93, 0.6);
  3155. flex-shrink: 0;
  3156. }
  3157. .reportCardValue {
  3158. font-size: 16rpx;
  3159. color: rgba(68, 82, 72, 0.85);
  3160. font-weight: 400;
  3161. text-align: right;
  3162. word-break: break-all;
  3163. }
  3164. .reportCardValueNo {
  3165. font-size: 14rpx;
  3166. color: rgba(68, 82, 72, 0.72);
  3167. }
  3168. /* 点击提示 */
  3169. .reportCardHint {
  3170. font-size: 14rpx;
  3171. color: rgba(39, 75, 57, 0.3);
  3172. text-align: center;
  3173. margin-top: auto;
  3174. }
  3175. /* 卡片触摸反馈:阴影增强(模拟按压感) */
  3176. .card:active {
  3177. transition: box-shadow 0.15s ease, transform 0.15s ease;
  3178. }
  3179. /* 触摸时轻微缩小,增加真实感 */
  3180. .card:active:not(.heroInfoPanel) {
  3181. transform: scale(0.99);
  3182. }
  3183. .sectionHeader {
  3184. display: flex;
  3185. align-items: center;
  3186. justify-content: space-between;
  3187. gap: 18rpx;
  3188. margin-bottom: 20rpx;
  3189. }
  3190. .sectionHeaderLeft {
  3191. display: flex;
  3192. flex-direction: column;
  3193. gap: 10rpx;
  3194. position: relative;
  3195. padding-bottom: 8rpx;
  3196. }
  3197. .sectionHeaderLeft::after {
  3198. content: '';
  3199. position: absolute;
  3200. left: 0;
  3201. bottom: 0;
  3202. width: 78rpx;
  3203. height: 2rpx;
  3204. border-radius: 999rpx;
  3205. background: linear-gradient(90deg, rgba(46, 82, 63, 0.3), rgba(203, 176, 128, 0.26), rgba(46, 82, 63, 0));
  3206. pointer-events: none;
  3207. }
  3208. .sectionEn {
  3209. font-size: 15rpx;
  3210. font-weight: 500;
  3211. letter-spacing: 0.24em;
  3212. text-transform: uppercase;
  3213. color: rgba(84, 106, 93, 0.76);
  3214. }
  3215. .sectionTitle {
  3216. font-size: 26rpx;
  3217. font-weight: 600;
  3218. color: rgba(60, 72, 64, 0.72);
  3219. }
  3220. .statusBadge {
  3221. font-size: 18rpx;
  3222. font-weight: 600;
  3223. padding: 9rpx 15rpx;
  3224. border-radius: 999rpx;
  3225. white-space: nowrap;
  3226. border: 1rpx solid transparent;
  3227. box-shadow: 0 1rpx 0 rgba(255, 255, 255, 0.34) inset;
  3228. }
  3229. .statusBadge.ok {
  3230. color: #1d5d40;
  3231. background: rgba(39, 113, 76, 0.12);
  3232. border-color: rgba(39, 113, 76, 0.2);
  3233. }
  3234. .statusBadge.wait {
  3235. color: #715726;
  3236. background: rgba(203, 171, 112, 0.2);
  3237. border-color: rgba(203, 171, 112, 0.26);
  3238. }
  3239. .statusBadge.warning {
  3240. color: #8a5e22;
  3241. background: rgba(214, 174, 95, 0.22);
  3242. border-color: rgba(214, 174, 95, 0.28);
  3243. }
  3244. .statusBadge.muted {
  3245. color: #677069;
  3246. background: rgba(126, 137, 128, 0.14);
  3247. border-color: rgba(126, 137, 128, 0.2);
  3248. }
  3249. /* =============================================
  3250. 商品信息面板专用信任认证徽章:强化图标主视觉、文字辅助
  3251. ============================================= */
  3252. /* 整体:认证章风格,低饱和细边框,无交互感 */
  3253. .trustBadge {
  3254. display: inline-flex;
  3255. align-items: center;
  3256. gap: 7rpx;
  3257. padding: 9rpx 18rpx 9rpx 15rpx;
  3258. border-radius: 999rpx;
  3259. border: 1rpx solid rgba(39, 113, 76, 0.22);
  3260. background: rgba(39, 113, 76, 0.06);
  3261. box-shadow:
  3262. 0 2rpx 6rpx rgba(39, 113, 76, 0.06),
  3263. 0 1rpx 0 rgba(255, 255, 255, 0.55) inset;
  3264. white-space: nowrap;
  3265. cursor: default;
  3266. pointer-events: none;
  3267. user-select: none;
  3268. }
  3269. /* 双圆环认证图标:20×20 viewBox,图标为第一视觉焦点 */
  3270. .trustBadgeIcon {
  3271. width: 30rpx;
  3272. height: 30rpx;
  3273. flex-shrink: 0;
  3274. vertical-align: middle;
  3275. display: inline-block;
  3276. }
  3277. /* 文案:品牌深绿,字重略降,视觉权重低于图标 */
  3278. .trustBadgeText {
  3279. font-size: 18rpx;
  3280. font-weight: 400;
  3281. letter-spacing: 0.05em;
  3282. color: rgba(27, 71, 42, 0.68);
  3283. }
  3284. .kv {
  3285. display: flex;
  3286. flex-direction: column;
  3287. gap: 16rpx;
  3288. }
  3289. .kvRow {
  3290. display: flex;
  3291. align-items: baseline;
  3292. justify-content: space-between;
  3293. gap: 16rpx;
  3294. }
  3295. .kvKey {
  3296. font-size: 22rpx;
  3297. font-weight: 480;
  3298. color: rgba(54, 68, 58, 0.62);
  3299. }
  3300. .kvVal {
  3301. font-size: 23rpx;
  3302. font-weight: 400;
  3303. text-align: right;
  3304. color: rgba(27, 41, 33, 0.92);
  3305. }
  3306. /* 农场主体:左图右文,右栏与图片垂直居中,名称/地址成组 */
  3307. .farmBody {
  3308. display: flex;
  3309. align-items: center;
  3310. gap: 24rpx;
  3311. margin-bottom: 18rpx;
  3312. }
  3313. .farmImageWrap {
  3314. flex-shrink: 0;
  3315. width: 180rpx;
  3316. height: 136rpx;
  3317. border-radius: 22rpx;
  3318. overflow: hidden;
  3319. position: relative;
  3320. box-shadow:
  3321. 0 12rpx 28rpx rgba(24, 41, 30, 0.14),
  3322. 0 2rpx 0 rgba(255, 255, 255, 0.3) inset;
  3323. }
  3324. .farmImage {
  3325. width: 100%;
  3326. height: 100%;
  3327. display: block;
  3328. background: linear-gradient(160deg, rgba(234, 245, 240, 0.9), rgba(220, 238, 228, 0.85));
  3329. }
  3330. /* 图片暗角效果:增强真实场景感 */
  3331. .farmImageVignette {
  3332. position: absolute;
  3333. top: 0;
  3334. left: 0;
  3335. width: 100%;
  3336. height: 100%;
  3337. border-radius: 22rpx;
  3338. background: radial-gradient(ellipse at 50% 50%, transparent 60%, rgba(24, 41, 30, 0.12) 100%);
  3339. pointer-events: none;
  3340. }
  3341. .farmMeta {
  3342. flex: 1;
  3343. display: flex;
  3344. flex-direction: column;
  3345. justify-content: center;
  3346. min-width: 0;
  3347. gap: 10rpx;
  3348. }
  3349. .farmName {
  3350. font-size: 30rpx;
  3351. font-weight: 600;
  3352. line-height: 1.4;
  3353. letter-spacing: 0.01em;
  3354. color: rgba(27, 41, 33, 0.94);
  3355. }
  3356. /* 农场地址:普通文本样式,弱于标题;多行时图标与首行对齐 */
  3357. .farmLocation {
  3358. display: flex;
  3359. align-items: flex-start;
  3360. gap: 8rpx;
  3361. margin-top: 8rpx;
  3362. }
  3363. /* 轻量标签:真实种植、可追溯来源 */
  3364. .farmTags {
  3365. display: flex;
  3366. flex-wrap: wrap;
  3367. gap: 8rpx;
  3368. margin-top: 6rpx;
  3369. }
  3370. .farmTag {
  3371. padding: 4rpx 12rpx;
  3372. font-size: 18rpx;
  3373. font-weight: 400;
  3374. color: rgba(39, 113, 76, 0.85);
  3375. background: rgba(39, 113, 76, 0.08);
  3376. border-radius: 8rpx;
  3377. line-height: 1.4;
  3378. letter-spacing: 0.01em;
  3379. }
  3380. /* 定位小图标:略弱、与首行文字视觉对齐 */
  3381. .locationIcon {
  3382. width: 18rpx;
  3383. height: 18rpx;
  3384. flex-shrink: 0;
  3385. margin-top: 6rpx;
  3386. opacity: 0.42;
  3387. }
  3388. .locationText {
  3389. flex: 1;
  3390. min-width: 0;
  3391. font-size: 21rpx;
  3392. font-weight: 400;
  3393. color: rgba(84, 106, 93, 0.82);
  3394. line-height: 1.55;
  3395. letter-spacing: 0.02em;
  3396. }
  3397. /* 农场介绍:融入主体,使用分隔线区分,与商品简介风格统一 */
  3398. .farmIntro {
  3399. display: flex;
  3400. flex-direction: column;
  3401. gap: 10rpx;
  3402. padding-top: 18rpx;
  3403. border-top: 1rpx solid rgba(39, 75, 57, 0.06);
  3404. font-size: 23rpx;
  3405. line-height: 2;
  3406. color: rgba(54, 68, 58, 0.76);
  3407. }
  3408. /* 原始农场简介 */
  3409. .farmIntroOrigin {
  3410. font-size: 23rpx;
  3411. line-height: 2;
  3412. color: rgba(54, 68, 58, 0.76);
  3413. }
  3414. .emptyText {
  3415. margin-top: 10rpx;
  3416. font-size: 24rpx;
  3417. line-height: 1.62;
  3418. color: rgba(16, 24, 19, 0.72);
  3419. }
  3420. .btnRow {
  3421. margin-top: 22rpx;
  3422. }
  3423. /* 合格证紧凑缩略图 */
  3424. /* ============================
  3425. 合格证:信息摘要 + 缩略图一体化布局
  3426. ============================ */
  3427. .certSummary {
  3428. display: flex;
  3429. align-items: flex-start;
  3430. gap: 24rpx;
  3431. }
  3432. .certSummaryInfo {
  3433. flex: 1;
  3434. display: flex;
  3435. flex-direction: column;
  3436. gap: 14rpx;
  3437. min-width: 0;
  3438. }
  3439. .certSummaryRow {
  3440. display: flex;
  3441. flex-direction: column;
  3442. gap: 2rpx;
  3443. }
  3444. .certSummaryLabel {
  3445. font-size: 20rpx;
  3446. font-weight: 500;
  3447. color: rgba(39, 75, 57, 0.55);
  3448. letter-spacing: 0.02em;
  3449. }
  3450. .certSummaryValue {
  3451. font-size: 23rpx;
  3452. font-weight: 400;
  3453. color: rgba(27, 41, 33, 0.8);
  3454. line-height: 1.4;
  3455. }
  3456. .certThumbContainer {
  3457. flex: 0 0 auto;
  3458. display: flex;
  3459. flex-direction: column;
  3460. align-items: center;
  3461. gap: 6rpx;
  3462. }
  3463. .certThumbContainer .certThumbWrap {
  3464. width: 100rpx;
  3465. height: 136rpx;
  3466. border-radius: 10rpx;
  3467. overflow: hidden;
  3468. background: #fff;
  3469. border: 1rpx solid rgba(200, 180, 140, 0.18);
  3470. box-shadow: 0 2rpx 8rpx rgba(30, 36, 26, 0.05);
  3471. }
  3472. .certThumbContainer .certThumbImage {
  3473. width: 100%;
  3474. height: 100%;
  3475. display: block;
  3476. }
  3477. .certPreviewHint {
  3478. font-size: 15rpx;
  3479. line-height: 1.2;
  3480. color: rgba(39, 75, 57, 0.38);
  3481. letter-spacing: 0.01em;
  3482. }
  3483. .certPendingHint {
  3484. flex: 1;
  3485. display: flex;
  3486. align-items: center;
  3487. padding: 12rpx 0;
  3488. }
  3489. .certPendingText {
  3490. font-size: 21rpx;
  3491. color: rgba(39, 75, 57, 0.5);
  3492. line-height: 1.5;
  3493. }
  3494. /* 旧样式保留但隐藏(兼容其他模块) */
  3495. .certPreviewCompact {
  3496. display: flex;
  3497. flex-direction: column;
  3498. align-items: center;
  3499. margin-top: 24rpx;
  3500. }
  3501. .docPlaceholder {
  3502. margin-top: 16rpx;
  3503. padding: 20rpx;
  3504. border-radius: 26rpx;
  3505. background: linear-gradient(160deg, rgba(244, 237, 224, 0.82), rgba(237, 244, 235, 0.72));
  3506. border: 1rpx solid rgba(201, 171, 120, 0.22);
  3507. }
  3508. .docPlaceholderTitle {
  3509. display: block;
  3510. margin-bottom: 12rpx;
  3511. font-size: 22rpx;
  3512. font-weight: 650;
  3513. color: rgba(35, 93, 64, 0.92);
  3514. }
  3515. .docPlaceholderText {
  3516. display: block;
  3517. font-size: 22rpx;
  3518. line-height: 1.75;
  3519. color: rgba(59, 71, 62, 0.82);
  3520. }
  3521. .docBlock {
  3522. margin-top: 14rpx;
  3523. padding: 18rpx;
  3524. border-radius: 22rpx;
  3525. background: rgba(255, 255, 255, 0.46);
  3526. }
  3527. .docBlock:first-of-type {
  3528. margin-top: 4rpx;
  3529. }
  3530. .docTitle {
  3531. display: block;
  3532. margin-bottom: 10rpx;
  3533. font-size: 22rpx;
  3534. font-weight: 600;
  3535. color: rgba(45, 87, 64, 0.84);
  3536. }
  3537. .docText {
  3538. font-size: 22rpx;
  3539. line-height: 1.8;
  3540. color: rgba(64, 75, 67, 0.8);
  3541. }
  3542. .cardCredential .certSummary {
  3543. margin-top: 4rpx;
  3544. }
  3545. /* 安心收口文案 */
  3546. .pageEndHint {
  3547. padding: 28rpx 32rpx 20rpx;
  3548. text-align: center;
  3549. }
  3550. .pageEndHint text {
  3551. font-size: 20rpx;
  3552. font-weight: 400;
  3553. line-height: 1.65;
  3554. color: rgba(88, 100, 92, 0.45);
  3555. letter-spacing: 0.03em;
  3556. }
  3557. .footerDivider {
  3558. display: block;
  3559. height: 1rpx;
  3560. margin: 0 36rpx 20rpx;
  3561. background: rgba(39, 75, 57, 0.1);
  3562. }
  3563. /* 微信小店复购引导 - 轻量品牌入口 */
  3564. .rebuyGuide {
  3565. width: 560rpx;
  3566. max-width: calc(100% - 128rpx);
  3567. margin: 26rpx auto 36rpx;
  3568. display: flex;
  3569. flex-direction: row;
  3570. align-items: center;
  3571. justify-content: space-between;
  3572. gap: 32rpx;
  3573. }
  3574. .rebuyGuideLeft {
  3575. flex: 1;
  3576. min-width: 0;
  3577. display: flex;
  3578. flex-direction: column;
  3579. gap: 6rpx;
  3580. }
  3581. .rebuyGuideBrandRow {
  3582. display: flex;
  3583. flex-direction: row;
  3584. align-items: center;
  3585. gap: 12rpx;
  3586. }
  3587. .rebuyGuideLogo {
  3588. width: 28rpx;
  3589. height: 28rpx;
  3590. border-radius: 50%;
  3591. }
  3592. .rebuyGuideTitle {
  3593. font-size: 21rpx;
  3594. font-weight: 500;
  3595. color: rgba(39, 75, 57, 0.6);
  3596. letter-spacing: 0.05em;
  3597. }
  3598. .rebuyGuideText {
  3599. font-size: 19rpx;
  3600. font-weight: 400;
  3601. color: rgba(39, 75, 57, 0.35);
  3602. line-height: 1.6;
  3603. margin-top: 10rpx;
  3604. }
  3605. .rebuyGuideBtn {
  3606. flex-shrink: 0;
  3607. padding: 6rpx 16rpx;
  3608. background: rgba(39, 75, 57, 0.05);
  3609. border-radius: 32rpx;
  3610. }
  3611. .rebuyGuideBtn text {
  3612. font-size: 19rpx;
  3613. color: rgba(39, 75, 57, 0.55);
  3614. font-weight: 400;
  3615. letter-spacing: 0.02em;
  3616. }
  3617. .rebuyGuideBtn:active {
  3618. background: rgba(39, 75, 57, 0.1);
  3619. }
  3620. /* 底部柔和收口渐变 */
  3621. .footerFade {
  3622. position: relative;
  3623. height: 1rpx;
  3624. margin: 0 100rpx;
  3625. background: linear-gradient(90deg,
  3626. transparent 0%,
  3627. rgba(39, 75, 57, 0.1) 30%,
  3628. rgba(39, 75, 57, 0.14) 50%,
  3629. rgba(39, 75, 57, 0.1) 70%,
  3630. transparent 100%
  3631. );
  3632. }
  3633. .footerFade::before {
  3634. content: '';
  3635. position: absolute;
  3636. top: 0;
  3637. left: 50%;
  3638. transform: translateX(-50%);
  3639. width: 50%;
  3640. height: 32rpx;
  3641. background: radial-gradient(ellipse at 50% 100%, rgba(39, 75, 57, 0.04), transparent 70%);
  3642. }
  3643. /* 轻量页脚 */
  3644. .traceFooter {
  3645. padding: 20rpx 32rpx 64rpx;
  3646. display: flex;
  3647. flex-direction: column;
  3648. align-items: center;
  3649. gap: 10rpx;
  3650. }
  3651. .traceFooterHint {
  3652. font-size: 19rpx;
  3653. font-weight: 400;
  3654. color: rgba(88, 100, 92, 0.4);
  3655. letter-spacing: 0.04em;
  3656. }
  3657. .traceFooterPhone {
  3658. display: flex;
  3659. align-items: center;
  3660. gap: 6rpx;
  3661. padding: 6rpx 14rpx;
  3662. border-radius: 6rpx;
  3663. transition: opacity 0.2s ease;
  3664. }
  3665. .traceFooterPhone:active {
  3666. opacity: 0.55;
  3667. }
  3668. .traceFooterPhoneIcon {
  3669. width: 20rpx;
  3670. height: 20rpx;
  3671. opacity: 0.45;
  3672. }
  3673. .traceFooterPhoneNum {
  3674. font-size: 21rpx;
  3675. font-weight: 400;
  3676. color: rgba(39, 75, 57, 0.52);
  3677. letter-spacing: 0.04em;
  3678. }
  3679. .traceFooterBrand {
  3680. font-size: 16rpx;
  3681. font-weight: 400;
  3682. letter-spacing: 0.1em;
  3683. color: rgba(88, 100, 92, 0.26);
  3684. margin-top: 6rpx;
  3685. }
  3686. /* 视频预览区域 */
  3687. .video-section {
  3688. /* margin: 0 30rpx 20rpx; */
  3689. position: relative;
  3690. z-index: 1;
  3691. }
  3692. .video-container {
  3693. position: relative;
  3694. width: 100%;
  3695. height: 420rpx;
  3696. background-color: #000000;
  3697. border-radius: 16rpx;
  3698. overflow: hidden;
  3699. box-shadow: 0 6rpx 20rpx rgba(0, 0, 0, 0.1);
  3700. transition: all 0.3s ease;
  3701. }
  3702. .video-container.fullscreen-mode {
  3703. position: fixed;
  3704. top: 0;
  3705. left: 0;
  3706. width: 100vw;
  3707. height: 100vh;
  3708. margin: 0;
  3709. z-index: 9999;
  3710. border-radius: 0;
  3711. }
  3712. .video-container.fullscreen-mode .video-controls {
  3713. padding: 30rpx;
  3714. }
  3715. .video-container.fullscreen-mode .top-controls,
  3716. .video-container.fullscreen-mode .bottom-controls {
  3717. opacity: 0;
  3718. transition: opacity 0.3s ease;
  3719. }
  3720. .video-container.fullscreen-mode:hover .top-controls,
  3721. .video-container.fullscreen-mode:hover .bottom-controls {
  3722. opacity: 1;
  3723. }
  3724. .video-player,
  3725. .video-placeholder {
  3726. width: 100%;
  3727. height: 100%;
  3728. object-fit: contain;
  3729. }
  3730. /* 微信小程序video组件样式 */
  3731. #myVideo {
  3732. width: 100%;
  3733. height: 100%;
  3734. background-color: #000000;
  3735. }
  3736. /* App端video组件样式 */
  3737. /* #ifdef APP-PLUS || APP-HARMONY */
  3738. #appVideo {
  3739. width: 100%;
  3740. height: 100%;
  3741. background-color: #000000;
  3742. }
  3743. /* #endif */
  3744. .h5-video-wrapper {
  3745. width: 100%;
  3746. height: 100%;
  3747. }
  3748. /* App端视频播放器样式优化 */
  3749. /* #ifdef APP-PLUS || APP-HARMONY */
  3750. #appVideoPlayer {
  3751. width: 100%;
  3752. height: 100%;
  3753. background-color: #000000;
  3754. }
  3755. /* #endif */
  3756. .video-controls {
  3757. position: absolute;
  3758. top: 0;
  3759. left: 0;
  3760. width: 100%;
  3761. height: 100%;
  3762. display: flex;
  3763. flex-direction: column;
  3764. justify-content: space-between;
  3765. padding: 20rpx;
  3766. box-sizing: border-box;
  3767. background: linear-gradient(to bottom, rgba(0, 0, 0, 0.3) 0%, rgba(0, 0, 0, 0) 30%, rgba(0, 0, 0, 0) 70%, rgba(0, 0, 0, 0.3) 100%);
  3768. }
  3769. .control-row {
  3770. display: flex;
  3771. justify-content: space-between;
  3772. align-items: center;
  3773. width: 100%;
  3774. }
  3775. .top-controls {
  3776. height: 80rpx;
  3777. }
  3778. .center-controls {
  3779. height: 120rpx;
  3780. justify-content: center;
  3781. align-items: center;
  3782. }
  3783. .bottom-controls {
  3784. height: 80rpx;
  3785. }
  3786. /* 信号指示器(轻量状态提示) */
  3787. .signal-indicator {
  3788. display: flex;
  3789. align-items: center;
  3790. color: rgba(200, 215, 205, 0.7);
  3791. font-size: 18rpx;
  3792. background-color: rgba(30, 55, 42, 0.5);
  3793. padding: 4rpx 10rpx;
  3794. border-radius: 16rpx;
  3795. opacity: 0.65;
  3796. }
  3797. .signal-subtle {
  3798. opacity: 0.55;
  3799. }
  3800. .signal-indicator image {
  3801. margin-right: 4rpx;
  3802. opacity: 0.7;
  3803. }
  3804. .signal-text {
  3805. font-weight: 400;
  3806. letter-spacing: 0.02em;
  3807. }
  3808. /* 全屏按钮(轻量透明图标按钮) */
  3809. .fullscreen-button {
  3810. position: absolute;
  3811. top: 12rpx;
  3812. right: 16rpx;
  3813. width: 44rpx;
  3814. height: 44rpx;
  3815. display: flex;
  3816. align-items: center;
  3817. justify-content: center;
  3818. color: rgba(235, 245, 240, 0.75);
  3819. background-color: transparent;
  3820. border: none;
  3821. border-radius: 0;
  3822. transition: all 0.2s;
  3823. z-index: 7;
  3824. }
  3825. .fullscreen-button:active {
  3826. color: rgba(235, 245, 240, 0.95);
  3827. transform: scale(0.92);
  3828. }
  3829. /* 实时在线状态标签(固定在右上角,全屏按钮左侧) */
  3830. .video-fixed-status {
  3831. position: absolute;
  3832. top: 24rpx;
  3833. right: 30rpx;
  3834. z-index: 6;
  3835. display: flex;
  3836. align-items: center;
  3837. }
  3838. .video-time {
  3839. color: #FFFFFF;
  3840. font-size: 26rpx;
  3841. background-color: rgba(0, 0, 0, 0.4);
  3842. padding: 6rpx 16rpx;
  3843. border-radius: 20rpx;
  3844. font-weight: 400;
  3845. }
  3846. /* 播放按钮(精致品牌风格,更柔和) */
  3847. .play-button {
  3848. width: 88rpx;
  3849. height: 88rpx;
  3850. border-radius: 50%;
  3851. background: rgba(255, 255, 255, 0.1);
  3852. backdrop-filter: blur(6px);
  3853. -webkit-backdrop-filter: blur(6px);
  3854. display: flex;
  3855. align-items: center;
  3856. justify-content: center;
  3857. border: 1rpx solid rgba(255, 255, 255, 0.2);
  3858. box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.15), inset 0 1rpx 0 rgba(255, 255, 255, 0.08);
  3859. transition: all 0.25s ease;
  3860. }
  3861. .play-button:active {
  3862. transform: scale(0.94);
  3863. background: rgba(255, 255, 255, 0.16);
  3864. }
  3865. /* 播放按钮内部图标(柔和米白) */
  3866. .play-btn-circle {
  3867. width: 54rpx;
  3868. height: 54rpx;
  3869. border-radius: 50%;
  3870. background: linear-gradient(135deg, rgba(250, 250, 248, 0.92) 0%, rgba(242, 245, 240, 0.88) 100%);
  3871. display: flex;
  3872. align-items: center;
  3873. justify-content: center;
  3874. box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.12);
  3875. }
  3876. /* CSS 三角形播放图标(柔和深绿灰) */
  3877. .play-btn-icon {
  3878. width: 0;
  3879. height: 0;
  3880. border-style: solid;
  3881. border-width: 10rpx 0 10rpx 17rpx;
  3882. border-color: transparent transparent transparent rgba(45, 70, 55, 0.82);
  3883. margin-left: 3rpx;
  3884. }
  3885. .center-button-container {
  3886. width: 100%;
  3887. height: 100%;
  3888. display: flex;
  3889. align-items: center;
  3890. justify-content: center;
  3891. }
  3892. .pause-icon {
  3893. width: 80rpx;
  3894. height: 80rpx;
  3895. border-radius: 50%;
  3896. background-color: rgba(0, 0, 0, 0.5);
  3897. display: flex;
  3898. align-items: center;
  3899. justify-content: center;
  3900. opacity: 0;
  3901. transition: opacity 0.3s;
  3902. }
  3903. .center-button-container:active .pause-icon {
  3904. opacity: 1;
  3905. background-color: rgba(76, 175, 80, 0.7);
  3906. }
  3907. </style>