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'
);
import
axios
from
"axios"
;
import
*
as
qiniu
from
"qiniu-js"
;
// eslint-disable-next-line no-undef
var
Helps
=
{};
Helps
.
install
=
function
(
Vue
,
options
)
{
Vue
.
prototype
.
$myMethod
=
function
()
{
Vue
.
prototype
.
$myMethod
=
function
()
{
console
.
log
(
options
)
}
// 格式化日期
Vue
.
prototype
.
$formatUnixDate
=
function
(
unix
,
format
)
{
Vue
.
prototype
.
$formatUnixDate
=
function
(
unix
,
format
)
{
return
moment
(
parseInt
(
unix
+
'000'
)).
format
(
format
)
}
// 格式化日期(相对日期)
Vue
.
prototype
.
$formatFromNowDate
=
function
(
unix
,
format
=
"YYYY-MM-DD HH:mm"
)
{
if
(
moment
().
format
(
"YYYYMMDD"
)
==
moment
(
parseInt
(
unix
+
'000'
)).
format
(
"YYYYMMDD"
))
{
Vue
.
prototype
.
$formatFromNowDate
=
function
(
unix
,
format
=
"YYYY-MM-DD HH:mm"
)
{
if
(
moment
().
format
(
"YYYYMMDD"
)
==
moment
(
parseInt
(
unix
+
'000'
)).
format
(
"YYYYMMDD"
))
{
return
"今天 "
+
moment
(
parseInt
(
unix
+
'000'
)).
format
(
"HH:mm"
)
}
return
moment
(
parseInt
(
unix
+
'000'
)).
format
(
format
)
}
Vue
.
prototype
.
$robotNickname
=
function
(
id
)
{
Vue
.
prototype
.
$robotNickname
=
function
(
id
)
{
var
nickname
var
robots
=
this
.
$store
.
getters
.
robots
for
(
let
i
=
0
;
i
<
robots
.
length
;
i
++
)
{
if
(
robots
[
i
].
id
==
id
)
{
for
(
let
i
=
0
;
i
<
robots
.
length
;
i
++
)
{
if
(
robots
[
i
].
id
==
id
)
{
nickname
=
robots
[
i
].
nickname
}
}
return
nickname
}
// 判断是否是全面屏
Vue
.
prototype
.
$judgeBigScreen
=
function
(){
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
;
// 上传文件
Vue
.
prototype
.
$uploadFile
=
function
({
mode
,
file
,
percent
,
success
,
fail
})
{
var
qiniuObservable
=
null
;
const
fileName
=
parseInt
(
Math
.
random
()
*
10000
*
new
Date
().
getTime
())
+
file
.
name
.
substr
(
file
.
name
.
lastIndexOf
(
"."
));
// 系统内置
if
(
mode
==
1
)
{
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
;
\ 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({
routes
:
[
{
path
:
'/'
,
name
:
'kefu'
,
redirect
:
'/index'
},
{
path
:
'/index'
,
name
:
'index'
,
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
{
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 {
},
robotAccount
(
state
)
{
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
{
updateState
(
state
,
newObj
){
var
oldState
=
state
for
(
var
i
in
newObj
)
{
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 {
artificialAccount
:
null
,
// 客服账号ID
robotInfo
:
null
,
// 机器人信息
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
>
<div
class=
"container"
>
<mt-header
v-if=
"isShowHeader"
fixed
:title=
"isInputPongIng ? inputPongIngString : '在线客服'
"
>
<mt-header
v-if=
"isShowHeader"
fixed
title=
"工单
"
>
<div
slot=
"left"
>
<mt-button
@
click=
"
back
"
icon=
"back"
></mt-button>
<mt-button
@
click=
"
$router.go(-1)
"
icon=
"back"
></mt-button>
</div>
<mt-button
@
click=
"headRightBtn"
slot=
"right"
>
<img
title=
"人工客服"
v-if=
"!isArtificial"
src=
"http://qiniu.cmp520.com/kefu_icon_2000.png"
alt
/>
<span
v-else
>
结束会话
</span>
<mt-button
@
click=
"$router.push('/workorder/create')"
slot=
"right"
>
<span>
创建工单
</span>
</mt-button>
</mt-header>
</div>
</
template
>
<
script
>
import
{
mapGetters
}
from
'vuex'
export
default
{
name
:
"workorder"
,
components
:
{},
data
()
{
return
{};
},
computed
:
{
...
mapGetters
([
'isShowHeader'
])
},
mounted
()
{},
methods
:
{}
methods
:
{
}
};
</
script
>
<
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