poster.vue 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  1. <template>
  2. <view>
  3. <view class="poster-container" v-if="poster.show">
  4. <l-painter
  5. v-if="poster.show"
  6. isRenderImage
  7. width="600rpx" height="940rpx"
  8. custom-style="position: fixed;z-index:999; left: 0rpx;right:0rpx;margin:0rpx auto;bottom:440rpx;background:#fff;border-radius:20rpx"
  9. :board="poster.base"
  10. @success="poster.path = $event"
  11. />
  12. </view>
  13. <view :class="{'poster-share':true, on:poster.show}">
  14. <view>分享到</view>
  15. <view class="poster-share-panel">
  16. <view @click="shareBtn(activity_project_id)">
  17. <button class="shareButton" open-type="share"><image src="/static/icon/wechat.svg" mode="aspectFit"/>
  18. <text>微信分享</text></button>
  19. </view>
  20. <view @click="save(activity_project_id)">
  21. <image src="/static/icon/wechat_moments.svg" mode="aspectFit"/>
  22. <text>保存相册</text>
  23. </view>
  24. </view>
  25. <view @click="cancel">取消分享</view>
  26. </view>
  27. </view>
  28. </template>
  29. <script>
  30. import lPainter from '@/components/lime-painter/index.vue'
  31. export default {
  32. components: {lPainter},
  33. props: ["title", "name", "img", "qrcode",'activity_project_id'],
  34. data() {
  35. return {
  36. activityId:'',
  37. poster:{
  38. show:false,
  39. path: "",
  40. base: {
  41. width: '600rpx',
  42. height: '940rpx',
  43. background: "#fff",
  44. radius: "20rpx",
  45. views: [
  46. {
  47. type: 'text',
  48. text: '成都IHG大酒店',
  49. css: {
  50. width: "500rpx",
  51. height: "80rpx",
  52. left: "50rpx",
  53. top: '20rpx',
  54. fontSize: '32rpx',
  55. fontWeight: "bold",
  56. lineHeight: '80rpx',
  57. color:'#000',
  58. textAlign: 'center',
  59. }
  60. },
  61. {
  62. type: 'text',
  63. text: '正在参与',
  64. css: {
  65. width: "170rpx",
  66. height: "80rpx",
  67. left: "50rpx",
  68. top: '70rpx',
  69. fontSize: '26rpx',
  70. lineHeight: '80rpx',
  71. color:'grey',
  72. textAlign: 'right',
  73. }
  74. },
  75. {
  76. type: 'text',
  77. text: '“最受欢迎-IHG酒店”',
  78. css: {
  79. width: "330rpx",
  80. height: "80rpx",
  81. left: "220rpx",
  82. display: "flex",
  83. justifyContent: 'center',
  84. top: '70rpx',
  85. fontSize: '26rpx',
  86. lineHeight: '80rpx',
  87. color:'#EEA470',
  88. textAlign: 'left',
  89. }
  90. },
  91. {
  92. type: 'image',
  93. src: 'http://img.xjishu.com/img/zl/2018/6/30/1241359458913.gif',
  94. css: {
  95. left: '240rpx',
  96. top: '720rpx',
  97. width: '120rpx',
  98. height: '120rpx',
  99. borderRadius: '30px'
  100. }
  101. },
  102. {
  103. type: 'text',
  104. text: '长按识别小程序码给他投票',
  105. css: {
  106. width: "500rpx",
  107. height: "80rpx",
  108. left: "50rpx",
  109. top: '830rpx',
  110. fontSize: '26rpx',
  111. lineHeight: '80rpx',
  112. color:'grey',
  113. textAlign: 'center',
  114. }
  115. },
  116. {
  117. type: 'image',
  118. src: 'https://img1.baidu.com/it/u=3841234653,2748754224&fm=253&fmt=auto&app=138&f=JPEG?w=900&h=500',
  119. css: {
  120. left: '30rpx',
  121. top: '150rpx',
  122. width: '540rpx',
  123. height: '540rpx',
  124. borderRadius: '20rpx'
  125. }
  126. }
  127. ]
  128. }
  129. },
  130. };
  131. },
  132. methods:{
  133. show({name, title, imgUrl, qrcodeUrl}){
  134. this.poster.base.views[0].text = name;
  135. this.poster.base.views[2].text = title;
  136. imgUrl && (this.poster.base.views[5].src = imgUrl);
  137. qrcodeUrl && (this.poster.base.views[3].src = qrcodeUrl);
  138. uni.pageScrollTo({
  139. scrollTop: 0,
  140. duration: 1
  141. });
  142. this.poster.show = true;
  143. },
  144. cancel(){
  145. this.poster.show = false;
  146. },
  147. save(id){
  148. this.$api.active.activityShare({
  149. share_type:2,
  150. activity_project_id:id
  151. }).then(res=>{
  152. console.log(res.data);
  153. })
  154. uni.saveImageToPhotosAlbum({
  155. filePath: this.poster.path,
  156. success(res) {
  157. uni.showToast({
  158. title: '已保存到相册',
  159. icon: 'success',
  160. duration: 2000
  161. })
  162. }
  163. })
  164. },
  165. shareBtn(id){
  166. this.$api.active.activityShare({
  167. share_type:2,
  168. activity_project_id:id
  169. }).then(res=>{
  170. console.log(res.data);
  171. })
  172. },
  173. share(){
  174. // wx.downloadFile({
  175. // url: this.poster.path, // 下载url
  176. // success (res) {
  177. // // 下载完成后转发
  178. // wx.shareFileMessage({
  179. // filePath: res.tempFilePath,
  180. // success() {
  181. // console.log('转发成功')
  182. // },
  183. // fail: console.error,
  184. // })
  185. // },
  186. // fail: console.error,
  187. // })
  188. }
  189. },
  190. }
  191. </script>
  192. <style lang="scss" scoped>
  193. .poster-container{
  194. width:100%;
  195. height:100%;
  196. position: fixed;
  197. top:0;
  198. left:0;
  199. z-index: 999;
  200. background-color: rgba(0, 0, 0, 0.4);
  201. }
  202. .poster-share{
  203. position: fixed;
  204. bottom:0;
  205. width: 100%;
  206. height: 380rpx;
  207. background-color: #fff;
  208. border-radius: 30rpx 30rpx 0px 0px;
  209. transform: translateY(500rpx);
  210. padding-top: 40rpx;
  211. transition: 0.3s all;
  212. z-index: 1000;
  213. color:rgba(0,0,0,0.5);
  214. display: flex;
  215. flex-direction: column;
  216. justify-content: space-between;
  217. &.on{
  218. transform: translateY(0rpx);
  219. }
  220. >view:first-child{
  221. text-align: center;
  222. color: #000;
  223. font-weight:bold;
  224. margin-bottom: 40rpx;
  225. }
  226. >view:nth-child(2){
  227. display: flex;
  228. justify-content: flex-start;
  229. align-items: center;
  230. margin-bottom: 40rpx;
  231. >view{
  232. text-align: center;
  233. margin-left: 40rpx;
  234. }
  235. image{
  236. width: 80rpx;
  237. height: 80rpx;
  238. }
  239. text{
  240. width: 100rpx;
  241. display: block;
  242. font-size: 24rpx;
  243. text-align: center;
  244. }
  245. }
  246. >view:last-child{
  247. height: 100rpx;
  248. line-height: 100rpx;
  249. text-align: center;
  250. border-top: 1px solid rgba(0,0,0,0.1);
  251. }
  252. .shareButton{
  253. background: transparent;
  254. border: 0px;
  255. line-height: inherit;
  256. color: inherit;
  257. &::after{
  258. border:0px;
  259. }
  260. }
  261. }
  262. </style>