Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
杨树贤
/
kefu_server
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
825ca73b
authored
Mar 21, 2020
by
chenxianqi
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
update code
parent
98c8f64f
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
220 additions
and
25 deletions
ui/kefu_client/plugins/help.js
ui/kefu_client/src/App.vue
ui/kefu_client/src/router.js
ui/kefu_client/src/store/actions.js
ui/kefu_client/src/store/getters.js
ui/kefu_client/src/store/mutations.js
ui/kefu_client/src/store/state.js
ui/kefu_client/src/views/kefu.vue
ui/kefu_client/src/views/workorder.vue
ui/kefu_client/plugins/help.js
View file @
825ca73b
var
moment
=
require
(
'moment'
);
var
moment
=
require
(
'moment'
);
import
axios
from
"axios"
;
import
*
as
qiniu
from
"qiniu-js"
;
// eslint-disable-next-line no-undef
// eslint-disable-next-line no-undef
var
Helps
=
{};
var
Helps
=
{};
Helps
.
install
=
function
(
Vue
,
options
)
{
Helps
.
install
=
function
(
Vue
,
options
)
{
Vue
.
prototype
.
$myMethod
=
function
()
{
Vue
.
prototype
.
$myMethod
=
function
()
{
console
.
log
(
options
)
console
.
log
(
options
)
}
}
// 格式化日期
// 格式化日期
Vue
.
prototype
.
$formatUnixDate
=
function
(
unix
,
format
)
{
Vue
.
prototype
.
$formatUnixDate
=
function
(
unix
,
format
)
{
return
moment
(
parseInt
(
unix
+
'000'
)).
format
(
format
)
return
moment
(
parseInt
(
unix
+
'000'
)).
format
(
format
)
}
}
// 格式化日期(相对日期)
// 格式化日期(相对日期)
Vue
.
prototype
.
$formatFromNowDate
=
function
(
unix
,
format
=
"YYYY-MM-DD HH:mm"
)
{
Vue
.
prototype
.
$formatFromNowDate
=
function
(
unix
,
format
=
"YYYY-MM-DD HH:mm"
)
{
if
(
moment
().
format
(
"YYYYMMDD"
)
==
moment
(
parseInt
(
unix
+
'000'
)).
format
(
"YYYYMMDD"
))
{
if
(
moment
().
format
(
"YYYYMMDD"
)
==
moment
(
parseInt
(
unix
+
'000'
)).
format
(
"YYYYMMDD"
))
{
return
"今天 "
+
moment
(
parseInt
(
unix
+
'000'
)).
format
(
"HH:mm"
)
return
"今天 "
+
moment
(
parseInt
(
unix
+
'000'
)).
format
(
"HH:mm"
)
}
}
return
moment
(
parseInt
(
unix
+
'000'
)).
format
(
format
)
return
moment
(
parseInt
(
unix
+
'000'
)).
format
(
format
)
}
}
Vue
.
prototype
.
$robotNickname
=
function
(
id
)
{
Vue
.
prototype
.
$robotNickname
=
function
(
id
)
{
var
nickname
var
nickname
var
robots
=
this
.
$store
.
getters
.
robots
var
robots
=
this
.
$store
.
getters
.
robots
for
(
let
i
=
0
;
i
<
robots
.
length
;
i
++
)
{
for
(
let
i
=
0
;
i
<
robots
.
length
;
i
++
)
{
if
(
robots
[
i
].
id
==
id
)
{
if
(
robots
[
i
].
id
==
id
)
{
nickname
=
robots
[
i
].
nickname
nickname
=
robots
[
i
].
nickname
}
}
}
}
return
nickname
return
nickname
}
}
// 判断是否是全面屏
// 上传文件
Vue
.
prototype
.
$judgeBigScreen
=
function
(){
Vue
.
prototype
.
$uploadFile
=
function
({
mode
,
file
,
percent
,
success
,
fail
})
{
let
yes
=
false
;
var
qiniuObservable
=
null
;
const
rate
=
window
.
screen
.
height
/
window
.
screen
.
width
;
const
fileName
=
parseInt
(
Math
.
random
()
*
10000
*
new
Date
().
getTime
())
+
file
.
name
.
substr
(
file
.
name
.
lastIndexOf
(
"."
));
let
limit
=
window
.
screen
.
height
==
window
.
screen
.
availHeight
?
1.8
:
1.65
;
// 系统内置
if
(
rate
>
limit
)
yes
=
true
;
if
(
mode
==
1
)
{
return
yes
;
let
fd
=
new
FormData
();
fd
.
append
(
"file"
,
file
);
fd
.
append
(
"file_name"
,
fileName
);
axios
.
post
(
"/public/upload"
,
fd
)
.
then
(
res
=>
{
if
(
success
)
success
(
res
.
data
.
data
);
})
.
catch
(()
=>
{
if
(
fail
)
fail
();
});
}
// 七牛云
else
if
(
mode
==
2
)
{
let
options
=
{
quality
:
0.92
,
noCompressIfLarger
:
true
,
maxWidth
:
1500
};
qiniu
.
compressImage
(
file
,
options
).
then
(
data
=>
{
const
observable
=
qiniu
.
upload
(
data
.
dist
,
fileName
,
self
.
uploadToken
.
secret
,
{},
{
mimeType
:
null
}
);
qiniuObservable
=
observable
.
subscribe
({
next
:
function
(
res
)
{
if
(
percent
)
percent
(
res
)
},
error
:
function
()
{
// 失败后再次使用FormData上传
var
formData
=
new
FormData
();
formData
.
append
(
"fileType"
,
"image"
);
formData
.
append
(
"fileName"
,
"file"
);
formData
.
append
(
"key"
,
fileName
);
formData
.
append
(
"token"
,
self
.
uploadToken
.
secret
);
formData
.
append
(
"file"
,
file
);
axios
.
post
(
"https://upload.qiniup.com"
,
formData
)
.
then
(()
=>
{
if
(
success
)
success
(
fileName
);
})
.
catch
(()
=>
{
if
(
fail
)
fail
();
});
},
complete
:
function
(
res
)
{
if
(
success
)
success
(
res
.
key
);
}
});
});
}
return
qiniuObservable
}
}
}
}
export
default
Helps
;
export
default
Helps
;
\ No newline at end of file
ui/kefu_client/src/App.vue
View file @
825ca73b
This diff is collapsed.
Click to expand it.
ui/kefu_client/src/router.js
View file @
825ca73b
...
@@ -7,7 +7,11 @@ const router = new Router({
...
@@ -7,7 +7,11 @@ const router = new Router({
routes
:
[
routes
:
[
{
{
path
:
'/'
,
path
:
'/'
,
name
:
'kefu'
,
redirect
:
'/index'
},
{
path
:
'/index'
,
name
:
'index'
,
component
:
()
=>
import
(
'./views/kefu.vue'
)
component
:
()
=>
import
(
'./views/kefu.vue'
)
},
},
{
{
...
...
ui/kefu_client/src/store/actions.js
View file @
825ca73b
const
axios
=
require
(
'axios'
)
import
axios
from
"axios"
;
export
default
{
export
default
{
ON_CHANGE_CAR_LIST
(
context
,
params
)
{
// 获取消息列表
context
.
commit
(
'onChangeCarList'
,
params
)
// params.timestamp
// params.callback
// params.oldMsg old msgs
onGetMessages
(
context
,
params
)
{
const
pageSize
=
20
;
axios
.
post
(
"/public/messages"
,
{
timestamp
:
params
.
timestamp
,
page_size
:
pageSize
})
.
then
(
response
=>
{
let
newMessage
=
[];
let
messages
=
response
.
data
.
data
.
list
||
[];
if
(
messages
.
length
<
pageSize
)
{
context
.
commit
(
'updateState'
,
{
isLoadMorEnd
:
true
})
}
if
(
params
.
oldMsg
.
length
==
0
&&
messages
.
length
>
0
)
{
newMessage
=
response
.
data
.
data
.
list
}
else
if
(
messages
.
length
>
0
)
{
newMessage
=
messages
.
concat
(
params
.
oldMsg
);
}
context
.
commit
(
'updateState'
,
{
messages
:
newMessage
})
if
(
params
.
callback
)
params
.
callback
()
})
.
catch
(
error
=>
{
console
.
log
(
error
);
});
},
},
// 获取用户位置
// APPKey 高德地图web应用key
onGetLocal
(
context
,
APPKey
)
{
axios
.
get
(
"https://restapi.amap.com/v3/ip?key="
+
APPKey
)
.
then
(
response
=>
{
if
(
response
.
data
.
province
)
{
context
.
commit
(
'updateState'
,
{
userLocal
:
response
.
data
.
province
+
response
.
data
.
city
})
}
})
.
catch
(
error
=>
{
console
.
error
(
error
);
});
},
// 清除未读消息
onCleanRead
()
{
axios
.
get
(
"/public/clean_read/"
);
},
// 上报最后活动时间
onUpdateLastActivity
()
{
axios
.
get
(
"/public/activity/"
);
},
// 用户是否在当前聊天页面
onToggleWindow
(
context
,
window
)
{
axios
.
put
(
"/public/window/"
,
{
window
});
},
// 用户是否在当前聊天页面
onGetCompanyInfo
(
context
)
{
axios
.
get
(
"/public/company"
)
.
then
(
response
=>
{
context
.
commit
(
'updateState'
,
{
companyInfo
:
response
.
data
.
data
})
})
.
catch
(
error
=>
{
console
.
error
(
error
);
});
},
// 获取上传配置
onGetUploadSecret
(
context
){
axios
.
get
(
"/public/secret"
).
then
(
response
=>
{
context
.
commit
(
'updateState'
,
{
uploadToken
:
response
.
data
.
data
})
});
}
}
}
\ No newline at end of file
ui/kefu_client/src/store/getters.js
View file @
825ca73b
...
@@ -25,5 +25,42 @@ export default {
...
@@ -25,5 +25,42 @@ export default {
},
},
robotAccount
(
state
)
{
robotAccount
(
state
)
{
return
state
.
robotAccount
return
state
.
robotAccount
},
isLoadMorEnd
(
state
)
{
return
state
.
isLoadMorEnd
},
messages
(
state
)
{
return
state
.
messages
||
[]
},
userLocal
(
state
)
{
return
state
.
userLocal
},
isLoadMorLoading
(
state
)
{
return
state
.
isLoadMorLoading
},
userInfo
(
state
)
{
return
state
.
userInfo
},
companyInfo
(
state
)
{
return
state
.
companyInfo
},
uploadToken
(
state
)
{
return
state
.
uploadToken
},
isIOS
()
{
return
!!
navigator
.
userAgent
.
match
(
/
\(
i
[^
;
]
+;
(
U;
)?
CPU.+Mac OS X/
);
},
isSafari
()
{
return
(
navigator
.
userAgent
.
indexOf
(
"Safari"
)
>
-
1
&&
navigator
.
userAgent
.
indexOf
(
"Chrome"
)
<
1
);
},
isJudgeBigScreen
()
{
let
yes
=
false
;
const
rate
=
window
.
screen
.
height
/
window
.
screen
.
width
;
let
limit
=
window
.
screen
.
height
==
window
.
screen
.
availHeight
?
1.8
:
1.65
;
if
(
rate
>
limit
)
yes
=
true
;
return
yes
;
}
}
}
}
\ No newline at end of file
ui/kefu_client/src/store/mutations.js
View file @
825ca73b
export
default
{
export
default
{
updateState
(
state
,
newObj
){
updateState
(
state
,
newObj
){
var
oldState
=
state
for
(
var
i
in
newObj
)
{
for
(
var
i
in
newObj
)
{
if
(
newObj
[
i
]
==
undefined
)
continue
if
(
newObj
[
i
]
==
undefined
)
continue
s
tate
[
i
]
=
newObj
[
i
]
oldS
tate
[
i
]
=
newObj
[
i
]
}
}
state
=
oldState
}
}
}
}
\ No newline at end of file
ui/kefu_client/src/store/state.js
View file @
825ca73b
...
@@ -8,4 +8,12 @@ export default {
...
@@ -8,4 +8,12 @@ export default {
artificialAccount
:
null
,
// 客服账号ID
artificialAccount
:
null
,
// 客服账号ID
robotInfo
:
null
,
// 机器人信息
robotInfo
:
null
,
// 机器人信息
robotAccount
:
null
,
// 机器人账号ID
robotAccount
:
null
,
// 机器人账号ID
messages
:
[],
// 消息列表
isLoadMorEnd
:
false
,
// 是否已经到末尾
userLocal
:
""
,
// 用户地理位置
AmapAPPKey
:
""
,
// 高德地图web appkey
isLoadMorLoading
:
false
,
// 是否在加装更多消息loading
userInfo
:
{},
// 用户信息
companyInfo
:
null
,
// 公司信息
uploadToken
:
null
,
// 上传token
}
}
\ No newline at end of file
ui/kefu_client/src/views/kefu.vue
View file @
825ca73b
This diff is collapsed.
Click to expand it.
ui/kefu_client/src/views/workorder.vue
View file @
825ca73b
<
template
>
<
template
>
<div
class=
"container"
>
<div
class=
"container"
>
<mt-header
v-if=
"isShowHeader"
fixed
:title=
"isInputPongIng ? inputPongIngString : '在线客服'
"
>
<mt-header
v-if=
"isShowHeader"
fixed
title=
"工单
"
>
<div
slot=
"left"
>
<div
slot=
"left"
>
<mt-button
@
click=
"
back
"
icon=
"back"
></mt-button>
<mt-button
@
click=
"
$router.go(-1)
"
icon=
"back"
></mt-button>
</div>
</div>
<mt-button
@
click=
"headRightBtn"
slot=
"right"
>
<mt-button
@
click=
"$router.push('/workorder/create')"
slot=
"right"
>
<img
title=
"人工客服"
v-if=
"!isArtificial"
src=
"http://qiniu.cmp520.com/kefu_icon_2000.png"
alt
/>
<span>
创建工单
</span>
<span
v-else
>
结束会话
</span>
</mt-button>
</mt-button>
</mt-header>
</mt-header>
</div>
</div>
</
template
>
</
template
>
<
script
>
<
script
>
import
{
mapGetters
}
from
'vuex'
export
default
{
export
default
{
name
:
"workorder"
,
name
:
"workorder"
,
components
:
{},
components
:
{},
data
()
{
data
()
{
return
{};
return
{};
},
},
computed
:
{
...
mapGetters
([
'isShowHeader'
])
},
mounted
()
{},
mounted
()
{},
methods
:
{}
methods
:
{
}
};
};
</
script
>
</
script
>
<
style
lang=
"stylus"
scoped
>
<
style
lang=
"stylus"
scoped
>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
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 comment