ZZJ
2022-07-28 fade1fbf16b2fb85dad87e3592d4ac9648e4d449
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
<template>
  <div class="Connect">
    <!-- 固定按钮 -->
    <div
      class="connectBox"
      @mouseenter="showConnectBox"
      @mouseleave="hiddenConnectBox"
      v-if="isShowConnectBox"
    >
      <div class="tele">
        <div class="title">
          <span class="iconfont">&#xe613;</span>售前咨询电话
        </div>
        <div class="teleNum">010-84155885</div>
      </div>
 
      <div class="advice" @click="jump1()">
        <div class="title"><span class="iconfont">&#xe612;</span>建议反馈</div>
        <div class="des">您的每一条建议声音,我们都认真对待</div>
      </div>
    </div>
 
    <!--  <div
      class="connect"
      @mouseenter="showConnectBox"
      @mouseleave="hiddenConnectBox"
    >
      <span class="iconfont">&#xe611;</span>联系我们
    </div> -->
    <div class="backToTop iconfont" v-if="showConnect" @click="backToTop">
      &#xe610;
    </div>
  </div>
</template>
 
<script>
export default {
  data() {
    return {
      isShowConnectBox: false, //固定定位弹层
      showConnect: false, //显示联系我们与回到顶部
    };
  },
  created() {
    window.addEventListener("scroll", this.scrollListener);
  },
  destroyed() {
    window.removeEventListener("scroll", this.scrollListener);
  },
  methods: {
    // 回到顶部
    backToTop() {
      const _this = this;
      cancelAnimationFrame(_this.timer);
      _this.timer = requestAnimationFrame(function fn() {
        var oTop =
          document.body.scrollTop || document.documentElement.scrollTop;
        if (oTop > 0) {
          document.body.scrollTop = document.documentElement.scrollTop =
            oTop - 90;
          //这里的100代表回到顶部的速度,可以按照实际情况调整
          _this.timer = requestAnimationFrame(fn);
        } else {
          cancelAnimationFrame(_this.timer);
        }
      });
    },
    showConnectBox() {
      if (this.ConnectTimer) {
        clearTimeout(this.ConnectTimer);
        this.ConnectTimer = null;
      }
      this.isShowConnectBox = true;
    },
    hiddenConnectBox() {
      const _this = this;
      this.ConnectTimer = setTimeout(() => {
        _this.isShowConnectBox = false;
      }, 100);
    },
    //添加滚动监听
    scrollListener() {
      //页面滑动触发事件 (滚动条移动则调用是否显示返回顶部按钮事件)
      var a = document.documentElement.clientHeight; // 滚动容器的可视高
      var b = document.documentElement.scrollTop; // 滚动条距离顶部的高度
      var c = document.documentElement.scrollHeight; // 滚动容器的整个高度
 
      if (c === a + b) {
        //当滚动容器的可视高+滚动容器滚动了的高度(滚动条顶部距离滚动容器顶部的距离) = 滚动容器的整个高度时,说明滚动条到底了
        this.showConnect = true;
      } else {
        this.showConnect = false;
      }
 
      //检查滚动条是否在顶部,控制返回顶部按钮的隐藏和显示
    },
    jump1() {
      window.open("http://smartai.com/consult");
    },
  },
};
</script>
 
<style lang="scss" scoped>
.connectBox {
  position: fixed;
  right: 94px;
  top: 662px;
  padding: 10px 0;
  box-sizing: border-box;
  width: 268px;
  height: 149px;
  background: #ffffff;
  box-shadow: 0px 4px 12px rgba(0, 51, 128, 0.18);
  border-radius: 8px;
  z-index: 2;
 
  .tele,
  .advice {
    box-sizing: border-box;
    padding: 0 20px 0 10px;
    overflow: hidden;
    height: 64px;
 
    &:hover {
      background-color: #fafafa;
 
      span,
      .title,
      .teleNum,
      .des {
        color: #0065ff;
      }
    }
  }
 
  .advice {
    cursor: pointer;
  }
 
  .title {
    display: flex;
    align-items: center;
    margin-top: 8px;
    font-weight: bold;
    font-size: 14px;
  }
 
  span {
    margin-right: 10px;
    font-size: 24px;
    font-weight: 700;
  }
 
  .teleNum {
    margin-top: 6px;
    margin-left: 34px;
    color: #0065ff;
    font-size: 12px;
  }
 
  .des {
    margin-top: 6px;
    margin-left: 34px;
    color: #666666;
    font-size: 12px;
  }
}
 
.connect {
  position: fixed;
  box-sizing: border-box;
  width: 44px;
  height: 120px;
  top: 662px;
  right: 40px;
  z-index: 2;
  padding: 10px 14px;
  background: #ffffff;
  box-shadow: 0px 4px 8px rgba(85, 93, 106, 0.12);
  border-radius: 22px;
  text-align: center;
  line-height: 20px;
  font-size: 14px;
  cursor: pointer;
 
  &:hover {
    color: #0065ff;
    box-shadow: 0px 4px 12px rgba(0, 51, 128, 0.18);
  }
}
 
.backToTop {
  position: fixed;
  right: 40px;
  top: 802px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  color: #666;
  text-align: center;
  line-height: 44px;
  font-size: 18px;
  background-color: #fff;
  box-shadow: 0px 4px 8px rgba(85, 93, 106, 0.12);
  cursor: pointer;
 
  &:hover {
    color: #0065ff;
    box-shadow: 0px 4px 12px rgba(0, 51, 128, 0.18);
  }
}
</style>