previewImage.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. <template>
  2. <view class="preview-image-page">
  3. <swiper
  4. class="swiper"
  5. circular
  6. :indicator-dots="false"
  7. :autoplay="false"
  8. :current="activeIndex"
  9. @change="swiperChange"
  10. >
  11. <swiper-item v-for="item in imgList" :key="item">
  12. <movable-area style="width:100%;height:100%">
  13. <movable-view
  14. class="max"
  15. scale
  16. direction="all"
  17. out-of-bounds
  18. style="width:100%;height:100%"
  19. >
  20. <image
  21. class="img-item"
  22. :src="item" mode="heightFix"
  23. />
  24. </movable-view>
  25. </movable-area>
  26. </swiper-item>
  27. </swiper>
  28. <view class="bot-fix-box" :style="{bottom:isOpen?'0':'-100px'}">
  29. <scroll-view
  30. class="imgs-box"
  31. scroll-x
  32. scroll-with-animation
  33. :scroll-into-view="aid"
  34. >
  35. <image
  36. :id="'img'+index"
  37. v-for="(img,index) in imgList"
  38. :key="img"
  39. :src="img"
  40. :class="index==activeIndex?'img-active':''"
  41. mode="heightFix"
  42. @click="handleChangeItem(index)"
  43. />
  44. </scroll-view>
  45. <view class="open-box" @click="handleOpen">
  46. <van-icon :name="isOpen?'arrow-down':'arrow-up'" color="#fff" size="25px"/>
  47. </view>
  48. </view>
  49. <image @click="closePage" class="close-icon" src="./static/close.png" mode="aspectFill"/>
  50. </view>
  51. </template>
  52. <script>
  53. import {apiReportPPtImgs} from '@/api/report'
  54. export default {
  55. data() {
  56. return {
  57. isOpen:true,
  58. imgList:[],
  59. activeIndex:0,
  60. reportId:0,
  61. chapterId:0,//章节id
  62. aid:''
  63. }
  64. },
  65. onLoad(options){
  66. this.reportId=options.reportId
  67. this.chapterId=options.chapterId
  68. this.getReportPPtImgs()
  69. uni.setPageOrientation({orientation : "landscape"})
  70. },
  71. onUnLoad(){
  72. uni.setPageOrientation({orientation : "portrait"})
  73. },
  74. methods: {
  75. // 获取ppt图片
  76. async getReportPPtImgs(){
  77. const res=await apiReportPPtImgs({
  78. report_id:Number(this.reportId),
  79. report_chapter_id:Number(this.chapterId)
  80. })
  81. if(res.code===200){
  82. this.imgList=res.data||[]
  83. }else{
  84. uni.showToast({
  85. title: res.msg,
  86. icon: 'none'
  87. })
  88. }
  89. },
  90. handleChangeItem(index){
  91. this.aid='img'+(index-1)
  92. this.activeIndex=index
  93. },
  94. handleOpen(){
  95. this.isOpen=!this.isOpen
  96. },
  97. swiperChange(e){
  98. this.activeIndex=e.detail.current
  99. },
  100. closePage(){
  101. wx.navigateBack({
  102. delta: 1
  103. });
  104. }
  105. },
  106. }
  107. </script>
  108. <style>
  109. page{
  110. padding-bottom: 0;
  111. }
  112. </style>
  113. <style lang="scss" scoped>
  114. .preview-image-page{
  115. background: #333333;
  116. width: 100vw;
  117. height: 100vh;
  118. .swiper{
  119. height: 100%;
  120. }
  121. .img-item{
  122. height: 100%;
  123. display: block;
  124. margin: auto;
  125. }
  126. .bot-fix-box{
  127. position: fixed;
  128. left: 0;
  129. right: 0;
  130. bottom: 0;
  131. height: 100px;
  132. background: rgba(255, 255, 255, 0.4);
  133. backdrop-filter: blur(12px);
  134. transition: 0.3s;
  135. display: flex;
  136. .imgs-box{
  137. max-width: 70%;
  138. width: auto;
  139. height: 100%;
  140. margin: auto;
  141. white-space: nowrap;
  142. image{
  143. height: 100%;
  144. }
  145. .img-active{
  146. border: 1px solid #E3B377;
  147. }
  148. }
  149. .open-box{
  150. position: absolute;
  151. bottom: 100%;
  152. right: 20px;
  153. width: 80px;
  154. height: 36px;
  155. background: rgba(255, 255, 255, 0.5);
  156. border-radius: 10px 10px 0 0;
  157. display: flex;
  158. align-items: center;
  159. justify-content: center;
  160. }
  161. }
  162. .close-icon{
  163. position: fixed;
  164. left: 100px;
  165. top: 20px;
  166. width: 24px;
  167. height: 24px;
  168. z-index: 99;
  169. }
  170. }
  171. </style>