posterPopup.vue 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319
  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 class="month">{{ treeObj.monthNumber }}</text>/{{ treeObj.day }}
  9. </view>
  10. </view>
  11. <view class="qr-code">
  12. <image class="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 class="logo" :src="`${config.BASIC_IMG}img/treePage/logo.png`" alt="" />
  41. <view class="text">飞鸟有味</view>
  42. </view>
  43. </view>
  44. </view>
  45. <view class="footer">
  46. <view class="btn" @click="handleDownload">保存图片</view>
  47. <view class="share btn" @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. getPosterData(props.farmBuyId)
  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 = uni.getStorageSync('userInfo')
  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. TREE.getPoster({farmBuyId}).then(({data,code}) =>{
  128. if (code === 0) {
  129. showPopup.value = true;
  130. treeObj.value = {
  131. ...data,
  132. watermarkArr: data.watermarkMsg && data.watermarkMsg.split(","),
  133. ...formatDate(data.createDate)
  134. };
  135. }
  136. })
  137. };
  138. const closePopup = () => {
  139. showPopup.value = false;
  140. };
  141. </script>
  142. <style lang="scss" scoped>
  143. @import "@/static/style/mixin.scss";
  144. .poster-popup {
  145. width: 90vw;
  146. box-sizing: border-box;
  147. position: relative;
  148. padding: 40rpx 30rpx;
  149. background: #fff;
  150. border-radius: 24rpx;
  151. .date-wrap {
  152. display: flex;
  153. justify-content: space-between;
  154. .time {
  155. line-height: 100rpx;
  156. margin-top: -42rpx;
  157. font-family: "SweiSpringCJKtc";
  158. .date {
  159. font-size: 48rpx;
  160. .month {
  161. font-size: 172rpx;
  162. }
  163. }
  164. }
  165. .qr-code {
  166. text-align: right;
  167. font-family: "SweiSpringCJKtc";
  168. .image {
  169. width: 112rpx;
  170. height: 124rpx;
  171. }
  172. .txt {
  173. font-size: 24rpx;
  174. line-height: 36rpx;
  175. margin-top: 12rpx;
  176. }
  177. }
  178. }
  179. .image-wrap {
  180. width: 100%;
  181. height: 480rpx;
  182. position: relative;
  183. margin: 30rpx 0 44rpx 0;
  184. pointer-events: none;
  185. .image {
  186. width: 100%;
  187. height: 100%;
  188. object-fit: cover;
  189. border-radius: 10rpx;
  190. }
  191. .common-bg {
  192. position: absolute;
  193. background: rgba(0, 0, 0, 0.6);
  194. font-size: 20rpx;
  195. color: #fff;
  196. padding: 8rpx 30rpx;
  197. border-radius: 50rpx;
  198. }
  199. .address {
  200. top: 20rpx;
  201. right: 12rpx;
  202. border: 1px solid rgba(255, 255, 255, 0.39);
  203. }
  204. .tag-image {
  205. position: absolute;
  206. z-index: 3;
  207. left: 0;
  208. bottom: 0;
  209. .tag-content {
  210. @include ossBg("treePage/tag-bg.png");
  211. width: 276rpx;
  212. height: 274rpx;
  213. display: flex;
  214. flex-direction: column;
  215. align-items: center;
  216. color: #fff;
  217. .tag-name {
  218. font-family: "jiangxizhuokai";
  219. font-size: 36rpx;
  220. padding-top: 56rpx;
  221. }
  222. .tag-user {
  223. padding-top: 6rpx;
  224. font-family: "jiangxizhuokai";
  225. font-size: 16rpx;
  226. .date {
  227. padding-left: 10rpx;
  228. }
  229. }
  230. }
  231. }
  232. }
  233. .info-wrap {
  234. display: flex;
  235. align-items: flex-end;
  236. justify-content: space-between;
  237. .text {
  238. font-size: 22rpx;
  239. font-family: "SweiSpringCJKtc";
  240. line-height: 32rpx;
  241. }
  242. .nickname {
  243. font-size: 24rpx;
  244. text-align: center;
  245. .logo {
  246. width: 68rpx;
  247. height: 72rpx;
  248. margin-bottom: 8rpx;
  249. }
  250. .text{
  251. font-family: "SweiSpringCJKtc";
  252. }
  253. }
  254. }
  255. }
  256. .footer {
  257. margin: 40rpx 0;
  258. display: flex;
  259. width: 100%;
  260. box-sizing: border-box;
  261. .btn {
  262. flex: 1;
  263. padding: 20rpx 0;
  264. font-size: 32rpx;
  265. border-radius: 50rpx;
  266. border: 1px solid #fff;
  267. background: #fff;
  268. text-align: center;
  269. color: #000;
  270. }
  271. .share {
  272. margin-left: 20rpx;
  273. color: #fff;
  274. background-image: linear-gradient(120deg, #ffd887, #ed9e1e);
  275. }
  276. }
  277. .close {
  278. margin-top: 36rpx;
  279. display: flex;
  280. justify-content: center;
  281. }
  282. </style>