index.vue 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. <template>
  2. <view>
  3. <uni-popup ref="popup" type="center">
  4. <view class="popup-container" @click="close">
  5. <swiper
  6. class="swiper"
  7. :current="current"
  8. :duration="500"
  9. @change="swiperChange"
  10. @click.stop
  11. >
  12. <swiper-item
  13. class="imgs-item"
  14. v-for="(item, index) in imgs"
  15. :key="index"
  16. >
  17. <movable-area scale-area class="movable-data">
  18. <movable-view
  19. class="movable-item"
  20. direction="all"
  21. :inertia="true"
  22. :scale="true"
  23. scale-min="1"
  24. scale-max="4"
  25. >
  26. <image :src="item.img" mode="aspectFit" class="img" />
  27. </movable-view>
  28. </movable-area>
  29. </swiper-item>
  30. </swiper>
  31. <view class="count">{{ count }}/{{ imgs.length }}</view>
  32. </view>
  33. </uni-popup>
  34. </view>
  35. </template>
  36. <script>
  37. export default {
  38. name: "PreviewImage",
  39. props: {
  40. imgs: {
  41. type: Array,
  42. },
  43. current: {
  44. type: Number,
  45. default: 0,
  46. },
  47. },
  48. data() {
  49. return {
  50. count: 1,
  51. };
  52. },
  53. methods: {
  54. swiperChange(e) {
  55. this.count = e.detail.current + 1;
  56. },
  57. open(index) {
  58. this.count = index + 1;
  59. this.$refs.popup.open();
  60. },
  61. close() {
  62. this.$refs.popup.close();
  63. },
  64. },
  65. };
  66. </script>
  67. <style lang="scss" scoped>
  68. .popup-container {
  69. position: relative;
  70. display: flex;
  71. justify-content: center;
  72. align-items: center;
  73. width: 100vw;
  74. height: 100vh;
  75. background-color: rgba(0, 0, 0, 0.5);
  76. color: #fff;
  77. .count {
  78. position: absolute;
  79. bottom: 192px;
  80. right: 10px;
  81. width: 80px;
  82. height: 30px;
  83. color: #fff;
  84. background-color: rgba(0, 0, 0, 0.5);
  85. border-radius: 30px;
  86. text-align: center;
  87. line-height: 30px;
  88. }
  89. }
  90. .swiper {
  91. width: 100%;
  92. height: 450px !important;
  93. }
  94. .imgs-item {
  95. height: 100%;
  96. .movable-data{
  97. width: 100%;
  98. height: 100%;
  99. display: flex;
  100. align-items: center;
  101. justify-content: center;
  102. .movable-item{
  103. height: 100%;
  104. width: 100%;
  105. position:fixed;
  106. overflow: hidden;
  107. .img {
  108. width: 100%;
  109. height: 100%;
  110. background-color: rgb(238, 238, 238);
  111. }
  112. }
  113. }
  114. }
  115. </style>