poster.vue 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  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. left: "100rpx",
  69. top: '70rpx',
  70. fontSize: '26rpx',
  71. lineHeight: '80rpx',
  72. color:'grey',
  73. textAlign: 'right',
  74. }
  75. },
  76. {
  77. type: 'text',
  78. text: '“最受欢迎-IHG酒店”',
  79. css: {
  80. width: "330rpx",
  81. height: "80rpx",
  82. // left: "220rpx",
  83. left: "280rpx",
  84. display: "flex",
  85. justifyContent: 'center',
  86. top: '70rpx',
  87. fontSize: '26rpx',
  88. lineHeight: '80rpx',
  89. color:'#FF6200',
  90. textAlign: 'left',
  91. }
  92. },
  93. {
  94. type: 'image',
  95. src: 'http://img.xjishu.com/img/zl/2018/6/30/1241359458913.gif',
  96. css: {
  97. left: '240rpx',
  98. top: '720rpx',
  99. width: '120rpx',
  100. height: '120rpx',
  101. borderRadius: '30px'
  102. }
  103. },
  104. {
  105. type: 'text',
  106. text: '长按识别小程序码给他投票',
  107. css: {
  108. width: "500rpx",
  109. height: "80rpx",
  110. left: "50rpx",
  111. top: '830rpx',
  112. fontSize: '26rpx',
  113. lineHeight: '80rpx',
  114. color:'grey',
  115. textAlign: 'center',
  116. }
  117. },
  118. {
  119. type: 'image',
  120. src: 'https://img1.baidu.com/it/u=3841234653,2748754224&fm=253&fmt=auto&app=138&f=JPEG?w=900&h=500',
  121. css: {
  122. left: '30rpx',
  123. top: '150rpx',
  124. width: '540rpx',
  125. height: '540rpx',
  126. borderRadius: '10rpx'
  127. }
  128. }
  129. ]
  130. }
  131. },
  132. };
  133. },
  134. methods:{
  135. show({name, title, imgUrl, qrcodeUrl}){
  136. this.poster.base.views[0].text = name;
  137. this.poster.base.views[2].text = title;
  138. imgUrl && (this.poster.base.views[5].src = imgUrl);
  139. qrcodeUrl && (this.poster.base.views[3].src = qrcodeUrl);
  140. uni.pageScrollTo({
  141. scrollTop: 0,
  142. duration: 1
  143. });
  144. this.poster.show = true;
  145. },
  146. cancel(){
  147. this.poster.show = false;
  148. },
  149. save(id){
  150. this.$api.active.activityShare({
  151. share_type:2,
  152. activity_project_id:id
  153. }).then(res=>{
  154. console.log(res.data);
  155. })
  156. uni.saveImageToPhotosAlbum({
  157. filePath: this.poster.path,
  158. success(res) {
  159. uni.showToast({
  160. title: '已保存到相册',
  161. icon: 'success',
  162. duration: 2000
  163. })
  164. }
  165. })
  166. },
  167. shareBtn(id){
  168. this.$api.active.activityShare({
  169. share_type:2,
  170. activity_project_id:id
  171. }).then(res=>{
  172. console.log(res.data);
  173. })
  174. },
  175. share(){
  176. // wx.downloadFile({
  177. // url: this.poster.path, // 下载url
  178. // success (res) {
  179. // // 下载完成后转发
  180. // wx.shareFileMessage({
  181. // filePath: res.tempFilePath,
  182. // success() {
  183. // console.log('转发成功')
  184. // },
  185. // fail: console.error,
  186. // })
  187. // },
  188. // fail: console.error,
  189. // })
  190. }
  191. },
  192. }
  193. </script>
  194. <style lang="scss" scoped>
  195. .poster-container{
  196. width:100%;
  197. height:100%;
  198. position: fixed;
  199. top:0;
  200. left:0;
  201. z-index: 999;
  202. background-color: rgba(0, 0, 0, 0.4);
  203. }
  204. .poster-share{
  205. position: fixed;
  206. bottom:0;
  207. width: 100%;
  208. height: 380rpx;
  209. background-color: #fff;
  210. border-radius: 30rpx 30rpx 0px 0px;
  211. transform: translateY(500rpx);
  212. padding-top: 40rpx;
  213. transition: 0.3s all;
  214. z-index: 1000;
  215. color:rgba(0,0,0,0.5);
  216. display: flex;
  217. flex-direction: column;
  218. justify-content: space-between;
  219. &.on{
  220. transform: translateY(0rpx);
  221. }
  222. >view:first-child{
  223. text-align: center;
  224. color: #000;
  225. font-weight:bold;
  226. margin-bottom: 40rpx;
  227. }
  228. >view:nth-child(2){
  229. display: flex;
  230. justify-content: flex-start;
  231. align-items: center;
  232. margin-bottom: 40rpx;
  233. >view{
  234. text-align: center;
  235. margin-left: 40rpx;
  236. }
  237. image{
  238. width: 80rpx;
  239. height: 80rpx;
  240. }
  241. text{
  242. width: 100rpx;
  243. display: block;
  244. font-size: 24rpx;
  245. text-align: center;
  246. }
  247. }
  248. >view:last-child{
  249. height: 100rpx;
  250. line-height: 100rpx;
  251. text-align: center;
  252. border-top: 1px solid rgba(0,0,0,0.1);
  253. }
  254. .shareButton{
  255. background: transparent;
  256. border: 0px;
  257. line-height: inherit;
  258. color: inherit;
  259. &::after{
  260. border:0px;
  261. }
  262. }
  263. }
  264. </style>