index.js 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. "use strict";
  2. const common_vendor = require("../../common/vendor.js");
  3. const common_assets = require("../../common/assets.js");
  4. const _sfc_main = {
  5. __name: "index",
  6. setup(__props) {
  7. const currentTab = common_vendor.ref(0);
  8. const techList = common_vendor.ref([
  9. {
  10. id: 1,
  11. title: "水稻高产栽培技术指南",
  12. description: "详解水稻种植关键技术要点,包括育苗、插秧、水肥管理等全过程技术要领",
  13. viewCount: "289",
  14. image: "https://img.freepik.com/free-photo/rice-field-with-beautiful-sky_74190-7490.jpg",
  15. type: "农技",
  16. contentType: "article",
  17. // 标记为文章类型
  18. source: "农业技术研究院"
  19. },
  20. {
  21. id: 2,
  22. title: "果树病虫害防治方案视频教学",
  23. description: "常见果树病虫害的识别方法、防治时期、用药指导,助您果园增产增收",
  24. viewCount: "856",
  25. image: "https://img.freepik.com/free-photo/apple-tree-with-ripe-red-apples_1150-9301.jpg",
  26. type: "农技",
  27. contentType: "video",
  28. // 标记为视频类型
  29. duration: "15:32",
  30. source: "中国农业科技"
  31. },
  32. {
  33. id: 3,
  34. title: "科学施肥技术指南",
  35. description: "解析不同作物的施肥特点,平衡施肥技术,提高肥料利用率",
  36. viewCount: "667",
  37. image: "https://img.freepik.com/free-photo/farmer-holding-chemical-fertilizer-field_1150-7167.jpg",
  38. type: "农技",
  39. contentType: "article",
  40. // 标记为文章类型
  41. source: "农业知识库"
  42. }
  43. ]);
  44. const policyList = common_vendor.ref([
  45. {
  46. id: 1,
  47. title: "2024年农业补贴政策要点解读",
  48. description: "最新农业补贴政策要点解读,包括种粮补贴、农机补贴等各项补贴申请指南",
  49. viewCount: "2,341",
  50. date: "05-23",
  51. image: "https://img.freepik.com/free-photo/modern-agricultural-machinery-field_1157-46386.jpg",
  52. type: "政策",
  53. contentType: "article",
  54. // 标记为文章类型
  55. source: "农业部官方"
  56. },
  57. {
  58. id: 2,
  59. title: "农业保险政策专家解析视频",
  60. description: "农业保险覆盖范围扩大,新增多项保障内容,理赔流程优化",
  61. viewCount: "1,856",
  62. date: "05-22",
  63. image: "https://img.freepik.com/free-photo/farmer-working-field_1157-46384.jpg",
  64. type: "政策",
  65. contentType: "video",
  66. // 标记为视频类型
  67. duration: "28:45",
  68. source: "农业部政策宣讲"
  69. },
  70. {
  71. id: 3,
  72. title: "绿色种植认证办理指南",
  73. description: "绿色种植认证最新申请流程及注意事项说明",
  74. viewCount: "1,667",
  75. date: "05-21",
  76. image: "https://img.freepik.com/free-photo/organic-farm-harvest_1157-46078.jpg",
  77. type: "政策",
  78. contentType: "article",
  79. // 标记为文章类型
  80. source: "农业部认证中心"
  81. }
  82. ]);
  83. const isRefreshing = common_vendor.ref(false);
  84. const handleTabChange = (index) => {
  85. currentTab.value = index;
  86. common_vendor.index.__f__("log", "at pages/knowledge/index.vue:222", "Tab changed to:", index);
  87. };
  88. const onRefresh = async () => {
  89. isRefreshing.value = true;
  90. try {
  91. await new Promise((resolve) => setTimeout(resolve, 1e3));
  92. if (currentTab.value === 0) {
  93. common_vendor.index.__f__("log", "at pages/knowledge/index.vue:233", "刷新农技知识数据");
  94. } else {
  95. common_vendor.index.__f__("log", "at pages/knowledge/index.vue:236", "刷新政策解读数据");
  96. }
  97. } finally {
  98. isRefreshing.value = false;
  99. }
  100. };
  101. const loadMore = () => {
  102. common_vendor.index.__f__("log", "at pages/knowledge/index.vue:245", "Loading more content");
  103. if (currentTab.value === 0) {
  104. common_vendor.index.__f__("log", "at pages/knowledge/index.vue:249", "加载更多农技知识数据");
  105. } else {
  106. common_vendor.index.__f__("log", "at pages/knowledge/index.vue:252", "加载更多政策解读数据");
  107. }
  108. };
  109. const navigateToAI = () => {
  110. common_vendor.index.navigateTo({
  111. url: "/pages/ai-chat/index"
  112. });
  113. };
  114. common_vendor.onMounted(() => {
  115. common_vendor.index.__f__("log", "at pages/knowledge/index.vue:264", "Page mounted, current tab:", currentTab.value);
  116. });
  117. return (_ctx, _cache) => {
  118. return common_vendor.e({
  119. a: currentTab.value === 0 ? 1 : "",
  120. b: currentTab.value === 0 ? 1 : "",
  121. c: common_vendor.o(($event) => handleTabChange(0)),
  122. d: currentTab.value === 1 ? 1 : "",
  123. e: currentTab.value === 1 ? 1 : "",
  124. f: common_vendor.o(($event) => handleTabChange(1)),
  125. g: currentTab.value === 0
  126. }, currentTab.value === 0 ? {
  127. h: common_vendor.f(techList.value, (item, index, i0) => {
  128. return common_vendor.e({
  129. a: item.image,
  130. b: item.contentType === "video"
  131. }, item.contentType === "video" ? {
  132. c: common_vendor.t(item.duration || "35:56")
  133. } : {}, {
  134. d: common_vendor.t(item.title),
  135. e: common_vendor.t(item.source || "中国农业科技"),
  136. f: common_vendor.t(item.viewCount),
  137. g: index,
  138. h: `/pages/knowledge/detail?id=${item.id}&type=tech`
  139. });
  140. })
  141. } : {}, {
  142. i: currentTab.value === 1
  143. }, currentTab.value === 1 ? {
  144. j: common_vendor.f(policyList.value, (item, index, i0) => {
  145. return common_vendor.e({
  146. a: item.image,
  147. b: item.contentType === "video"
  148. }, item.contentType === "video" ? {
  149. c: common_vendor.t(item.duration || "28:32")
  150. } : {}, {
  151. d: common_vendor.t(item.title),
  152. e: common_vendor.t(item.source || "农业部官方"),
  153. f: common_vendor.t(item.viewCount),
  154. g: index,
  155. h: `/pages/knowledge/detail?id=${item.id}&type=policy`
  156. });
  157. })
  158. } : {}, {
  159. k: currentTab.value === 0 && techList.value.length === 0 || currentTab.value === 1 && policyList.value.length === 0
  160. }, currentTab.value === 0 && techList.value.length === 0 || currentTab.value === 1 && policyList.value.length === 0 ? {
  161. l: common_assets._imports_0$1
  162. } : {}, {
  163. m: common_vendor.o(loadMore),
  164. n: common_vendor.o(onRefresh),
  165. o: isRefreshing.value,
  166. p: common_assets._imports_0,
  167. q: common_vendor.o(navigateToAI)
  168. });
  169. };
  170. }
  171. };
  172. const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-502b983e"]]);
  173. wx.createPage(MiniProgramPage);
  174. //# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/knowledge/index.js.map