detail.vue 28 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139
  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. uni.pageScrollTo({
  412. scrollTop: 0,
  413. duration: 300
  414. });
  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-overlay {
  527. position: absolute;
  528. bottom: 0;
  529. left: 0;
  530. right: 0;
  531. padding: 40rpx 30rpx;
  532. background: linear-gradient(to top, rgba(0,0,0,0.7), rgba(0,0,0,0));
  533. display: flex;
  534. flex-direction: column;
  535. justify-content: flex-end;
  536. align-items: flex-start;
  537. color: #fff;
  538. height: 100%;
  539. }
  540. .swiper-title {
  541. font-size: 42rpx;
  542. font-weight: bold;
  543. margin-bottom: 10rpx;
  544. text-shadow: 0 2px 4px rgba(0,0,0,0.5);
  545. max-width: 80%;
  546. line-height: 1.3;
  547. }
  548. .swiper-subtitle {
  549. font-size: 28rpx;
  550. opacity: 0.9;
  551. text-shadow: 0 1px 2px rgba(0,0,0,0.5);
  552. background-color: rgba(255,255,255,0.2);
  553. padding: 4rpx 12rpx;
  554. border-radius: 4rpx;
  555. }
  556. /* 文章头部信息 */
  557. .article-header {
  558. padding: 30rpx 30rpx 0;
  559. }
  560. .article-title {
  561. font-size: 42rpx;
  562. font-weight: bold;
  563. color: #333;
  564. line-height: 1.4;
  565. margin-bottom: 20rpx;
  566. }
  567. .article-meta {
  568. display: flex;
  569. align-items: center;
  570. margin-bottom: 40rpx;
  571. }
  572. .source {
  573. font-size: 24rpx;
  574. color: #666;
  575. }
  576. .dot {
  577. margin: 0 10rpx;
  578. color: #999;
  579. }
  580. .date {
  581. font-size: 24rpx;
  582. color: #999;
  583. }
  584. .views {
  585. margin-left: auto;
  586. display: flex;
  587. align-items: center;
  588. }
  589. .view-icon {
  590. font-size: 24rpx;
  591. color: #999;
  592. margin-right: 6rpx;
  593. }
  594. .view-count {
  595. font-size: 24rpx;
  596. color: #999;
  597. }
  598. /* 文章内容 */
  599. .article-content {
  600. padding: 0 30rpx 40rpx;
  601. }
  602. /* 富文本内容样式 */
  603. .article-content >>> h3,
  604. .article-content >>> h1,
  605. .article-content >>> h2 {
  606. font-size: 34rpx;
  607. font-weight: bold;
  608. margin: 30rpx 0 20rpx;
  609. color: #333;
  610. }
  611. .article-content >>> p {
  612. font-size: 30rpx;
  613. line-height: 1.8;
  614. color: #333;
  615. margin-bottom: 20rpx;
  616. }
  617. /* 分节样式 */
  618. .article-content >>> h3:first-child,
  619. .article-content >>> h2:first-child,
  620. .article-content >>> h1:first-child {
  621. margin-top: 10rpx;
  622. }
  623. /* 章节标题 */
  624. .article-content >>> h3 {
  625. color: #4CAF50;
  626. font-size: 32rpx;
  627. font-weight: bold;
  628. margin: 40rpx 0 20rpx;
  629. position: relative;
  630. padding-left: 20rpx;
  631. }
  632. .article-content >>> h3::before {
  633. content: '';
  634. position: absolute;
  635. left: 0;
  636. top: 8rpx;
  637. bottom: 8rpx;
  638. width: 6rpx;
  639. background-color: #4CAF50;
  640. border-radius: 3rpx;
  641. }
  642. /* 注意事项样式 */
  643. .article-content >>> .notice-box {
  644. background-color: #F8F9E5;
  645. border-left: 10rpx solid #8BC34A;
  646. padding: 0;
  647. margin: 30rpx 0;
  648. border-radius: 6rpx;
  649. position: relative;
  650. }
  651. .article-content >>> .notice-content {
  652. padding: 20rpx;
  653. font-size: 28rpx;
  654. color: #555;
  655. line-height: 1.6;
  656. }
  657. .article-content >>> .notice-content::before {
  658. content: '[注意事项]';
  659. display: block;
  660. font-weight: bold;
  661. color: #5C8D2A;
  662. margin-bottom: 10rpx;
  663. }
  664. /* 旧的样式保留兼容性 */
  665. .article-content >>> blockquote {
  666. background-color: #F8F9E5;
  667. border-left: 10rpx solid #8BC34A;
  668. padding: 20rpx;
  669. margin: 20rpx 0;
  670. border-radius: 6rpx;
  671. }
  672. /* 绿色背景区域 */
  673. .article-content >>> .green-block {
  674. background-color: #4CAF50;
  675. color: white;
  676. padding: 30rpx;
  677. text-align: center;
  678. font-size: 32rpx;
  679. font-weight: bold;
  680. margin: 20rpx 0;
  681. border-radius: 6rpx;
  682. }
  683. /* 文章内容图片容器 */
  684. .article-content >>> .content-image-wrapper {
  685. margin: 20rpx 0 30rpx;
  686. width: 100%;
  687. }
  688. .article-content >>> .content-image {
  689. background-color: #8BC34A;
  690. height: 200rpx;
  691. display: flex;
  692. align-items: center;
  693. justify-content: center;
  694. color: white;
  695. border-radius: 6rpx;
  696. position: relative;
  697. overflow: hidden;
  698. }
  699. .article-content >>> .content-image::before {
  700. content: '';
  701. position: absolute;
  702. top: 0;
  703. left: 0;
  704. right: 0;
  705. bottom: 0;
  706. 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);
  707. background-size: 50px 50px;
  708. opacity: 0.2;
  709. }
  710. .article-content >>> .image-text {
  711. font-size: 36rpx;
  712. font-weight: bold;
  713. text-shadow: 0 2px 4px rgba(0,0,0,0.3);
  714. z-index: 2;
  715. }
  716. /* 真实图片样式 */
  717. .article-content >>> .content-image-real {
  718. height: 200rpx;
  719. background-size: cover;
  720. background-position: center;
  721. border-radius: 6rpx;
  722. position: relative;
  723. overflow: hidden;
  724. }
  725. .article-content >>> .image-text-overlay {
  726. position: absolute;
  727. top: 0;
  728. left: 0;
  729. right: 0;
  730. bottom: 0;
  731. background: linear-gradient(to bottom, rgba(0,0,0,0), rgba(0,0,0,0.6));
  732. display: flex;
  733. align-items: center;
  734. justify-content: center;
  735. }
  736. /* 确保内容不超出容器 */
  737. .article-content >>> img {
  738. max-width: 100%;
  739. height: auto;
  740. }
  741. /* 视频容器 */
  742. .video-container {
  743. margin: 0 30rpx 40rpx;
  744. border-radius: 0;
  745. overflow: hidden;
  746. background-color: #fff;
  747. }
  748. .video-player {
  749. width: 100%;
  750. height: 420rpx;
  751. }
  752. .video-poster {
  753. position: relative;
  754. width: 100%;
  755. height: 380rpx;
  756. }
  757. .video-color-bg {
  758. position: absolute;
  759. top: 0;
  760. left: 0;
  761. right: 0;
  762. bottom: 0;
  763. display: flex;
  764. align-items: center;
  765. justify-content: center;
  766. border-radius: 0;
  767. }
  768. .video-pattern {
  769. position: absolute;
  770. top: 0;
  771. left: 0;
  772. right: 0;
  773. bottom: 0;
  774. opacity: 0.1;
  775. background-image:
  776. linear-gradient(45deg, rgba(255,255,255,0.15) 25%, transparent 25%, transparent 50%,
  777. rgba(255,255,255,0.15) 50%, rgba(255,255,255,0.15) 75%, transparent 75%, transparent);
  778. background-size: 50px 50px;
  779. }
  780. .video-label {
  781. color: white;
  782. font-size: 32rpx;
  783. font-weight: bold;
  784. text-shadow: 0 2px 4px rgba(0,0,0,0.5);
  785. z-index: 5;
  786. }
  787. .play-button {
  788. position: absolute;
  789. top: 50%;
  790. left: 50%;
  791. transform: translate(-50%, -50%);
  792. width: 120rpx;
  793. height: 120rpx;
  794. background-color: rgba(0, 0, 0, 0.6);
  795. border-radius: 50%;
  796. display: flex;
  797. align-items: center;
  798. justify-content: center;
  799. z-index: 10;
  800. box-shadow: 0 0 20rpx rgba(0, 0, 0, 0.3);
  801. border: 4rpx solid rgba(255, 255, 255, 0.8);
  802. }
  803. .triangle-play {
  804. width: 0;
  805. height: 0;
  806. border-top: 26rpx solid transparent;
  807. border-bottom: 26rpx solid transparent;
  808. border-left: 40rpx solid #fff;
  809. margin-left: 10rpx;
  810. }
  811. .video-duration {
  812. position: absolute;
  813. bottom: 20rpx;
  814. right: 20rpx;
  815. padding: 6rpx 12rpx;
  816. background-color: rgba(0, 0, 0, 0.6);
  817. color: #fff;
  818. font-size: 22rpx;
  819. border-radius: 4rpx;
  820. }
  821. .video-title {
  822. font-size: 28rpx;
  823. font-weight: bold;
  824. color: #333;
  825. padding: 20rpx;
  826. display: block;
  827. }
  828. /* 底部功能区 */
  829. .footer-action {
  830. position: fixed;
  831. bottom: 0;
  832. left: 0;
  833. right: 0;
  834. height: 100rpx;
  835. background-color: #fff;
  836. display: flex;
  837. align-items: center;
  838. justify-content: space-around;
  839. box-shadow: 0 -2rpx 10rpx rgba(0, 0, 0, 0.05);
  840. z-index: 99;
  841. }
  842. .action-button {
  843. display: flex;
  844. flex-direction: column;
  845. align-items: center;
  846. padding: 10rpx 0;
  847. }
  848. .action-icon-wrapper {
  849. display: flex;
  850. align-items: center;
  851. justify-content: center;
  852. margin-bottom: 6rpx;
  853. }
  854. .action-text {
  855. font-size: 24rpx;
  856. color: #4CAF50;
  857. font-weight: 500;
  858. }
  859. .action-button:active {
  860. opacity: 0.7;
  861. }
  862. /* 返回顶部按钮 */
  863. .back-to-top {
  864. position: fixed;
  865. right: 30rpx;
  866. bottom: 120rpx;
  867. width: 100rpx;
  868. height: 100rpx;
  869. background-color: rgba(46, 125, 50, 0.9);
  870. border-radius: 50%;
  871. display: flex;
  872. flex-direction: column;
  873. align-items: center;
  874. justify-content: center;
  875. z-index: 99;
  876. }
  877. .top-arrow {
  878. width: 20rpx;
  879. height: 20rpx;
  880. border-top: 4rpx solid #fff;
  881. border-left: 4rpx solid #fff;
  882. transform: rotate(45deg);
  883. margin-bottom: 6rpx;
  884. }
  885. .top-text {
  886. color: #fff;
  887. font-size: 22rpx;
  888. }
  889. .swiper-counter {
  890. position: absolute;
  891. top: 30rpx;
  892. right: 30rpx;
  893. padding: 6rpx 12rpx;
  894. background-color: rgba(0, 0, 0, 0.5);
  895. color: #fff;
  896. font-size: 22rpx;
  897. border-radius: 20rpx;
  898. z-index: 10;
  899. }
  900. .pattern-overlay {
  901. position: absolute;
  902. top: 0;
  903. left: 0;
  904. right: 0;
  905. bottom: 0;
  906. opacity: 0.1;
  907. background-image:
  908. linear-gradient(45deg, rgba(255,255,255,0.15) 25%, transparent 25%, transparent 50%,
  909. rgba(255,255,255,0.15) 50%, rgba(255,255,255,0.15) 75%, transparent 75%, transparent);
  910. background-size: 50px 50px;
  911. }
  912. .agri-icon {
  913. position: absolute;
  914. top: 40%;
  915. left: 50%;
  916. transform: translate(-50%, -50%);
  917. opacity: 0.8;
  918. width: 120rpx;
  919. height: 120rpx;
  920. z-index: 5;
  921. }
  922. .agri-icon svg {
  923. width: 100%;
  924. height: 100%;
  925. stroke-width: 1.5;
  926. }
  927. .section-image {
  928. margin: 20rpx 0;
  929. width: 100%;
  930. }
  931. .color-image {
  932. width: 100%;
  933. height: 300rpx;
  934. border-radius: 0;
  935. display: flex;
  936. align-items: center;
  937. justify-content: center;
  938. position: relative;
  939. overflow: hidden;
  940. }
  941. .color-image::before {
  942. content: "";
  943. position: absolute;
  944. top: 0;
  945. left: 0;
  946. right: 0;
  947. bottom: 0;
  948. background-image:
  949. linear-gradient(45deg, rgba(255,255,255,0.15) 25%, transparent 25%, transparent 50%,
  950. rgba(255,255,255,0.15) 50%, rgba(255,255,255,0.15) 75%, transparent 75%, transparent);
  951. background-size: 50px 50px;
  952. opacity: 0.2;
  953. }
  954. .image-label {
  955. color: white;
  956. font-size: 32rpx;
  957. font-weight: bold;
  958. text-shadow: 0 2px 4px rgba(0,0,0,0.5);
  959. z-index: 5;
  960. }
  961. /* 删除浮动返回按钮样式 */
  962. .float-back-button, .float-back-icon {
  963. display: none;
  964. }
  965. /* H5导航栏样式 */
  966. .h5-custom-navbar {
  967. position: fixed;
  968. top: 0;
  969. left: 0;
  970. right: 0;
  971. height: 90rpx;
  972. background-color: #fff;
  973. display: flex;
  974. align-items: center;
  975. padding: 0 30rpx;
  976. z-index: 100;
  977. box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.05);
  978. }
  979. .h5-navbar-left {
  980. width: 80rpx;
  981. height: 80rpx;
  982. display: flex;
  983. align-items: center;
  984. justify-content: center;
  985. }
  986. .h5-back-icon {
  987. font-size: 40rpx;
  988. color: #333;
  989. display: flex;
  990. align-items: center;
  991. justify-content: center;
  992. }
  993. .h5-navbar-title {
  994. flex: 1;
  995. text-align: center;
  996. font-size: 32rpx;
  997. font-weight: bold;
  998. color: #333;
  999. }
  1000. .h5-navbar-right {
  1001. width: 60rpx;
  1002. }
  1003. .h5-arrow-left {
  1004. width: 24rpx;
  1005. height: 24rpx;
  1006. border-top: 4rpx solid #333;
  1007. border-left: 4rpx solid #333;
  1008. transform: rotate(-45deg);
  1009. }
  1010. </style>