Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
glsx
/
dj-scrm-wx-work-attachment-psd
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 210cadac
authored
Jul 26, 2023
by
李伟康
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
提交
1 parent
7c4d2007
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
92 additions
and
20 deletions
src/api/chatgptApi.js
src/components/ChatGPT.vue
src/config/env.development.js
src/api/chatgptApi.js
View file @
210cada
const
url
=
'/router'
const
url
=
'/ro
p-scrm-marketing/ro
uter'
import
{
utils
}
from
'glsx-common'
import
{
utils
}
from
'glsx-common'
export
default
{
export
default
{
...
@@ -8,6 +8,27 @@ export default {
...
@@ -8,6 +8,27 @@ export default {
return
httpRequest
(
method
,
data
)
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
httpRequest
=
(
method
,
data
)
=>
{
const
{
secret
,
sign
,
request
}
=
window
.
$fetchConfig
const
{
secret
,
sign
,
request
}
=
window
.
$fetchConfig
...
@@ -16,7 +37,7 @@ const httpRequest = (method, data) => {
...
@@ -16,7 +37,7 @@ const httpRequest = (method, data) => {
...
sign
...
sign
})
})
return
new
Promise
((
resolve
,
reject
)
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
window
.
fetch
(
`
${
request
.
base
URL
}
/router/
${
method
}
/1.0.0`
,
{
window
.
fetch
(
`
${
request
.
chatGpt
URL
}
/router/
${
method
}
/1.0.0`
,
{
method
:
'POST'
,
method
:
'POST'
,
headers
:
{
'Content-Type'
:
'application/json;charset=UTF-8'
},
headers
:
{
'Content-Type'
:
'application/json;charset=UTF-8'
},
body
:
JSON
.
stringify
(
utils
.
createSign
(
data
,
secret
))
body
:
JSON
.
stringify
(
utils
.
createSign
(
data
,
secret
))
...
...
src/components/ChatGPT.vue
View file @
210cada
...
@@ -4,9 +4,15 @@
...
@@ -4,9 +4,15 @@
:class=
"['view',
{'show-tips':showTips
&&
issuesList.length}]"
:class=
"['view',
{'show-tips':showTips
&&
issuesList.length}]"
ref="contentView"
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"
>
<template
v-for=
"(i,index) in contentList"
>
<div
:key=
"index"
>
<div
:key=
"index"
>
<template
v-if=
"i.
speaker == 'AI'
"
>
<template
v-if=
"i.
contentType == 1
"
>
<div
class=
"content-item left"
>
<div
class=
"content-item left"
>
<div
class=
"sprite-icon icon-ai icon"
></div>
<div
class=
"sprite-icon icon-ai icon"
></div>
<div
class=
"content"
>
<div
class=
"content"
>
...
@@ -70,24 +76,40 @@
...
@@ -70,24 +76,40 @@
<
script
type=
'text/ecmascript-6'
>
<
script
type=
'text/ecmascript-6'
>
import
{
chatgptApi
}
from
'@/api'
import
{
chatgptApi
}
from
'@/api'
import
*
as
dayjs
from
'dayjs'
export
default
{
export
default
{
name
:
'ChatGpt'
,
name
:
'ChatGpt'
,
data
()
{
data
()
{
return
{
return
{
contentList
:
[{
contentList
:
[],
content
:
'您可以向我提问公司的业务产品或销售等相关问题,我将给您组织语言并提供建议,您可以复制段落稍作润色并答复给您的客户。'
,
speaker
:
'AI'
}],
issuesList
:
window
.
$fetchConfig
.
issuesList
||
[],
issuesList
:
window
.
$fetchConfig
.
issuesList
||
[],
showTips
:
true
,
showTips
:
true
,
issue
:
''
issue
:
''
,
scriptLibraryAIId
:
''
}
}
},
},
mounted
()
{
mounted
()
{
this
.
getAiId
()
},
},
methods
:
{
methods
:
{
async
getAiId
()
{
this
.
showLoading
()
const
{
merchantId
,
uuid
,
merchantName
,
userName
}
=
this
.
getLocalStorage
(
'dj_scrm_userInfo'
)
try
{
const
{
code
,
data
,
message
}
=
await
chatgptApi
.
getAiId
({
merchantId
,
merchantName
,
staffUuid
:
uuid
,
staffName
:
userName
})
if
(
code
==
0
&&
data
)
this
.
scriptLibraryAIId
=
data
else
throw
message
this
.
hideLoading
()
}
catch
(
error
)
{
console
.
log
(
error
)
this
.
showToast
(
error
)
}
},
onkeydown
(
e
)
{
onkeydown
(
e
)
{
if
(
e
.
keyCode
==
13
)
{
if
(
e
.
keyCode
==
13
)
{
this
.
send
()
this
.
send
()
...
@@ -97,16 +119,20 @@ export default {
...
@@ -97,16 +119,20 @@ export default {
const
{
issue
}
=
this
,
const
{
issue
}
=
this
,
content
=
val
||
issue
content
=
val
||
issue
if
(
!
content
)
return
if
(
!
content
)
return
const
chatTime
=
Date
.
now
()
this
.
contentList
.
push
({
this
.
contentList
.
push
({
speaker
:
'ME'
,
contentType
:
0
,
content
content
,
chatTime
:
dayjs
(
chatTime
).
format
(
'YYYY-MM-DD HH:mm:ss'
)
})
})
if
(
!
val
)
{
if
(
!
val
)
{
this
.
issue
=
''
this
.
issue
=
''
this
.
$refs
.
input
.
blur
()
this
.
$refs
.
input
.
blur
()
}
}
this
.
toBottom
()
this
.
toBottom
()
this
.
$nextTick
(()
=>
{
this
.
toQuestionChatGPT
(
content
)
this
.
toQuestionChatGPT
(
content
)
})
},
},
toBottom
()
{
toBottom
()
{
this
.
$nextTick
(()
=>
{
this
.
$nextTick
(()
=>
{
...
@@ -116,14 +142,17 @@ export default {
...
@@ -116,14 +142,17 @@ export default {
async
toQuestionChatGPT
(
question
)
{
async
toQuestionChatGPT
(
question
)
{
const
id
=
Date
.
now
()
const
id
=
Date
.
now
()
this
.
contentList
.
push
({
this
.
contentList
.
push
({
speaker
:
'AI'
,
contentType
:
1
,
id
,
content
:
''
,
content
:
''
id
})
})
const
{
response
}
=
await
chatgptApi
.
issueChatGpt
({
const
{
response
}
=
await
chatgptApi
.
issueChatGpt
({
question
,
question
,
history
:
''
history
:
''
})
})
let
questionEffectiveCount
=
0
if
(
response
.
indexOf
(
'很抱歉'
)
==
-
1
)
questionEffectiveCount
=
1
this
.
contentList
.
find
(
i
=>
i
.
id
==
id
).
chatTime
=
dayjs
().
format
(
'YYYY-MM-DD HH:mm:ss'
)
let
index
=
0
,
speed
=
10
let
index
=
0
,
speed
=
10
const
typeWriter
=
()
=>
{
const
typeWriter
=
()
=>
{
if
(
index
<
response
.
length
)
{
if
(
index
<
response
.
length
)
{
...
@@ -131,10 +160,28 @@ export default {
...
@@ -131,10 +160,28 @@ export default {
index
++
index
++
setTimeout
(
typeWriter
,
speed
)
setTimeout
(
typeWriter
,
speed
)
this
.
toBottom
()
this
.
toBottom
()
}
}
else
this
.
addRecord
(
id
,
questionEffectiveCount
)
}
}
typeWriter
()
typeWriter
()
},
},
addRecord
(
id
,
questionEffectiveCount
)
{
const
{
contentList
,
scriptLibraryAIId
}
=
this
,
index
=
this
.
contentList
.
findIndex
(
i
=>
i
.
id
==
id
),
questionItem
=
contentList
[
index
-
1
],
answerItem
=
contentList
[
index
],
lastQuestionTime
=
dayjs
(
questionItem
.
chatTime
).
format
(
'YYYY-MM-DD HH:mm:ss'
)
delete
answerItem
.
id
// aiRecordList[index - 1] = questionItem
// aiRecordList[index] = answerItem
chatgptApi
.
updatedAiRecord
({
scriptLibraryAIId
,
lastQuestionTime
,
aiRecordList
:
[
questionItem
,
answerItem
],
questionCount
:
1
,
questionEffectiveCount
})
}
}
}
}
}
</
script
>
</
script
>
...
...
src/config/env.development.js
View file @
210cada
...
@@ -11,8 +11,8 @@ module.exports = {
...
@@ -11,8 +11,8 @@ module.exports = {
title
:
'嘻嘻'
,
title
:
'嘻嘻'
,
envVersion
:
'trial'
,
envVersion
:
'trial'
,
request
:
{
request
:
{
baseURL
:
'//192.168.1.124
:7860'
,
// 本地测试项目地址,
// baseURL: '//192.168.3.191
:7860', // 本地测试项目地址,
// baseURL: '//scrm.test
.glsx.com.cn', // 本地测试项目地址,
baseURL
:
'//scrm.dev
.glsx.com.cn'
,
// 本地测试项目地址,
// 设置超时时间
// 设置超时时间
timeout
:
180000
,
timeout
:
180000
,
...
@@ -20,7 +20,11 @@ module.exports = {
...
@@ -20,7 +20,11 @@ module.exports = {
withCredentials
:
true
,
withCredentials
:
true
,
// 返回数据类型
// 返回数据类型
responseType
:
'json'
,
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'
ropMerchantURL
:
'http://rop-merchant.dev.glsx.com.cn'
/**
/**
* 开发:http://rop-merchant.dev.glsx.com.cn
* 开发:http://rop-merchant.dev.glsx.com.cn
...
@@ -47,7 +51,7 @@ module.exports = {
...
@@ -47,7 +51,7 @@ module.exports = {
source
:
"scrm-main"
,
source
:
"scrm-main"
,
v
:
"1.0.0"
,
v
:
"1.0.0"
,
},
},
vconsole
:
fals
e
,
vconsole
:
tru
e
,
issuesList
:
[
issuesList
:
[
'你这个保险有点贵啊,好像别人那里都没有那么高的价格。'
,
'你这个保险有点贵啊,好像别人那里都没有那么高的价格。'
,
'我这个保险在外面朋友买没那么便宜。'
,
'我这个保险在外面朋友买没那么便宜。'
,
...
...
Write
Preview
Markdown
is supported
Attach a file
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 post a comment