Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
施宇
/
icsales
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
e0eaf2e3
authored
Aug 05, 2019
by
施宇
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
11111
parent
4e38dbad
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
100 additions
and
40 deletions
Application/Home/View/Chat/index.html
dist/js/chat/index.js
Application/Home/View/Chat/index.html
View file @
e0eaf2e3
...
...
@@ -36,7 +36,7 @@
<li
class=
"fl"
><img
src=
"__PUBLIC__/faces/ee_12.png"
alt=
""
data-text=
"[:|]"
></li>
<li
class=
"fl"
><img
src=
"__PUBLIC__/faces/ee_13.png"
alt=
""
data-text=
"[(a)]"
></li>
<li
class=
"fl"
><img
src=
"__PUBLIC__/faces/ee_14.png"
alt=
""
data-text=
"[8o|]"
></li>
<li
class=
"fl"
><img
src=
"__PUBLIC__/faces/ee_15.png"
alt=
""
data-text=
"[|]"
></li>
<li
class=
"fl"
><img
src=
"__PUBLIC__/faces/ee_15.png"
alt=
""
data-text=
"[
8-
|]"
></li>
<li
class=
"fl"
><img
src=
"__PUBLIC__/faces/ee_16.png"
alt=
""
data-text=
"[+o(]"
></li>
<li
class=
"fl"
><img
src=
"__PUBLIC__/faces/ee_17.png"
alt=
""
data-text=
"[o)]"
></li>
<li
class=
"fl"
><img
src=
"__PUBLIC__/faces/ee_18.png"
alt=
""
data-text=
"[|-)]"
></li>
...
...
dist/js/chat/index.js
View file @
e0eaf2e3
...
...
@@ -3,7 +3,8 @@ $(function () {
conn
:
{},
orgName
:
"1113190618181018"
,
appName
:
"icsales"
,
defaultName
:
"18664936975"
,
defaultName
:
"001"
,
customerNum
:
""
,
templateObj
:
JSON
.
parse
(
Util
.
getCookie
(
'template'
)
||
"{}"
),
customerText
:
Util
.
getCookie
(
'customer'
)
||
""
,
isLoginSuccess
:
false
,
...
...
@@ -31,6 +32,7 @@ $(function () {
self
.
img
=
res
.
data
.
avatar
;
self
.
name
=
res
.
data
.
company_name
||
'--'
;
self
.
id
=
res
.
data
.
user_id
+
''
;
self
.
customerNum
=
res
.
data
.
im_username
||
''
;
self
.
getHistoryUsers
(
res
.
data
.
im_username
,
res
.
data
.
im_password
);
}
else
{
...
...
@@ -68,15 +70,21 @@ $(function () {
},
false
);
},
rendChatSection
:
function
(
data
)
{
console
.
log
(
'获取成员'
)
if
(
this
.
customerNum
!==
this
.
defaultName
)
{
this
.
addUser
({},
true
);
}
for
(
var
i
=
0
;
i
<
data
.
length
;
i
++
)
{
this
.
addUser
(
data
[
i
])
}
},
singleChat
:
function
()
{
if
(
JSON
.
stringify
(
this
.
templateObj
)
==
'{}'
)
{
if
(
this
.
customerNum
!==
this
.
defaultName
)
{
$
(
".notice_classify[userid="
+
this
.
defaultName
+
"]"
).
click
();
}
else
{
$
(
".notice_classify"
).
first
().
click
();
}
}
else
{
Util
.
delCookie
(
'template'
,
cookieHostname
);
this
.
addUser
({},
false
,
true
);
...
...
@@ -98,24 +106,29 @@ $(function () {
},
addUser
:
function
(
obj
,
isDefault
,
isFirst
)
{
var
id
,
name
,
img
,
touserid
;
var
id
,
name
,
img
,
touserid
,
img1
;
if
(
isDefault
)
{
id
=
this
.
defaultName
;
name
=
'IC助手客服'
;
touserid
=
""
;
img
=
dist
+
"/images/timg.jpg"
;
img1
=
dist
+
"/images/timg.jpg"
;
}
else
{
if
(
isFirst
)
{
id
=
this
.
templateObj
.
userId
;
touserid
=
this
.
templateObj
.
touserid
;
name
=
this
.
templateObj
.
userName
;
img
=
this
.
templateObj
.
userImg
||
(
dist
+
"/images/default.jpg"
);
img1
=
this
.
templateObj
.
userImg
||
""
}
else
{
id
=
obj
.
im_username
;
name
=
obj
.
company_name
||
'--'
;
touserid
=
obj
.
user_id
;
img
=
obj
.
avatar
||
(
dist
+
"/images/default.jpg"
)
img
=
obj
.
avatar
||
(
dist
+
"/images/default.jpg"
);
img1
=
obj
.
avatar
||
""
}
}
...
...
@@ -123,11 +136,11 @@ $(function () {
if
(
userLen
)
{
//用户存在
return
;
}
else
{
//用户不存在
var
lefthtml
=
'<div class="notice_classify" userid="'
+
id
+
'" firstClick="true" touserid=
'
+
touserid
+
'
>'
+
this
.
userHtml
(
0
,
{
var
lefthtml
=
'<div class="notice_classify" userid="'
+
id
+
'" firstClick="true" touserid=
"'
+
touserid
+
'"name="'
+
name
+
'" img="'
+
img1
+
'"
>'
+
this
.
userHtml
(
0
,
{
name
:
name
,
id
:
id
,
img
:
img
},
''
)
+
'</div>'
;
;
},
''
)
+
'</div>'
;
var
righthtml
=
'<div class="chat_item" id="'
+
id
+
'">'
+
'<div class="title clr">'
+
// '<div class="fr btn btn_border">' +
...
...
@@ -183,7 +196,7 @@ $(function () {
'[:|]'
:
'ee_12.png'
,
'[(a)]'
:
'ee_13.png'
,
'[8o|]'
:
'ee_14.png'
,
'[|]'
:
'ee_15.png'
,
'[
8-
|]'
:
'ee_15.png'
,
'[+o(]'
:
'ee_16.png'
,
'[o)]'
:
'ee_17.png'
,
'[|-)]'
:
'ee_18.png'
,
...
...
@@ -376,11 +389,17 @@ $(function () {
if
(
!
len
)
{
//新用户
Util
.
delCookie
(
'templateBoolean'
,
cookieHostname
);
var
userStr
=
'<div class="notice_classify active" userid="'
+
message
.
from
+
'" firstClick="true" newMember="true" touserid=
'
+
message
.
touserid
+
'
>'
+
var
userStr
=
'<div class="notice_classify active" userid="'
+
message
.
from
+
'" firstClick="true" newMember="true" touserid=
"'
+
message
.
touserid
+
'"name="'
+
message
.
name
+
'" img="'
+
message
.
img
+
'"
>'
+
self
.
userHtml
(
0
,
message
,
regContent
)
+
'</div>'
;
var
messageStr
=
'<div class="chat_item active" id="'
+
message
.
from
+
'">'
+
messageSigleStr
+
'</div>'
if
(
self
.
defaultName
!=
self
.
customerNum
)
{
if
(
self
.
defaultName
!=
message
.
from
)
{
$
(
".notice_classify[userid="
+
self
.
defaultName
+
"]"
).
after
(
userStr
);
}
}
else
{
$
(
".notice_left_content"
).
prepend
(
userStr
);
}
// $('.notice_left_content').append(userStr);
$
(
'.chat_item_content'
).
append
(
messageStr
)
}
else
{
...
...
@@ -422,8 +441,15 @@ $(function () {
var
num
=
Number
(
$
(
this
).
find
(
'.num'
).
text
());
$
(
this
).
html
(
self
.
userHtml
(
num
+
1
,
message
,
regContent
));
var
html
=
$
(
this
).
clone
();
if
(
self
.
defaultName
!=
self
.
customerNum
)
{
//不是客服
if
(
message
.
from
!=
self
.
defaultName
)
{
$
(
this
).
remove
();
$
(
".notice_classify[userid="
+
self
.
defaultName
+
"]"
).
after
(
html
);
}
}
else
{
$
(
this
).
remove
();
$
(
".notice_left_content"
).
prepend
(
html
);
}
if
(
!
firstClick
)
{
$
(
'#'
+
userId
).
find
(
'.notice_item_content'
).
append
(
self
.
messageHtml
(
2
,
htmlStr
,
isTemplate
));
...
...
@@ -436,12 +462,18 @@ $(function () {
//新用户
Util
.
delCookie
(
'templateBoolean'
,
cookieHostname
);
var
userStr
=
'<div class="notice_classify" userid="'
+
message
.
from
+
'" newMember="true" touserid=
'
+
message
.
touserid
+
'
>'
+
message
.
from
+
'" newMember="true" touserid=
"'
+
message
.
touserid
+
'"name="'
+
message
.
name
+
'" img="'
+
message
.
img
+
'"
>'
+
self
.
userHtml
(
1
,
message
,
regContent
)
+
'</div>'
;
var
messageStr
=
'<div class="chat_item" id="'
+
message
.
from
+
'">'
+
messageSigleStr
+
'</div>'
;
if
(
self
.
defaultName
!=
self
.
customerNum
)
{
if
(
self
.
defaultName
!=
message
.
from
)
{
$
(
".notice_classify[userid="
+
self
.
defaultName
+
"]"
).
after
(
userStr
);
}
}
else
{
$
(
".notice_left_content"
).
prepend
(
userStr
);
}
$
(
'.chat_item_content'
).
append
(
messageStr
)
}
}
...
...
@@ -460,31 +492,36 @@ $(function () {
},
onTextMessage
:
function
(
message
)
{
self
.
receiveData
(
1
,
{
name
:
message
.
ext
.
name
||
'--'
,
name
:
self
.
judgeCustomer
(
message
).
name
,
id
:
message
.
ext
.
id
,
img
:
message
.
ext
.
img
||
(
dist
+
"/images/default.jpg"
)
,
img
:
self
.
judgeCustomer
(
message
).
img
,
message
:
message
.
data
,
from
:
message
.
from
,
touserid
:
message
.
ext
.
touserid
},
false
)
},
false
);
if
(
self
.
customerNum
==
self
.
defaultName
)
{
self
.
addChatMember
(
message
.
ext
.
id
)
}
},
//收到文本消息;
onEmojiMessage
:
function
(
message
)
{
self
.
receiveData
(
3
,
{
name
:
message
.
ext
.
name
||
'--'
,
name
:
self
.
judgeCustomer
(
message
).
name
,
id
:
message
.
ext
.
id
,
img
:
message
.
ext
.
img
||
(
dist
+
"/images/default.jpg"
)
,
img
:
self
.
judgeCustomer
(
message
).
img
,
message
:
message
.
data
,
from
:
message
.
from
,
touserid
:
message
.
ext
.
touserid
},
false
)
},
false
);
if
(
self
.
customerNum
==
self
.
defaultName
)
{
self
.
addChatMember
(
message
.
ext
.
id
)
}
},
//收到表情消息;
onCmdMessage
:
function
(
message
)
{
console
.
log
(
message
)
self
.
receiveData
(
1
,
{
name
:
message
.
ext
.
name
||
'--'
,
name
:
self
.
judgeCustomer
(
message
).
name
,
id
:
message
.
ext
.
id
,
img
:
message
.
ext
.
img
||
(
dist
+
"/images/default.jpg"
)
,
img
:
self
.
judgeCustomer
(
message
).
img
,
from
:
message
.
from
,
type
:
message
.
ext
.
type
,
price
:
message
.
ext
.
price
,
...
...
@@ -505,15 +542,16 @@ $(function () {
options
.
onFileDownloadComplete
=
function
()
{
// 图片下载成功;
self
.
receiveData
(
2
,
{
name
:
message
.
ext
.
name
||
'--'
,
name
:
self
.
judgeCustomer
(
message
).
name
,
id
:
message
.
ext
.
id
,
img
:
message
.
ext
.
img
||
(
dist
+
"/images/default.jpg"
)
,
img
:
self
.
judgeCustomer
(
message
).
img
,
from
:
message
.
from
,
url
:
message
.
url
,
touserid
:
message
.
ext
.
touserid
},
false
)
},
false
);
if
(
self
.
customerNum
==
self
.
defaultName
)
{
self
.
addChatMember
(
message
.
ext
.
id
)
}
};
options
.
onFileDownloadError
=
function
()
{
// 图片下载失败
...
...
@@ -536,6 +574,17 @@ $(function () {
},
//失败回调;
});
},
judgeCustomer
:
function
(
message
)
{
//1 标题 2//图片
var
obj
=
{
name
:
""
,
img
:
""
};
if
(
message
.
from
==
this
.
defaultName
)
{
obj
.
img
=
dist
+
"/images/timg.jpg"
;
obj
.
name
=
'IC助手客服'
;
}
else
{
obj
.
img
=
message
.
ext
.
img
||
(
dist
+
"/images/default.jpg"
);
obj
.
name
=
message
.
ext
.
name
||
'--'
;
}
return
obj
},
login
:
function
(
user
,
password
)
{
// open,登录;
...
...
@@ -559,6 +608,8 @@ $(function () {
// 私聊发送文本消息,发送表情同发送文本消息,只是会在对方客户端将表情文本进行解析成图片;
var
userId
=
$
(
'.notice_left '
).
find
(
'.active'
).
attr
(
'userid'
);
var
touserid
=
$
(
'.notice_left '
).
find
(
'.active'
).
attr
(
'touserid'
);
var
name
=
$
(
'.notice_left '
).
find
(
'.active'
).
attr
(
'name'
);
var
img
=
$
(
'.notice_left '
).
find
(
'.active'
).
attr
(
'img'
);
var
id
=
this
.
conn
.
getUniqueId
();
var
msg
=
new
WebIM
.
default
.
message
(
'txt'
,
id
);
var
emojiMessage
=
WebIM
.
default
.
utils
.
parseEmoji
(
content
);
//表情解析工具
...
...
@@ -567,7 +618,9 @@ $(function () {
id
:
self
.
id
,
name
:
self
.
name
,
img
:
self
.
img
,
touserid
:
touserid
touserid
:
touserid
,
name1
:
name
,
img1
:
img
};
msg
.
set
({
msg
:
content
,
// 消息内容;
...
...
@@ -576,8 +629,8 @@ $(function () {
success
:
function
(
id
,
serverMsgId
)
{
$
(
'#'
+
userId
).
find
(
'.notice_item_content'
).
append
(
self
.
messageHtml
(
1
,
{
message
:
emojiMessage
,
name
:
self
.
name
,
img
:
self
.
img
,
name
:
self
.
customerNum
==
self
.
defaultName
?
'IC助手客服'
:
self
.
name
,
img
:
self
.
customerNum
==
self
.
defaultName
?
dist
+
"/images/timg.jpg"
:
self
.
img
,
id
:
self
.
id
},
false
));
...
...
@@ -612,6 +665,8 @@ $(function () {
var
self
=
this
;
var
userId
=
$
(
'.notice_left '
).
find
(
'.active'
).
attr
(
'userid'
);
var
touserid
=
$
(
'.notice_left '
).
find
(
'.active'
).
attr
(
'touserid'
);
var
name
=
$
(
'.notice_left '
).
find
(
'.active'
).
attr
(
'name'
);
var
img
=
$
(
'.notice_left '
).
find
(
'.active'
).
attr
(
'img'
);
var
id
=
this
.
conn
.
getUniqueId
();
var
msg
=
new
WebIM
.
default
.
message
(
'cmd'
,
id
);
var
params
=
$
.
extend
({},
templateObj
,
{
...
...
@@ -619,7 +674,9 @@ $(function () {
name
:
self
.
name
,
id
:
self
.
id
,
img
:
self
.
img
,
touserid
:
touserid
touserid
:
touserid
,
name1
:
name
,
img1
:
img
});
msg
.
set
({
msg
:
'template'
,
...
...
@@ -665,7 +722,8 @@ $(function () {
var
file
=
WebIM
.
default
.
utils
.
getFileUrl
(
input
);
// 将图片转化为二进制文件;
var
userId
=
$
(
'.notice_left'
).
find
(
'.active'
).
attr
(
'userid'
);
var
touserid
=
$
(
'.notice_left '
).
find
(
'.active'
).
attr
(
'touserid'
);
var
name
=
$
(
'.notice_left '
).
find
(
'.active'
).
attr
(
'name'
);
var
img
=
$
(
'.notice_left '
).
find
(
'.active'
).
attr
(
'img'
);
var
option
=
{
apiUrl
:
WebIM
.
config
.
apiURL
,
file
:
file
,
...
...
@@ -673,9 +731,11 @@ $(function () {
ext
:
{
timer
:
self
.
curentTime
(),
id
:
self
.
id
,
name
:
self
.
name
,
name
:
self
.
name
,
img
:
self
.
img
,
touserid
:
touserid
touserid
:
touserid
,
name1
:
name
,
img1
:
img
},
flashUpload
:
WebIM
.
flashUpload
,
onFileUploadError
:
function
()
{
...
...
@@ -688,8 +748,8 @@ $(function () {
var
htmlStr
=
'<img src ="'
+
file
.
url
+
'" class="edit_img"/>'
;
$
(
'#'
+
userId
).
find
(
'.notice_item_content'
).
append
(
self
.
messageHtml
(
1
,
{
message
:
htmlStr
,
name
:
self
.
name
,
img
:
self
.
img
,
name
:
self
.
customerNum
==
self
.
defaultName
?
'IC助手客服'
:
self
.
name
,
img
:
self
.
customerNum
==
self
.
defaultName
?
dist
+
"/images/timg.jpg"
:
self
.
img
,
id
:
self
.
id
},
false
));
var
imgLen
=
$
(
'#'
+
userId
).
find
(
'img'
).
length
;
...
...
@@ -716,7 +776,6 @@ $(function () {
}
};
msg
.
set
(
option
);
console
.
log
(
msg
.
body
)
this
.
conn
.
send
(
msg
.
body
);
},
...
...
@@ -855,6 +914,7 @@ $(function () {
})
},
rendHistoryMessage
:
function
(
id
,
data
,
isTemplate
)
{
console
.
log
(
data
)
var
chatCon
=
""
;
for
(
var
i
=
0
;
i
<
data
.
length
;
i
++
)
{
var
fromId
=
data
[
i
].
from
;
...
...
@@ -867,8 +927,8 @@ $(function () {
if
(
typeof
(
data
[
i
].
data
)
==
'string'
)
{
chatCon
+=
this
.
messageHtml
(
rightOrLeft
,
{
message
:
data
[
i
].
data
,
name
:
data
[
i
].
ext
.
name
,
img
:
data
[
i
].
ext
.
img
,
name
:
this
.
judgeCustomer
(
data
[
i
])
.
name
,
img
:
this
.
judgeCustomer
(
data
[
i
])
.
img
,
id
:
data
[
i
].
ext
.
id
},
false
,
true
,
data
[
i
].
ext
.
timer
);
}
else
{
...
...
@@ -881,8 +941,8 @@ $(function () {
}
chatCon
+=
this
.
messageHtml
(
rightOrLeft
,
{
message
:
emojiTxt
,
name
:
data
[
i
].
ext
.
name
,
img
:
data
[
i
].
ext
.
img
,
name
:
this
.
judgeCustomer
(
data
[
i
])
.
name
,
img
:
this
.
judgeCustomer
(
data
[
i
])
.
img
,
id
:
data
[
i
].
ext
.
id
},
false
,
true
,
data
[
i
].
ext
.
timer
);
}
...
...
@@ -890,8 +950,8 @@ $(function () {
}
else
if
(
data
[
i
].
url
)
{
//图片
chatCon
+=
this
.
messageHtml
(
rightOrLeft
,
{
message
:
'<img src ="'
+
data
[
i
].
url
+
'" class="edit_img"/>'
,
name
:
data
[
i
].
ext
.
name
,
img
:
data
[
i
].
ext
.
img
,
name
:
this
.
judgeCustomer
(
data
[
i
])
.
name
,
img
:
this
.
judgeCustomer
(
data
[
i
])
.
img
,
id
:
data
[
i
].
ext
.
id
},
false
,
true
,
data
[
i
].
ext
.
timer
);
}
else
if
(
data
[
i
].
action
==
'template'
)
{
//模板
...
...
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