You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

81 lines
2.2 KiB

<template>
<div class="content">
<p class="font-w">使用简介</p>
<p class="text-i">网页内快速接入客服让网页拥有客服窗口请把一下代码复制到网页最底部, 如果需要指定用户ID, 则在token后参数中添加kefuid=用户ID</p>
<el-divider />
<p class="typetitle">获取代码</p>
<div class="fenlei">
<div class="code-content-wrap">
<textarea id="NormalCodeTextarea1" class="code" rows="22">
<script>
(function() {
_s = document.createElement('script');
_s.src="{{ siteUrl }}/customerServer.js"
_s.onload = function(){
var option = {
"authInit":true,
openUrl: '{{ siteUrl }}',
token: '{{ uniqueToken }}',
isShowTip: true,
kefuid: '',
mobileIcon: '{{ floatConfig?.mobileImage || "" }}',
pcIcon: '{{ floatConfig?.pcImage || "" }}',
windowStyle:'',
};
var canCustomerServer = new initCustomerServer(option);
canCustomerServer.init();
}
document.head.appendChild(_s)
})();
</script>
</textarea>
<div class="other-wrap">
<a class="btn btn-blue btn-large mr10" href="javascript:void(0);" @click="jiazai">点击体验</a>
<a class="btn btn-blue btn-large" href="javascript:void(0);" @click="getCopy('NormalCodeTextarea1')"><span>复制代码</span></a>
</div>
</div>
</div>
</div>
</template>
<script setup lang="ts">
import { ref, onMounted, defineProps, defineEmits } from 'vue';
// 从父组件接收 uniqueToken ✅
const props = defineProps<{
tokeninfo?: any;
siteUrl?: string;
uniqueToken: string;
floatConfig?: { // 新增
pcImage: string;
mobileImage: string;
};
}>();
const emit = defineEmits<{
(e: 'cgetCopy', id: string): void;
}>();
// 点击体验
function jiazai() {
const token = props.uniqueToken || '';
window.open(`${location.origin}/chat/index?token=${token}&noCanClose=1`);
}
// 复制
function getCopy(id: string) {
emit('cgetCopy', id);
}
</script>
<style>
.a {
display: none;
display: block;
border-radius: 8px;
overflow: hidden;
}
</style>