宜呗小程序--微信小程序
Lzk
2025-08-05 b7bcaf556aa2424e808b6e6426ab22df9cfe11c1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
<template>
  <view
      :style="{bottom: bot + 'rpx'}"
      class="loan-sfkef"
      @tap="handleGoToSupport"
      @touchstart="handleTouchStart"
      @touchmove="handleTouchMove"
      @touchend="handleTouchEnd"
      @mousedown="handleMouseDown"
      @mousemove="handleMouseMove"
      @mouseup="handleMouseUp"
      @mouseleave="handleMouseLeave"
  >
    <image :src="`${$images}/static/img/hskf.png`"></image>
  </view>
</template>
 
<script>
export default {
  name: "index",
  props: {
    bottom: {
      type: Number,
      default: 270
    }
  },
  data() {
    return {
      bot: 270,
      isDragging: false,
      startY: 0,
      startBottom: 0
    };
  },
  created() {
    this.bot = this.bottom;
  },
  methods: {
    handleGoToSupport() {
      uni.navigateTo({
        url: '/pages/web/index'
      });
    },
    handleTouchStart(event) {
      this.isDragging = true;
      this.startY = event.touches[0].clientY;
      this.startBottom = this.bot;
    },
    handleTouchMove(event) {
      if (this.isDragging) {
        const deltaY = event.touches[0].clientY - this.startY;
        this.updateBot(this.startBottom - deltaY);
      }
    },
    handleTouchEnd() {
      this.isDragging = false;
    },
    handleMouseDown(event) {
      this.isDragging = true;
      this.startY = event.clientY;
      this.startBottom = this.bot;
    },
    handleMouseMove(event) {
      if (this.isDragging) {
        const deltaY = event.clientY - this.startY;
        this.updateBot(this.startBottom - deltaY);
      }
    },
    handleMouseUp() {
      this.isDragging = false;
    },
    handleMouseLeave() {
      this.isDragging = false;
    },
    updateBot(newBottom) {
      // 添加边界检查
      const minHeight = 0;
      const maxHeight = window.innerHeight - 162; // 假设组件高度为 162rpx
      this.bot = Math.max(minHeight, Math.min(maxHeight, newBottom));
    }
  }
};
</script>
 
<style scoped lang="scss">
.loan-sfkef {
  width: 140rpx;
  height: 162rpx;
  position: fixed;
  right: 20rpx;
  bottom: 270rpx;
  z-index: 66;
  image {
    width: 140rpx;
    height: 162rpx;
  }
}
</style>