posterPopup.vue 7.2 KB

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