posterPopup.vue 7.2 KB

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