reviewPopup.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669
  1. <template>
  2. <popup class="price-sheet-popup" v-model:show="showPopup">
  3. <div class="price-sheet-content">
  4. <div class="price-sheet-content-inner">
  5. <div class="sheet-content">
  6. <div class="review-image">
  7. <div class="vs-wrap" v-if="preImg">
  8. <img src="@/assets/img/home/vs.png" alt="" />
  9. </div>
  10. <div class="review-image-item" v-if="preImg">
  11. <div class="review-image-item-title">农事前</div>
  12. <img class="review-image-item-img" :src="preImg" alt="" />
  13. </div>
  14. <div class="review-image-item" v-if="resImg">
  15. <div class="review-image-item-title">农事后</div>
  16. <img class="review-image-item-img" :src="resImg" alt="" />
  17. </div>
  18. </div>
  19. <!-- 报价详情区域 -->
  20. <div class="quotation-info">
  21. <div class="info-item">
  22. <span class="info-label">执行农资</span>
  23. <span class="info-value">{{ quotationData.serviceMain || "--" }}</span>
  24. </div>
  25. <div class="info-item">
  26. <span class="info-label">农事名称</span>
  27. <span class="info-value">{{ quotationData?.farmWorkName || "--" }}</span>
  28. </div>
  29. <div class="info-item flex-wrap">
  30. <div class="info-label">复核成效</div>
  31. <div class="info-value">
  32. 促进分蘖芽萌发、加快分蘖生长,同时补充氮素等关键养分,增强植株长势,为形成足够穗数、提高群体产量打基础。
  33. </div>
  34. </div>
  35. </div>
  36. <div class="bottom-info">
  37. <div class="bottom-l">
  38. <div class="l-img">
  39. <img src="@/assets/img/home/bird.png" alt="" />
  40. </div>
  41. <div class="l-text">
  42. <div class="l-text-title">飞鸟管家</div>
  43. <div class="l-text-time">扫描二维码,查看更多详情</div>
  44. </div>
  45. </div>
  46. <div class="bottom-r">
  47. <img src="@/assets/img/home/qrcode.png" alt="" />
  48. </div>
  49. </div>
  50. </div>
  51. </div>
  52. <!-- 底部操作按钮 -->
  53. <div class="bottom-actions" @click.stop="showPopup = false">
  54. <div class="action-buttons">
  55. <div class="action-btn blue-btn" @click.stop="handleShare">
  56. <div class="icon-circle">
  57. <img src="@/assets/img/home/bird.png" alt="" />
  58. </div>
  59. <span class="btn-label">飞鸟用户</span>
  60. </div>
  61. <div class="action-btn green-btn" @click.stop="handleWechat">
  62. <div class="icon-circle">
  63. <img src="@/assets/img/home/wechat.png" alt="" />
  64. </div>
  65. <span class="btn-label">微信</span>
  66. </div>
  67. <div class="action-btn orange-btn">
  68. <div class="icon-circle">
  69. <el-icon :size="24"><Download /></el-icon>
  70. </div>
  71. <span class="btn-label">保存图片</span>
  72. </div>
  73. </div>
  74. <div class="cancel-btn" @click="handleCancel">取消</div>
  75. </div>
  76. </div>
  77. </popup>
  78. </template>
  79. <script setup>
  80. import { Popup } from "vant";
  81. import { ref, computed, onActivated } from "vue";
  82. import { useRouter } from "vue-router";
  83. import { ElMessage } from "element-plus";
  84. import wx from "weixin-js-sdk";
  85. import html2canvas from "html2canvas";
  86. const router = useRouter();
  87. const showPopup = ref(false);
  88. const contentEl = ref(null);
  89. const preImg = ref("");
  90. const resImg = ref("");
  91. // 报价数据
  92. const quotationData = ref({});
  93. onActivated(() => {});
  94. const recordId = ref("");
  95. const handleShowPopup = async (id, preImgVal, resImgVal) => {
  96. recordId.value = id;
  97. await getDetail();
  98. preImg.value = preImgVal;
  99. resImg.value = resImgVal;
  100. showPopup.value = true;
  101. };
  102. async function getDetail() {
  103. const { data } = await VE_API.z_farm_work_record.getDetail({ id: recordId.value });
  104. quotationData.value = data[0];
  105. }
  106. const handleShare = () => {
  107. const userId = quotationData.value.users[0]?.userId;
  108. const parmasPage = {
  109. farmWorkOrderId: quotationData.value.orderId,
  110. farmMiniUserId: userId,
  111. farmMiniUserName: quotationData.value.expertUserName,
  112. farmId: quotationData.value.farmId,
  113. farmWorkName: quotationData.value.farmWorkName,
  114. id: quotationData.value.id,
  115. type: "quotation",
  116. };
  117. if (userId) {
  118. router.push(
  119. `/chat_frame?userId=${userId}&name=${parmasPage.farmMiniUserName}&farmId=${
  120. parmasPage.farmId
  121. }&pageParams=${JSON.stringify(parmasPage)}`
  122. );
  123. } else {
  124. ElMessage.warning("尚未绑定用户,暂时无法分享");
  125. }
  126. };
  127. const handleWechat = () => {
  128. console.log("handleWechat");
  129. // router.push({
  130. // path: "/completed_work",
  131. // query: { id: quotationData.value.id, farmWorkOrderId: quotationData.value.orderId, isAssign: true },
  132. // });
  133. const query = {
  134. askInfo: { title: "农事执行成果", content: "是否分享该农事执行成果给好友" },
  135. shareText: "向您分享了农事执行成果",
  136. id: recordId.value,
  137. postImg: resImg.value,
  138. };
  139. wx.miniProgram.navigateTo({
  140. url: `/pages/subPages/share_page/index?pageParams=${JSON.stringify(query)}&type=reviewWork`,
  141. });
  142. };
  143. const handleSaveImage = async () => {
  144. try {
  145. if (!contentEl.value) return;
  146. const element = contentEl.value;
  147. const scroller = element.querySelector(".sheet-content");
  148. // 记录原样式
  149. const prev = {
  150. elementOverflow: element.style.overflow,
  151. elementMaxHeight: element.style.maxHeight,
  152. elementHeight: element.style.height,
  153. scrollerOverflow: scroller ? scroller.style.overflow : undefined,
  154. scrollerMaxHeight: scroller ? scroller.style.maxHeight : undefined,
  155. scrollerHeight: scroller ? scroller.style.height : undefined,
  156. };
  157. // 展开内容,去除滚动限制,确保截图包含全部内容
  158. element.style.overflow = "visible";
  159. element.style.maxHeight = "none";
  160. element.style.height = "auto";
  161. if (scroller) {
  162. scroller.style.overflow = "visible";
  163. scroller.style.maxHeight = "none";
  164. scroller.style.height = "auto";
  165. }
  166. // 计算完整尺寸
  167. const width = element.scrollWidth;
  168. const height = element.scrollHeight;
  169. const canvas = await html2canvas(element, {
  170. backgroundColor: "#ffffff",
  171. useCORS: true,
  172. allowTaint: true,
  173. scale: Math.min(2, window.devicePixelRatio || 2),
  174. width,
  175. height,
  176. windowWidth: width,
  177. windowHeight: height,
  178. scrollX: 0,
  179. scrollY: 0,
  180. });
  181. const dataUrl = canvas.toDataURL("image/png");
  182. const link = document.createElement("a");
  183. link.href = dataUrl;
  184. link.download = "服务报价单.png";
  185. document.body.appendChild(link);
  186. link.click();
  187. document.body.removeChild(link);
  188. // 还原样式
  189. element.style.overflow = prev.elementOverflow;
  190. element.style.maxHeight = prev.elementMaxHeight;
  191. element.style.height = prev.elementHeight;
  192. if (scroller) {
  193. scroller.style.overflow = prev.scrollerOverflow;
  194. scroller.style.maxHeight = prev.scrollerMaxHeight;
  195. scroller.style.height = prev.scrollerHeight;
  196. }
  197. } catch (e) {
  198. console.error("保存图片失败", e);
  199. }
  200. };
  201. const handleCancel = () => {
  202. showPopup.value = false;
  203. };
  204. defineExpose({
  205. handleShowPopup,
  206. });
  207. </script>
  208. <style lang="scss" scoped>
  209. .price-sheet-popup {
  210. width: 90%;
  211. max-height: 84vh;
  212. background: none;
  213. border-radius: 12px;
  214. overflow: hidden;
  215. display: flex;
  216. flex-direction: column;
  217. backdrop-filter: 4px;
  218. ::v-deep {
  219. .van-popup__close-icon {
  220. color: #000;
  221. font-size: 18px;
  222. top: 12px;
  223. right: 12px;
  224. }
  225. }
  226. }
  227. .price-sheet-content {
  228. display: flex;
  229. flex-direction: column;
  230. max-height: 84vh;
  231. // height: 95vh;
  232. .price-sheet-content-inner {
  233. background: #fff;
  234. border-radius: 12px;
  235. display: flex;
  236. flex-direction: column;
  237. height: 100%;
  238. overflow: hidden;
  239. }
  240. }
  241. .sheet-content {
  242. padding: 12px 12px 10px 12px;
  243. flex: 1;
  244. overflow-y: auto;
  245. overflow-x: hidden;
  246. position: relative;
  247. }
  248. .bottom-info {
  249. padding: 16px 16px 16px 16px;
  250. border-top: 1px dotted rgba(0, 0, 0, 0.3);
  251. display: flex;
  252. align-items: center;
  253. justify-content: space-between;
  254. .bottom-l {
  255. display: flex;
  256. align-items: center;
  257. gap: 8px;
  258. .l-img {
  259. img {
  260. width: 40px;
  261. }
  262. }
  263. .l-text-time {
  264. font-size: 12px;
  265. }
  266. }
  267. .bottom-r {
  268. width: 40px;
  269. height: 40px;
  270. img {
  271. width: 100%;
  272. height: 100%;
  273. object-fit: cover;
  274. }
  275. }
  276. }
  277. .review-image {
  278. position: relative;
  279. display: flex;
  280. align-items: center;
  281. justify-content: center;
  282. gap: 8px;
  283. .vs-wrap {
  284. position: absolute;
  285. left: 50%;
  286. top: 50%;
  287. transform: translate(-50%, -50%);
  288. width: 40px;
  289. height: 40px;
  290. z-index: 10;
  291. img {
  292. width: 100%;
  293. height: 100%;
  294. object-fit: cover;
  295. }
  296. }
  297. .review-image-item {
  298. position: relative;
  299. flex: 1;
  300. .review-image-item-title {
  301. position: absolute;
  302. top: 0;
  303. left: 0;
  304. background: rgba(54, 52, 52, 0.6);
  305. padding: 4px 10px;
  306. border-radius: 8px 0 8px 0;
  307. backdrop-filter: 4px;
  308. font-size: 12px;
  309. color: #fff;
  310. }
  311. .review-image-item-img {
  312. width: 100%;
  313. height: 250px;
  314. object-fit: cover;
  315. }
  316. }
  317. }
  318. // 报价详情区域
  319. .quotation-info {
  320. margin-top: 12px;
  321. .flex-wrap {
  322. display: flex;
  323. .info-label {
  324. flex: none;
  325. }
  326. }
  327. .info-item {
  328. font-size: 14px;
  329. color: #000;
  330. margin-bottom: 8px;
  331. .info-label {
  332. padding-right: 8px;
  333. color: rgba(0, 0, 0, 0.5);
  334. }
  335. .info-value {
  336. color: #000;
  337. }
  338. &.catalog-label {
  339. font-weight: bold;
  340. margin-top: 10px;
  341. margin-bottom: 10px;
  342. position: relative;
  343. .info-label {
  344. color: #000;
  345. }
  346. }
  347. }
  348. .total-bar {
  349. display: flex;
  350. align-items: center;
  351. justify-content: center;
  352. background: rgba(33, 153, 248, 0.1);
  353. border: 1px solid rgba(33, 153, 248, 0.5);
  354. height: 38px;
  355. border-radius: 4px;
  356. .total-label {
  357. font-size: 14px;
  358. color: #000000;
  359. }
  360. .total-value {
  361. font-size: 22px;
  362. font-weight: bold;
  363. color: #2199f8;
  364. }
  365. .total-unit {
  366. font-size: 14px;
  367. color: #000;
  368. margin-left: 4px;
  369. }
  370. }
  371. }
  372. // 肥药费用区域
  373. .fertilizer-cost-section {
  374. margin-bottom: 10px;
  375. .section-header {
  376. display: flex;
  377. justify-content: space-between;
  378. align-items: center;
  379. margin-bottom: 8px;
  380. .section-title {
  381. font-size: 14px;
  382. color: #000;
  383. }
  384. .section-total {
  385. font-size: 16px;
  386. font-weight: bold;
  387. color: #000;
  388. .unit-text {
  389. padding-left: 2px;
  390. font-size: 12px;
  391. font-weight: normal;
  392. }
  393. }
  394. }
  395. .cost-table {
  396. border: 1px solid rgba(225, 225, 225, 0.5);
  397. border-radius: 5px;
  398. overflow: hidden;
  399. .table-header {
  400. display: flex;
  401. background: rgba(241, 241, 241, 0.4);
  402. padding: 8px 6px;
  403. font-size: 12px;
  404. color: #767676;
  405. border-bottom: 1px solid rgba(225, 225, 225, 0.5);
  406. .col-1 {
  407. width: 40px;
  408. text-align: center;
  409. }
  410. .col-2 {
  411. flex: 1;
  412. text-align: center;
  413. }
  414. .col-3 {
  415. width: 52px;
  416. text-align: center;
  417. }
  418. .col-4 {
  419. width: 56px;
  420. text-align: center;
  421. }
  422. .col-5 {
  423. width: 52px;
  424. text-align: center;
  425. }
  426. .col-6 {
  427. width: 52px;
  428. text-align: center;
  429. }
  430. }
  431. .table-row {
  432. display: flex;
  433. padding: 8px 6px;
  434. font-size: 11px;
  435. color: rgba(0, 0, 0, 0.6);
  436. background: #fff;
  437. border-bottom: 1px solid rgba(225, 225, 225, 0.3);
  438. &:last-child {
  439. border-bottom: none;
  440. }
  441. .col-1,
  442. .col-2,
  443. .col-3,
  444. .col-4,
  445. .col-5,
  446. .col-6 {
  447. display: flex;
  448. align-items: center;
  449. justify-content: center;
  450. }
  451. .col-1 {
  452. width: 40px;
  453. }
  454. .col-2 {
  455. flex: 1;
  456. }
  457. .col-3 {
  458. width: 52px;
  459. }
  460. .col-4 {
  461. width: 56px;
  462. }
  463. .col-5 {
  464. width: 52px;
  465. }
  466. .col-6 {
  467. width: 52px;
  468. }
  469. }
  470. }
  471. }
  472. // 服务费用区域
  473. .service-cost-section {
  474. position: relative;
  475. .section-header {
  476. display: flex;
  477. justify-content: space-between;
  478. align-items: center;
  479. margin-bottom: 12px;
  480. .section-title {
  481. font-size: 14px;
  482. color: #000;
  483. }
  484. .section-total {
  485. font-size: 16px;
  486. font-weight: bold;
  487. color: #000;
  488. .unit-text {
  489. padding-left: 2px;
  490. font-size: 12px;
  491. font-weight: normal;
  492. }
  493. }
  494. }
  495. .service-details {
  496. display: flex;
  497. align-items: center;
  498. border: 1px solid rgba(206, 206, 206, 0.5);
  499. padding: 8px 0;
  500. border-radius: 4px;
  501. margin-bottom: 10px;
  502. .detail-item {
  503. font-size: 14px;
  504. flex: 1;
  505. text-align: center;
  506. .detail-label {
  507. color: rgba(0, 0, 0, 0.2);
  508. margin-top: 6px;
  509. }
  510. .detail-value {
  511. color: rgba(0, 0, 0, 0.8);
  512. }
  513. }
  514. .detail-item + .detail-item {
  515. position: relative;
  516. &::before {
  517. content: "";
  518. position: absolute;
  519. left: 0;
  520. top: 50%;
  521. transform: translateY(-50%);
  522. width: 1px;
  523. height: 20px;
  524. background: rgba(0, 0, 0, 0.1);
  525. }
  526. }
  527. }
  528. }
  529. .edit-btn-box {
  530. display: flex;
  531. justify-content: end;
  532. position: absolute;
  533. right: 0;
  534. top: -8px;
  535. z-index: 10;
  536. }
  537. .edit-btn {
  538. background: rgba(33, 153, 248, 0.1);
  539. color: #2199f8;
  540. padding: 6px 16px;
  541. border-radius: 20px;
  542. font-size: 14px;
  543. width: fit-content;
  544. cursor: pointer;
  545. }
  546. // 底部操作按钮
  547. .bottom-actions {
  548. flex-shrink: 0;
  549. .action-buttons {
  550. padding: 16px;
  551. display: flex;
  552. justify-content: space-around;
  553. .action-btn {
  554. display: flex;
  555. flex-direction: column;
  556. align-items: center;
  557. cursor: pointer;
  558. .icon-circle {
  559. width: 48px;
  560. height: 48px;
  561. border-radius: 50%;
  562. display: flex;
  563. align-items: center;
  564. justify-content: center;
  565. color: #fff;
  566. margin-bottom: 4px;
  567. .el-icon {
  568. color: #fff;
  569. }
  570. img {
  571. width: 50px;
  572. }
  573. }
  574. &.blue-btn .icon-circle {
  575. background: #2199f8;
  576. }
  577. &.green-btn .icon-circle {
  578. background: #07c160;
  579. }
  580. &.orange-btn .icon-circle {
  581. background: #ff790b;
  582. }
  583. .btn-label {
  584. font-size: 12px;
  585. color: #fff;
  586. }
  587. }
  588. }
  589. .cancel-btn {
  590. text-align: center;
  591. font-size: 18px;
  592. color: #fff;
  593. cursor: pointer;
  594. }
  595. }
  596. </style>