detail.vue 108 KB

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