boka-human-cliend-v2 0.0.34 → 0.0.35
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/boka-human-v2.common.js +22 -22
- package/dist/boka-human-v2.css +1 -1
- package/dist/boka-human-v2.umd.js +22 -22
- package/dist/boka-human-v2.umd.min.js +2 -2
- package/package.json +2 -1
- package/src/BokaHumanV2.vue +6 -5
- package/src/demo/App.vue +8 -4
- package/src/demo/Hello.vue +257 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "boka-human-cliend-v2",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.35",
|
|
4
4
|
"main": "dist/boka-human-v2.umd.js",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"serve": "vue-cli-service serve src/demo/main.js",
|
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
21
|
"interactjs": "^1.10.27",
|
|
22
|
+
"vconsole": "^2.5.2",
|
|
22
23
|
"viewerjs": "^1.11.7"
|
|
23
24
|
}
|
|
24
25
|
}
|
package/src/BokaHumanV2.vue
CHANGED
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
<div class="boka-human-v2">
|
|
3
3
|
<div class="humanEnterIcon" id="humanEnterIcon" :class="[unreadCount>0?'unreadCount':'']" @click="changeChatViewVisible">
|
|
4
4
|
<template v-if="unreadCount<1">
|
|
5
|
-
|
|
5
|
+
<!--<svg t="1755741820144" viewBox="0 0 1051 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="1470" width="32" height="32"><path d="M135.73310782 546.11486502v91.39864856a68.41216214 68.41216214 0 0 0 136.82432428 0v-91.39864856a68.41216214 68.41216214 0 0 0-136.82432428 0z m628.77618292 174.3141893A113.58699363 113.58699363 0 0 1 728.63851358 637.51351358v-91.39864856A114.02026996 114.02026996 0 0 1 841.86064218 432.18581069C830.16216214 266.51435782 692.03800637 135.73310782 523.40202716 135.73310782 354.74324363 135.73310782 216.64189218 266.51435782 204.94341214 432.18581069A114.0886821 114.0886821 0 0 1 318.16554074 546.11486502v91.39864856a114.02026996 114.02026996 0 0 1-228.04054074 0v-91.39864856a114.02026996 114.02026996 0 0 1 68.64020288-104.53378353C165.83445926 246.28716214 326.375 90.125 523.40202716 90.125s357.5675679 156.16216214 364.63682428 351.45608149A114.0886821 114.0886821 0 0 1 956.67905432 546.11486502v91.39864856a114.02026996 114.02026996 0 0 1-152.26266934 107.3386821 387.89695926 387.89695926 0 0 1-155.61486503 99.8817572A79.76858148 79.76858148 0 0 1 568.78209424 922.47297284h-68.00168848c-44.23986502 0-80.01942573-35.57432428-80.01942572-79.8141893 0-44.17145288 35.66554074-79.81418931 80.04222922-79.8141893h67.95608148c28.80151995 0 54 15.05067573 68.09290494 37.74071008a342.17483148 342.17483148 0 0 0 127.63429074-80.15625zM774.2466214 546.11486502v91.39864856a68.41216214 68.41216214 0 0 0 136.82432428 0v-91.39864856a68.41216214 68.41216214 0 0 0-136.82432427 0zM500.82601358 876.86486502h67.95608066c19.20101358 0 34.43412141-15.23310782 34.43412222-34.20608148 0-18.99577716-15.30151996-34.20608149-34.43412222-34.20608066h-67.95608066c-19.20101358 0-34.43412141 15.23310782-34.4341214 34.20608066 0 18.99577716 15.30151996 34.20608149 34.4341214 34.20608148z" p-id="1471"></path></svg>-->
|
|
6
|
+
<img @touchstart="changeChatViewVisible" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEIAAABACAYAAACunKHjAAAF70lEQVR4Aeyai5HbIBCGrasnPeSuipQTp5t0kUsRqUf5P45lFoRkJMtInnGGNYjHsvuxoMfl7dLp3ziO75JrlD/KTVQMya6tz7WTaWGah4KQezgfHNRsfyQ/o7wrN1ExJLu2Pj81nsR44NAeOj7i5yEgZD2GjzIY53EA0eWmxFjgAESqx4dEyq4gZKUBwPA5rz/V4OWXrk2sXlWziUgByq5AdgEhAGELy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Ljx/f2m3ejciHD2+QNQ7z96Pj9VllNXq1xdqJLEAinTMmk0zEV2WLIzqr9mKY2QOEHl0gYS0SkCwpRgKEx41U/JihAYpeQzb6yh1Z+OogW86ppfGSU9hPp4Rum+nkIRANjvz7MREWBjDr6xOqbZArUiT8DBiUqnyEt2c8ClvZjc/q2YhFhZGrKGFAKkZCUlI0HXdccnTOF6Mk+3iQQjCAyJLX/1UozYgpOEwnauiHsZRyRqywlbE0XsUAdABDKsfrytTXSVSwIBt/4lA2Dqhg0xH+UMwVqPywBQZPXwh47kWh2yqir2p9FhJROklRUB046NlZgvISDC1GxmsIBvaRSo4hKIPhu2DrrrO9Ylm+CKAfccy3jMRxhPyNz6ghzO/lTP40P20D5qIH0UZYSh/cmCGjoBkLGs4LJKSZvFCKHCAEgUtNx9+HdBUSEMFlBgeAuVRM1ZYmxNQC2FYCcDVh70QVExaiwgjp/OJRrwiGNk5WhoYo2tgFCOVTe89MLhH+rBULLChIppW84jfMI5bJ983UvEN5AD8XXl+VyKwBwdwA26REgOPlLJ82e2ZxtNNu4Q0MvEGWY250gQNFhWubcHTggzcVdt4Ep9XkXEFpNHEH83DiKwzUpI6YE6fXsUu4CIlqKMyWM2LSYcTZsGLeoc9LYDQRRIeGNtRUIznM4ttxhJo6tregGwgwTDJ4bcJBnBcBkonZL9AGGDX1o/h8AAP//85TBrAAAAAZJREFUAwCgHqvQJpFL5wAAAABJRU5ErkJggg==" alt="" style="width: 100%;">
|
|
6
7
|
</template>
|
|
7
8
|
<template v-else>
|
|
8
9
|
{{unreadCount>99?'99+' : unreadCount}}
|
|
@@ -169,9 +170,9 @@ export default {
|
|
|
169
170
|
tmpIcon.setAttribute('data-y', defy);
|
|
170
171
|
|
|
171
172
|
interact('.humanEnterIcon')
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
173
|
+
.on('tap', function (event) {
|
|
174
|
+
event.preventDefault()
|
|
175
|
+
}).draggable({
|
|
175
176
|
inertia: true,
|
|
176
177
|
modifiers: [
|
|
177
178
|
interact.modifiers.restrictRect({
|
|
@@ -259,7 +260,7 @@ export default {
|
|
|
259
260
|
<style lang="less">
|
|
260
261
|
/* 可根据需要添加样式 */
|
|
261
262
|
.boka-human-v2 {
|
|
262
|
-
overflow: hidden;
|
|
263
|
+
//overflow: hidden;
|
|
263
264
|
position: fixed;
|
|
264
265
|
top: 0;
|
|
265
266
|
left: 0;
|
package/src/demo/App.vue
CHANGED
|
@@ -1,17 +1,21 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div id="app">
|
|
3
|
-
|
|
3
|
+
===
|
|
4
|
+
<BokaHumanV2 :token="'Bearer 8937d9ccf21264a83c3cb29aaf16dc7'" :product="'manageCenterPlus'" :sub-cust-type="'standard'"/>
|
|
5
|
+
<!--<Hello :token="'Bearer 8937d9ccf21264a83c3cb29aaf16dc7'" :product="'manageCenterPlus'" :sub-cust-type="'standard'"/>-->
|
|
6
|
+
---
|
|
4
7
|
</div>
|
|
5
8
|
</template>
|
|
6
9
|
|
|
7
10
|
<script>
|
|
8
|
-
import
|
|
9
|
-
|
|
11
|
+
import BokaHumanV2 from '../BokaHumanV2.vue'
|
|
12
|
+
import Hello from './Hello.vue'
|
|
10
13
|
|
|
11
14
|
export default {
|
|
12
15
|
name: 'App',
|
|
13
16
|
components: {
|
|
14
|
-
BokaHumanV2
|
|
17
|
+
BokaHumanV2:BokaHumanV2,
|
|
18
|
+
Hello
|
|
15
19
|
},
|
|
16
20
|
mounted() {
|
|
17
21
|
|
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="boka-human-v2">
|
|
3
|
+
<div class="humanEnterIcon" id="humanEnterIcon" :class="[unreadCount>0?'unreadCount':'']" @touchstart="changeChatViewVisible">
|
|
4
|
+
<template v-if="unreadCount<1">
|
|
5
|
+
<!--<svg t="1755741820144" viewBox="0 0 1051 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="1470" width="32" height="32"><path d="M135.73310782 546.11486502v91.39864856a68.41216214 68.41216214 0 0 0 136.82432428 0v-91.39864856a68.41216214 68.41216214 0 0 0-136.82432428 0z m628.77618292 174.3141893A113.58699363 113.58699363 0 0 1 728.63851358 637.51351358v-91.39864856A114.02026996 114.02026996 0 0 1 841.86064218 432.18581069C830.16216214 266.51435782 692.03800637 135.73310782 523.40202716 135.73310782 354.74324363 135.73310782 216.64189218 266.51435782 204.94341214 432.18581069A114.0886821 114.0886821 0 0 1 318.16554074 546.11486502v91.39864856a114.02026996 114.02026996 0 0 1-228.04054074 0v-91.39864856a114.02026996 114.02026996 0 0 1 68.64020288-104.53378353C165.83445926 246.28716214 326.375 90.125 523.40202716 90.125s357.5675679 156.16216214 364.63682428 351.45608149A114.0886821 114.0886821 0 0 1 956.67905432 546.11486502v91.39864856a114.02026996 114.02026996 0 0 1-152.26266934 107.3386821 387.89695926 387.89695926 0 0 1-155.61486503 99.8817572A79.76858148 79.76858148 0 0 1 568.78209424 922.47297284h-68.00168848c-44.23986502 0-80.01942573-35.57432428-80.01942572-79.8141893 0-44.17145288 35.66554074-79.81418931 80.04222922-79.8141893h67.95608148c28.80151995 0 54 15.05067573 68.09290494 37.74071008a342.17483148 342.17483148 0 0 0 127.63429074-80.15625zM774.2466214 546.11486502v91.39864856a68.41216214 68.41216214 0 0 0 136.82432428 0v-91.39864856a68.41216214 68.41216214 0 0 0-136.82432427 0zM500.82601358 876.86486502h67.95608066c19.20101358 0 34.43412141-15.23310782 34.43412222-34.20608148 0-18.99577716-15.30151996-34.20608149-34.43412222-34.20608066h-67.95608066c-19.20101358 0-34.43412141 15.23310782-34.4341214 34.20608066 0 18.99577716 15.30151996 34.20608149 34.4341214 34.20608148z" p-id="1471"></path></svg>-->
|
|
6
|
+
<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEIAAABACAYAAACunKHjAAAF70lEQVR4Aeyai5HbIBCGrasnPeSuipQTp5t0kUsRqUf5P45lFoRkJMtInnGGNYjHsvuxoMfl7dLp3ziO75J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jyrJ+MORSGt00LxYr7qklZffxC0v4DEKdxAos6SgYDEB3nPu9ULxBxbV4gXiAigZi9IuIFIhKI2SsiZkBkT5mxTy0707NH9jxQM3amzvvwj4jYqijprzyppbbehZan3FofQPjHZV5AFh9RpYR2/5Ljx/f2m3ejciHD2+QNQ7z96Pj9VllNXq1xdqJLEAinTMmk0zEV2WLIzqr9mKY2QOEHl0gYS0SkCwpRgKEx41U/JihAYpeQzb6yh1Z+OogW86ppfGSU9hPp4Rum+nkIRANjvz7MREWBjDr6xOqbZArUiT8DBiUqnyEt2c8ClvZjc/q2YhFhZGrKGFAKkZCUlI0HXdccnTOF6Mk+3iQQjCAyJLX/1UozYgpOEwnauiHsZRyRqywlbE0XsUAdABDKsfrytTXSVSwIBt/4lA2Dqhg0xH+UMwVqPywBQZPXwh47kWh2yqir2p9FhJROklRUB046NlZgvISDC1GxmsIBvaRSo4hKIPhu2DrrrO9Ylm+CKAfccy3jMRxhPyNz6ghzO/lTP40P20D5qIH0UZYSh/cmCGjoBkLGs4LJKSZvFCKHCAEgUtNx9+HdBUSEMFlBgeAuVRM1ZYmxNQC2FYCcDVh70QVExaiwgjp/OJRrwiGNk5WhoYo2tgFCOVTe89MLhH+rBULLChIppW84jfMI5bJ983UvEN5AD8XXl+VyKwBwdwA26REgOPlLJ82e2ZxtNNu4Q0MvEGWY250gQNFhWubcHTggzcVdt4Ep9XkXEFpNHEH83DiKwzUpI6YE6fXsUu4CIlqKMyWM2LSYcTZsGLeoc9LYDQRRIeGNtRUIznM4ttxhJo6tregGwgwTDJ4bcJBnBcBkonZL9AGGDX1o/h8AAP//85TBrAAAAAZJREFUAwCgHqvQJpFL5wAAAABJRU5ErkJggg==" alt="">
|
|
7
|
+
</template>
|
|
8
|
+
<template v-else>
|
|
9
|
+
{{unreadCount>99?'99+' : unreadCount}}
|
|
10
|
+
</template>
|
|
11
|
+
<!--{{ visible ? '隐藏' : '显示' }}-->
|
|
12
|
+
</div>
|
|
13
|
+
<div class="humanMainView" :class="fullScreen?'full':''" v-show="visible">
|
|
14
|
+
<div class="humanMainHeader my-dialog__header">
|
|
15
|
+
<div class="humanMainHeaderLeft"></div>
|
|
16
|
+
<div class="humanMainHeaderCenter">客服</div>
|
|
17
|
+
<div class="humanMainHeaderRight">
|
|
18
|
+
<span @click="visible=!visible">
|
|
19
|
+
<svg style="display: inline-block;vertical-align: middle;" t="1759046770151" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="9352" width="14" height="14"><path d="M585.412525 512.594747L973.601616 124.418586c19.600808-19.600808 19.600808-51.898182 0-71.49899l-2.120404-2.120404c-19.600808-19.600808-51.898182-19.600808-71.49899 0L511.793131 439.518384 123.61697 50.799192c-19.600808-19.600808-51.898182-19.600808-71.49899 0l-2.120404 2.120404c-20.11798 19.600808-20.11798 51.898182 0 71.49899l388.189091 388.189091L49.997576 900.783838c-19.587879 19.600808-19.587879 51.898182 0 71.49899l2.120404 2.120404c19.600808 19.600808 51.898182 19.600808 71.49899 0L511.793131 586.214141l388.189091 388.176162c19.600808 19.600808 51.898182 19.600808 71.49899 0l2.120404-2.120404c19.600808-19.600808 19.600808-51.898182 0-71.49899L585.412525 512.594747z m0 0" p-id="9353"></path></svg>
|
|
20
|
+
<!--关闭-->
|
|
21
|
+
</span>
|
|
22
|
+
</div>
|
|
23
|
+
</div>
|
|
24
|
+
<iframe id="iframe" :src="src" frameborder="0" allowfullscreen></iframe>
|
|
25
|
+
</div>
|
|
26
|
+
</div>
|
|
27
|
+
</template>
|
|
28
|
+
<script>
|
|
29
|
+
|
|
30
|
+
import interact from "interactjs";
|
|
31
|
+
|
|
32
|
+
export default {
|
|
33
|
+
name: "Hello",
|
|
34
|
+
title: "这里是组件名",
|
|
35
|
+
props: {
|
|
36
|
+
/*fullScreen: {
|
|
37
|
+
type: Boolean,
|
|
38
|
+
default(){
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
}*/
|
|
42
|
+
},
|
|
43
|
+
data() {
|
|
44
|
+
return {
|
|
45
|
+
fullScreen:false,
|
|
46
|
+
visible: false,
|
|
47
|
+
unreadCount: 0,
|
|
48
|
+
src:"https://human.shboka.com?token=Bearer 8937d9ccf21264a83c3cb29aaf16dc7&product=manageCenterPlus&custType=manageCenterPlus&subCustType=standard&source=g8&human=1&isIFrame=true&terminal=&domain=https%3A%2F%2Fgl.boka.vc%3A8082%3A8082&time=1760680460361"
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
mounted(){
|
|
52
|
+
console.log(`%c 客服组件宿主 %c ${location.href}`, 'background: #f00; color: #fff; padding: 2px 2px; border-radius: 3px 0 0 3px;', 'background: #dedede; color: #000; padding: 2px 8px 2px 2px; border-radius: 0 3px 3px 0;')
|
|
53
|
+
console.log(`%c 客服组件属性 `, 'background: #f00; color: #fff; padding: 2px 2px; border-radius: 3px;')
|
|
54
|
+
console.log(this.$props)
|
|
55
|
+
setTimeout(()=>{
|
|
56
|
+
this.icon();
|
|
57
|
+
this.chatMainInitDrag();
|
|
58
|
+
})
|
|
59
|
+
},
|
|
60
|
+
methods: {
|
|
61
|
+
sendMsgToFrame(info){
|
|
62
|
+
let frame = document.querySelector("#iframe");
|
|
63
|
+
frame.contentWindow.postMessage({from:"human",info:info},"*")
|
|
64
|
+
},
|
|
65
|
+
showChat(flag=true){
|
|
66
|
+
this.visible = flag;
|
|
67
|
+
},
|
|
68
|
+
changeChatViewVisible(){
|
|
69
|
+
this.visible=!this.visible;
|
|
70
|
+
if(this.visible){
|
|
71
|
+
this.unreadCount=0;
|
|
72
|
+
|
|
73
|
+
this.sendMsgToFrame({type:"toBottom"});
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
icon(){
|
|
77
|
+
const container = document.body;
|
|
78
|
+
let defx = container.clientWidth-40;
|
|
79
|
+
let defy = Math.min(screen.availHeight,container.clientHeight)-300;
|
|
80
|
+
let tmpIcon = document.querySelector('#humanEnterIcon');
|
|
81
|
+
tmpIcon.style.transform = `translate(${defx}px, ${defy}px)`;
|
|
82
|
+
tmpIcon.setAttribute('data-x', defx);
|
|
83
|
+
tmpIcon.setAttribute('data-y', defy);
|
|
84
|
+
|
|
85
|
+
interact('.humanEnterIcon')
|
|
86
|
+
.on('tap', function (event) {
|
|
87
|
+
event.preventDefault()
|
|
88
|
+
}).draggable({
|
|
89
|
+
inertia: true,
|
|
90
|
+
modifiers: [
|
|
91
|
+
interact.modifiers.restrictRect({
|
|
92
|
+
restriction: 'body',
|
|
93
|
+
endOnly: true
|
|
94
|
+
})
|
|
95
|
+
],
|
|
96
|
+
autoScroll: true,
|
|
97
|
+
listeners: {
|
|
98
|
+
move: (event)=>{
|
|
99
|
+
var target = event.target
|
|
100
|
+
var x = (parseFloat(target.getAttribute('data-x')) || 0) + event.dx
|
|
101
|
+
var y = (parseFloat(target.getAttribute('data-y')) || 0) + event.dy
|
|
102
|
+
|
|
103
|
+
// 限制纵向位置在容器内
|
|
104
|
+
if (y < 0) {
|
|
105
|
+
y = 0;
|
|
106
|
+
}
|
|
107
|
+
if (y > container.clientHeight - target.offsetHeight) {
|
|
108
|
+
y = container.clientHeight - target.offsetHeight;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// 横向限制:不允许停留在中间,拖动时允许在左侧区和右侧区之间滑动
|
|
112
|
+
// 这里允许水平拖动到左右边界之间,但不允许停留中间,拖动结束时自动吸附
|
|
113
|
+
// 但为了拖动顺畅,这里不限制x,吸附逻辑放在 dragend 事件
|
|
114
|
+
|
|
115
|
+
target.style.transform = `translate(${x}px, ${y}px)`;
|
|
116
|
+
|
|
117
|
+
// update the posiion attributes
|
|
118
|
+
target.setAttribute('data-x', x)
|
|
119
|
+
target.setAttribute('data-y', y)
|
|
120
|
+
},
|
|
121
|
+
end(event) {
|
|
122
|
+
var target = event.target;
|
|
123
|
+
var x = (parseFloat(target.getAttribute('data-x')) || 0)
|
|
124
|
+
var y = (parseFloat(target.getAttribute('data-y')) || 0)
|
|
125
|
+
const middleX = container.clientWidth / 2;
|
|
126
|
+
const leftX = 0;
|
|
127
|
+
const rightX = container.clientWidth - target.offsetWidth;
|
|
128
|
+
if (x + target.offsetWidth / 2 < middleX) {
|
|
129
|
+
// 靠左吸附
|
|
130
|
+
x = leftX;
|
|
131
|
+
} else {
|
|
132
|
+
// 靠右吸附
|
|
133
|
+
x = rightX;
|
|
134
|
+
}
|
|
135
|
+
target.setAttribute('data-x', x)
|
|
136
|
+
target.setAttribute('data-y', y)
|
|
137
|
+
target.style.transform = `translate(${x}px, ${y}px)`;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
})
|
|
141
|
+
},
|
|
142
|
+
chatMainInitDrag(){
|
|
143
|
+
interact('.humanMainView').draggable({
|
|
144
|
+
inertia: true,
|
|
145
|
+
modifiers: [
|
|
146
|
+
interact.modifiers.restrictRect({
|
|
147
|
+
restriction: 'body',
|
|
148
|
+
endOnly: true
|
|
149
|
+
})
|
|
150
|
+
],
|
|
151
|
+
autoScroll: true,
|
|
152
|
+
listeners: {
|
|
153
|
+
move: (event)=>{
|
|
154
|
+
var target = event.target
|
|
155
|
+
var x = (parseFloat(target.getAttribute('data-x')) || 0) + event.dx
|
|
156
|
+
var y = (parseFloat(target.getAttribute('data-y')) || 0) + event.dy
|
|
157
|
+
|
|
158
|
+
target.style.transform = 'translate(' + x + 'px, ' + y + 'px)'
|
|
159
|
+
|
|
160
|
+
// update the posiion attributes
|
|
161
|
+
target.setAttribute('data-x', x)
|
|
162
|
+
target.setAttribute('data-y', y)
|
|
163
|
+
},
|
|
164
|
+
end(event) {
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
})
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
</script>
|
|
172
|
+
<style lang="less">
|
|
173
|
+
|
|
174
|
+
.boka-human-v2 {
|
|
175
|
+
//overflow: hidden;
|
|
176
|
+
position: fixed;
|
|
177
|
+
top: 0;
|
|
178
|
+
left: 0;
|
|
179
|
+
z-index: 999;
|
|
180
|
+
}
|
|
181
|
+
.humanEnterIcon{
|
|
182
|
+
position: fixed;
|
|
183
|
+
z-index: 999;
|
|
184
|
+
background-color: #0074ff;
|
|
185
|
+
border-radius: 50%;
|
|
186
|
+
width: 40px;
|
|
187
|
+
height: 40px;
|
|
188
|
+
text-align: center;
|
|
189
|
+
padding: 8px;
|
|
190
|
+
box-sizing: border-box;
|
|
191
|
+
/*transform: translate(100vw, 100vh);*/
|
|
192
|
+
transform: translate(50vw, 50vh);
|
|
193
|
+
>svg{
|
|
194
|
+
width: 100%;
|
|
195
|
+
height:100%;
|
|
196
|
+
fill:#fff;
|
|
197
|
+
}
|
|
198
|
+
&.unreadCount{
|
|
199
|
+
background-color: red;
|
|
200
|
+
color: #fff;
|
|
201
|
+
line-height: 24px;
|
|
202
|
+
font-size: 14px;
|
|
203
|
+
font-weight: bold;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
.humanMainView {
|
|
207
|
+
position: fixed;
|
|
208
|
+
min-width: 360px;
|
|
209
|
+
max-width: 600px;
|
|
210
|
+
min-height: 360px;
|
|
211
|
+
height: 80vh;
|
|
212
|
+
border: 1px solid #ccc;
|
|
213
|
+
&.full{
|
|
214
|
+
padding-top: env(safe-area-inset-top); /* 0 ~ 50px 不等,由系统决定 */
|
|
215
|
+
width: 100vw!important;
|
|
216
|
+
max-width: 100vw!important;
|
|
217
|
+
height: 100vh!important;
|
|
218
|
+
max-height: 100vh!important;
|
|
219
|
+
}
|
|
220
|
+
.humanMainHeader {
|
|
221
|
+
width: 100%;
|
|
222
|
+
height: 40px;
|
|
223
|
+
text-align: center;
|
|
224
|
+
cursor: move;
|
|
225
|
+
font-size: 0;
|
|
226
|
+
box-sizing: border-box;
|
|
227
|
+
border-bottom: 1px solid #f5f5f5;
|
|
228
|
+
position: relative;
|
|
229
|
+
z-index: 999;
|
|
230
|
+
background: #fff;
|
|
231
|
+
white-space: nowrap;
|
|
232
|
+
.humanMainHeaderRight{
|
|
233
|
+
text-align: right;
|
|
234
|
+
}
|
|
235
|
+
.humanMainHeaderLeft,.humanMainHeaderRight{
|
|
236
|
+
width:20%;
|
|
237
|
+
display: inline-block;
|
|
238
|
+
vertical-align: middle;
|
|
239
|
+
padding: 0 10px;
|
|
240
|
+
line-height: 40px;
|
|
241
|
+
font-size: 14px;
|
|
242
|
+
box-sizing: border-box;
|
|
243
|
+
}
|
|
244
|
+
.humanMainHeaderCenter{
|
|
245
|
+
width:60%;
|
|
246
|
+
display: inline-block;
|
|
247
|
+
vertical-align: middle;
|
|
248
|
+
font-size: 16px;
|
|
249
|
+
box-sizing: border-box;
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
>iframe{
|
|
253
|
+
width: 100%;
|
|
254
|
+
height: calc(100% - 40px);
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
</style>
|