detail.vue 28 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169
  1. #<template>
  2. <view class="container">
  3. <!-- H5环境自定义导航栏 -->
  4. <view class="h5-custom-navbar" v-if="isH5">
  5. <view class="h5-navbar-left" @click="goBack">
  6. <view class="h5-back-icon">
  7. <view class="h5-arrow-left"></view>
  8. </view>
  9. </view>
  10. <text class="h5-navbar-title">农业知识</text>
  11. <view class="h5-navbar-right"></view>
  12. </view>
  13. <!-- 非H5环境返回按钮 -->
  14. <!-- <view class="float-back-button" v-if="!isH5" @click="goBack">
  15. <view class="float-back-icon">
  16. <view class="h5-arrow-left"></view>
  17. </view>
  18. </view> -->
  19. <!-- 加载中状态 -->
  20. <view class="loading-container" v-if="loading">
  21. <view class="spinner"></view>
  22. <text class="loading-text">加载中...</text>
  23. </view>
  24. <!-- 文章内容区 -->
  25. <view class="article-container" v-if="!loading && articleInfo">
  26. <!-- 封面图轮播 -->
  27. <swiper class="cover-swiper"
  28. indicator-dots
  29. autoplay
  30. circular
  31. interval="3000"
  32. duration="500"
  33. indicator-active-color="#4CAF50"
  34. indicator-color="rgba(255,255,255,0.5)"
  35. @change="handleSwiperChange">
  36. <swiper-item v-for="(slide, index) in carouselImages" :key="index">
  37. <view class="swiper-item-container" :style="{ backgroundColor: slide.color }">
  38. <image class="swiper-bg" :src="slide.url" mode="aspectFill" />
  39. <view class="pattern-overlay"></view>
  40. <view class="agri-icon" v-html="slide.icon"></view>
  41. <view class="swiper-overlay">
  42. <text class="swiper-title">{{ slide.title }}</text>
  43. <text class="swiper-subtitle">{{ slide.subtitle }}</text>
  44. </view>
  45. </view>
  46. </swiper-item>
  47. </swiper>
  48. <view class="swiper-counter">
  49. <text>{{ currentSwiperIndex + 1 }}/{{ carouselImages.length }}</text>
  50. </view>
  51. <!-- 标题及元信息 -->
  52. <view class="article-header">
  53. <text class="article-title">{{ articleInfo.title }}</text>
  54. <view class="article-meta">
  55. <text class="source">{{ articleInfo.source }}</text>
  56. <text class="dot">·</text>
  57. <text class="date">{{ articleInfo.publishDate }}</text>
  58. <view class="views">
  59. <image src="@/static/icons/read.png" style="width: 30rpx;height: 30rpx;"></image>
  60. <text class="view-count">{{ articleInfo.viewCount }}</text>
  61. </view>
  62. </view>
  63. </view>
  64. <!-- 文章正文 -->
  65. <view class="article-content" v-if="articleInfo.contentType === 'article' || !articleInfo.contentType">
  66. <rich-text :nodes="processedContent"></rich-text>
  67. </view>
  68. <!-- 视频内容 -->
  69. <view class="video-container" v-if="articleInfo.contentType === 'video'">
  70. <video
  71. v-if="videoPlaying"
  72. :src="articleInfo.videoUrl"
  73. class="video-player"
  74. controls
  75. :poster="articleInfo.imageUrl"
  76. ></video>
  77. <view class="video-poster" v-else @click="playVideo">
  78. <view class="video-color-bg" :style="{ backgroundColor: getRandomColor() }">
  79. <view class="video-pattern"></view>
  80. <text class="video-label">视频教学</text>
  81. </view>
  82. <view class="play-button">
  83. <view class="triangle-play"></view>
  84. </view>
  85. <text class="video-duration">{{ articleInfo.duration || '00:00' }}</text>
  86. </view>
  87. <text class="video-title">{{ articleInfo.title }}</text>
  88. </view>
  89. </view>
  90. <!-- 底部功能区 -->
  91. <!-- <view class="footer-action" v-if="!loading && articleInfo">
  92. <view class="action-button like" @click="handleLike">
  93. <view class="action-icon-wrapper">
  94. <text v-if="articleInfo.liked" class="material-icon">&#xe87d;</text>
  95. <text v-else class="material-icon">&#xe87e;</text>
  96. </view>
  97. <text class="action-text">{{ articleInfo.liked ? '已点赞' : '点赞' }}</text>
  98. </view>
  99. <view class="action-button collect" @click="handleCollect">
  100. <view class="action-icon-wrapper">
  101. <text v-if="articleInfo.collected" class="material-icon">&#xe838;</text>
  102. <text v-else class="material-icon">&#xe83a;</text>
  103. </view>
  104. <text class="action-text">{{ articleInfo.collected ? '已收藏' : '收藏' }}</text>
  105. </view>
  106. <view class="action-button share" @click="handleShare">
  107. <view class="action-icon-wrapper">
  108. <text class="material-icon">&#xe80d;</text>
  109. </view>
  110. <text class="action-text">分享</text>
  111. </view>
  112. </view> -->
  113. <!-- 返回顶部 -->
  114. <view class="back-to-top" @click="scrollToTop" v-if="!loading && articleInfo">
  115. <view class="top-arrow"></view>
  116. <text class="top-text">顶部</text>
  117. </view>
  118. </view>
  119. </template>
  120. <script setup>
  121. import { ref, reactive, computed, onMounted } from 'vue'
  122. import { getKnowledgeDetail, getKnowledgeView } from "@/api/services/knowledge.js"
  123. import { onShow, onLoad, onNavigationBarButtonTap} from '@dcloudio/uni-app'
  124. // 响应式数据
  125. const title = ref("农业知识")
  126. const loading = ref(true)
  127. const articleInfo = ref(null)
  128. const knowledgeImages = ref([]) // 文章关联的图片
  129. const currentSwiperIndex = ref(0)
  130. const isH5 = ref(false) // 是否是H5环境
  131. const videoPlaying = ref(false)
  132. const id = ref(null)
  133. const type = ref('')
  134. const carouselImages = ref([])
  135. // 计算属性
  136. // 计算属性
  137. const processedContent = computed(() => {
  138. console.log("articleInfo", articleInfo.value)
  139. // 检查文章内容是否存在于article_content或content_category字段
  140. if (!articleInfo.value) return ''
  141. // 优先使用content_category字段,如果不存在则尝试使用article_content字段
  142. let content = articleInfo.value.content_category || articleInfo.value.articleContent || ''
  143. // 如果内容已经包含HTML标签
  144. if (content.includes('<') && content.includes('>')) {
  145. // 增强绿色背景区块显示
  146. content = content.replace(/<div[^>]*>水稻秧苗培育<\/div>/g, '<div class="green-block">水稻秧苗培育</div>')
  147. content = content.replace(/<div[^>]*>水稻收获与储存<\/div>/g, '<div class="green-block">水稻收获与储存</div>')
  148. // 增强注意事项样式
  149. content = content.replace(/<div[^>]*>\s*\[注意事项\]\s*(.*?)<\/div>/gs, '<div class="notice-box"><div class="notice-content">$1</div></div>')
  150. // 识别H3标题并在其后插入对应的图片
  151. if (knowledgeImages.value && knowledgeImages.value.length > 0) {
  152. // 为每个标题后添加对应的图片
  153. const titleRegex = /<h[1-3][^>]*>(.*?)<\/h[1-3]>/g
  154. let titleMatch
  155. let imageIndex = 0
  156. let titleCount = 0
  157. let imageHtml = ''
  158. let matches = []
  159. // 先计算有多少个标题
  160. while ((titleMatch = titleRegex.exec(content)) !== null) {
  161. matches.push({
  162. fullMatch: titleMatch[0],
  163. title: titleMatch[1],
  164. index: titleMatch.index
  165. })
  166. }
  167. // 处理每个标题,插入相应的图片
  168. for (let i = matches.length - 1; i >= 0; i--) {
  169. if (imageIndex < knowledgeImages.value.length) {
  170. const image = knowledgeImages.value[imageIndex]
  171. console.log("image打打符:", image)
  172. // 根据是否有真实图片URL来决定显示方式
  173. imageHtml = image.url?
  174. `
  175. <div class="content-image-wrapper">
  176. <div class="content-image-real" style="background-image: url('${image.url}');">
  177. </div>
  178. </div>
  179. ` :
  180. `
  181. <div class="content-image-wrapper">
  182. <div class="content-image" style="background-color: ${image.color || '#8BC34A'};">
  183. <div class="image-text">${image.title || '农业知识图解'}</div>
  184. </div>
  185. </div>
  186. `
  187. content = content.substring(0, matches[i].index + matches[i].fullMatch.length) + imageHtml + content.substring(matches[i].index + matches[i].fullMatch.length)
  188. imageIndex++
  189. }
  190. }
  191. }
  192. return content
  193. }
  194. // 如果是纯文本内容,则增强格式化
  195. // 替换\n为<br>标签
  196. content = content.replace(/\n/g, '<br>')
  197. // 识别章节标题
  198. content = content.replace(/([一二三四五六七八九十])、\s*([^\n<]+)/g, '<h3>$1、$2</h3>')
  199. // 识别注意事项段落
  200. content = content.replace(/\[注意事项\]\s*(.*?)(\n|$)/g, '<div class="notice-box"><div class="notice-content">$1</div></div>')
  201. // 在标题后插入对应图片
  202. if (knowledgeImages.value && knowledgeImages.value.length > 0) {
  203. const sections = content.split(/<h3>/)
  204. let newContent = sections[0] // 保留第一部分
  205. for (let i = 1; i < sections.length; i++) {
  206. newContent += '<h3>' + sections[i]
  207. // 如果有对应的图片,在标题后插入图片
  208. if (i - 1 < knowledgeImages.value.length) {
  209. const image = knowledgeImages.value[i - 1]
  210. console.log("image打打符:", image)
  211. // 根据是否有真实图片URL来决定显示方式
  212. newContent += image.url ?
  213. `
  214. <div class="content-image-wrapper">
  215. <div class="content-image-real" style="background-image: url('${image.url}');">
  216. <div class="image-text-overlay">
  217. <div class="image-text">${image.title || '农业知识图解'}</div>
  218. </div>
  219. </div>
  220. </div>
  221. ` :
  222. `
  223. <div class="content-image-wrapper">
  224. <div class="content-image" style="background-color: ${image.color || '#8BC34A'};">
  225. <div class="image-text">${image.title || '农业知识图解'}</div>
  226. </div>
  227. </div>
  228. `
  229. }
  230. }
  231. content = newContent
  232. }
  233. // 包装段落
  234. content = `<div style="font-size: 30rpx; line-height: 1.8; color: #333; margin-bottom: 20rpx;">${content}</div>`
  235. return content
  236. })
  237. // 获取文章详情数据
  238. const fetchArticleDetail = async () => {
  239. loading.value = true
  240. try {
  241. await getKnowledgeDetail({
  242. id: id.value,
  243. type: type.value
  244. }).then(response => {
  245. if (response.data.data && response.data.code === 200) {
  246. articleInfo.value = response.data.data
  247. // 设置默认的点赞和收藏状态
  248. articleInfo.value.liked = false
  249. articleInfo.value.collected = false
  250. // 处理文章关联的图片
  251. if (articleInfo.value.knowledgeImage && articleInfo.value.knowledgeImage.length > 0) {
  252. articleInfo.value.knowledgeImage.forEach(image => {
  253. // 检查 imageType 是否为 'carousel'
  254. if (image.imageType === 'carousel') {
  255. // 如果是,将该元素添加到 carouselImages 数组中
  256. carouselImages.value.push(image)
  257. } else {
  258. knowledgeImages.value.push(image)
  259. }
  260. console.log("carouselImages", carouselImages.value)
  261. })
  262. console.log('文章图片数据:', knowledgeImages.value)
  263. }
  264. // 增加浏览量
  265. updateViewCount()
  266. } else {
  267. uni.showToast({
  268. title: (response.data && response.data.message) || '获取文章详情失败',
  269. icon: 'none'
  270. })
  271. }
  272. }).catch(err => [err, null])
  273. } catch (error) {
  274. console.error('获取文章详情失败:', error)
  275. uni.showToast({
  276. title: '网络异常,请稍后再试',
  277. icon: 'none'
  278. })
  279. } finally {
  280. loading.value = false
  281. }
  282. }
  283. // 更新浏览量
  284. const updateViewCount = async () => {
  285. try {
  286. getKnowledgeView({
  287. id: id.value,
  288. type: type.value
  289. }).then(res => {
  290. if (res.data && res.data.code === 200) {
  291. // 记录已更新的文章ID和新阅读量
  292. if (articleInfo.value) {
  293. // 增加阅读量计数,假设API成功更新了阅读量
  294. articleInfo.value.viewCount = (articleInfo.value.viewCount || 0) + 1
  295. // 发送全局事件通知列表页更新阅读量
  296. uni.$emit('updateArticleViewCount', {
  297. id: id.value,
  298. type: type.value,
  299. viewCount: articleInfo.value.viewCount
  300. })
  301. }
  302. }
  303. })
  304. } catch (error) {
  305. console.error('更新浏览量失败:', error)
  306. }
  307. }
  308. // 处理点赞
  309. const handleLike = async () => {
  310. try {
  311. const action = articleInfo.value.liked ? 'unlike' : 'like'
  312. const [error, res] = await uni.request({
  313. url: `http://localhost:8080/knowledge/${action}`, // 替换为实际的API地址
  314. method: 'POST',
  315. data: {
  316. id: id.value,
  317. type: type.value
  318. }
  319. }).catch(err => [err, null])
  320. const response = res || {}
  321. if (response.data && response.data.code === 0) {
  322. articleInfo.value.liked = !articleInfo.value.liked
  323. } else {
  324. uni.showToast({
  325. title: (response.data && response.data.message) || '操作失败',
  326. icon: 'none'
  327. })
  328. }
  329. } catch (error) {
  330. console.error('点赞操作失败:', error)
  331. uni.showToast({
  332. title: '网络异常,请稍后再试',
  333. icon: 'none'
  334. })
  335. }
  336. }
  337. // 处理收藏
  338. const handleCollect = async () => {
  339. try {
  340. const action = articleInfo.value.collected ? 'uncollect' : 'collect'
  341. const [error, res] = await uni.request({
  342. url: `http://localhost:8080/knowledge/${action}`, // 替换为实际的API地址
  343. method: 'POST',
  344. data: {
  345. id: id.value,
  346. type: type.value
  347. }
  348. }).catch(err => [err, null])
  349. const response = res || {}
  350. if (response.data && response.data.code === 0) {
  351. articleInfo.value.collected = !articleInfo.value.collected
  352. } else {
  353. uni.showToast({
  354. title: (response.data && response.data.message) || '操作失败',
  355. icon: 'none'
  356. })
  357. }
  358. } catch (error) {
  359. console.error('收藏操作失败:', error)
  360. uni.showToast({
  361. title: '网络异常,请稍后再试',
  362. icon: 'none'
  363. })
  364. }
  365. }
  366. // 播放视频
  367. const playVideo = () => {
  368. videoPlaying.value = true
  369. }
  370. // 格式化日期
  371. const formatDate = (dateStr) => {
  372. if (!dateStr) return ''
  373. const date = new Date(dateStr)
  374. return `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, '0')}-${String(date.getDate()).padStart(2, '0')}`
  375. }
  376. // 获取随机颜色
  377. const getRandomColor = () => {
  378. const colors = ['#8BC34A', '#4CAF50', '#7CB342', '#689F38', '#33691E']
  379. return colors[Math.floor(Math.random() * colors.length)]
  380. }
  381. // 根据类型获取图标
  382. const getIconByType = () => {
  383. if (type.value === 'tech') {
  384. return '<svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 0 24 24" fill="none" stroke="white" stroke-width="1" stroke-linecap="round" stroke-linejoin="round"><path d="M12 2a10 10 0 1 0 10 10A10 10 0 0 0 12 2zm0 18a8 8 0 1 1 8-8 8 8 0 0 1-8 8z"></path><path d="M12 6a1 1 0 0 0-1 1v5a1 1 0 0 0 .55.89l4 2a1 1 0 0 0 .9-1.78L13 11.28V7a1 1 0 0 0-1-1z"></path></svg>'
  385. } else {
  386. return '<svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 0 24 24" fill="none" stroke="white" stroke-width="1" stroke-linecap="round" stroke-linejoin="round"><path d="M21 12h-4 M17 12l-3-3 M17 12l-3 3 M3 6h10 M13 6l-3-3 M13 6l-3 3 M3 18h10 M13 18l-3-3 M13 18l-3 3"></path></svg>'
  387. }
  388. }
  389. const goBack = () => {
  390. uni.navigateBack()
  391. }
  392. const scrollToTop = () => {
  393. setTimeout(() => {
  394. uni.pageScrollTo({ scrollTop: 0, duration: 0 })
  395. }, 50)
  396. }
  397. const handleShare = () => {
  398. uni.showShareMenu({
  399. withShareTicket: true,
  400. menus: ['shareAppMessage', 'shareTimeline']
  401. })
  402. }
  403. const handleSwiperChange = (e) => {
  404. currentSwiperIndex.value = e.detail.current
  405. }
  406. // uni-app 生命周期钩子
  407. onLoad((options) => {
  408. // 获取传递的参数
  409. id.value = Number(options.id)
  410. type.value = options.type
  411. // 检测是否在H5环境中运行
  412. // #ifdef H5
  413. isH5.value = true
  414. // #endif
  415. console.log("isH5", isH5.value)
  416. // 设置导航栏标题
  417. uni.setNavigationBarTitle({
  418. title: type.value === 'tech' ? '农技知识' : '政策解读'
  419. })
  420. // 加载文章详情
  421. fetchArticleDetail()
  422. })
  423. onNavigationBarButtonTap((e) => {
  424. if (e.index === 0) {
  425. goBack()
  426. }
  427. })
  428. </script>
  429. <style>
  430. /* 字体图标 */
  431. @font-face {
  432. font-family: 'iconfont';
  433. src: url('https://at.alicdn.com/t/font_3442238_cosd6rj55jg.ttf') format('truetype');
  434. }
  435. @font-face {
  436. font-family: 'Material Icons';
  437. font-style: normal;
  438. font-weight: 400;
  439. src: url(https://fonts.gstatic.com/s/materialicons/v139/flUhRq6tzZclQEJ-Vdg-IuiaDsNc.woff2) format('woff2');
  440. }
  441. .icon, .view-icon, .play-icon, .action-icon, .top-icon {
  442. font-family: 'iconfont';
  443. }
  444. .material-icon {
  445. font-family: 'Material Icons';
  446. font-weight: normal;
  447. font-style: normal;
  448. font-size: 50rpx;
  449. line-height: 1;
  450. letter-spacing: normal;
  451. text-transform: none;
  452. display: inline-block;
  453. white-space: nowrap;
  454. word-wrap: normal;
  455. direction: ltr;
  456. -webkit-font-smoothing: antialiased;
  457. color: #4CAF50;
  458. }
  459. /* 容器样式 */
  460. .container {
  461. background-color: #f8f8f8;
  462. min-height: 100vh;
  463. position: relative;
  464. padding-bottom: 120rpx;
  465. padding-top: 90rpx; /* 为H5导航栏留出空间 */
  466. }
  467. /* 加载状态 */
  468. .loading-container {
  469. display: flex;
  470. flex-direction: column;
  471. align-items: center;
  472. justify-content: center;
  473. height: 100vh;
  474. }
  475. .spinner {
  476. width: 80rpx;
  477. height: 80rpx;
  478. border: 6rpx solid rgba(77, 201, 113, 0.2);
  479. border-radius: 50%;
  480. border-top-color: #4dc971;
  481. animation: spin 0.8s linear infinite;
  482. margin-bottom: 20rpx;
  483. }
  484. @keyframes spin {
  485. to {
  486. transform: rotate(360deg);
  487. }
  488. }
  489. .loading-text {
  490. font-size: 28rpx;
  491. color: #999;
  492. }
  493. /* 删除自定义导航栏样式 */
  494. .custom-navbar {
  495. display: none;
  496. }
  497. .navbar-left, .back-icon, .navbar-title, .navbar-right, .arrow-left {
  498. display: none;
  499. }
  500. /* 文章容器 */
  501. .article-container {
  502. background-color: #fff;
  503. border-radius: 0;
  504. overflow: hidden;
  505. }
  506. /* 封面图轮播 */
  507. .cover-swiper {
  508. width: 100%;
  509. height: 420rpx;
  510. position: relative;
  511. background-color: #4CAF50;
  512. }
  513. .swiper-item-container {
  514. position: relative;
  515. width: 100%;
  516. height: 100%;
  517. display: flex;
  518. align-items: center;
  519. justify-content: center;
  520. border-radius: 0;
  521. background-color: #4CAF50;
  522. }
  523. .swiper-image {
  524. width: 100%;
  525. height: 100%;
  526. display: block;
  527. }
  528. .swiper-bg {
  529. width: 100%;
  530. height: 100%;
  531. position: absolute;
  532. top: 0;
  533. left: 0;
  534. }
  535. .swiper-overlay {
  536. position: absolute;
  537. bottom: 0;
  538. left: 0;
  539. right: 0;
  540. padding: 40rpx 30rpx;
  541. background: linear-gradient(to top, rgba(0,0,0,0.7), rgba(0,0,0,0));
  542. display: flex;
  543. flex-direction: column;
  544. justify-content: flex-end;
  545. align-items: flex-start;
  546. color: #fff;
  547. height: 100%;
  548. }
  549. .swiper-title {
  550. font-size: 42rpx;
  551. font-weight: bold;
  552. margin-bottom: 10rpx;
  553. text-shadow: 0 2px 4px rgba(0,0,0,0.5);
  554. max-width: 80%;
  555. line-height: 1.3;
  556. }
  557. .swiper-subtitle {
  558. font-size: 28rpx;
  559. opacity: 0.9;
  560. text-shadow: 0 1px 2px rgba(0,0,0,0.5);
  561. background-color: rgba(255,255,255,0.2);
  562. padding: 4rpx 12rpx;
  563. border-radius: 4rpx;
  564. }
  565. /* 文章头部信息 */
  566. .article-header {
  567. padding: 30rpx 30rpx 0;
  568. }
  569. .article-title {
  570. font-size: 42rpx;
  571. font-weight: bold;
  572. color: #333;
  573. line-height: 1.4;
  574. margin-bottom: 20rpx;
  575. }
  576. .article-meta {
  577. display: flex;
  578. align-items: center;
  579. margin-bottom: 40rpx;
  580. }
  581. .source {
  582. font-size: 24rpx;
  583. color: #666;
  584. }
  585. .dot {
  586. margin: 0 10rpx;
  587. color: #999;
  588. }
  589. .date {
  590. font-size: 24rpx;
  591. color: #999;
  592. }
  593. .views {
  594. margin-left: auto;
  595. display: flex;
  596. align-items: center;
  597. }
  598. .view-icon {
  599. font-size: 24rpx;
  600. color: #999;
  601. margin-right: 6rpx;
  602. }
  603. .view-count {
  604. font-size: 24rpx;
  605. color: #999;
  606. }
  607. /* 文章内容 */
  608. .article-content {
  609. padding: 0 30rpx 40rpx;
  610. }
  611. /* 富文本内容样式 */
  612. .article-content >>> h3,
  613. .article-content >>> h1,
  614. .article-content >>> h2 {
  615. font-size: 34rpx;
  616. font-weight: bold;
  617. margin: 30rpx 0 20rpx;
  618. color: #333;
  619. }
  620. .article-content >>> p {
  621. font-size: 30rpx;
  622. line-height: 1.8;
  623. color: #333;
  624. margin-bottom: 20rpx;
  625. }
  626. /* 分节样式 */
  627. .article-content >>> h3:first-child,
  628. .article-content >>> h2:first-child,
  629. .article-content >>> h1:first-child {
  630. margin-top: 10rpx;
  631. }
  632. /* 章节标题 */
  633. .article-content >>> h3 {
  634. color: #4CAF50;
  635. font-size: 32rpx;
  636. font-weight: bold;
  637. margin: 40rpx 0 20rpx;
  638. position: relative;
  639. padding-left: 20rpx;
  640. }
  641. .article-content >>> h3::before {
  642. content: '';
  643. position: absolute;
  644. left: 0;
  645. top: 8rpx;
  646. bottom: 8rpx;
  647. width: 6rpx;
  648. background-color: #4CAF50;
  649. border-radius: 3rpx;
  650. }
  651. /* 注意事项样式 */
  652. .article-content >>> .notice-box {
  653. background-color: #F8F9E5;
  654. border-left: 10rpx solid #8BC34A;
  655. padding: 0;
  656. margin: 30rpx 0;
  657. border-radius: 6rpx;
  658. position: relative;
  659. }
  660. .article-content >>> .notice-content {
  661. padding: 20rpx;
  662. font-size: 28rpx;
  663. color: #555;
  664. line-height: 1.6;
  665. }
  666. .article-content >>> .notice-content::before {
  667. content: '[注意事项]';
  668. display: block;
  669. font-weight: bold;
  670. color: #5C8D2A;
  671. margin-bottom: 10rpx;
  672. }
  673. /* 旧的样式保留兼容性 */
  674. .article-content >>> blockquote {
  675. background-color: #F8F9E5;
  676. border-left: 10rpx solid #8BC34A;
  677. padding: 20rpx;
  678. margin: 20rpx 0;
  679. border-radius: 6rpx;
  680. }
  681. /* 绿色背景区域 */
  682. .article-content >>> .green-block {
  683. background-color: #4CAF50;
  684. color: white;
  685. padding: 30rpx;
  686. text-align: center;
  687. font-size: 32rpx;
  688. font-weight: bold;
  689. margin: 20rpx 0;
  690. border-radius: 6rpx;
  691. }
  692. /* 文章内容图片容器 */
  693. .article-content >>> .content-image-wrapper {
  694. margin: 20rpx 0 30rpx;
  695. width: 100%;
  696. }
  697. .article-content >>> .content-image {
  698. background-color: #8BC34A;
  699. height: 200rpx;
  700. display: flex;
  701. align-items: center;
  702. justify-content: center;
  703. color: white;
  704. border-radius: 6rpx;
  705. position: relative;
  706. overflow: hidden;
  707. }
  708. .article-content >>> .content-image::before {
  709. content: '';
  710. position: absolute;
  711. top: 0;
  712. left: 0;
  713. right: 0;
  714. bottom: 0;
  715. background-image: linear-gradient(45deg, rgba(255,255,255,0.15) 25%, transparent 25%, transparent 50%, rgba(255,255,255,0.15) 50%, rgba(255,255,255,0.15) 75%, transparent 75%, transparent);
  716. background-size: 50px 50px;
  717. opacity: 0.2;
  718. }
  719. .article-content >>> .image-text {
  720. font-size: 36rpx;
  721. font-weight: bold;
  722. text-shadow: 0 2px 4px rgba(0,0,0,0.3);
  723. z-index: 2;
  724. }
  725. /* 真实图片样式 */
  726. .article-content >>> .content-image-real {
  727. height: 200rpx;
  728. background-size: cover;
  729. background-position: center;
  730. border-radius: 6rpx;
  731. position: relative;
  732. overflow: hidden;
  733. }
  734. .article-content >>> .image-text-overlay {
  735. position: absolute;
  736. top: 0;
  737. left: 0;
  738. right: 0;
  739. bottom: 0;
  740. background: linear-gradient(to bottom, rgba(0,0,0,0), rgba(0,0,0,0.6));
  741. display: flex;
  742. align-items: center;
  743. justify-content: center;
  744. }
  745. /* 确保内容不超出容器 */
  746. .article-content >>> img {
  747. max-width: 100%;
  748. height: auto;
  749. }
  750. /* 视频容器 */
  751. .video-container {
  752. margin: 0 30rpx 40rpx;
  753. border-radius: 0;
  754. overflow: hidden;
  755. background-color: #fff;
  756. }
  757. .video-player {
  758. width: 100%;
  759. height: 420rpx;
  760. }
  761. .video-poster {
  762. position: relative;
  763. width: 100%;
  764. height: 380rpx;
  765. }
  766. .video-color-bg {
  767. position: absolute;
  768. top: 0;
  769. left: 0;
  770. right: 0;
  771. bottom: 0;
  772. display: flex;
  773. align-items: center;
  774. justify-content: center;
  775. border-radius: 0;
  776. }
  777. .video-pattern {
  778. position: absolute;
  779. top: 0;
  780. left: 0;
  781. right: 0;
  782. bottom: 0;
  783. opacity: 0.1;
  784. background-image:
  785. linear-gradient(45deg, rgba(255,255,255,0.15) 25%, transparent 25%, transparent 50%,
  786. rgba(255,255,255,0.15) 50%, rgba(255,255,255,0.15) 75%, transparent 75%, transparent);
  787. background-size: 50px 50px;
  788. }
  789. .video-label {
  790. color: white;
  791. font-size: 32rpx;
  792. font-weight: bold;
  793. text-shadow: 0 2px 4px rgba(0,0,0,0.5);
  794. z-index: 5;
  795. }
  796. .play-button {
  797. position: absolute;
  798. top: 50%;
  799. left: 50%;
  800. transform: translate(-50%, -50%);
  801. width: 120rpx;
  802. height: 120rpx;
  803. background-color: rgba(0, 0, 0, 0.6);
  804. border-radius: 50%;
  805. display: flex;
  806. align-items: center;
  807. justify-content: center;
  808. z-index: 10;
  809. box-shadow: 0 0 20rpx rgba(0, 0, 0, 0.3);
  810. border: 4rpx solid rgba(255, 255, 255, 0.8);
  811. }
  812. .triangle-play {
  813. width: 0;
  814. height: 0;
  815. border-top: 26rpx solid transparent;
  816. border-bottom: 26rpx solid transparent;
  817. border-left: 40rpx solid #fff;
  818. margin-left: 10rpx;
  819. }
  820. .video-duration {
  821. position: absolute;
  822. bottom: 20rpx;
  823. right: 20rpx;
  824. padding: 6rpx 12rpx;
  825. background-color: rgba(0, 0, 0, 0.6);
  826. color: #fff;
  827. font-size: 22rpx;
  828. border-radius: 4rpx;
  829. }
  830. .video-title {
  831. font-size: 28rpx;
  832. font-weight: bold;
  833. color: #333;
  834. padding: 20rpx;
  835. display: block;
  836. }
  837. /* 底部功能区 */
  838. .footer-action {
  839. position: fixed;
  840. bottom: 0;
  841. left: 0;
  842. right: 0;
  843. height: 100rpx;
  844. background-color: #fff;
  845. display: flex;
  846. align-items: center;
  847. justify-content: space-around;
  848. box-shadow: 0 -2rpx 10rpx rgba(0, 0, 0, 0.05);
  849. z-index: 99;
  850. }
  851. .action-button {
  852. display: flex;
  853. flex-direction: column;
  854. align-items: center;
  855. padding: 10rpx 0;
  856. }
  857. .action-icon-wrapper {
  858. display: flex;
  859. align-items: center;
  860. justify-content: center;
  861. margin-bottom: 6rpx;
  862. }
  863. .action-text {
  864. font-size: 24rpx;
  865. color: #4CAF50;
  866. font-weight: 500;
  867. }
  868. .action-button:active {
  869. opacity: 0.7;
  870. }
  871. /* 返回顶部按钮 */
  872. .back-to-top {
  873. position: fixed;
  874. right: 30rpx;
  875. bottom: 120rpx;
  876. width: 100rpx;
  877. height: 100rpx;
  878. background-color: rgba(46, 125, 50, 0.9);
  879. border-radius: 50%;
  880. display: flex;
  881. flex-direction: column;
  882. align-items: center;
  883. justify-content: center;
  884. z-index: 99;
  885. }
  886. .top-arrow {
  887. width: 20rpx;
  888. height: 20rpx;
  889. border-top: 4rpx solid #fff;
  890. border-left: 4rpx solid #fff;
  891. transform: rotate(45deg);
  892. margin-bottom: 6rpx;
  893. }
  894. .top-text {
  895. color: #fff;
  896. font-size: 22rpx;
  897. }
  898. .swiper-counter {
  899. position: absolute;
  900. top: 30rpx;
  901. right: 30rpx;
  902. padding: 6rpx 12rpx;
  903. background-color: rgba(0, 0, 0, 0.5);
  904. color: #fff;
  905. font-size: 22rpx;
  906. border-radius: 20rpx;
  907. z-index: 10;
  908. }
  909. .pattern-overlay {
  910. position: absolute;
  911. top: 0;
  912. left: 0;
  913. right: 0;
  914. bottom: 0;
  915. opacity: 0.1;
  916. background-image:
  917. linear-gradient(45deg, rgba(255,255,255,0.15) 25%, transparent 25%, transparent 50%,
  918. rgba(255,255,255,0.15) 50%, rgba(255,255,255,0.15) 75%, transparent 75%, transparent);
  919. background-size: 50px 50px;
  920. }
  921. .agri-icon {
  922. position: absolute;
  923. top: 40%;
  924. left: 50%;
  925. transform: translate(-50%, -50%);
  926. opacity: 0.8;
  927. width: 120rpx;
  928. height: 120rpx;
  929. z-index: 5;
  930. }
  931. .agri-icon svg {
  932. width: 100%;
  933. height: 100%;
  934. stroke-width: 1.5;
  935. }
  936. .section-image {
  937. margin: 20rpx 0;
  938. width: 100%;
  939. }
  940. .color-image {
  941. width: 100%;
  942. height: 300rpx;
  943. border-radius: 0;
  944. display: flex;
  945. align-items: center;
  946. justify-content: center;
  947. position: relative;
  948. overflow: hidden;
  949. }
  950. .color-image::before {
  951. content: "";
  952. position: absolute;
  953. top: 0;
  954. left: 0;
  955. right: 0;
  956. bottom: 0;
  957. background-image:
  958. linear-gradient(45deg, rgba(255,255,255,0.15) 25%, transparent 25%, transparent 50%,
  959. rgba(255,255,255,0.15) 50%, rgba(255,255,255,0.15) 75%, transparent 75%, transparent);
  960. background-size: 50px 50px;
  961. opacity: 0.2;
  962. }
  963. .image-label {
  964. color: white;
  965. font-size: 32rpx;
  966. font-weight: bold;
  967. text-shadow: 0 2px 4px rgba(0,0,0,0.5);
  968. z-index: 5;
  969. }
  970. /* 删除浮动返回按钮样式 */
  971. .float-back-button {
  972. position: fixed;
  973. top: 30rpx;
  974. left: 30rpx;
  975. width: 80rpx;
  976. height: 80rpx;
  977. background-color: rgba(255, 255, 255, 0.9);
  978. border-radius: 50%;
  979. display: flex;
  980. align-items: center;
  981. justify-content: center;
  982. z-index: 100;
  983. box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.1);
  984. }
  985. .float-back-icon {
  986. display: flex;
  987. align-items: center;
  988. justify-content: center;
  989. }
  990. /* H5导航栏样式 */
  991. .h5-custom-navbar {
  992. position: fixed;
  993. top: 0;
  994. left: 0;
  995. right: 0;
  996. height: 90rpx;
  997. background-color: #fff;
  998. display: flex;
  999. align-items: center;
  1000. padding: 0 30rpx;
  1001. z-index: 100;
  1002. box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.05);
  1003. }
  1004. .h5-navbar-left {
  1005. width: 80rpx;
  1006. height: 80rpx;
  1007. display: flex;
  1008. align-items: center;
  1009. justify-content: center;
  1010. }
  1011. .h5-back-icon {
  1012. font-size: 40rpx;
  1013. color: #333;
  1014. display: flex;
  1015. align-items: center;
  1016. justify-content: center;
  1017. }
  1018. .h5-navbar-title {
  1019. flex: 1;
  1020. text-align: center;
  1021. font-size: 32rpx;
  1022. font-weight: bold;
  1023. color: #333;
  1024. }
  1025. .h5-navbar-right {
  1026. width: 60rpx;
  1027. }
  1028. .h5-arrow-left {
  1029. width: 24rpx;
  1030. height: 24rpx;
  1031. border-top: 4rpx solid #333;
  1032. border-left: 4rpx solid #333;
  1033. transform: rotate(-45deg);
  1034. }
  1035. </style>