previewImage.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  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. shareTitle:'',
  64. shareImg:''
  65. }
  66. },
  67. onLoad(options){
  68. console.log(options);
  69. this.reportId=options.reportId
  70. this.chapterId=options.chapterId
  71. this.shareTitle=options.shareTitle||''
  72. this.shareImg=options.shareImg||''
  73. this.getReportPPtImgs()
  74. uni.setPageOrientation({orientation : "landscape"})
  75. },
  76. onUnLoad(){
  77. uni.setPageOrientation({orientation : "portrait"})
  78. },
  79. onShareAppMessage() {
  80. let path=''
  81. if(this.chapterId!=0){
  82. path=`/pages-report/chapterDetail?chapterId=${this.chapterId}`
  83. }else{
  84. path=`/pages-report/reportDetail?reportId=${this.reportId}`
  85. }
  86. return {
  87. title:this.shareTitle,
  88. path:path,
  89. imageUrl:this.shareImg
  90. }
  91. },
  92. methods: {
  93. // 获取ppt图片
  94. async getReportPPtImgs(){
  95. const res=await apiReportPPtImgs({
  96. report_id:Number(this.reportId),
  97. report_chapter_id:Number(this.chapterId)
  98. })
  99. if(res.code===200){
  100. this.imgList=res.data||[]
  101. }else{
  102. uni.showToast({
  103. title: res.msg,
  104. icon: 'none'
  105. })
  106. }
  107. },
  108. handleChangeItem(index){
  109. this.aid='img'+(index-1)
  110. this.activeIndex=index
  111. },
  112. handleOpen(){
  113. this.isOpen=!this.isOpen
  114. },
  115. swiperChange(e){
  116. this.activeIndex=e.detail.current
  117. },
  118. closePage(){
  119. wx.navigateBack({
  120. delta: 1
  121. });
  122. }
  123. },
  124. }
  125. </script>
  126. <style>
  127. page{
  128. padding-bottom: 0;
  129. }
  130. </style>
  131. <style lang="scss" scoped>
  132. .preview-image-page{
  133. background: #333333;
  134. width: 100vw;
  135. height: 100vh;
  136. .swiper{
  137. height: 100%;
  138. }
  139. .img-item{
  140. height: 100%;
  141. display: block;
  142. margin: auto;
  143. }
  144. .bot-fix-box{
  145. position: fixed;
  146. left: 0;
  147. right: 0;
  148. bottom: 0;
  149. height: 100px;
  150. background: rgba(255, 255, 255, 0.4);
  151. backdrop-filter: blur(12px);
  152. transition: 0.3s;
  153. display: flex;
  154. .imgs-box{
  155. max-width: 70%;
  156. width: auto;
  157. height: 100%;
  158. margin: auto;
  159. white-space: nowrap;
  160. image{
  161. height: 100%;
  162. }
  163. .img-active{
  164. border: 1px solid #E3B377;
  165. }
  166. }
  167. .open-box{
  168. position: absolute;
  169. bottom: 100%;
  170. right: 20px;
  171. width: 80px;
  172. height: 36px;
  173. background: rgba(255, 255, 255, 0.5);
  174. border-radius: 10px 10px 0 0;
  175. display: flex;
  176. align-items: center;
  177. justify-content: center;
  178. }
  179. }
  180. .close-icon{
  181. position: fixed;
  182. left: 100px;
  183. top: 20px;
  184. width: 24px;
  185. height: 24px;
  186. z-index: 99;
  187. }
  188. }
  189. </style>