Poster.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. <template>
  2. <view class="distribution-posters">
  3. <view class="slider-banner banner">
  4. <swiper indicatorDots="true">
  5. <block v-for="(item, infoIndex) in info" :key="infoIndex">
  6. <swiper-item>
  7. <image class="slide-image" :src="item.wap_poster" mode="widthFix" show-menu-by-longpress />
  8. </swiper-item>
  9. </block>
  10. </swiper>
  11. </view>
  12. <view class="keep bg-color-red" @click="saveImg">保存海报</view>
  13. </view>
  14. </template>
  15. <script>
  16. export default {
  17. name: 'Poster',
  18. components: {
  19. // swiper,
  20. // swiperSlide
  21. },
  22. props: {},
  23. data: function () {
  24. return {
  25. swiperPosters: {
  26. speed: 1000,
  27. effect: 'coverflow',
  28. slidesPerView: 'auto',
  29. centeredSlides: true,
  30. coverflowEffect: {
  31. rotate: 0, // 旋转的角度
  32. stretch: -20, // 拉伸 图片间左右的间距和密集度
  33. depth: 100, // 深度 切换图片间上下的间距和密集度
  34. modifier: 3, // 修正值 该值越大前面的效果越明显
  35. slideShadows: false, // 页面阴影效果
  36. },
  37. observer: true,
  38. observeParents: true,
  39. },
  40. info: [],
  41. activeIndex: 0,
  42. }
  43. },
  44. mounted: function () {
  45. this.getIndex()
  46. let that = this
  47. // this.swiper.on("slideChange", function() {
  48. // that.activeIndex = that.swiper.activeIndex;
  49. // });
  50. },
  51. computed: {
  52. swiper() {
  53. // return this.$refs.mySwiper.swiper;
  54. },
  55. },
  56. methods: {
  57. getIndex: function () {
  58. let that = this
  59. this.$api.request('get', 'user/app/spread/banner',{
  60. from: this.$deviceType == 'weixin' || this.$deviceType == 'weixinh5' ? 'uniappH5' : this.$deviceType,
  61. }).then(
  62. res => {
  63. that.info = res.data
  64. },
  65. err => {
  66. uni.showToast({
  67. title: err.msg || err.response.data.msg || err.response.data.message,
  68. icon: 'none',
  69. duration: 2000,
  70. })
  71. }
  72. )
  73. },
  74. downloadIamge(imgsrc, name) {
  75. var that = this
  76. this.isDown = true
  77. var downloadUrl = imgsrc
  78. that.downloadFile(downloadUrl)
  79. },
  80. saveImg: function () {
  81. this.downloadIamge(this.info[this.activeIndex].wap_poster, 'poster' + this.activeIndex)
  82. },
  83. downloadFile(url) {
  84. uni.downloadFile({
  85. url,
  86. fail: function (res) {
  87. uni.showModal({
  88. title: '提示',
  89. content: '保存失败',
  90. })
  91. },
  92. success: function (res) {
  93. uni.saveImageToPhotosAlbum({
  94. filePath: res.tempFilePath,
  95. success: () => {
  96. uni.showToast({
  97. title: '保存成功!',
  98. })
  99. },
  100. fail: () => {
  101. uni.showToast({
  102. title: '保存失败',
  103. })
  104. },
  105. })
  106. },
  107. })
  108. },
  109. },
  110. }
  111. </script>
  112. <style lang="less">
  113. page {
  114. height: 100%;
  115. }
  116. .distribution-posters {
  117. height: 100vh;
  118. position: relative;
  119. .banner {
  120. height: 88vh; /* 或您需要的高度 */
  121. swiper {
  122. height: 100%;
  123. }
  124. .slide-image {
  125. width: 100%;
  126. height: 100%;
  127. object-fit: contain; /* 保持图片比例 */
  128. }
  129. }
  130. }
  131. .banenr {
  132. height: 100%;
  133. }
  134. .banner swiper {
  135. height: 100%;
  136. }
  137. .banner .slide-image {
  138. width: 100%;
  139. height: auto;
  140. }
  141. .distribution-posters {
  142. .keep {
  143. position: fixed;
  144. bottom: 80rpx;
  145. left: 50%;
  146. transform: translateX(-50%);
  147. width: 80%;
  148. max-width: 600rpx;
  149. height: 90rpx;
  150. line-height: 90rpx;
  151. text-align: center;
  152. color: #fff;
  153. border-radius: 45rpx;
  154. font-size: 32rpx;
  155. font-weight: 500;
  156. z-index: 10;
  157. box-shadow: 0 10rpx 20rpx rgba(229, 77, 66, 0.3);
  158. transition: all 0.3s ease;
  159. &.bg-color-red {
  160. background: linear-gradient(135deg, #ff5e3a 0%, #e54d42 100%);
  161. }
  162. &:active {
  163. transform: translateX(-50%) scale(0.98);
  164. box-shadow: 0 5rpx 10rpx rgba(229, 77, 66, 0.3);
  165. }
  166. }
  167. }
  168. </style>