restorePlantingPopup.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433
  1. <template>
  2. <popup
  3. v-model:show="showValue"
  4. round
  5. teleport="body"
  6. class="restore-planting-popup"
  7. :close-on-click-overlay="true"
  8. >
  9. <div class="popup-content">
  10. <img
  11. class="restore-planting-popup__decor"
  12. src="@/assets/img/agricultural/question.png"
  13. alt=""
  14. />
  15. <div class="restore-planting-popup__header">
  16. <div class="restore-planting-popup__title">
  17. <div>{{ t("agriFile.restoreFillQuestions") }}</div>
  18. <div>{{ t("agriFile.restorePlantingService") }}</div>
  19. </div>
  20. </div>
  21. <!-- 问题一:选择时间 -->
  22. <div v-if="questionType === 'time'" class="restore-planting-popup__card">
  23. <div class="restore-planting-popup__question">
  24. <template v-if="highlightWord && questionText.includes(highlightWord)">
  25. <span>{{ questionText.split(highlightWord)[0] }}</span>
  26. <span class="restore-planting-popup__keyword">{{ highlightWord }}</span>
  27. <span>{{ questionText.split(highlightWord).slice(1).join(highlightWord) }}</span>
  28. </template>
  29. <template v-else>{{ questionText }}</template>
  30. </div>
  31. <div class="restore-planting-popup__hint">{{ hintText }}</div>
  32. <div class="restore-planting-popup__photo">
  33. <img :src="sampleImage" alt="" />
  34. <!-- <div class="restore-planting-popup__bbox">
  35. <span>{{ stageTag }}</span>
  36. </div>
  37. <div class="restore-planting-popup__detect">{{ detectText }}</div> -->
  38. </div>
  39. <el-date-picker
  40. v-model="selectedDate"
  41. class="restore-planting-popup__date-picker"
  42. type="date"
  43. format="YYYY.MM.DD"
  44. value-format="YYYY.MM.DD"
  45. :placeholder="t('agriFile.selectTime')"
  46. :editable="false"
  47. :clearable="false"
  48. style="width: 100%"
  49. />
  50. </div>
  51. <!-- 问题二:物候期选择 -->
  52. <div v-else class="restore-planting-popup__card">
  53. <div class="restore-planting-popup__question">
  54. <template v-if="phenologyHighlight && phenologyQuestion.includes(phenologyHighlight)">
  55. <span>{{ phenologyQuestion.split(phenologyHighlight)[0] }}</span>
  56. <span class="restore-planting-popup__keyword">{{ phenologyHighlight }}</span>
  57. <span>{{ phenologyQuestion.split(phenologyHighlight).slice(1).join(phenologyHighlight) }}</span>
  58. </template>
  59. <template v-else>{{ phenologyQuestion }}</template>
  60. </div>
  61. <div class="restore-planting-popup__photo restore-planting-popup__photo--guide">
  62. <img :src="phenologyImage" alt="" />
  63. <div class="restore-planting-popup__guide-btn" @click="handleViewGuide">
  64. {{ t("agriFile.viewPatrolGuide") }}
  65. </div>
  66. </div>
  67. <div class="restore-planting-popup__options">
  68. <div
  69. v-for="item in phenologyOptions"
  70. :key="item.value"
  71. class="restore-planting-popup__option"
  72. :class="{ active: phenologyAnswer === item.value }"
  73. @click="phenologyAnswer = item.value"
  74. >
  75. <span>{{ item.label }}</span>
  76. <span v-if="phenologyAnswer === item.value" class="restore-planting-popup__option-check">
  77. <el-icon><Check /></el-icon>
  78. </span>
  79. </div>
  80. </div>
  81. </div>
  82. <div class="restore-planting-popup__actions">
  83. <div class="restore-planting-popup__btn restore-planting-popup__btn--ghost" @click="handleChangeQuestion">
  84. {{ t("agriFile.changeQuestion") }}
  85. </div>
  86. <div class="restore-planting-popup__btn restore-planting-popup__btn--primary" @click="handleConfirm">
  87. {{ questionType === 'time' ? t("agriFile.confirmNow") : t("agriFile.submitInfo") }}
  88. </div>
  89. </div>
  90. </div>
  91. </popup>
  92. </template>
  93. <script setup>
  94. import { computed, ref, watch } from "vue";
  95. import { Popup } from "vant";
  96. import { Check } from "@element-plus/icons-vue";
  97. import { useI18n } from "@/i18n";
  98. const { t } = useI18n();
  99. const props = defineProps({
  100. show: {
  101. type: Boolean,
  102. default: false,
  103. },
  104. questionText: {
  105. type: String,
  106. default: "还记得农场的 “来梢” 的时间吗?",
  107. },
  108. highlightWord: {
  109. type: String,
  110. default: "来梢",
  111. },
  112. hintText: {
  113. type: String,
  114. default: "时间误差 5-7 天无需担心,系统将结合作物生长模拟模型自动校准",
  115. },
  116. sampleImage: {
  117. type: String,
  118. default: require("@/assets/img/agricultural/baidian.png"),
  119. },
  120. stageTag: {
  121. type: String,
  122. default: "白点",
  123. },
  124. detectText: {
  125. type: String,
  126. default: "生育期检测:当前检测到白点期",
  127. },
  128. phenologyQuestion: {
  129. type: String,
  130. default: "您的农场是否进入到 某某物候期 ?",
  131. },
  132. phenologyHighlight: {
  133. type: String,
  134. default: "某某物候期",
  135. },
  136. phenologyImage: {
  137. type: String,
  138. default: require("@/assets/img/common/sd-1.jpg"),
  139. },
  140. });
  141. const emit = defineEmits(["update:show", "changeQuestion", "confirm", "viewGuide"]);
  142. const showValue = computed({
  143. get: () => props.show,
  144. set: (val) => emit("update:show", val),
  145. });
  146. const questionType = ref("time"); // time | phenology
  147. const selectedDate = ref("");
  148. const phenologyAnswer = ref("reached");
  149. const phenologyOptions = computed(() => [
  150. { value: "not_reached", label: t("agriFile.notReached") },
  151. { value: "reached", label: t("agriFile.reached") },
  152. { value: "passed", label: t("agriFile.passed") },
  153. ]);
  154. watch(
  155. () => props.show,
  156. (visible) => {
  157. if (visible) {
  158. questionType.value = "time";
  159. selectedDate.value = "";
  160. phenologyAnswer.value = "reached";
  161. }
  162. }
  163. );
  164. const handleChangeQuestion = () => {
  165. questionType.value = questionType.value === "time" ? "phenology" : "time";
  166. emit("changeQuestion", questionType.value);
  167. };
  168. const handleViewGuide = () => {
  169. emit("viewGuide");
  170. };
  171. const handleConfirm = () => {
  172. emit("confirm", {
  173. type: questionType.value,
  174. date: selectedDate.value,
  175. phenologyAnswer: phenologyAnswer.value,
  176. });
  177. showValue.value = false;
  178. };
  179. </script>
  180. <style scoped lang="scss">
  181. .restore-planting-popup {
  182. width: 86%;
  183. padding: 18px 14px 16px;
  184. box-sizing: border-box;
  185. background: linear-gradient(180deg, #d7ecff 0%, #ffffff 28%);
  186. overflow: visible;
  187. &__header {
  188. // position: relative;
  189. display: flex;
  190. align-items: flex-start;
  191. justify-content: space-between;
  192. // padding-right: 72px;
  193. // min-height: 64px;
  194. }
  195. &__title {
  196. font-size: 22px;
  197. line-height: 25px;
  198. color: #111;
  199. div {
  200. font-family: "PangMenZhengDao";
  201. }
  202. }
  203. .popup-content {
  204. position: relative;
  205. }
  206. &__decor {
  207. position: absolute;
  208. top: -8px;
  209. right: -4px;
  210. width: 78px;
  211. height: 78px;
  212. object-fit: contain;
  213. pointer-events: none;
  214. }
  215. &__card {
  216. margin-top: 12px;
  217. padding: 10px 12px 12px;
  218. border-radius: 12px;
  219. background: #eaf5ff;
  220. box-sizing: border-box;
  221. position: relative;
  222. z-index: 2;
  223. }
  224. &__question {
  225. font-size: 16px;
  226. line-height: 24px;
  227. color: #252525;
  228. font-weight: 500;
  229. }
  230. &__keyword {
  231. color: #2199f8;
  232. }
  233. &__hint {
  234. margin-top: 4px;
  235. font-size: 12px;
  236. line-height: 16px;
  237. color: #9E9E9E;
  238. }
  239. &__photo {
  240. position: relative;
  241. margin: 12px 0;
  242. border-radius: 8px;
  243. overflow: hidden;
  244. background: #dfeaf5;
  245. img {
  246. display: block;
  247. width: 100%;
  248. height: 148px;
  249. object-fit: cover;
  250. }
  251. &--guide img {
  252. height: 132px;
  253. }
  254. }
  255. &__bbox {
  256. position: absolute;
  257. top: 36%;
  258. left: 50%;
  259. width: 72px;
  260. height: 72px;
  261. transform: translate(-50%, -50%);
  262. border: 2px solid #2199f8;
  263. box-sizing: border-box;
  264. pointer-events: none;
  265. span {
  266. position: absolute;
  267. top: -18px;
  268. left: 50%;
  269. transform: translateX(-50%);
  270. padding: 0 4px;
  271. font-size: 12px;
  272. line-height: 16px;
  273. color: #2199f8;
  274. white-space: nowrap;
  275. background: rgba(255, 255, 255, 0.85);
  276. }
  277. }
  278. &__detect {
  279. position: absolute;
  280. left: 0;
  281. right: 0;
  282. bottom: 0;
  283. padding: 8px 10px;
  284. background: rgba(0, 0, 0, 0.55);
  285. color: #fff;
  286. font-size: 12px;
  287. line-height: 18px;
  288. }
  289. &__guide-btn {
  290. position: absolute;
  291. top: 8px;
  292. right: 8px;
  293. height: 28px;
  294. padding: 0 10px;
  295. border-radius: 14px;
  296. background: rgba(0, 0, 0, 0.55);
  297. color: #fff;
  298. font-size: 12px;
  299. display: flex;
  300. align-items: center;
  301. justify-content: center;
  302. }
  303. &__options {
  304. margin-top: 12px;
  305. display: flex;
  306. gap: 8px;
  307. }
  308. &__option {
  309. position: relative;
  310. flex: 1;
  311. height: 36px;
  312. border-radius: 8px;
  313. background: #fff;
  314. border: 1px solid transparent;
  315. display: flex;
  316. align-items: center;
  317. justify-content: center;
  318. font-size: 13px;
  319. color: #333;
  320. box-sizing: border-box;
  321. &.active {
  322. border-color: #2199f8;
  323. color: #2199f8;
  324. }
  325. }
  326. &__option-check {
  327. position: absolute;
  328. top: 0;
  329. right: 0;
  330. width: 16px;
  331. height: 16px;
  332. border-radius: 0 6px 0 6px;
  333. background: #2199f8;
  334. color: #fff;
  335. display: flex;
  336. align-items: center;
  337. justify-content: center;
  338. font-size: 10px;
  339. }
  340. &__date-picker {
  341. width: 100%;
  342. :deep(.el-input__wrapper) {
  343. height: 40px;
  344. border-radius: 8px;
  345. box-shadow: none !important;
  346. background: #fff;
  347. padding: 0 12px;
  348. }
  349. :deep(.el-input__inner) {
  350. font-size: 14px;
  351. color: #333;
  352. }
  353. :deep(.el-input__prefix),
  354. :deep(.el-input__suffix) {
  355. color: rgba(0, 0, 0, 0.35);
  356. }
  357. }
  358. &__actions {
  359. margin-top: 12px;
  360. display: flex;
  361. align-items: center;
  362. justify-content: space-between;
  363. gap: 12px;
  364. }
  365. &__btn {
  366. height: 40px;
  367. line-height: 40px;
  368. padding: 0 30px;
  369. border-radius: 20px;
  370. display: flex;
  371. align-items: center;
  372. justify-content: center;
  373. font-size: 16px;
  374. font-weight: 500;
  375. box-sizing: border-box;
  376. &--ghost {
  377. background: rgba(236, 236, 236, 0.5);
  378. color: rgba(0, 0, 0, 0.6);
  379. }
  380. &--primary {
  381. background: linear-gradient(180deg, #76C3FF 0%, #2199F8 100%);
  382. color: #fff;
  383. }
  384. }
  385. }
  386. </style>