posterPopup.vue 8.0 KB

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