index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400
  1. <template>
  2. <div class="home-index" :style="{ height: `calc(100vh - ${tabBarHeight}px)` }">
  3. <!-- <div class="banner-wrap" @click="handleBannerClick">
  4. <img class="banner-img" :src="bannerObj?.media?.[0]" alt="" />
  5. <div class="banner-title">
  6. <span class="van-multi-ellipsis--l2">{{ bannerObj?.title }}</span>
  7. </div>
  8. </div> -->
  9. <!-- 天气遮罩 -->
  10. <div class="weather-mask" v-show="isExpanded" @click="handleMaskClick"></div>
  11. <!-- 天气 -->
  12. <weather-info
  13. ref="weatherInfoRef"
  14. class="weather-info"
  15. @weatherExpanded="weatherExpanded"
  16. :isGarden="false"
  17. @changeGarden="changeGarden"
  18. ></weather-info>
  19. <div class="expert-home">
  20. <div class="expert-banner" @click="handleExpertBannerClick">
  21. <img class="expert-banner-img" src="@/assets/img/home/banner.png" alt="">
  22. <div class="expert-desc">
  23. <img class="expert-desc-icon" src="@/assets/img/home/expert-text.png" alt="">
  24. <div class="desc-text"><span class="dotted"></span>您有一条长势报告,请查看</div>
  25. </div>
  26. </div>
  27. </div>
  28. <knowledge-card />
  29. <!-- <template v-if="userType == 2">
  30. </template> -->
  31. <!-- <template v-else>
  32. <AgriculturalDynamics />
  33. </template> -->
  34. </div>
  35. <tip-popup
  36. v-model:show="showTipPopup"
  37. type="warning"
  38. text="请设置"
  39. highlightText="种植方案"
  40. buttonText="去设置"
  41. @confirm="handleBtn"
  42. :closeOnClickOverlay="false"
  43. :zIndex="9999"
  44. />
  45. <!-- 农事执行弹窗 -->
  46. <agri-execute-popup
  47. v-model:show="showAgriExecutePopup"
  48. :popupData="agriExecuteData"
  49. @later="handleAgriLater"
  50. @executed="handleAgriExecuted"
  51. />
  52. <!-- 提醒时间选择弹窗 -->
  53. <reminder-time-popup
  54. v-model:show="showReminderTimePopup"
  55. @confirm="handleReminderTimeConfirm"
  56. />
  57. <!-- 执行轨迹弹窗 -->
  58. <execute-trace-popup
  59. v-model:show="showExecuteTracePopup"
  60. @later="handleTraceLater"
  61. @confirm="handleTraceConfirm"
  62. />
  63. </template>
  64. <script setup>
  65. import { ref, computed, onActivated, onMounted } from "vue";
  66. import { useStore } from "vuex";
  67. import weatherInfo from "@/components/weatherInfo.vue";
  68. import AgriculturalDynamics from "./components/AgriculturalDynamics.vue";
  69. import { useRouter, useRoute } from "vue-router";
  70. import wx from "weixin-js-sdk";
  71. import tipPopup from "@/components/popup/tipPopup.vue";
  72. import agriExecutePopup from "@/components/popup/agriExecutePopup.vue";
  73. import reminderTimePopup from "@/components/popup/reminderTimePopup.vue";
  74. import executeTracePopup from "@/components/popup/executeTracePopup.vue";
  75. import knowledgeCard from "./components/knowledgeCard.vue";
  76. const store = useStore();
  77. const tabBarHeight = computed(() => store.state.home.tabBarHeight);
  78. const router = useRouter();
  79. const route = useRoute();
  80. const showTipPopup = ref(false);
  81. const handleBtn = () => {
  82. router.push("/plan?pageType=plant&headerTitle=请设置您的种植方案");
  83. };
  84. // 农事执行弹窗相关
  85. const showAgriExecutePopup = ref(false); // 农事执行弹窗
  86. const agriExecuteData = ref({
  87. expertName: "韦帮稳",
  88. title: "梢期杀虫 农事执行",
  89. abnormalText: "由于***异常的出现,由于***异常的出现,由于***异常的出现,由于***异常的出现,",
  90. imageUrl: "",
  91. laterBtn:true,
  92. });
  93. // const agriExecuteData = ref({
  94. // expertName: "韦帮稳",
  95. // title: "农情互动任务采集",
  96. // abnormalText: "现在已处于 花芽分化期 ,上传照片反馈您的荔枝生长近况",
  97. // imageUrl: "",
  98. // executedButtonText:'查看任务',
  99. // });
  100. // 农事执行弹窗相关方法
  101. const handleAgriLater = () => {
  102. console.log("稍后执行");
  103. // 可以在这里添加稍后执行的逻辑
  104. // 关闭当前弹窗
  105. showAgriExecutePopup.value = false;
  106. // 显示提醒时间选择弹窗
  107. showReminderTimePopup.value = true;
  108. };
  109. const handleAgriExecuted = () => {
  110. console.log("我已执行");
  111. // 关闭当前弹窗
  112. showAgriExecutePopup.value = false;
  113. // 显示执行轨迹弹窗
  114. showExecuteTracePopup.value = true;
  115. };
  116. // 提醒时间选择弹窗相关
  117. const showReminderTimePopup = ref(false);
  118. // 确认提醒时间
  119. const handleReminderTimeConfirm = (time) => {
  120. console.log("选择的提醒时间:", time);
  121. // 可以在这里添加提交提醒时间的逻辑
  122. };
  123. // 执行轨迹弹窗相关
  124. const showExecuteTracePopup = ref(false);
  125. // 稍后上传
  126. const handleTraceLater = () => {
  127. console.log("稍后上传");
  128. // 可以在这里添加稍后上传的逻辑
  129. };
  130. // 确认上传
  131. const handleTraceConfirm = () => {
  132. console.log("确认上传");
  133. // 可以在这里添加确认上传的逻辑
  134. };
  135. // 显示农事执行弹窗的方法(可以在需要的地方调用)
  136. const showAgriExecute = (data = {}) => {
  137. agriExecuteData.value = {
  138. expertName: data.expertName || "韦帮稳",
  139. expertAvatar: data.expertAvatar || "",
  140. title: data.title || "梢期杀虫 农事执行",
  141. abnormalText: data.abnormalText || "由于***异常的出现,由于***异常的出现,由于***异常的出现,由于***异常的出现,",
  142. imageUrl: data.imageUrl || "",
  143. showMarker: data.showMarker !== undefined ? data.showMarker : true,
  144. };
  145. showAgriExecutePopup.value = true;
  146. };
  147. //判断是否存在可用方案
  148. async function checkExistsEnabledScheme() {
  149. const { data } = await VE_API.home.existsEnabledScheme({containerId:null});
  150. if(!data && localStorage.getItem("SET_USER_CUR_ROLE") == 2) {
  151. showTipPopup.value = true;
  152. }
  153. }
  154. const gardenId = ref(null);
  155. const isGarden = ref(false);
  156. const changeGarden = ({ id }) => {
  157. gardenId.value = id;
  158. getExpertByFarmId();
  159. };
  160. const expertInfo = ref({});
  161. const getExpertByFarmId = () => {
  162. VE_API.home.getExpertByFarmId({ farmId: gardenId.value }).then(({ data }) => {
  163. expertInfo.value = data || {};
  164. sessionStorage.setItem("expertId", data.appUserId);
  165. });
  166. };
  167. // 监测卡片数据
  168. const monitorCards = ref({
  169. left: {
  170. title: "农情采集",
  171. content: "精准监测 科学决策",
  172. route: "/pest",
  173. },
  174. right: [
  175. {
  176. title: "病虫识别",
  177. content: "智能识别 快速诊断",
  178. route: "/pest",
  179. },
  180. // {
  181. // title: "新增客户",
  182. // content: "农情先知 高效管理",
  183. // route: "/create_farm?type=client&isReload=true&from=home",
  184. // },
  185. ],
  186. });
  187. // 卡片点击事件
  188. const handleCardClick = (card) => {
  189. const dropdownGardenItem = ref({
  190. organId: 766,
  191. periodId: 1,
  192. name: "荔博园",
  193. });
  194. if (card.title === "农情采集") {
  195. dropdownGardenItem.value.page = "create_farm";
  196. wx.miniProgram.navigateTo({
  197. url: `/pages/subPages/new_recognize/index?gardenData=${JSON.stringify(dropdownGardenItem.value)}`,
  198. });
  199. } else if (card.title === "病虫识别") {
  200. dropdownGardenItem.value.page = "album_recognize";
  201. wx.miniProgram.navigateTo({
  202. url: `/pages/subPages/new_recognize/index?gardenData=${JSON.stringify(dropdownGardenItem.value)}`,
  203. });
  204. } else {
  205. router.push(card.route);
  206. }
  207. };
  208. onActivated(() => {
  209. getManagerList();
  210. if (userType.value != 2) {
  211. checkExistsEnabledScheme()
  212. }
  213. getBannerList();
  214. // 检测是否从创建农场页面成功返回
  215. if (route.query.showSuccess === "true") {
  216. // 清除URL参数,避免刷新页面时再次显示弹窗
  217. router.replace({
  218. path: "/home",
  219. query: { reload: route.query.reload },
  220. });
  221. }
  222. });
  223. const userType = ref(localStorage.getItem("USER_TYPE"));
  224. onMounted(() => {
  225. if (userType.value != 2) {
  226. monitorCards.value.right.push({
  227. title: "新增客户",
  228. content: "农情先知 高效管理",
  229. route: "/create_farm?type=client&isReload=true&from=home",
  230. });
  231. }
  232. });
  233. // 查询当前农资店的成员列表(只保留有"任务接单"权限的成员)
  234. const getManagerList = async () => {
  235. const { data } = await VE_API.mine.listManagerList({ onlyExecutor: true });
  236. if (data && data.length > 0) {
  237. // 过滤 permissionList 中包含"任务接单"的成员,并过滤掉超管(role为1)
  238. const executorList = data.filter((item) => item.role !== 1);
  239. sessionStorage.setItem("executorList", JSON.stringify(executorList));
  240. }
  241. };
  242. const bannerObj = ref({});
  243. const getBannerList = () => {
  244. const params = {
  245. page: 1,
  246. limit: 1,
  247. topicId: 5,
  248. };
  249. VE_API.home.warningPageList(params).then(({ data }) => {
  250. bannerObj.value = data[0] || {};
  251. });
  252. };
  253. const isExpanded = ref(false);
  254. const weatherInfoRef = ref(null);
  255. const weatherExpanded = (isExpandedValue) => {
  256. isExpanded.value = isExpandedValue;
  257. };
  258. // 点击遮罩时收起天气
  259. const handleMaskClick = () => {
  260. if (weatherInfoRef.value && weatherInfoRef.value.toggleExpand) {
  261. weatherInfoRef.value.toggleExpand();
  262. }
  263. };
  264. const handleExpertBannerClick = () => {
  265. router.push("/consult?userId=81881");
  266. };
  267. const handleBannerClick = () => {
  268. router.push(`/warning_detail?id=${bannerObj.value.id}`);
  269. };
  270. </script>
  271. <style scoped lang="scss">
  272. .home-index {
  273. width: 100%;
  274. height: 100vh;
  275. overflow: auto;
  276. position: relative;
  277. // background: linear-gradient(180deg, #f4f9fd 0%, #f9f9f9 100%);
  278. background: linear-gradient(180deg, #F9F9F9 0%, #F0F8FF 31.47%, #F9F9F9 46.81%, #F9F9F9 100%);
  279. .banner-wrap {
  280. width: 100%;
  281. height: 200px;
  282. position: relative;
  283. z-index: 1;
  284. .banner-img {
  285. width: 100%;
  286. height: 100%;
  287. object-fit: cover;
  288. }
  289. .banner-title {
  290. position: absolute;
  291. bottom: 0;
  292. left: 0;
  293. width: 100%;
  294. padding: 10px 12px 34px 12px;
  295. box-sizing: border-box;
  296. background: linear-gradient(
  297. 180deg,
  298. rgba(102, 102, 102, 0) -64.3%,
  299. rgba(0, 0, 0, 0.0074) -1.43%,
  300. rgba(0, 0, 0, 0.684747) 39.67%,
  301. rgba(0, 0, 0, 0.74) 40.09%,
  302. rgba(0, 0, 0, 0.74) 83.2%
  303. );
  304. color: #fff;
  305. font-weight: bold;
  306. backdrop-filter: blur(2px);
  307. }
  308. }
  309. .weather-mask {
  310. position: fixed;
  311. top: 0;
  312. left: 0;
  313. width: 100%;
  314. height: 100%;
  315. background-color: rgba(0, 0, 0, 0.52);
  316. z-index: 2;
  317. }
  318. .weather-info {
  319. width: calc(100% - 20px);
  320. position: absolute;
  321. // top: calc(200px - 28px);
  322. top: 8px;
  323. left: 10px;
  324. z-index: 3;
  325. }
  326. .expert-home {
  327. padding: 90px 10px 10px 10px;
  328. .expert-banner {
  329. position: relative;
  330. .expert-banner-img {
  331. width: 100%;
  332. }
  333. .expert-desc {
  334. position: absolute;
  335. bottom: 0;
  336. left: 0;
  337. width: 100%;
  338. border-radius: 0 0 8px 8px;
  339. padding: 6px 8px;
  340. box-sizing: border-box;
  341. background: rgba(0, 0, 0, 0.5);
  342. color: #fff;
  343. backdrop-filter: blur(4px);
  344. display: flex;
  345. align-items: center;
  346. justify-content: space-between;
  347. .expert-desc-icon {
  348. width: 91px;
  349. }
  350. .desc-text {
  351. font-family: "PangMenZhengDao";
  352. font-size: 14px;
  353. color: #fff;
  354. display: flex;
  355. align-items: center;
  356. justify-content: center;
  357. gap: 6px;
  358. .dotted {
  359. width: 5px;
  360. height: 5px;
  361. background: #fff;
  362. border-radius: 50%;
  363. }
  364. }
  365. }
  366. }
  367. }
  368. }
  369. </style>