posterPopup.vue 7.4 KB

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