Commit e5b5b2b8 by 前端

Merge branch 'saas+v4.25.0' into 'master'

合并Saas+v4.25.0

See merge request !21
2 parents 0807eec2 f1e806e7
......@@ -15,6 +15,7 @@
"autoprefixer": "^8.0.0",
"core-js": "^3.6.4",
"dayjs": "^1.10.5",
"emoji-regex": "^10.2.1",
"glsx-common": "^2.1.0",
"lib-flexible": "^0.3.2",
"postcss-loader": "^6.2.0",
......
const url = '/rop-scrm-marketing/router'
import { utils } from 'glsx-common'
export default {
/**查询喜报战报推送日志分页列表 */
issueChatGpt (data) {
const method = 'scrm.api.knowledge.gptchat'
return httpRequest(method, data)
},
/**
* 获取AI id
*/
getAiId (data) {
data.method = 'marketing.api.scriptlibrary.ai.id'
return window.$HTTP({
url,
data,
returnAll: true
})
},
/**
* 新增聊天记录
*/
updatedAiRecord (data) {
data.method = 'marketing.api.scriptlibrary.ai.record.add'
return window.$HTTP({
url,
data
})
},
}
const httpRequest = (method, data) => {
const { secret, sign, request } = window.$fetchConfig
Object.assign(data, {
method,
...sign
})
return new Promise((resolve, reject) => {
window.fetch(`${request.chatGptURL}/router/${method}/1.0.0`, {
method: 'POST',
headers: { 'Content-Type': 'application/json;charset=UTF-8' },
body: JSON.stringify(utils.createSign(data, secret))
}).then(res => {
resolve(res.json())
}).catch(err => {
reject(err)
})
})
}
\ No newline at end of file
......@@ -11,11 +11,12 @@ import merchantsApi from './merchantsApi'
import wxConfig from './wxConfig'
import marketingApi from './marketingApi'
import entmicroApi from './entmicroApi'
import chatgptApi from './chatgptApi'
export {
ssoApi,
wxConfig,
merchantsApi,
marketingApi,
entmicroApi
entmicroApi,
chatgptApi
}
\ No newline at end of file
......@@ -16,6 +16,11 @@ body .app {
--envSafeAreaInsetBottom: env(safe-area-inset-bottom);
}
.isFullSucreen {
padding-bottom: var(--constantSafeAreaInsetBottom) !important;
padding-bottom: var(--envSafeAreaInsetBottom) !important;
}
img {
width: 100%;
height: 100%;
......@@ -79,6 +84,7 @@ img {
.van-dropdown-menu {
margin-left: auto;
.icon-down {
transition: all 0.25s;
}
......@@ -95,6 +101,7 @@ img {
.van-dropdown-menu__title {
color: #545454 !important;
font-size: 16px;
&::after {
display: none;
}
......@@ -108,8 +115,9 @@ img {
color: #5F5F5F !important;
font-size: 12px;
}
.van-dropdown-menu__title--active {
color: var(--themeColor) !important;
color: var(--themeColor) !important;
}
}
}
\ No newline at end of file
.sprite-icon { background-image: url(../images/sprite.png);background-size: 105px 90px;}
.icon-down { width: 12px; height: 12px; background-position: -26px -74px;}
.icon-eye { width: 13px; height: 8px; background-position: -48px -74px;}
.icon-gift-del { width: 18px; height: 18px; background-position: -84px -30px;}
.icon-grctx { width: 16px; height: 16px; background-position: 0px -74px;}
.sprite-icon { background-image: url(../images/sprite.png);background-size: 133px 94px;}
.icon-ai { width: 20px; height: 20px; background-position: -84px -30px;}
.icon-close { width: 20px; height: 20px; background-position: 0px -74px;}
.icon-down { width: 12px; height: 12px; background-position: -115px -54px;}
.icon-eye { width: 13px; height: 8px; background-position: -115px -76px;}
.icon-gift-del { width: 18px; height: 18px; background-position: -115px 0px;}
.icon-grctx { width: 16px; height: 16px; background-position: -115px -28px;}
.icon-link { width: 32px; height: 32px; background-position: -42px 0px;}
.icon-menu-active { width: 22px; height: 20px; background-position: 0px -44px;}
.icon-menu { width: 22px; height: 20px; background-position: -32px -44px;}
.icon-more { width: 20px; height: 20px; background-position: -30px -74px;}
.icon-pdf { width: 32px; height: 34px; background-position: 0px 0px;}
.icon-profile { width: 20px; height: 20px; background-position: -60px -74px;}
.icon-PYQ { width: 21px; height: 20px; background-position: -84px 0px;}
.icon-send { width: 10px; height: 10px; background-position: -64px -44px;}
\ No newline at end of file

10 KB | W: | H:

16 KB | W: | H:

src/assets/images/sprite.png
src/assets/images/sprite.png
src/assets/images/sprite.png
src/assets/images/sprite.png
  • 2-up
  • Swipe
  • Onion skin
<template>
<div
class="chat-gpt-box"
v-show="show"
>
<div
:class="['view',{'show-tips':showTips&& issuesList.length}]"
ref="contentView"
>
<div class="content-item left">
<div class="sprite-icon icon-ai icon"></div>
<div class="content">
您可以向我提问公司的业务产品或销售等相关问题,我将给您组织语言并提供建议,您可以复制段落稍作润色并答复给您的客户。
</div>
</div>
<template v-for="(i,index) in contentList">
<div :key="index">
<template v-if="i.contentType == 1">
<div class="content-item left">
<div class="sprite-icon icon-ai icon"></div>
<div class="content">
<template v-if="!i.content">
<van-loading
class="loading"
color="#3582EE"
/>
</template>
<template v-else>
{{ i.content }}
</template>
</div>
</div>
</template>
<template v-else>
<div class="content-item right">
<div class="content">{{i.content}}</div>
<div class="sprite-icon icon-profile icon"></div>
</div>
</template>
</div>
</template>
</div>
<template v-if="showTips && issuesList.length">
<div class="tips-box">
<div class="tips-title flex">
您可以这样向我提问
<div
class="sprite-icon icon-close"
@click="showTips = false"
></div>
</div>
<div class="tips-view">
<template v-for="(i,index) in issuesList">
<div
:key="index"
class="tips-item flex"
@click="send(i)"
>
{{ i }}
<div class="sprite-icon icon-more"></div>
</div>
</template>
</div>
</div>
</template>
<div :class="['input-box flex isFullSucreen']">
<van-field
v-model="issue"
:border="false"
placeholder="请输入文字向AI提问"
enterKeyhint="send"
@keydown="onkeydown"
ref="input"
maxlength="1000"
></van-field>
<van-button @click="send()">发送</van-button>
</div>
</div>
</template>
<script type='text/ecmascript-6'>
import { chatgptApi } from '@/api'
import * as dayjs from 'dayjs'
import emojiRegex from 'emoji-regex'
export default {
name: 'ChatGpt',
props: {
show: Boolean
},
data () {
return {
contentList: [],
issuesList: window.$fetchConfig.issuesList || [],
showTips: true,
issue: '',
scriptLibraryAIId: '',
todayQuestionLeft: 0,
questionCountTotal: 20,
lastQuestionTime: '',
padding: false
}
},
watch: {
issue (newText) {
this.issue = this.filterText(newText);
}
},
mounted () {
this.getAiId()
},
methods: {
filterText (text) {
const whitespaceRegex = /^\s+$/g
return text.replace(emojiRegex(), '').replace(whitespaceRegex, '')
},
async getAiId () {
this.showLoading()
const { merchantId, uuid, merchantName, userName, loginList } = this.getLocalStorage('dj_scrm_userInfo')
let { phone } = loginList.find(e => e.merchantNo == merchantId)
try {
const { code, data, message } = await chatgptApi.getAiId({
merchantId,
merchantName,
staffUuid: uuid,
staffName: userName,
staffPhone: phone
})
if (code == 0 && data) {
this.scriptLibraryAIId = data.scriptLibraryAIId
this.todayQuestionLeft = data.todayQuestionLeft
this.questionCountTotal = data.questionCountTotal
}
else throw message
this.hideLoading()
} catch (error) {
console.log(error)
this.showToast(error)
}
},
onkeydown (e) {
if (e.keyCode == 13) {
this.send()
}
},
send (val) {
const { issue, todayQuestionLeft, questionCountTotal, padding } = this,
content = val || issue
try {
if (!content) throw false
if (padding) throw '请等待回复后再试'
if (todayQuestionLeft < 1) throw `每天每个用户最多发送提问${questionCountTotal}个问题`
} catch (error) {
if (error) this.showToast(error)
return
}
const id = Date.now()
this.contentList.push({
contentType: 0,
content,
chatTime: dayjs(id).format('YYYY-MM-DD HH:mm:ss'),
id
})
this.padding = true
this.lastQuestionTime = dayjs().format('YYYY-MM-DD HH:mm:ss')
if (!val) {
this.issue = ''
this.$refs.input.blur()
}
this.$nextTick(() => {
this.addRecord(id)
this.toQuestionChatGPT(content)
})
},
toBottom () {
this.$nextTick(() => {
this.$refs.contentView.scrollTop = 999999999
})
},
async toQuestionChatGPT (question) {
const id = Date.now()
this.contentList.push({
contentType: 1,
content: '',
id
})
this.toBottom()
try {
const { response } = await chatgptApi.issueChatGpt({
question,
history: ''
})
this.padding = false
this.contentList.find(i => i.id == id).chatTime = dayjs().format('YYYY-MM-DD HH:mm:ss')
let index = 0, speed = 10
const typeWriter = () => {
if (index < response.length) {
this.contentList.find(i => i.id == id).content += response.charAt(index)
index++
setTimeout(typeWriter, speed)
this.toBottom()
} else this.addRecord(id)
}
typeWriter()
} catch (error) {
this.padding = false
}
},
addRecord (id) {
const { contentList, scriptLibraryAIId, lastQuestionTime } = this,
item = contentList.find(i => i.id == id)
delete item.id
let params = {
lastQuestionTime,
aiRecordList: [item],
scriptLibraryAIId
}
if (item.contentType == 1 && item.content.indexOf('很抱歉') == -1) params.questionEffectiveCount = 1
if (item.contentType != 1) params.questionCount = 1
chatgptApi.updatedAiRecord(params).then(res => {
this.getAiId()
})
}
}
}
</script>
<style scoped lang='scss'>
.chat-gpt-box {
height: calc(100vh - 50px - var(--constantSafeAreaInsetBottom));
height: calc(100vh - 50px - var(--envSafeAreaInsetBottom));
.view {
height: calc(100% - 52px);
overflow-y: scroll;
position: relative;
box-sizing: border-box;
padding-bottom: 12px;
background-color: #fff;
.content-item {
margin-top: 12px;
padding: 0 12px;
display: flex;
.icon {
width: 20px;
height: 20px;
user-select: none;
}
.content {
max-width: 290px;
background: #f8f9f9;
box-sizing: border-box;
padding: 10px;
font-size: 16px;
color: #333333;
line-height: 22px;
word-break: break-all;
}
}
@keyframes typing {
from {
width: 0;
}
to {
width: 100%;
}
}
.left {
.icon {
margin-right: 6px;
}
.content {
border-radius: 0 10px 10px 10px;
}
}
.right {
.icon {
margin-left: 6px;
}
.content {
margin-left: auto;
background: #c9e7fe;
border: 1px solid #3582ee33;
border-radius: 10px 0 10px 10px;
}
}
}
.show-tips {
height: calc(100% - 262px);
}
.tips-box {
width: 100%;
height: 210px;
background-image: linear-gradient(180deg, #d6e6fb 0%, #ffffff 14%);
position: relative;
box-sizing: border-box;
.tips-title {
padding: 14px 16px 7px;
font-weight: 600;
font-size: 16px;
color: #3582ee;
.icon-close {
margin-left: auto;
}
}
.tips-view {
height: calc(100% - 42px);
overflow-y: scroll;
padding: 0 16px;
.tips-item {
border-bottom: 1px solid #e4e6ee;
line-height: 18px;
padding: 7px 0;
font-size: 13px;
color: #333333;
.icon-more {
margin-left: auto;
flex-shrink: 0;
// background-position: -60px -72px;
// transform: translateY(-2px);
}
&:last-of-type {
border: none;
}
}
}
}
.input-box {
padding: 7px 11px 7px 16px;
background: #ffffff;
.van-field {
width: 278px;
padding: 9px 16px;
font-size: 14px;
color: #c8c9cc;
line-height: 20px;
background: #f7f8fa;
border-radius: 19px;
}
.van-button {
width: 60px;
height: 38px;
background: #3582ee;
border-radius: 19px;
margin-left: auto;
font-weight: 500;
font-size: 16px;
color: #ffffff;
padding: 0;
}
}
.fixedKeyboard {
// position: fixed;
// width: 100%;
// box-sizing: border-box;
// bottom: 0;
}
}
</style>
\ No newline at end of file
......@@ -4,7 +4,7 @@
v-model="tabIndex"
color="#3975C6"
title-inactive-color="#BBB"
title-active-color="#2c2c2c"
title-active-color="#3975C6"
@click="click"
:key="updata"
v-bind="$attrs"
......
......@@ -8,16 +8,23 @@
*/
// 本地环境配置
module.exports = {
title: '嘀加企微助手',
title: '嘻嘻',
envVersion: 'trial',
request: {
// baseURL: '//192.168.3.191:7860', // 本地测试项目地址,
baseURL: '//scrm.test.glsx.com.cn', // 本地测试项目地址,
// 设置超时时间
timeout: 180000,
// 携带凭证
withCredentials: true,
// 返回数据类型
responseType: 'json',
chatGptURL:'//chatgpt.dev.glsx.com.cn',
/**
* 开发//chatgpt.dev.glsx.com.cn
* 测试//chatgpt.dev.glsx.com.cn
*/
ropMerchantURL: 'http://rop-merchant.dev.glsx.com.cn'
/**
* 开发:http://rop-merchant.dev.glsx.com.cn
......@@ -44,5 +51,18 @@ module.exports = {
source: "scrm-main",
v: "1.0.0",
},
vconsole: true
vconsole: true,
issuesList: [
'你这个保险有点贵啊,好像别人那里都没有那么高的价格。',
'我这个保险在外面朋友买没那么便宜。',
'这个保费怎么那么贵,我第二年的保费多少钱?',
'座位险/驾乘险可以不要吗?',
'第三者怎么要买300万,我买200万/100万就可以了?',
'这个保险我可以不买吗?', '这个保险怎么理赔的?',
'你说的那些服务我也不一定能用上啊',
'我之前开车那么多年,没有过爆胎这些情况的。',
'我家里有其他车了,你们的补贴我不需要。',
'这个保险我买2年的话,第二年你买其他保险也可以的吗?',
'我这个车用车比较少,车辆那么新,不会爆胎的。'
]
}
\ No newline at end of file
......@@ -16,15 +16,15 @@ const state = {
lastPath: ''
}
const mutations = {
SET_PAGE_META(state, meta) {
SET_PAGE_META (state, meta) {
state.pageMeta = meta
},
PUSH_KEEP(state, name) {
PUSH_KEEP (state, name) {
if (!state.keepAlives.includes(name)) {
state.keepAlives.push(name)
}
},
REMOVE_KEEP(state, names) {
REMOVE_KEEP (state, names) {
state.keepAlives = state.keepAlives.reduce((arr, name) => {
if (!names.includes(name)) {
return arr.push(name)
......@@ -32,28 +32,28 @@ const mutations = {
return arr
}, [])
},
SET_LAST_PATH(state, path) {
SET_LAST_PATH (state, path) {
state.lastPath = path
}
}
const actions = {
setPageMeta({ commit }, meta) {
setPageMeta ({ commit }, meta) {
document.title = meta.title
commit('SET_PAGE_META', meta)
},
setLoginToken({ commit }, val) {
setLoginToken ({ commit }, val) {
commit('SET_LOGIN_TOKEN', val)
},
setAccountList({ commit }, list) {
setAccountList ({ commit }, list) {
commit('SET_ACCOUNT_LIST', list)
},
pushKeep({ commit }, name) {
pushKeep ({ commit }, name) {
commit('PUSH_KEEP', name)
},
removeKeep({ commit }, names) {
removeKeep ({ commit }, names) {
commit('REMOVE_KEEP', names)
},
login({ dispatch }) {
login ({ dispatch }) {
let [redirectUrl] = window.location.href.split('?')
// 以下是 本地调试
if (process.env.NODE_ENV == 'development') {
......@@ -114,7 +114,7 @@ const actions = {
} else {
util.showLoading()
let appid = getParams('corpId') //从链接获取
let dj_scrm = util.getLocalStorage('dj_scrm_corpId')
let dj_scrm = util.getLocalStorage('dj_scrm_corpId')
if (!appid) appid = (dj_scrm && dj_scrm.corpId) || 'wwc33bc9a3c72d45f3'
util.setLocalStorage('dj_scrm_corpId', { corpId: appid })
// 'ww657a2d4ae89a4424'
......@@ -128,7 +128,7 @@ const actions = {
window.location.href = `${url}?redirect_uri=${encodeURIComponent(redirectUrl)}&corpId=${corpId}&agentId=${agentId}`
}
},
navigation({ dispatch }) {
navigation ({ dispatch }) {
let { sessionId, corpId, agentId } = getParams()
const storage_corpId = util.getLocalStorage('dj_scrm_corpId')
if (!corpId) corpId = storage_corpId && storage_corpId.corpId
......@@ -154,7 +154,7 @@ const actions = {
}
state.showWindow = true
},
registerHttp({}, sessionId = '') {
registerHttp ({ }, sessionId = '') {
window.$HTTP = new Http({ ...window.$fetchConfig, alert: Notify, headers: { token: sessionId } })
}
}
......
<template>
<div class="layout">
<div class="sticky">
<tab
:list="tabList"
@change="change"
>
</tab>
<search-box
v-show="tabIndex == 1"
@search="search"
placeholder="输入关键词搜索"
:showDropdown="false"
></search-box>
<template v-if="groupList.length">
<tab
:list="groupList"
@change="change"
>
</tab>
</template>
</div>
<template v-if="flag">
<template v-if="list.length">
<scroll-view
class="list-box"
@ReachBottom="onReachBottom"
ref="scrollView"
>
<div class="box">
<template v-for="(i,index) in list">
<div
class="item"
:key="index"
>
<chat-gpt :show="tabIndex == 0"></chat-gpt>
<template v-if="tabIndex == 1">
<template v-if="flag">
<template v-if="list.length">
<scroll-view
class="list-box"
@ReachBottom="onReachBottom"
ref="scrollView"
>
<div class="box">
<template v-for="(i,index) in list">
<div
v-html="decodeURIComponent(i.text)"
:class="['content',{'line-clamp':i.moreState}]"
></div>
<div class="chat-btns flex">
<template v-if="i.moreBtn">
<div
class="more"
@click="i.moreState = !i.moreState"
>{{ i.moreState ? '展开' :'收起' }}</div>
</template>
<van-button
class="send"
block
round
color="#3975C6"
:disabled="sendChatMessageDisabled"
@click="sendChatMessage(i.scriptContent)"
>发送</van-button>
class="item"
:key="index"
>
<div
v-html="decodeURIComponent(i.text)"
:class="['content',{'line-clamp':i.moreState}]"
></div>
<div class="chat-btns flex">
<template v-if="i.moreBtn">
<div
class="more"
@click="i.moreState = !i.moreState"
>{{ i.moreState ? '展开' :'收起' }}</div>
</template>
<van-button
class="send"
block
round
color="#3975C6"
:disabled="sendChatMessageDisabled"
@click="sendChatMessage(i.scriptContent)"
>发送</van-button>
</div>
</div>
</div>
</template>
</div>
</scroll-view>
</template>
<template v-else>
<nothing
class="nothing-box"
image="https://img01.glsx.com.cn/weapp/resource/scrm-mobile/psd/list-nothing.png"
>暂无可用话术</nothing>
</template>
</div>
</scroll-view>
</template>
<template v-else>
<nothing
class="nothing-box"
image="https://img01.glsx.com.cn/weapp/resource/scrm-mobile/psd/list-nothing.png"
>暂无可用话术</nothing>
</template>
</template>
</template>
</div>
......@@ -69,7 +71,7 @@ export default {
name: 'library',
data () {
return {
groupList: [],
tabList: ['智能AI话术', '企业话术'],
flag: false,
list: [],
pageNum: 1,
......@@ -80,7 +82,8 @@ export default {
pageNum: 1,
pageSize: 10
},
total: 0
total: 0,
tabIndex: 0
}
},
async mounted () {
......@@ -89,8 +92,6 @@ export default {
} catch (error) {
this.sendChatMessageDisabled = true
}
this.getChatGroupList()
this.getChatLibraryList()
},
methods: {
/**发送 */
......@@ -127,18 +128,20 @@ export default {
},
/**切换tab */
change (index) {
const { groupList, params: { scriptGroup } } = this
if (scriptGroup == groupList[index] || (index == 0 && scriptGroup == '')) return
this.params.scriptGroup = index == 0 ? '' : groupList[index]
this.clearData()
this.tabIndex = index
if (index == 1) this.clearData()
// const { groupList, params: { scriptGroup } } = this
// if (scriptGroup == groupList[index] || (index == 0 && scriptGroup == '')) return
// this.params.scriptGroup = index == 0 ? '' : groupList[index]
// this.clearData()
},
/**话术组 */
async getChatGroupList () {
let res = await marketingApi.getChatGroupList() || [],
maxLength = 10
if (res.length > maxLength) res = res.splice(0, maxLength)
this.groupList = ['全部', ...res]
},
// async getChatGroupList () {
// let res = await marketingApi.getChatGroupList() || [],
// maxLength = 10
// if (res.length > maxLength) res = res.splice(0, maxLength)
// this.groupList = ['全部', ...res]
// },
/**话术 */
async getChatLibraryList () {
const { params, list, $refs: {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!