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
f47d5204
authored
Jul 16, 2019
by
施宇
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
1111
parent
c82f6320
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
113 additions
and
95 deletions
Application/Home/View/RobOrder/index.html
Application/Home/View/Search/index.html
dist/css/chat.css
dist/css/chat.less
dist/js/chat/index.js
dist/js/chat/websdk-1.4.8.js
dist/js/global/global.min.js
dist/js/search/index.js
Application/Home/View/RobOrder/index.html
View file @
f47d5204
...
...
@@ -40,8 +40,7 @@
<script
type=
"text/html"
id=
"zqTpl"
>
<
div
class
=
"my_xj_list clr "
>
{{
#
layui
.
each
(
d
,
function
(
index
,
item
){
}}
<
div
class
=
"my_xj_item fl boxsiz"
style
=
"cursor:pointer"
userid
=
"{{item.inquiry_items_id}}"
offerid
=
"{{item.offer_id}}"
>
<
div
class
=
"my_xj_item fl boxsiz"
style
=
"cursor:pointer"
userid
=
"{{item.inquiry_items_id}}"
>
<
div
class
=
"item_top clr"
>
<
div
class
=
"fl num ellipsis"
>
{{
item
.
goods_name
}}
<
/div
>
<
/div
>
...
...
Application/Home/View/Search/index.html
View file @
f47d5204
...
...
@@ -98,7 +98,7 @@
<script
type=
"text/html"
id=
"xjhtml"
>
<
div
class
=
"my_xj_list clr "
>
{{
#
layui
.
each
(
d
,
function
(
index
,
item
){
}}
<
div
class
=
"my_xj_item fl boxsiz"
>
<
div
class
=
"my_xj_item fl boxsiz
xj_item"
style
=
"cursor:pointer"
userid
=
"{{item.inquiry_items_id}}
"
>
<
div
class
=
"item_top clr"
>
<
div
class
=
"fl num ellipsis"
>
{{
item
.
goods_name
}}
<
/div
>
<
/div
>
...
...
dist/css/chat.css
View file @
f47d5204
...
...
@@ -88,6 +88,7 @@
}
.chat_content
.content
.content_div
.notice_right
.edit_img
{
cursor
:
pointer
;
max-width
:
100%
;
}
.chat_content
.content
.content_div
.notice_right
.chat_item
{
display
:
none
;
...
...
dist/css/chat.less
View file @
f47d5204
...
...
@@ -108,6 +108,7 @@
.edit_img {
cursor: pointer;
max-width: 100%;
}
.chat_item {
...
...
dist/js/chat/index.js
View file @
f47d5204
...
...
@@ -3,106 +3,64 @@ $(function () {
conn
:
{},
orgName
:
"1113190618181018"
,
appName
:
"icsales"
,
// defaultName:
"18664936975",
defaultName
:
"18589050841"
,
eleTarget
:
"18589050841"
,
defaultName
:
"18664936975"
,
templateObj
:
JSON
.
parse
(
Util
.
getCookie
(
'template'
)
||
"{}"
)
,
isLoginSuccess
:
false
,
init
:
function
()
{
this
.
ieFun
()
this
.
ieFun
()
;
this
.
connection
();
this
.
connListen
();
this
.
bindFunction
();
this
.
get
UserInfo
();
this
.
get
HistoryUsers
();
},
getUserInfo
:
function
()
{
//获取用户的基本信息
var
self
=
this
;
IcController
.
getData
(
apis
.
authme
,
'POST'
,
null
,
function
(
res
)
{
IcController
.
getData
(
apis
.
authme
,
'POST'
,
{
"token"
:
Util
.
getCookie
(
'token'
)
||
''
,
},
function
(
res
)
{
if
(
res
.
err_code
==
0
)
{
self
.
login
(
res
.
data
.
im_username
,
res
.
data
.
im_password
)
}
else
{
console
.
log
(
'获取用户名失败'
);
layer
.
msg
(
'聊天系统出错'
);
}
},
undefined
,
true
)
},
true
,
true
)
},
getHistoryData
:
function
(
id
,
isCustomer
)
{
getHistoryUsers
:
function
()
{
//获取用户聊天的成员记录
var
self
=
this
;
this
.
conn
.
fetchHistoryMessages
({
queue
:
id
,
count
:
"10"
,
success
:
function
(
data
)
{
self
.
renderHistory
(
isCustomer
,
data
,
id
)
},
fail
:
function
(
e
)
{
console
.
log
(
e
)
IcController
.
getData
(
apis
.
listrecord
,
'GET'
,
{
"token"
:
Util
.
getCookie
(
'token'
)
||
''
,
},
function
(
res
)
{
if
(
res
.
errcode
===
0
)
{
self
.
rendChatSection
(
res
.
data
);
self
.
getUserInfo
();
}
else
{
layer
.
msg
(
'获取历史纪录失败'
);
}
})
},
renderHistory
:
function
(
isCustomer
,
data
,
id
)
{
var
len
=
data
.
length
;
var
arr
=
[];
for
(
var
i
=
0
;
i
<
len
;
i
++
)
{
var
fromId
=
data
[
i
].
from
,
//发送者的id
toId
=
data
[
i
].
to
;
//接收者的id
if
(
fromId
==
'18271408717'
)
{
//自己发送的
this
.
historyHtml
(
1
,
data
[
i
])
}
else
{
//自己接收的
this
.
historyHtml
(
2
,
data
[
i
]);
if
(
data
.
action
==
'action'
)
{
arr
.
push
({
type
:
1
,
data
:
{
ext
:
data
.
ext
}
})
}
else
{
if
(
typeof
(
data
.
data
)
==
'string'
)
{
arr
.
push
({
type
:
3
,
data
:
{
ext
:
data
.
ext
}
})
}
else
{
arr
.
push
({
type
:
3
,
data
:
{
ext
:
data
.
ext
}
})
}
}
}
}
},
historyHtml
:
function
(
leftOrRight
,
data
)
{
//1右边 2左边
if
(
leftOrRight
==
1
)
{
}
else
{
}
});
},
defaultUser
:
function
()
{
//默认客服
this
.
addUser
(
this
.
defaultName
,
true
)
rendChatSection
:
function
(
data
)
{
this
.
addUser
(
this
.
defaultName
);
for
(
var
key
in
data
)
{
this
.
addUser
(
data
[
key
]);
};
},
singleChat
:
function
()
{
var
templateObj
=
JSON
.
parse
(
Util
.
getCookie
(
'template'
)
||
"{}"
)
if
(
JSON
.
stringify
(
templateObj
)
!==
'{}'
)
{
this
.
addUser
(
templateObj
.
userId
,
false
)
this
.
sendCmd
(
templateObj
);
if
(
JSON
.
stringify
(
this
.
templateObj
)
==
'{}'
)
{
$
(
".notice_classify[userid="
+
this
.
defaultName
+
"]"
).
click
();
}
else
{
this
.
addUser
(
this
.
templateObj
.
userId
);
$
(
".notice_classify[userid="
+
this
.
templateObj
.
userId
+
"]"
).
click
();
this
.
sendCmd
(
this
.
templateObj
);
Util
.
delCookie
(
'template'
,
cookieHostname
);
}
},
addUser
:
function
(
id
,
isCustom
)
{
addUser
:
function
(
id
)
{
var
userLen
=
$
(
'.chat_item_content'
).
find
(
'#'
+
id
).
length
;
if
(
userLen
)
{
//用户存在
$
(
".notice_classify[userid="
+
id
+
"]"
).
click
()
;
return
;
}
else
{
//用户不存在
var
lefthtml
=
'<div class="notice_classify" userid="'
+
id
+
'">'
+
this
.
userHtml
(
0
,
id
,
''
)
+
'</div>'
;;
var
righthtml
=
'<div class="chat_item" id="'
+
id
+
'">'
+
...
...
@@ -119,15 +77,9 @@ $(function () {
'</div>'
+
'</div>'
+
'</div>'
;
if
(
isCustom
)
{
//是客服
$
(
'.notice_left_content'
).
prepend
(
lefthtml
);
$
(
'.chat_item_content'
).
prepend
(
righthtml
)
}
else
{
//不是客服
$
(
'.notice_left_content'
).
append
(
lefthtml
);
$
(
'.chat_item_content'
).
append
(
righthtml
)
$
(
'.notice_left_content'
).
append
(
lefthtml
);
$
(
'.chat_item_content'
).
append
(
righthtml
)
}
$
(
".notice_classify[userid="
+
id
+
"]"
).
click
();
}
},
connection
:
function
()
{
...
...
@@ -279,6 +231,7 @@ $(function () {
'<div class="notice_content">'
+
htmlp
+
'<div>'
+
this
.
curentTime
()
+
'</div>'
+
'</div>'
+
'</div>'
}
else
{
return
''
...
...
@@ -291,6 +244,7 @@ $(function () {
'<div class="notice_content">'
+
htmlp
+
'<div>'
+
this
.
curentTime
()
+
'</div>'
+
'</div>'
+
'</div>'
}
else
{
return
''
...
...
@@ -396,9 +350,8 @@ $(function () {
self
.
conn
.
listen
({
onOpened
:
function
(
message
)
{
console
.
log
(
'登入成功'
)
self
.
defaultUser
()
;
self
.
isLoginSuccess
=
true
;
self
.
singleChat
();
self
.
getHistoryData
(
self
.
defaultName
,
true
);
},
onTextMessage
:
function
(
message
)
{
...
...
@@ -444,17 +397,19 @@ $(function () {
},
login
:
function
(
user
,
password
)
{
// open,登录;
var
options
=
{
apiUrl
:
WebIM
.
config
.
apiURL
,
user
:
'18271408717'
,
pwd
:
'123456'
,
user
:
user
,
pwd
:
password
,
appKey
:
WebIM
.
config
.
appkey
};
try
{
this
.
conn
.
open
(
options
);
}
catch
(
e
)
{
console
.
log
(
'登入失败'
);
console
.
log
(
e
);
layer
.
msg
(
'登入失败'
);
}
},
...
...
@@ -493,7 +448,9 @@ $(function () {
msg
:
'template'
,
to
:
userId
,
action
:
"template"
,
ext
:
templateObj
,
ext
:
$
.
extend
({},
templateObj
,
{
time
:
self
.
curentTime
()
}),
success
:
function
()
{
$
(
'#'
+
userId
).
find
(
'.notice_item_content'
).
append
(
self
.
messageHtml
(
1
,
templateObj
,
true
));
...
...
@@ -588,13 +545,69 @@ $(function () {
$
(
this
).
addClass
(
'active'
).
siblings
(
'.notice_classify'
).
removeClass
(
'active'
);
var
contentHeight
=
$
(
'#'
+
id
).
find
(
'.notice_item_content'
).
height
();
$
(
'#'
+
id
).
find
(
'.notice_list'
).
scrollTop
(
contentHeight
);
if
(
self
.
isLoginSuccess
)
{
//登入成功 获取聊天记录
self
.
getHistoryData
(
id
)
}
else
{
layer
.
msg
(
'获取聊天记录失败'
);
return
;
}
});
$
(
'.notice_right '
).
on
(
'click'
,
'.edit_img'
,
function
()
{
})
}
},
getHistoryData
:
function
(
id
)
{
var
self
=
this
;
this
.
conn
.
fetchHistoryMessages
({
queue
:
id
,
count
:
"50"
,
success
:
function
(
data
)
{
self
.
rendHistoryMessage
(
id
,
data
)
},
fail
:
function
(
e
)
{
console
.
log
(
e
)
layer
.
msg
(
'获取历史纪录失败'
);
}
})
},
rendHistoryMessage
:
function
(
id
,
data
)
{
var
chatCon
=
""
;
for
(
var
i
=
0
;
i
<
data
.
length
;
i
++
)
{
var
fromId
=
data
[
i
].
from
;
var
rightOrLeft
=
1
;
//默认右边
var
emojiTxt
=
""
;
if
(
fromId
==
id
)
{
//接收的 左边
rightOrLeft
=
2
;
}
if
(
data
[
i
].
data
)
{
//消息或者表情
if
(
typeof
(
data
[
i
].
data
)
==
'string'
)
{
chatCon
+=
this
.
messageHtml
(
rightOrLeft
,
data
[
i
].
data
);
}
else
{
for
(
var
j
=
0
;
j
<
data
[
i
].
data
.
length
;
j
++
)
{
if
(
data
[
i
].
data
[
j
].
type
==
"txt"
)
{
emojiTxt
+=
data
[
i
].
data
[
j
].
data
}
else
{
emojiTxt
+=
'<img src ="'
+
data
[
i
].
data
[
j
].
data
+
'" width=25 height=25/>'
;
}
}
chatCon
+=
this
.
messageHtml
(
rightOrLeft
,
emojiTxt
);
}
}
else
if
(
data
[
i
].
url
)
{
//图片
chatCon
+=
this
.
messageHtml
(
rightOrLeft
,
'<img src ="'
+
data
[
i
].
url
+
'" class="edit_img"/>'
);
}
else
if
(
data
.
action
)
{
//模板
}
}
$
(
'#'
+
id
).
find
(
'.notice_item_content'
).
prepend
(
chatCon
);
var
contentHeight
=
$
(
'#'
+
id
).
find
(
'.notice_item_content'
)
.
height
();
$
(
'#'
+
id
).
find
(
'.notice_list'
).
scrollTop
(
contentHeight
);
},
};
chatObj
.
init
();
})
\ No newline at end of file
dist/js/chat/websdk-1.4.8.js
View file @
f47d5204
This diff could not be displayed because it is too large.
dist/js/global/global.min.js
View file @
f47d5204
...
...
@@ -43,7 +43,7 @@
withCredentials
:
true
},
success
:
function
(
data
)
{
//处理token失效的情况
if
(
data
.
errcode
===
501
||
data
.
err_code
===
501
)
{
...
...
@@ -55,7 +55,6 @@
});
}
else
{
typeof
callback
==
'function'
&&
callback
(
data
);
layer
.
close
(
index
);
...
...
dist/js/search/index.js
View file @
f47d5204
...
...
@@ -86,7 +86,11 @@ $(function () {
time
=
new
Date
(
Util
.
getDay
(
-
7
));
self
.
getData
(
spOrXj
,
1
,
time
.
getTime
()
/
1000
)
}
})
});
$
(
'.goods_data_list'
).
on
(
'click'
,
'.xj_item'
,
function
(){
var
userid
=
$
(
this
).
attr
(
'userid'
);
window
.
location
.
href
=
"/quotedetail?id="
+
userid
});
}
};
search
.
init
();
...
...
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