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
47589bcc
authored
Jul 23, 2019
by
施宇
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
1111
parent
ab06d6e9
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
77 additions
and
36 deletions
Application/Home/View/QuotePrice/inquirydetail.html
dist/js/chat/index.js
dist/js/quoteprice/inquirydetail.js
Application/Home/View/QuotePrice/inquirydetail.html
View file @
47589bcc
...
...
@@ -151,7 +151,7 @@
<
/div> --
>
<
/div
>
<
div
class
=
"bottom clr"
>
<
div
class
=
"gt_div fl btn btn_yellow"
imid
=
"{{item.im_username}}"
userid
=
"{{item.user_id}}"
>
<
div
class
=
"gt_div fl btn btn_yellow"
imid
=
"{{item.im_username}}"
userid
=
"{{item.user_id}}"
avatar
=
"{{item.avatar}}"
>
<
span
class
=
"icon iconfont iconjuxing7 va-m"
><
/span
>
在线沟通
<
/div
>
...
...
dist/js/chat/index.js
View file @
47589bcc
...
...
@@ -10,11 +10,11 @@ $(function () {
name
:
""
,
id
:
""
,
init
:
function
()
{
this
.
ieFun
();
this
.
getUserInfo
();
// this.ieFun();
this
.
connection
();
this
.
connListen
();
this
.
bindFunction
();
this
.
getUserInfo
();
},
getUserInfo
:
function
()
{
//获取用户的基本信息
var
self
=
this
;
...
...
@@ -25,14 +25,15 @@ $(function () {
self
.
img
=
res
.
data
.
avatar
;
self
.
name
=
res
.
data
.
company_name
;
self
.
id
=
res
.
data
.
user_id
+
''
;
self
.
login
(
res
.
data
.
im_username
,
res
.
data
.
im_password
);
self
.
getHistoryUsers
(
res
.
data
.
im_username
,
res
.
data
.
im_password
);
}
else
{
console
.
log
(
'获取用户名失败'
);
layer
.
msg
(
'聊天系统出错'
);
}
},
true
,
false
)
},
getHistoryUsers
:
function
()
{
getHistoryUsers
:
function
(
name
,
password
)
{
//获取用户聊天的成员记录
var
self
=
this
;
IcController
.
getData
(
apis
.
listrecord
,
'GET'
,
{
...
...
@@ -40,25 +41,27 @@ $(function () {
},
function
(
res
)
{
if
(
res
.
errcode
===
0
)
{
self
.
rendChatSection
(
res
.
data
);
self
.
singleChat
(
);
self
.
login
(
name
,
password
);
}
else
{
layer
.
msg
(
'获取历史纪录失败'
);
}
});
},
addChatMember
:
function
(
id
)
{
IcController
.
getData
(
apis
.
addrecord
,
'GET'
,
{
"token"
:
Util
.
getCookie
(
'token'
)
||
''
,
"user_id"
:
id
},
function
(
res
)
{
if
(
res
.
errcode
===
0
)
{
console
.
log
(
id
)
// IcController.getData(apis.addrecord, 'GET', {
// "token": Util.getCookie('token') || '',
// "user_id": id
// }, function (res) {
// if (res.errcode === 0) {
}
else
{
console
.
log
(
'添加聊天成员失败'
)
}
},
false
);
//
} else {
//
console.log('添加聊天成员失败')
//
}
//
},false);
},
rendChatSection
:
function
(
data
)
{
console
.
log
(
'获取成员'
)
this
.
addUser
({},
true
);
for
(
var
i
=
0
;
i
<
data
.
length
;
i
++
)
{
this
.
addUser
(
data
[
i
])
...
...
@@ -70,6 +73,9 @@ $(function () {
}
else
{
Util
.
delCookie
(
'template'
,
cookieHostname
);
this
.
addUser
({},
false
,
true
);
var
html
=
$
(
".notice_classify[userid="
+
this
.
templateObj
.
userId
+
"]"
).
clone
();
$
(
".notice_classify[userid="
+
this
.
templateObj
.
userId
+
"]"
).
remove
();
$
(
".notice_classify[userid="
+
this
.
defaultName
+
"]"
).
after
(
html
);
$
(
".notice_classify[userid="
+
this
.
templateObj
.
userId
+
"]"
).
attr
(
'isTemplate'
,
true
);
//先获取历史纪录再发送模板,否则可能出现发送的消息显示两条
$
(
".notice_classify[userid="
+
this
.
templateObj
.
userId
+
"]"
).
click
();
...
...
@@ -84,9 +90,10 @@ $(function () {
img
=
dist
+
"/images/default.jpg"
;
}
else
{
if
(
isFirst
)
{
console
.
log
(
this
.
templateObj
)
id
=
this
.
templateObj
.
userId
;
name
=
this
.
templateObj
.
userName
;
img
=
this
.
templateObj
.
i
mg
||
(
dist
+
"/images/default.jpg"
)
img
=
this
.
templateObj
.
userI
mg
||
(
dist
+
"/images/default.jpg"
)
}
else
{
id
=
obj
.
im_username
;
name
=
obj
.
company_name
;
...
...
@@ -98,7 +105,7 @@ $(function () {
if
(
userLen
)
{
//用户存在
return
;
}
else
{
//用户不存在
var
lefthtml
=
'<div class="notice_classify" userid="'
+
id
+
'">'
+
this
.
userHtml
(
0
,
{
var
lefthtml
=
'<div class="notice_classify" userid="'
+
id
+
'"
firstClick="true"
>'
+
this
.
userHtml
(
0
,
{
name
:
name
,
id
:
id
,
img
:
img
...
...
@@ -309,7 +316,7 @@ $(function () {
}
else
if
(
type
==
2
)
{
regContent
=
'[图片]'
;
htmlStr
=
{
message
:
'<img src ="'
+
message
.
url
+
'" class="edit_img"/>'
,
message
:
'<img src ="'
+
message
.
url
+
'" class="edit_img"/>'
,
name
:
message
.
name
,
img
:
message
.
img
,
id
:
message
.
id
...
...
@@ -326,7 +333,7 @@ $(function () {
}
};
htmlStr
=
{
message
:
emojiTxt
,
message
:
emojiTxt
,
name
:
message
.
name
,
img
:
message
.
img
,
id
:
message
.
id
...
...
@@ -350,23 +357,29 @@ $(function () {
if
(
!
len
)
{
//新用户
var
userStr
=
'<div class="notice_classify active" userid="'
+
message
.
from
+
'">'
+
var
userStr
=
'<div class="notice_classify active" userid="'
+
message
.
from
+
'"
firstClick="true" newMember="true"
>'
+
self
.
userHtml
(
0
,
message
,
regContent
)
+
'</div>'
;
var
messageStr
=
'<div class="chat_item active" id="'
+
message
.
from
+
'">'
+
messageSigleStr
+
'</div>'
$
(
'.notice_left_content'
).
append
(
userStr
);
$
(
".notice_classify[userid="
+
this
.
defaultName
+
"]"
).
after
(
userStr
);
// $('.notice_left_content').append(userStr);
$
(
'.chat_item_content'
).
append
(
messageStr
)
}
else
{
$
(
'.notice_classify'
).
each
(
function
(
index
)
{
var
userId
=
$
(
this
).
attr
(
'userid'
);
var
isNowChat
=
$
(
'.notice_classify'
).
eq
(
index
).
hasClass
(
'active'
);
var
firstClick
=
$
(
this
).
attr
(
'firstClick'
);
if
(
userId
==
message
.
from
)
{
//已有用户
if
(
isNowChat
)
{
//当前用户
$
(
this
).
html
(
self
.
userHtml
(
0
,
message
,
regContent
));
if
(
Util
.
getCookie
(
'templateBoolean'
))
{
Util
.
delCookie
(
'templateBoolean'
,
cookieHostname
);
}
else
{
$
(
'#'
+
userId
).
find
(
'.notice_item_content'
).
append
(
self
.
messageHtml
(
2
,
htmlStr
,
isTemplate
));
}
var
contentHeight
=
$
(
'#'
+
userId
).
find
(
'.notice_item_content'
)
.
height
();
$
(
'#'
+
userId
).
find
(
'.notice_list'
).
scrollTop
(
contentHeight
);
...
...
@@ -375,8 +388,14 @@ $(function () {
//非当前用户
var
num
=
Number
(
$
(
this
).
find
(
'.num'
).
text
());
$
(
this
).
html
(
self
.
userHtml
(
num
+
1
,
message
,
regContent
));
// $('#' + userId).find('.notice_item_content').append(self.messageHtml(2,
// htmlStr, isTemplate));
var
html
=
$
(
this
).
clone
();
$
(
this
).
remove
();
$
(
".notice_classify[userid="
+
this
.
defaultName
+
"]"
).
after
(
html
);
if
(
!
firstClick
)
{
$
(
'#'
+
userId
).
find
(
'.notice_item_content'
).
append
(
self
.
messageHtml
(
2
,
htmlStr
,
isTemplate
));
}
}
return
false
;
...
...
@@ -384,12 +403,12 @@ $(function () {
if
(
index
==
len
-
1
)
{
//新用户
var
userStr
=
'<div class="notice_classify" userid="'
+
message
.
from
+
'">'
+
message
.
from
+
'"
newMember="true"
>'
+
self
.
userHtml
(
1
,
message
,
regContent
)
+
'</div>'
;
var
messageStr
=
'<div class="chat_item" id="'
+
message
.
from
+
'">'
+
messageSigleStr
+
'</div>'
$
(
'.notice_left_content'
).
append
(
userStr
);
$
(
".notice_classify[userid="
+
this
.
defaultName
+
"]"
).
after
(
userStr
)
$
(
'.chat_item_content'
).
append
(
messageStr
)
}
}
...
...
@@ -403,7 +422,7 @@ $(function () {
onOpened
:
function
(
message
)
{
console
.
log
(
'登入成功'
)
self
.
isLoginSuccess
=
true
;
self
.
getHistoryUsers
();
self
.
singleChat
();
},
onTextMessage
:
function
(
message
)
{
self
.
receiveData
(
1
,
{
...
...
@@ -430,14 +449,14 @@ $(function () {
id
:
message
.
ext
.
id
,
img
:
message
.
ext
.
img
,
from
:
message
.
from
,
type
:
message
.
ext
.
type
,
price
:
message
.
ext
.
price
,
goodImage
:
message
.
ext
.
goodImage
,
brand
:
message
.
ext
.
brand
,
hq
:
message
.
ext
.
hq
,
num
:
message
.
ext
.
num
,
hq
:
message
.
ext
.
hq
,
time
:
message
.
ext
.
time
type
:
message
.
ext
.
type
,
price
:
message
.
ext
.
price
,
goodImage
:
message
.
ext
.
goodImage
,
brand
:
message
.
ext
.
brand
,
hq
:
message
.
ext
.
hq
,
num
:
message
.
ext
.
num
,
hq
:
message
.
ext
.
hq
,
time
:
message
.
ext
.
time
},
true
);
self
.
addChatMember
(
message
.
ext
.
id
)
},
//收到命令消息;
...
...
@@ -535,6 +554,7 @@ $(function () {
this
.
conn
.
send
(
msg
.
body
);
},
sendCmd
:
function
(
templateObj
)
{
console
.
log
(
'发送模板'
)
var
self
=
this
;
var
userId
=
$
(
'.notice_left '
).
find
(
'.active'
).
attr
(
'userid'
);
var
id
=
this
.
conn
.
getUniqueId
();
...
...
@@ -657,18 +677,36 @@ $(function () {
$
(
'.notice_left'
).
on
(
'click'
,
'.notice_classify'
,
function
()
{
var
id
=
$
(
this
).
attr
(
'userid'
);
var
isTemplate
=
$
(
this
).
attr
(
'isTemplate'
);
var
firstClick
=
$
(
this
).
attr
(
'firstClick'
);
var
newMember
=
$
(
this
).
attr
(
'newMember'
);
$
(
'#'
+
id
).
addClass
(
'active'
).
siblings
(
'.chat_item'
).
removeClass
(
'active'
);
$
(
this
).
find
(
'.num'
).
remove
();
$
(
this
).
addClass
(
'active'
).
siblings
(
'.notice_classify'
).
removeClass
(
'active'
);
if
(
isTemplate
)
{
$
(
this
).
removeAttr
(
'isTemplate'
);
}
$
(
this
).
removeAttr
(
'firstClick'
);
if
(
self
.
isLoginSuccess
)
{
//登入成功 获取聊天记录
self
.
getHistoryData
(
id
,
isTemplate
)
}
else
{
layer
.
msg
(
'聊天系统出错'
);
return
;
}
}
else
{
var
contentHeight
=
$
(
'#'
+
id
).
find
(
'.notice_item_content'
).
height
();
$
(
'#'
+
id
).
find
(
'.notice_list'
).
scrollTop
(
contentHeight
);
if
(
newMember
)
{
return
}
if
(
firstClick
)
{
$
(
this
).
removeAttr
(
'firstClick'
);
if
(
self
.
isLoginSuccess
)
{
//登入成功 获取聊天记录
self
.
getHistoryData
(
id
)
}
else
{
layer
.
msg
(
'聊天系统出错'
);
return
;
}
}
}
});
$
(
'.notice_right '
).
on
(
'click'
,
'.edit_img'
,
function
()
{
...
...
dist/js/quoteprice/inquirydetail.js
View file @
47589bcc
...
...
@@ -81,6 +81,7 @@ $(function () {
self
.
isClick
=
false
;
var
userId
=
$
(
this
).
attr
(
'imid'
),
id
=
$
(
this
).
attr
(
'userid'
),
userImg
=
$
(
this
).
attr
(
'avatar'
),
parent
=
$
(
this
).
parents
(
'.bj_item'
),
type
=
parent
.
find
(
'.goods_name'
).
text
(),
price
=
parent
.
find
(
'.price'
).
text
(),
...
...
@@ -103,8 +104,10 @@ $(function () {
time
:
time
,
goodImage
:
img
,
userName
:
name
,
targetId
:
id
targetId
:
id
,
userImg
:
userImg
};
Util
.
setCookie
(
'templateBoolean'
,
'1'
,
1
,
cookieHostname
)
Util
.
setCookie
(
'template'
,
JSON
.
stringify
(
obj
),
1
,
cookieHostname
)
window
.
location
.
href
=
'/chat'
}
else
{
...
...
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