reportDetail.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. <template>
  2. <view class="page" :style="{'min-height':h+'px', 'padding-top':mt+'px'}">
  3. <cus-header title='报告详情'></cus-header>
  4. <div class="pdf" :style="{'height':'calc(100vh - '+(mt+20)+'px)'}"
  5. @touchstart.prevent="touchStart" @touchmove.prevent="touchMove" @touchend.prevent="touchEnd">
  6. <div class="items" :style="{'transform':`translateX(${-(currentIndex * bl)}%)`,'transition':moveDistance !== 0 ? 'none' : 'transform 0.3s ease'}">
  7. <div class="item" v-for="(item,index) in slides" :key="index">
  8. <image :src="item" mode="widthFix" @touchstart="e=>touchStart2(e,item)" @touchend="touchEnd2"></image>
  9. </div>
  10. </div>
  11. </div>
  12. <div class="bottom">
  13. <div class="zt_btn" @tap="askReport">对报告提问</div>
  14. </div>
  15. </view>
  16. </template>
  17. <script>
  18. export default {
  19. data(){
  20. return {
  21. pdfUrl:'',
  22. fileName:'',
  23. slides:[],
  24. startX: 0,
  25. currentIndex: 0,
  26. moveDistance: 0,
  27. bl:0,
  28. touchStartTime: 0,
  29. longPressTimeout: null
  30. }
  31. },
  32. onLoad(option) {
  33. this.pdfUrl = option.pdfUrl;
  34. this.fileName = option.fileName;
  35. this.getDetail(option.reportId);
  36. },
  37. methods:{
  38. getDetail(reportId){
  39. this.$api.get('/core/report/member/viewReport/'+reportId).then(res=>{
  40. if(res.data.code!==0) return this.$showToast(res.data.msg)
  41. this.slides = res.data.data;
  42. this.bl = 100/res.data.data.length;
  43. })
  44. },
  45. askReport(){
  46. uni.navigateTo({
  47. url:`/pages/reportAsk?pdfUrl=${this.pdfUrl}&fileName=${this.fileName}`
  48. })
  49. },
  50. touchStart(event) {
  51. this.startX = event.touches[0].clientX;
  52. this.moveDistance = 0;
  53. },
  54. touchMove(event) {
  55. const currentX = event.touches[0].clientX;
  56. this.moveDistance = currentX - this.startX;
  57. },
  58. touchEnd() {
  59. if (this.moveDistance > 50 && this.currentIndex > 0) {
  60. this.currentIndex--;
  61. } else if (this.moveDistance < -50 && this.currentIndex < this.slides.length - 1) {
  62. this.currentIndex++;
  63. }
  64. this.moveDistance = 0; // 重置移动距离
  65. },
  66. touchStart2(e,img) {
  67. this.touchStartTime = Date.now();
  68. this.longPressTimeout = setTimeout(() => {
  69. this.previewImage(img);
  70. }, 1000);
  71. },
  72. touchEnd2() {
  73. clearTimeout(this.longPressTimeout);
  74. },
  75. previewImage(img) {
  76. uni.previewImage({
  77. urls: [img]
  78. });
  79. }
  80. }
  81. }
  82. </script>
  83. <style scoped lang="less">
  84. .page{
  85. padding: 0 24px 192rpx;
  86. box-sizing: border-box;
  87. background: #FFFFFF;
  88. .pdf{
  89. width: 100%;
  90. overflow-x: hidden;
  91. position: relative;
  92. .items{
  93. display: flex;
  94. width: fit-content;
  95. .item{
  96. width: 702rpx;
  97. flex: 1;
  98. image{
  99. width: 100%;
  100. }
  101. }
  102. }
  103. }
  104. .bottom{
  105. width: 100%;
  106. height: 172rpx;
  107. background: #FFFFFF;
  108. box-shadow: 0rpx -2rpx 8rpx 0rpx rgba(0,0,0,0.06);
  109. padding: 34rpx 40rpx;
  110. box-sizing: border-box;
  111. position: fixed;
  112. left: 0;
  113. bottom: 0;
  114. }
  115. }
  116. </style>