Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
CFFP-HB
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chao Sun
CFFP-HB
Commits
8a87023f
Commit
8a87023f
authored
Jun 23, 2025
by
yuzhenWang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加客服按钮
parent
9b3d8abf
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
94 additions
and
75 deletions
+94
-75
components/FloatingButton/FloatingButton.vue
+79
-31
main.js
+0
-31
pages/index/index.vue
+1
-2
pages/personalCenter/personalCenter.vue
+3
-0
static/font1/demo_index.html
+5
-5
static/font1/iconfont.css
+4
-4
static/font1/iconfont.json
+2
-2
static/font1/iconfont.ttf
+0
-0
static/font1/iconfont.woff
+0
-0
static/font1/iconfont.woff2
+0
-0
static/logo1.png
+0
-0
No files found.
components/FloatingButton/FloatingButton.vue
View file @
8a87023f
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
<!-- 悬浮按钮 -->
<!-- 悬浮按钮 -->
<view
<view
class=
"floating-button"
class=
"floating-button"
:style=
"
{
left: buttonLeft + 'px', top: buttonTop + '
px' }"
:style=
"
{
right: buttonRight + 'rpx', bottom: buttonBottom + 'r
px' }"
@touchstart="handleTouchStart"
@touchstart="handleTouchStart"
@touchmove="handleTouchMove"
@touchmove="handleTouchMove"
@touchend="handleTouchEnd"
@touchend="handleTouchEnd"
...
@@ -11,8 +11,8 @@
...
@@ -11,8 +11,8 @@
<!-- 默认内容 -->
<!-- 默认内容 -->
<slot>
<slot>
<view
class=
"consultBtn"
>
<view
class=
"consultBtn"
>
<text
class=
"iconfont icon-kefu"
></text
>
<view
class=
"iconfont icon-kefu"
></view
>
<text>
咨询客服
</text
>
<view>
咨询客服
</view
>
</view>
</view>
</slot>
</slot>
</view>
</view>
...
@@ -23,38 +23,69 @@ export default {
...
@@ -23,38 +23,69 @@ export default {
name
:
'FloatingButton'
,
name
:
'FloatingButton'
,
data
()
{
data
()
{
return
{
return
{
button
Left
:
310
,
// 初始位置
button
Right
:
10
,
// 初始位置,单位rpx
button
Top
:
200
,
// 初始位置
button
Bottom
:
200
,
// 初始位置,单位rpx
startX
:
0
,
startX
:
0
,
startY
:
0
,
startY
:
0
,
isDragging
:
false
isDragging
:
false
,
windowWidth
:
0
,
windowHeight
:
0
,
buttonWidth
:
140
,
// 按钮宽度,单位rpx
buttonHeight
:
140
// 按钮高度,单位rpx
}
}
},
},
mounted
()
{
this
.
updateWindowSize
();
// 监听窗口变化
uni
.
onWindowResize
(()
=>
{
this
.
updateWindowSize
();
});
},
methods
:
{
methods
:
{
// 更新窗口尺寸
updateWindowSize
()
{
const
systemInfo
=
uni
.
getSystemInfoSync
();
this
.
windowWidth
=
systemInfo
.
windowWidth
;
this
.
windowHeight
=
systemInfo
.
windowHeight
;
},
// 触摸开始事件
// 触摸开始事件
handleTouchStart
(
event
)
{
handleTouchStart
(
event
)
{
const
touch
=
event
.
touches
[
0
];
const
touch
=
event
.
touches
[
0
];
this
.
startX
=
touch
.
clientX
-
this
.
buttonLeft
;
// 记录触摸点相对于按钮右下角的偏移量
this
.
startY
=
touch
.
clientY
-
this
.
buttonTop
;
this
.
startX
=
touch
.
clientX
-
(
this
.
windowWidth
-
this
.
rpxToPx
(
this
.
buttonRight
));
this
.
startY
=
touch
.
clientY
-
(
this
.
windowHeight
-
this
.
rpxToPx
(
this
.
buttonBottom
));
this
.
isDragging
=
false
;
this
.
isDragging
=
false
;
},
},
// 触摸移动事件
// 触摸移动事件
handleTouchMove
(
event
)
{
handleTouchMove
(
event
)
{
event
.
preventDefault
();
// 阻止默认滚动行为
event
.
preventDefault
();
// 阻止默认滚动行为
const
touch
=
event
.
touches
[
0
];
const
touch
=
event
.
touches
[
0
];
this
.
buttonLeft
=
touch
.
clientX
-
this
.
startX
;
this
.
buttonTop
=
touch
.
clientY
-
this
.
startY
;
// 计算新的right和bottom值(像素单位)
let
newRight
=
this
.
windowWidth
-
touch
.
clientX
+
this
.
startX
;
let
newBottom
=
this
.
windowHeight
-
touch
.
clientY
+
this
.
startY
;
// 转换为rpx单位
this
.
buttonRight
=
this
.
pxToRpx
(
newRight
);
this
.
buttonBottom
=
this
.
pxToRpx
(
newBottom
);
this
.
isDragging
=
true
;
this
.
isDragging
=
true
;
// 限制按钮不超出屏幕
// 限制按钮不超出屏幕(rpx单位)
const
windowWidth
=
uni
.
getSystemInfoSync
().
windowWidth
;
const
maxRight
=
this
.
windowWidth
-
this
.
rpxToPx
(
this
.
buttonWidth
);
const
windowHeight
=
uni
.
getSystemInfoSync
().
windowHeight
;
const
maxBottom
=
this
.
windowHeight
-
this
.
rpxToPx
(
this
.
buttonHeight
);
const
buttonSize
=
80
;
// 按钮大小
if
(
this
.
buttonLeft
<
0
)
this
.
buttonLeft
=
0
;
if
(
newRight
<
0
)
{
if
(
this
.
buttonLeft
>
windowWidth
-
buttonSize
)
this
.
buttonLeft
=
windowWidth
-
buttonSize
;
this
.
buttonRight
=
this
.
pxToRpx
(
0
);
if
(
this
.
buttonTop
<
0
)
this
.
buttonTop
=
0
;
}
else
if
(
newRight
>
maxRight
)
{
if
(
this
.
buttonTop
>
windowHeight
-
buttonSize
)
this
.
buttonTop
=
windowHeight
-
buttonSize
;
this
.
buttonRight
=
this
.
pxToRpx
(
maxRight
);
}
if
(
newBottom
<
0
)
{
this
.
buttonBottom
=
this
.
pxToRpx
(
0
);
}
else
if
(
newBottom
>
maxBottom
)
{
this
.
buttonBottom
=
this
.
pxToRpx
(
maxBottom
);
}
},
},
// 触摸结束事件
// 触摸结束事件
handleTouchEnd
()
{
handleTouchEnd
()
{
...
@@ -64,7 +95,30 @@ export default {
...
@@ -64,7 +95,30 @@ export default {
},
},
// 点击事件
// 点击事件
handleClick
()
{
handleClick
()
{
this
.
$emit
(
'floatingButton'
);
// 现在还没转化成小程序,暂时放在这
// #ifdef MP-WEIXIN
uni
.
openCustomerServiceChat
({
extInfo
:
{
url
:
'https://work.weixin.qq.com/kfid/kfc08c55f4170e7fc9e'
},
corpId
:
'ww43cac1cf9dd6a3d0'
,
// 客服会话按钮打开后,在微信客服会话按钮处理的事件类型
showMessageCard
:
true
,
sendMessageTitle
:
(
uni
.
getStorageSync
(
'hoservice_mobileNo'
)?(
uni
.
getStorageSync
(
'hoservice_mobileNo'
)
+
","
)
:
""
)
+
"进入个人中心-->咨询客服"
,
sendMessagePath
:
`/pages/index/mySelf.html`
,
//sendMessageImg: cardItem.value['list'][0]['itemImg']
});
// #endif
// #ifndef MP-WEIXIN
window
.
open
(
'https://work.weixin.qq.com/kfid/kfc08c55f4170e7fc9e'
)
// #endif
},
// rpx转px
rpxToPx
(
rpx
)
{
return
rpx
/
750
*
this
.
windowWidth
;
},
// px转rpx
pxToRpx
(
px
)
{
return
px
*
750
/
this
.
windowWidth
;
}
}
}
}
}
}
...
@@ -84,20 +138,15 @@ export default {
...
@@ -84,20 +138,15 @@ export default {
cursor
:
pointer
;
cursor
:
pointer
;
user-select
:
none
;
user-select
:
none
;
z-index
:
9999
;
z-index
:
9999
;
background-color
:
#007AFF
;
/* 默认背景色 */
box-shadow
:
0
4px
8px
rgba
(
0
,
0
,
0
,
0.2
);
/* 添加阴影效果 */
.consultBtn{
.consultBtn{
display
:
flex
;
align-items
:
center
;
flex-direction
:
column
;
color
:
#20279B
;
color
:
#20279B
;
font-size
:
28
rpx
;
font-size
:
28
rpx
;
//
.icon-kefu{
.icon-kefu{
//
width
:
60
rpx
;
font-size
:
60
rpx
;
//
height
:
60
rpx
;
}
//
color
:
#20279B
;
//
}
}
}
}
}
</
style
>
</
style
>
\ No newline at end of file
main.js
View file @
8a87023f
// import App from './App';
// // #ifndef VUE3
// import Vue from 'vue'
// App.mpType = 'app'
// const app = new Vue({
// ...App
// })
// app.$mount()
// // #endif
// // #ifdef VUE3
// import { createSSRApp } from 'vue'
// export function createApp() {
// const app = createSSRApp(App)
// return {
// app
// }
// }
// // #endif
// //#ifdef H5
// window.sessionStorage.setItem('firstEntryUrl',window.location.href.split('#')[0])
// // #endif
import
App
from
'./App'
;
import
App
from
'./App'
;
import
FloatingButton
from
'@/components/FloatingButton/FloatingButton.vue'
;
// #ifndef VUE3
// #ifndef VUE3
import
Vue
from
'vue'
import
Vue
from
'vue'
App
.
mpType
=
'app'
App
.
mpType
=
'app'
// 全局注册悬浮按钮组件
Vue
.
component
(
'FloatingButton'
,
FloatingButton
);
const
app
=
new
Vue
({
const
app
=
new
Vue
({
...
App
...
App
})
})
...
...
pages/index/index.vue
View file @
8a87023f
<
template
>
<
template
>
<view
class=
"container"
>
<view
class=
"container"
>
<!-- 使用默认图标的悬浮按钮 -->
<FloatingButton
></FloatingButton>
<view
class=
"homeHeader"
>
<view
class=
"homeHeader"
>
<view
class=
"top"
>
<view
class=
"top"
>
<view
class=
"one"
>
<view
class=
"one"
>
...
@@ -193,6 +191,7 @@
...
@@ -193,6 +191,7 @@
import
search
from
'@/components/search/search.vue'
;
import
search
from
'@/components/search/search.vue'
;
import
courseItem
from
"@/components/courseItem/courseItem.vue"
;
import
courseItem
from
"@/components/courseItem/courseItem.vue"
;
import
{
companyInfo
}
from
"@/environments/environment"
;
import
{
companyInfo
}
from
"@/environments/environment"
;
export
default
{
export
default
{
data
()
{
data
()
{
return
{
return
{
...
...
pages/personalCenter/personalCenter.vue
View file @
8a87023f
<
template
>
<
template
>
<view
class=
"container"
>
<view
class=
"container"
>
<!-- 使用默认图标的悬浮按钮 -->
<FloatingButton
></FloatingButton>
<view
class=
"myHeader"
>
<view
class=
"myHeader"
>
<view
class=
"left"
@
click=
"userinfo()"
>
<view
class=
"left"
@
click=
"userinfo()"
>
<view
<view
...
@@ -90,6 +92,7 @@
...
@@ -90,6 +92,7 @@
import
tabBar
from
'../../components/tabBar/tabBar.vue'
;
import
tabBar
from
'../../components/tabBar/tabBar.vue'
;
import
api
from
"@/api/api"
;
import
api
from
"@/api/api"
;
import
{
companyInfo
}
from
"@/environments/environment"
;
import
{
companyInfo
}
from
"@/environments/environment"
;
import
FloatingButton
from
'@/components/FloatingButton/FloatingButton.vue'
;
export
default
{
export
default
{
data
()
{
data
()
{
return
{
return
{
...
...
static/font1/demo_index.html
View file @
8a87023f
...
@@ -55,9 +55,9 @@
...
@@ -55,9 +55,9 @@
<ul
class=
"icon_lists dib-box"
>
<ul
class=
"icon_lists dib-box"
>
<li
class=
"dib"
>
<li
class=
"dib"
>
<span
class=
"icon iconfont"
>

604
;
</span>
<span
class=
"icon iconfont"
>

116
;
</span>
<div
class=
"name"
>
客服
</div>
<div
class=
"name"
>
客服
</div>
<div
class=
"code-name"
>
&
#xe
604
;
</div>
<div
class=
"code-name"
>
&
#xe
116
;
</div>
</li>
</li>
<li
class=
"dib"
>
<li
class=
"dib"
>
...
@@ -270,9 +270,9 @@
...
@@ -270,9 +270,9 @@
<pre><code
class=
"language-css"
<pre><code
class=
"language-css"
>
@font-face {
>
@font-face {
font-family: 'iconfont';
font-family: 'iconfont';
src: url('iconfont.woff2?t=175064
443249
7') format('woff2'),
src: url('iconfont.woff2?t=175064
929285
7') format('woff2'),
url('iconfont.woff?t=175064
443249
7') format('woff'),
url('iconfont.woff?t=175064
929285
7') format('woff'),
url('iconfont.ttf?t=175064
443249
7') format('truetype');
url('iconfont.ttf?t=175064
929285
7') format('truetype');
}
}
</code></pre>
</code></pre>
<h3
id=
"-iconfont-"
>
第二步:定义使用 iconfont 的样式
</h3>
<h3
id=
"-iconfont-"
>
第二步:定义使用 iconfont 的样式
</h3>
...
...
static/font1/iconfont.css
View file @
8a87023f
@font-face
{
@font-face
{
font-family
:
"iconfont"
;
/* Project id 4933433 */
font-family
:
"iconfont"
;
/* Project id 4933433 */
src
:
url('iconfont.woff2?t=175064
443249
7')
format
(
'woff2'
),
src
:
url('iconfont.woff2?t=175064
929285
7')
format
(
'woff2'
),
url('iconfont.woff?t=175064
443249
7')
format
(
'woff'
),
url('iconfont.woff?t=175064
929285
7')
format
(
'woff'
),
url('iconfont.ttf?t=175064
443249
7')
format
(
'truetype'
);
url('iconfont.ttf?t=175064
929285
7')
format
(
'truetype'
);
}
}
.iconfont
{
.iconfont
{
...
@@ -14,7 +14,7 @@
...
@@ -14,7 +14,7 @@
}
}
.icon-kefu
:before
{
.icon-kefu
:before
{
content
:
"\e
604
"
;
content
:
"\e
116
"
;
}
}
.icon-shuangyoujiantou
:before
{
.icon-shuangyoujiantou
:before
{
...
...
static/font1/iconfont.json
View file @
8a87023f
...
@@ -9,8 +9,8 @@
...
@@ -9,8 +9,8 @@
"icon_id"
:
"518189"
,
"icon_id"
:
"518189"
,
"name"
:
"客服"
,
"name"
:
"客服"
,
"font_class"
:
"kefu"
,
"font_class"
:
"kefu"
,
"unicode"
:
"e
604
"
,
"unicode"
:
"e
116
"
,
"unicode_decimal"
:
5
8884
"unicode_decimal"
:
5
7622
},
},
{
{
"icon_id"
:
"6999657"
,
"icon_id"
:
"6999657"
,
...
...
static/font1/iconfont.ttf
View file @
8a87023f
No preview for this file type
static/font1/iconfont.woff
View file @
8a87023f
No preview for this file type
static/font1/iconfont.woff2
View file @
8a87023f
No preview for this file type
static/logo1.png
View file @
8a87023f
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment