detail.vue 109 KB

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