detail.vue 28 KB

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