|
|
|
|
@ -14,11 +14,11 @@
|
|
|
|
|
<template v-for="i in chatInfo">
|
|
|
|
|
<div v-if="i.type===0" class="message">
|
|
|
|
|
<div class="userInfo">{{ i.userName }} {{ formatTime(i.time) }}</div>
|
|
|
|
|
<div class="info">{{ i.content }}</div>
|
|
|
|
|
<div class="info" @click="handleClick" v-html="i.content"></div>
|
|
|
|
|
</div>
|
|
|
|
|
<div v-if="i.type===1" class="message1">
|
|
|
|
|
<div class="userInfo">{{ i.userName }} {{ formatTime(i.time) }}</div>
|
|
|
|
|
<div class="info">{{ i.content }}</div>
|
|
|
|
|
<div class="info" @click="handleClick" v-html="i.content"></div>
|
|
|
|
|
</div>
|
|
|
|
|
<div v-if="i.type===2" class="message">
|
|
|
|
|
<div class="userInfo">{{ i.userName }} {{ formatTime(i.time) }}</div>
|
|
|
|
|
@ -28,6 +28,7 @@
|
|
|
|
|
</div>
|
|
|
|
|
<el-button size="mini" @click="busy(1)">设备相关</el-button>
|
|
|
|
|
<el-button size="mini" @click="busy(2)">软件相关</el-button>
|
|
|
|
|
<el-button size="mini" @click="busy(3)">测试</el-button>
|
|
|
|
|
</div>
|
|
|
|
|
<div>
|
|
|
|
|
</div>
|
|
|
|
|
@ -46,6 +47,9 @@
|
|
|
|
|
</el-button>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="viewImg" v-if="imgUrl" @click="imgUrl = ''">
|
|
|
|
|
<img :src="imgUrl" alt="" class="img"/>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
<script>
|
|
|
|
|
@ -56,6 +60,7 @@ export default {
|
|
|
|
|
name: "Chat",
|
|
|
|
|
data() {
|
|
|
|
|
return {
|
|
|
|
|
imgUrl: '',
|
|
|
|
|
customerService,
|
|
|
|
|
textarea: '',
|
|
|
|
|
isChat: false,
|
|
|
|
|
@ -221,7 +226,7 @@ export default {
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
this.chatInfo.push({
|
|
|
|
|
type: 0,
|
|
|
|
|
content: '目前咨询人数过多,如有疑问,请致电xxxx',
|
|
|
|
|
content: `<text>目前咨询人数过多,如有疑问,请致电xxxx,或</text> <a href="javascript:void(0)" data-action="addWechat">添加微信</a>`,
|
|
|
|
|
time: new Date().getTime(),
|
|
|
|
|
userName: '海威物联',
|
|
|
|
|
})
|
|
|
|
|
@ -249,9 +254,63 @@ export default {
|
|
|
|
|
})
|
|
|
|
|
}, 1000)
|
|
|
|
|
}
|
|
|
|
|
if (e === 3) {
|
|
|
|
|
window.location.href = "weixin://dl/add";
|
|
|
|
|
}
|
|
|
|
|
this.$nextTick(() => {
|
|
|
|
|
this.scrollToBottom()
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
handleClick(e) {
|
|
|
|
|
const action = e.target.dataset.action
|
|
|
|
|
if (action && typeof this[action] === 'function') {
|
|
|
|
|
this[action](e.target.dataset.parmas) // 调用 Vue methods 里的函数
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
copyToClipboard(text) {
|
|
|
|
|
if (!navigator.clipboard) {
|
|
|
|
|
console.warn('浏览器不支持 Clipboard API,使用 fallback 方法')
|
|
|
|
|
this.fallbackCopy(text)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
navigator.clipboard.writeText(text)
|
|
|
|
|
},
|
|
|
|
|
fallbackCopy(text) {
|
|
|
|
|
const input = document.createElement('textarea')
|
|
|
|
|
input.value = text
|
|
|
|
|
document.body.appendChild(input)
|
|
|
|
|
input.select()
|
|
|
|
|
try {
|
|
|
|
|
document.execCommand('copy')
|
|
|
|
|
} catch (err) {
|
|
|
|
|
}
|
|
|
|
|
document.body.removeChild(input)
|
|
|
|
|
},
|
|
|
|
|
addWechat() {
|
|
|
|
|
window.location.href = "weixin://dl/add";
|
|
|
|
|
this.copyToClipboard('Yeshenge_')
|
|
|
|
|
this.chatInfo.push({
|
|
|
|
|
type: 0,
|
|
|
|
|
content: '已复制微信号,请打开微信添加好友,或扫描下方二维码添加好友',
|
|
|
|
|
time: new Date().getTime(),
|
|
|
|
|
userName: '海威物联',
|
|
|
|
|
})
|
|
|
|
|
let img = require('@/assets/image/wechatQRCode.png')
|
|
|
|
|
this.chatInfo.push({
|
|
|
|
|
type: 0,
|
|
|
|
|
content: `<img data-action="viewImg" data-parmas='${JSON.stringify({img: img})}' src="${img}" alt="" style="width: 100px;">`,
|
|
|
|
|
time: new Date().getTime(),
|
|
|
|
|
userName: '海威物联',
|
|
|
|
|
})
|
|
|
|
|
this.$nextTick(() => {
|
|
|
|
|
this.scrollToBottom()
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
viewImg(e) {
|
|
|
|
|
let data = JSON.parse(e)
|
|
|
|
|
console.log(data.img)
|
|
|
|
|
this.imgUrl = data.img
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@ -395,4 +454,22 @@ export default {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.viewImg {
|
|
|
|
|
z-index: 9999;
|
|
|
|
|
position: fixed;
|
|
|
|
|
width: 100%;
|
|
|
|
|
height: 100%;
|
|
|
|
|
top: 0;
|
|
|
|
|
left: 0;
|
|
|
|
|
background-color: rgba(0, 0, 0, .2);
|
|
|
|
|
|
|
|
|
|
.img {
|
|
|
|
|
position: absolute;
|
|
|
|
|
top: 50%;
|
|
|
|
|
left: 50%;
|
|
|
|
|
transform: translate(-50%, -50%);
|
|
|
|
|
width: 40vw;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</style>
|