Poster.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. <template>
  2. <div class="distribution-posters">
  3. <NavBar title="推广名片"></NavBar>
  4. <div class="slider-banner banner">
  5. <swiper class="swiper-wrapper" :options="swiperPosters" ref="mySwiper">
  6. <swiperSlide
  7. class="swiper-slide"
  8. v-for="(item, index) in info"
  9. :key="index"
  10. >
  11. <img class="slide-image" :src="item.wap_poster" />
  12. </swiperSlide>
  13. </swiper>
  14. </div>
  15. <!--<div class="keep bg-color-red" @click="saveImg">保存海报</div>-->
  16. <div class="preserve acea-row row-center-wrapper">
  17. <div class="line"></div>
  18. <div class="tip">长按保存图片</div>
  19. <div class="line"></div>
  20. </div>
  21. </div>
  22. </template>
  23. <style>
  24. .preserve {
  25. color: #fff;
  26. text-align: center;
  27. margin-top: 0.2rem;
  28. }
  29. .preserve .line {
  30. width: 1rem;
  31. height: 0.01rem;
  32. background-color: #fff;
  33. }
  34. .preserve .tip {
  35. margin: 0 0.3rem;
  36. }
  37. </style>
  38. <script>
  39. import { swiper, swiperSlide } from "vue-awesome-swiper";
  40. import "@assets/css/swiper.min.css";
  41. import { getSpreadImg } from "../../../api/user";
  42. import NavBar from "@components/NavBar";
  43. export default {
  44. name: "Poster",
  45. components: {
  46. swiper,
  47. swiperSlide,
  48. NavBar
  49. },
  50. props: {},
  51. data: function() {
  52. return {
  53. swiperPosters: {
  54. speed: 1000,
  55. effect: "coverflow",
  56. slidesPerView: "auto",
  57. centeredSlides: true,
  58. coverflowEffect: {
  59. rotate: 0, // 旋转的角度
  60. stretch: -20, // 拉伸 图片间左右的间距和密集度
  61. depth: 100, // 深度 切换图片间上下的间距和密集度
  62. modifier: 3, // 修正值 该值越大前面的效果越明显
  63. slideShadows: false // 页面阴影效果
  64. },
  65. observer: true,
  66. observeParents: true
  67. },
  68. info: [],
  69. activeIndex: 0
  70. };
  71. },
  72. mounted: function() {
  73. this.getIndex();
  74. let that = this;
  75. this.swiper.on("slideChange", function() {
  76. that.activeIndex = that.swiper.activeIndex;
  77. });
  78. },
  79. computed: {
  80. swiper() {
  81. return this.$refs.mySwiper.swiper;
  82. }
  83. },
  84. methods: {
  85. getIndex: function() {
  86. let that = this;
  87. getSpreadImg().then(
  88. res => {
  89. that.info = res.data;
  90. },
  91. err => {
  92. that.$dialog.message(err.msg);
  93. }
  94. );
  95. }
  96. // downloadIamge: function(imgsrc, name) {
  97. // let image = new Image();
  98. // image.setAttribute("crossOrigin", "anonymous");
  99. // image.onload = function() {
  100. // let canvas = document.createElement("canvas");
  101. // canvas.width = image.width;
  102. // canvas.height = image.height;
  103. // let context = canvas.getContext("2d");
  104. // context.drawImage(image, 0, 0, image.width, image.height);
  105. // let url = canvas.toDataURL("image/png"); //得到图片的base64编码数据
  106. // let a = document.createElement("a"); // 生成一个a元素
  107. // let event = new MouseEvent("click"); // 创建一个单击事件
  108. // a.download = name || "photo"; // 设置图片名称
  109. // a.href = url; // 将生成的URL设置为a.href属性
  110. // a.dispatchEvent(event); // 触发a的单击事件
  111. // };
  112. // image.src = imgsrc;
  113. // },
  114. // saveImg: function() {
  115. // console.log(this.info[this.activeIndex].wap_poster);
  116. // this.downloadIamge(
  117. // this.info[this.activeIndex].wap_poster,
  118. // "poster" + this.activeIndex
  119. // );
  120. // }
  121. }
  122. };
  123. </script>