detail.vue 28 KB

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