reportDetail.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  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+100)+'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. slides:[],
  23. startX: 0,
  24. currentIndex: 0,
  25. moveDistance: 0,
  26. bl:0,
  27. touchStartTime: 0,
  28. longPressTimeout: null
  29. }
  30. },
  31. onLoad(option) {
  32. this.pdfUrl = option.pdfUrl;
  33. this.getDetail(option.reportId);
  34. },
  35. methods:{
  36. getDetail(reportId){
  37. this.$api.get('/core/report/member/viewReport/'+reportId).then(res=>{
  38. if(res.data.code!==0) return this.$showToast(res.data.msg)
  39. this.slides = res.data.data;
  40. this.bl = 100/res.data.data.length;
  41. })
  42. },
  43. askReport(){
  44. uni.navigateTo({
  45. url:`/pages/reportAsk?pdf=${this.pdfUrl}`
  46. })
  47. },
  48. touchStart(event) {
  49. this.startX = event.touches[0].clientX;
  50. this.moveDistance = 0;
  51. },
  52. touchMove(event) {
  53. const currentX = event.touches[0].clientX;
  54. this.moveDistance = currentX - this.startX;
  55. },
  56. touchEnd() {
  57. if (this.moveDistance > 50 && this.currentIndex > 0) {
  58. this.currentIndex--;
  59. } else if (this.moveDistance < -50 && this.currentIndex < this.slides.length - 1) {
  60. this.currentIndex++;
  61. }
  62. this.moveDistance = 0; // 重置移动距离
  63. },
  64. touchStart2(e,img) {
  65. this.touchStartTime = Date.now();
  66. this.longPressTimeout = setTimeout(() => {
  67. this.previewImage(img);
  68. }, 1000);
  69. },
  70. touchEnd2() {
  71. clearTimeout(this.longPressTimeout);
  72. },
  73. previewImage(img) {
  74. uni.previewImage({
  75. urls: [img]
  76. });
  77. }
  78. }
  79. }
  80. </script>
  81. <style scoped lang="less">
  82. .page{
  83. padding: 0 24px 192rpx;
  84. box-sizing: border-box;
  85. background: #FFFFFF;
  86. .pdf{
  87. width: 100%;
  88. overflow-x: hidden;
  89. position: relative;
  90. .items{
  91. display: flex;
  92. width: fit-content;
  93. .item{
  94. width: 702rpx;
  95. flex: 1;
  96. image{
  97. width: 100%;
  98. }
  99. }
  100. }
  101. }
  102. .bottom{
  103. width: 100%;
  104. height: 172rpx;
  105. background: #FFFFFF;
  106. box-shadow: 0rpx -2rpx 8rpx 0rpx rgba(0,0,0,0.06);
  107. padding: 34rpx 40rpx;
  108. box-sizing: border-box;
  109. position: fixed;
  110. left: 0;
  111. bottom: 0;
  112. }
  113. }
  114. </style>