detail.vue 28 KB

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