posterPopup.vue 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352
  1. <template>
  2. <up-popup :show="showPopup" @close="closePopup" mode="center" bgColor="transparent">
  3. <view class="poster-popup" ref="contentDom">
  4. <view class="date-wrap">
  5. <view class="time">
  6. <text class="month">{{ treeObj.year }}</text>
  7. <view class="date">
  8. <text>{{ treeObj.monthNumber }}</text>/{{ treeObj.day }}
  9. </view>
  10. </view>
  11. <view class="qr-code">
  12. <image :src="treeObj.qrCodeUrl" alt="" />
  13. <view class="txt">
  14. <text>{{ treeObj.age }}年 {{ treeObj.age > 9 ? "老树" : "树龄" }} {{ treeObj.pz }}</text>
  15. <view>{{treeObj.phenology}} 气候适宜-{{ treeObj.howTxt || "果园采摘" }}</view>
  16. </view>
  17. </view>
  18. </view>
  19. <view class="image-wrap">
  20. <image class="image" :src="treeObj.posterUrl" alt="" />
  21. <view class="address common-bg">{{ treeObj.pz }}-{{ treeObj.countyName }}</view>
  22. <view class="tag-image">
  23. <view class="tag-content">
  24. <view class="tag-name">【{{ treeName || '茜茜荔' }}】</view>
  25. <view class="tag-user">
  26. <text>{{ treeObj.nickname || treeObj.name || '12' }}</text>
  27. <text class="date">{{ treeObj.year }}.{{
  28. treeObj.monthNumber >= 10 ? treeObj.monthNumber : "0" + treeObj.monthNumber
  29. }}.{{ treeObj.day }}</text>
  30. </view>
  31. </view>
  32. </view>
  33. </view>
  34. <view class="info-wrap">
  35. <view class="text">
  36. <!-- <el-viewider class="viewider" /> -->
  37. <view v-for="(text, textI) in treeObj.watermarkArr" :key="textI">{{ text }}</view>
  38. </view>
  39. <view class="nickname">
  40. <image :src="`${config.BASIC_IMG}img/treePage/logo.png`" alt="" />
  41. <view>飞鸟有味</view>
  42. </view>
  43. </view>
  44. </view>
  45. <view class="footer">
  46. <view @click="handleDownload">保存图片</view>
  47. <view class="share" @click="handleShare">去分享</view>
  48. </view>
  49. <up-icon class="close" name="close-circle-fill" size="30" @click="showPopup = false"
  50. color="rgba(255, 255, 255, 0.7)"></up-icon>
  51. </up-popup>
  52. <!-- 保存弹窗 -->
  53. <!-- <save-photo-popup ref="savePhotoDom" height="480"></save-photo-popup> -->
  54. </template>
  55. <script setup>
  56. import {
  57. ref,
  58. watch
  59. } from "vue";
  60. // import savePhotoPopup from "@/components/common/savePhotoPopup.vue";
  61. import config from "@/api/config.js"
  62. const resize = "?x-oss-process=image/resize,w_1000";
  63. const props = defineProps({
  64. farmBuyId: {
  65. type: [Number, String],
  66. defalut: "",
  67. },
  68. sampleId: {
  69. type: [Number, String],
  70. defalut: "",
  71. },
  72. treeName: {
  73. type: String,
  74. defalut: "",
  75. },
  76. showPoster: {
  77. type: Boolean,
  78. defalut: false,
  79. },
  80. });
  81. watch(
  82. () => props.farmBuyId,
  83. (newValue) => {
  84. if (newValue && userInfo?.tel && props.showPoster) {
  85. getPosterData(newValue);
  86. }
  87. }
  88. );
  89. watch(
  90. () => props.showPoster,
  91. (newValue) => {
  92. // if (newValue && userInfo?.tel && props.showPoster) {
  93. // getPosterData(props.farmBuyId);
  94. // }
  95. getPosterData()
  96. }
  97. );
  98. const handleShare = () => {
  99. const params = {
  100. sampleId: props.sampleId,
  101. farmBuyId: props.farmBuyId,
  102. };
  103. // wx.miniProgram.navigateTo({
  104. // url: `/pages/subPages/share_page/index?type=treeExample&pageParams=${JSON.stringify(params)}`,
  105. // });
  106. };
  107. const showPopup = ref(false);
  108. // const userInfo = JSON.parse(localStorage.getItem("localUserInfo"));
  109. function formatDate(dateStr) {
  110. const date = new Date(dateStr);
  111. return {
  112. month: date.toLocaleString("en-US", {
  113. month: "short"
  114. }), // "Jun"
  115. year: date.getFullYear(),
  116. monthNumber: date.getMonth() + 1, // 6
  117. day: date.getDate(), // 23
  118. };
  119. }
  120. const treeObj = ref({});
  121. const savePhotoDom = ref(null);
  122. const contentDom = ref(null);
  123. const handleDownload = () => {
  124. savePhotoDom.value.handleDownload(contentDom.value);
  125. };
  126. const getPosterData = (farmBuyId) => {
  127. // VE_API.lj_home.getPoster({ farmBuyId }).then((res) => {
  128. // if (res.code === 0) {
  129. // if(!props.isShow){
  130. showPopup.value = true;
  131. const data = {
  132. "posterUrl": "https://birdseye-img-ali-cdn.sysuimars.com/562ba414-9517-4789-98f9-42fdae26cee4/bc27ee0c-8177-47fb-823c-c81d6f8b514c/DJI_202507281100_002_bc27ee0c-8177-47fb-823c-c81d6f8b514c/DJI_20250728110246_0016_Z_code-ws0y1mu3uwb2.jpeg",
  133. "qrCodeUrl": "https://birdseye-img.sysuimars.com/birdseye-look-mini/temp/1751087233847.jpg",
  134. "age": 2,
  135. "countyName": "从化",
  136. "pz": "井岗红糯",
  137. "watermarkMsg": "山海皆可平,无处不风景",
  138. "watermarkUrl": "",
  139. "fosterCode": "LCJGHN-GZCH-LBY1003",
  140. "countdown": -40,
  141. "sampleId": 172055,
  142. "posterId": "740994773711589376",
  143. "ssDate": null,
  144. "createDate": "2025-08-06",
  145. "phenology": "秋梢期",
  146. "howTxt": "梢期防虫"
  147. }
  148. treeObj.value = {
  149. ...data,
  150. watermarkArr: data.watermarkMsg && data.watermarkMsg.split(","),
  151. ...formatDate(data.createDate)
  152. };
  153. // }else{
  154. // closePopup()
  155. // }
  156. // }
  157. // });
  158. };
  159. const closePopup = () => {
  160. showPopup.value = false;
  161. // VE_API.lj_home.posterRead({ posterId: treeObj.value.posterId });
  162. };
  163. </script>
  164. <style lang="scss" scoped>
  165. @import "@/static/style/mixin.scss";
  166. .poster-popup {
  167. width: 90vw;
  168. box-sizing: border-box;
  169. position: relative;
  170. padding: 40rpx 30rpx;
  171. background: #fff;
  172. border-radius: 24rpx;
  173. .date-wrap {
  174. display: flex;
  175. justify-content: space-between;
  176. view {
  177. font-family: "SweiSpringCJKtc";
  178. }
  179. .time {
  180. line-height: 100rpx;
  181. margin-top: -42rpx;
  182. .date {
  183. font-size: 48rpx;
  184. text {
  185. font-size: 172rpx;
  186. }
  187. }
  188. }
  189. .qr-code {
  190. text-align: right;
  191. image {
  192. width: 112rpx;
  193. height: 124rpx;
  194. }
  195. .txt {
  196. font-size: 24rpx;
  197. line-height: 36rpx;
  198. margin-top: 12rpx;
  199. }
  200. }
  201. }
  202. .image-wrap {
  203. width: 100%;
  204. height: 480rpx;
  205. position: relative;
  206. margin: 30rpx 0 44rpx 0;
  207. pointer-events: none;
  208. image {
  209. width: 100%;
  210. height: 100%;
  211. object-fit: cover;
  212. border-radius: 10rpx;
  213. }
  214. .common-bg {
  215. position: absolute;
  216. background: rgba(0, 0, 0, 0.6);
  217. font-size: 20rpx;
  218. color: #fff;
  219. padding: 8rpx 30rpx;
  220. border-radius: 50rpx;
  221. }
  222. .address {
  223. top: 20rpx;
  224. right: 12rpx;
  225. border: 1px solid rgba(255, 255, 255, 0.39);
  226. }
  227. .tag-image {
  228. position: absolute;
  229. z-index: 3;
  230. left: 0;
  231. bottom: 0;
  232. .tag-content {
  233. @include ossBg("treePage/tag-bg.png");
  234. width: 276rpx;
  235. height: 274rpx;
  236. display: flex;
  237. flex-direction: column;
  238. align-items: center;
  239. color: #fff;
  240. .tag-name {
  241. font-family: "jiangxizhuokai";
  242. font-size: 36rpx;
  243. padding-top: 56rpx;
  244. }
  245. .tag-user {
  246. padding-top: 6rpx;
  247. font-family: "jiangxizhuokai";
  248. font-size: 16rpx;
  249. .date {
  250. padding-left: 10rpx;
  251. }
  252. }
  253. }
  254. }
  255. }
  256. .info-wrap {
  257. display: flex;
  258. align-items: flex-end;
  259. justify-content: space-between;
  260. .text {
  261. font-size: 22rpx;
  262. view {
  263. font-family: "SweiSpringCJKtc";
  264. line-height: 32rpx;
  265. }
  266. .viewider {
  267. width: 60rpx;
  268. border-top-color: #000;
  269. margin: 12rpx 0;
  270. height: 4rpx;
  271. }
  272. }
  273. .nickname {
  274. font-size: 24rpx;
  275. text-align: center;
  276. image {
  277. width: 68rpx;
  278. height: 72rpx;
  279. margin-bottom: 8rpx;
  280. }
  281. view {
  282. font-family: "SweiSpringCJKtc-Black";
  283. }
  284. }
  285. }
  286. }
  287. .footer {
  288. margin: 40rpx 0;
  289. display: flex;
  290. width: 100%;
  291. box-sizing: border-box;
  292. view {
  293. flex: 1;
  294. padding: 20rpx 0;
  295. font-size: 32rpx;
  296. border-radius: 50rpx;
  297. border: 1px solid #fff;
  298. background: #fff;
  299. text-align: center;
  300. color: #000;
  301. }
  302. .share {
  303. margin-left: 20rpx;
  304. color: #fff;
  305. background-image: linear-gradient(120deg, #ffd887, #ed9e1e);
  306. }
  307. }
  308. .close {
  309. margin-top: 36rpx;
  310. justify-content: center;
  311. }
  312. </style>