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
5ea1d4b7
authored
Jun 26, 2019
by
施宇
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
1111
parent
3122b539
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
101 additions
and
91 deletions
Application/Home/View/QuotePrice/inquirydetail.html
dist/js/chat/index.js
Application/Home/View/QuotePrice/inquirydetail.html
View file @
5ea1d4b7
...
@@ -134,7 +134,16 @@
...
@@ -134,7 +134,16 @@
<include
file=
"public/foot"
/>
<include
file=
"public/foot"
/>
<script>
<script>
$
(
'.gt_div '
).
on
(
'click'
,
function
()
{
$
(
'.gt_div '
).
on
(
'click'
,
function
()
{
Util
.
setCookie
(
'test'
,
'1'
,
1
)
var
obj
=
{
userId
:
'18589050841'
,
type
:
"STM32F103ZET6"
,
price
:
"67.9800"
,
brand
:
"Texas Instruments"
,
fz
:
"LQFP-144"
,
num
:
"100,000"
,
hq
:
"现货"
,
}
Util
.
setCookie
(
'template'
,
JSON
.
stringify
(
obj
),
1
)
window
.
location
.
href
=
'/chat'
window
.
location
.
href
=
'/chat'
})
})
</script>
</script>
...
...
dist/js/chat/index.js
View file @
5ea1d4b7
...
@@ -48,45 +48,26 @@ $(function () {
...
@@ -48,45 +48,26 @@ $(function () {
from
:
"18664936975"
,
from
:
"18664936975"
,
data
:
''
data
:
''
}
}
this
.
receiveData
(
1
,
message
);
this
.
receiveData
(
1
,
message
,
false
);
},
},
singleChat
:
function
()
{
singleChat
:
function
()
{
var
type
=
Util
.
getCookie
(
'test'
);
var
templateStr
=
Util
.
getCookie
(
'template'
);
if
(
type
)
{
var
templateObj
=
{};
var
id
=
'18589050841'
;
if
(
templateStr
)
{
templateObj
=
JSON
.
parse
(
templateStr
)
}
if
(
JSON
.
stringify
(
templateObj
)
!==
'{}'
)
{
var
message
=
{
var
message
=
{
from
:
"18589050841"
,
from
:
templateObj
.
userId
,
data
:
''
data
:
''
};
};
var
content
=
'<div class="template lineBlock boxsiz">'
+
this
.
receiveData
(
1
,
message
,
false
);
'<img src="http://resic.liexin.com/images/test.jpg" alt="">'
+
$
(
".notice_classify[userid="
+
templateObj
.
userId
+
"]"
).
click
();
'<div class="template_right">'
+
this
.
sendCmd
(
templateObj
);
'<div class="template_right_top clr">'
+
Util
.
delCookie
(
'template'
);
'<h3 class="bold fl">STM32F103ZE</h3>'
+
'<div class="price bold fr">¥67.9800</div>'
+
'</div>'
+
'<div class="template_right_bottom">'
+
'<div class="desc1 clr">'
+
'<div class="brand fl">品牌:<i>TexasInstruments</i></div>'
+
'<div class="hq fl">货期:<i> 现货</i></div>'
+
'</div>'
+
'<div class="desc2 clr">'
+
'<div class="num fl">数量:<i class="bold">100,000PCS</i></div>'
+
'<div class="time fl">时间:<i>2019-05-23 15:57 </i></div>'
+
'</div>'
+
'</div>'
+
'</div>'
+
'</div>'
;
this
.
receiveData
(
1
,
message
);
$
(
".notice_classify[userid="
+
id
+
"]"
).
click
();
this
.
sendPrivateText
(
content
,
{
test
:
1
});
Util
.
delCookie
(
'test'
);
}
}
...
@@ -185,22 +166,15 @@ $(function () {
...
@@ -185,22 +166,15 @@ $(function () {
clock
+=
ss
;
clock
+=
ss
;
return
(
clock
);
return
(
clock
);
},
},
userHtml
:
function
(
num
,
user
,
message
,
isTest
)
{
userHtml
:
function
(
num
,
user
,
message
)
{
//左边用户的dom拼接
//左边用户的dom拼接
var
messageContent
=
''
;
if
(
isTest
)
{
messageContent
=
'100,000PCS ¥67.9800'
;
}
else
{
messageContent
=
message
;
}
if
(
num
==
0
)
{
if
(
num
==
0
)
{
return
'<img src="'
+
dist
+
'/images/test.jpg" alt="" class="user_logo">'
+
return
'<img src="'
+
dist
+
'/images/test.jpg" alt="" class="user_logo">'
+
'<div class="user_right">'
+
'<div class="user_right">'
+
'<div class="clr">'
+
'<div class="clr">'
+
'<h3 class="boxsiz ellipsis">'
+
user
+
'</h3>'
+
'<h3 class="boxsiz ellipsis">'
+
user
+
'</h3>'
+
'</div>'
+
'</div>'
+
'<div class="message ellipsis">'
+
message
Content
+
'</div>'
+
'<div class="message ellipsis">'
+
message
+
'</div>'
+
'</div>'
'</div>'
}
else
{
}
else
{
return
'<img src="'
+
dist
+
'/images/test.jpg" alt="" class="user_logo">'
+
return
'<img src="'
+
dist
+
'/images/test.jpg" alt="" class="user_logo">'
+
...
@@ -209,26 +183,41 @@ $(function () {
...
@@ -209,26 +183,41 @@ $(function () {
'<span class="num fr">'
+
num
+
'</span>'
+
'<span class="num fr">'
+
num
+
'</span>'
+
'<h3 class="boxsiz ellipsis">'
+
user
+
'</h3>'
+
'<h3 class="boxsiz ellipsis">'
+
user
+
'</h3>'
+
'</div>'
+
'</div>'
+
'<div class="message ellipsis">'
+
message
Content
+
'</div>'
+
'<div class="message ellipsis">'
+
message
+
'</div>'
+
'</div>'
'</div>'
}
}
},
},
messageHtml
:
function
(
leftOrRight
,
html
,
obj
)
{
messageHtml
:
function
(
leftOrRight
,
html
,
isTemplate
)
{
//右边消息的dom拼接
//右边消息的dom拼接 isTemplate 是否是模板
var
htmlp
=
''
var
htmlp
=
'<p>'
+
html
+
'</p>'
;
if
(
obj
.
test
)
{
if
(
isTemplate
)
{
htmlp
=
html
;
var
htmlp
=
'<div class="template lineBlock boxsiz">'
+
}
else
{
'<img src="http://resic.liexin.com/images/test.jpg" alt="">'
+
htmlp
=
'<p>'
+
html
+
'</p>'
'<div class="template_right">'
+
'<div class="template_right_top clr">'
+
'<h3 class="bold fl">'
+
html
.
type
+
'</h3>'
+
'<div class="price bold fr">'
+
html
.
price
+
'</div>'
+
'</div>'
+
'<div class="template_right_bottom">'
+
'<div class="desc1 clr">'
+
'<div class="brand fl">品牌:<i>'
+
html
.
brand
+
'</i></div>'
+
'<div class="hq fl">货期:<i>'
+
html
.
hq
+
'</i></div>'
+
'</div>'
+
'<div class="desc2 clr">'
+
'<div class="num fl">数量:<i class="bold">'
+
html
.
num
+
'PCS</i></div>'
+
'<div class="time fl">时间:<i>2019-05-23 15:57 </i></div>'
+
'</div>'
+
'</div>'
+
'</div>'
+
'</div>'
;
}
}
if
(
leftOrRight
==
1
)
{
//右边
if
(
leftOrRight
==
1
)
{
//右边
if
(
html
)
{
if
(
html
)
{
return
'<div class="notice_item right clr">'
+
return
'<div class="notice_item right clr">'
+
'<img src="'
+
dist
+
'/images/test.jpg" alt="" class="fr user_logo">'
+
'<img src="'
+
dist
+
'/images/test.jpg" alt="" class="fr user_logo">'
+
'<div class="notice_content">'
+
'<div class="notice_content">'
+
// '<p>' +
htmlp
+
htmlp
+
// '</p>' +
'<div>'
+
this
.
curentTime
()
+
'</div>'
+
'<div>'
+
this
.
curentTime
()
+
'</div>'
+
'</div>'
'</div>'
}
else
{
}
else
{
...
@@ -240,9 +229,7 @@ $(function () {
...
@@ -240,9 +229,7 @@ $(function () {
return
'<div class = "notice_item left clr" > '
+
return
'<div class = "notice_item left clr" > '
+
'<img src="'
+
dist
+
'/images/test.jpg" alt="" class="fl user_logo">'
+
'<img src="'
+
dist
+
'/images/test.jpg" alt="" class="fl user_logo">'
+
'<div class="notice_content">'
+
'<div class="notice_content">'
+
// '<p>' +
htmlp
+
htmlp
+
// '</p>' +
'<div>'
+
this
.
curentTime
()
+
'</div>'
+
'<div>'
+
this
.
curentTime
()
+
'</div>'
+
'</div>'
'</div>'
}
else
{
}
else
{
...
@@ -251,26 +238,19 @@ $(function () {
...
@@ -251,26 +238,19 @@ $(function () {
}
}
},
},
receiveData
:
function
(
type
,
message
)
{
receiveData
:
function
(
type
,
message
,
isTemplate
)
{
//接收到消息后处理数据 1 文字 2 图片 3 表情
//接收到消息后处理数据 1 文字 2 图片 3 表情
isTemplate 是否是模板
var
regContent
=
""
;
var
regContent
=
""
;
var
htmlStr
=
""
;
var
htmlStr
=
""
;
var
self
=
this
;
var
self
=
this
;
var
isTest
=
''
;
try
{
isTest
=
message
.
ext
.
test
}
catch
(
e
)
{
}
var
obj
=
{};
if
(
isTest
)
{
obj
=
{
test
:
1
}
}
if
(
type
==
1
)
{
if
(
type
==
1
)
{
if
(
isTemplate
)
{
regContent
=
message
.
ext
.
type
+
' '
+
message
.
ext
.
price
;
htmlStr
=
message
.
ext
;
}
else
{
regContent
=
message
.
data
;
regContent
=
message
.
data
;
htmlStr
=
message
.
data
;
htmlStr
=
message
.
data
;
}
}
else
if
(
type
==
2
)
{
}
else
if
(
type
==
2
)
{
regContent
=
'[图片]'
;
regContent
=
'[图片]'
;
htmlStr
=
'<img src ="'
+
message
.
url
+
'" class="edit_img"/>'
;
htmlStr
=
'<img src ="'
+
message
.
url
+
'" class="edit_img"/>'
;
...
@@ -297,7 +277,7 @@ $(function () {
...
@@ -297,7 +277,7 @@ $(function () {
'</div>'
+
'</div>'
+
'<div class="notice_list boxsiz">'
+
'<div class="notice_list boxsiz">'
+
'<div class="notice_item_content">'
+
'<div class="notice_item_content">'
+
self
.
messageHtml
(
2
,
htmlStr
,
obj
)
+
self
.
messageHtml
(
2
,
htmlStr
,
isTemplate
)
+
'</div>'
+
'</div>'
+
'</div>'
+
'</div>'
+
'</div>'
;
'</div>'
;
...
@@ -305,7 +285,7 @@ $(function () {
...
@@ -305,7 +285,7 @@ $(function () {
if
(
!
len
)
{
if
(
!
len
)
{
//新用户
//新用户
var
userStr
=
'<div class="notice_classify active" userid="'
+
message
.
from
+
'">'
+
var
userStr
=
'<div class="notice_classify active" userid="'
+
message
.
from
+
'">'
+
self
.
userHtml
(
0
,
message
.
from
,
regContent
,
isTest
)
+
'</div>'
;
self
.
userHtml
(
0
,
message
.
from
,
regContent
)
+
'</div>'
;
var
messageStr
=
'<div class="chat_item active" id="'
+
message
.
from
+
'">'
+
var
messageStr
=
'<div class="chat_item active" id="'
+
message
.
from
+
'">'
+
messageSigleStr
+
'</div>'
messageSigleStr
+
'</div>'
$
(
'.notice_left_content'
).
append
(
userStr
);
$
(
'.notice_left_content'
).
append
(
userStr
);
...
@@ -318,9 +298,9 @@ $(function () {
...
@@ -318,9 +298,9 @@ $(function () {
//已有用户
//已有用户
if
(
isNowChat
)
{
if
(
isNowChat
)
{
//当前用户
//当前用户
$
(
this
).
html
(
self
.
userHtml
(
0
,
message
.
from
,
regContent
,
isTest
));
$
(
this
).
html
(
self
.
userHtml
(
0
,
message
.
from
,
regContent
));
$
(
'#'
+
userId
).
find
(
'.notice_item_content'
).
append
(
self
.
messageHtml
(
2
,
$
(
'#'
+
userId
).
find
(
'.notice_item_content'
).
append
(
self
.
messageHtml
(
2
,
htmlStr
,
obj
));
htmlStr
,
isTemplate
));
var
contentHeight
=
$
(
'#'
+
userId
).
find
(
'.notice_item_content'
)
var
contentHeight
=
$
(
'#'
+
userId
).
find
(
'.notice_item_content'
)
.
height
();
.
height
();
$
(
'#'
+
userId
).
find
(
'.notice_list'
).
scrollTop
(
contentHeight
);
$
(
'#'
+
userId
).
find
(
'.notice_list'
).
scrollTop
(
contentHeight
);
...
@@ -328,9 +308,9 @@ $(function () {
...
@@ -328,9 +308,9 @@ $(function () {
}
else
{
}
else
{
//非当前用户
//非当前用户
var
num
=
Number
(
$
(
this
).
find
(
'.num'
).
text
());
var
num
=
Number
(
$
(
this
).
find
(
'.num'
).
text
());
$
(
this
).
html
(
self
.
userHtml
(
num
+
1
,
message
.
from
,
regContent
,
isTest
));
$
(
this
).
html
(
self
.
userHtml
(
num
+
1
,
message
.
from
,
regContent
));
$
(
'#'
+
userId
).
find
(
'.notice_item_content'
).
append
(
self
.
messageHtml
(
2
,
$
(
'#'
+
userId
).
find
(
'.notice_item_content'
).
append
(
self
.
messageHtml
(
2
,
htmlStr
,
obj
));
htmlStr
,
isTemplate
));
}
}
return
false
;
return
false
;
...
@@ -339,7 +319,7 @@ $(function () {
...
@@ -339,7 +319,7 @@ $(function () {
//新用户
//新用户
var
userStr
=
'<div class="notice_classify" userid="'
+
var
userStr
=
'<div class="notice_classify" userid="'
+
message
.
from
+
'">'
+
message
.
from
+
'">'
+
self
.
userHtml
(
1
,
message
.
from
,
regContent
,
isTest
)
+
'</div>'
;
self
.
userHtml
(
1
,
message
.
from
,
regContent
)
+
'</div>'
;
var
messageStr
=
'<div class="chat_item" id="'
+
var
messageStr
=
'<div class="chat_item" id="'
+
message
.
from
+
'">'
+
message
.
from
+
'">'
+
messageSigleStr
+
'</div>'
messageSigleStr
+
'</div>'
...
@@ -359,19 +339,23 @@ $(function () {
...
@@ -359,19 +339,23 @@ $(function () {
self
.
singleChat
();
self
.
singleChat
();
},
},
onTextMessage
:
function
(
message
)
{
onTextMessage
:
function
(
message
)
{
self
.
receiveData
(
1
,
message
)
self
.
receiveData
(
1
,
message
,
false
)
},
//收到文本消息;
},
//收到文本消息;
onEmojiMessage
:
function
(
message
)
{
onEmojiMessage
:
function
(
message
)
{
self
.
receiveData
(
3
,
message
)
self
.
receiveData
(
3
,
message
,
false
)
},
//收到表情消息;
},
//收到表情消息;
onCmdMessage
:
function
(
message
)
{
// console.log('CMD');
self
.
receiveData
(
1
,
message
,
true
);
},
//收到命令消息;
onPictureMessage
:
function
(
message
)
{
onPictureMessage
:
function
(
message
)
{
var
options
=
{
var
options
=
{
url
:
message
.
url
url
:
message
.
url
};
};
options
.
onFileDownloadComplete
=
function
()
{
options
.
onFileDownloadComplete
=
function
()
{
// 图片下载成功;
// 图片下载成功;
self
.
receiveData
(
2
,
message
)
self
.
receiveData
(
2
,
message
,
false
)
};
};
...
@@ -397,7 +381,6 @@ $(function () {
...
@@ -397,7 +381,6 @@ $(function () {
},
},
login
:
function
()
{
login
:
function
()
{
// open,登录;
// open,登录;
let
self
=
this
;
var
options
=
{
var
options
=
{
apiUrl
:
WebIM
.
config
.
apiURL
,
apiUrl
:
WebIM
.
config
.
apiURL
,
user
:
"18271408717"
,
user
:
"18271408717"
,
...
@@ -406,34 +389,27 @@ $(function () {
...
@@ -406,34 +389,27 @@ $(function () {
};
};
try
{
try
{
this
.
conn
.
open
(
options
);
this
.
conn
.
open
(
options
);
}
catch
(
e
)
{
}
catch
(
e
)
{
console
.
log
(
WebIM
.
config
.
apiURL
)
console
.
log
(
WebIM
.
config
.
apiURL
)
// alert('open fail' + e.message)
// alert('open fail' + e.message)
}
}
},
},
sendPrivateText
:
function
(
content
,
obj
)
{
sendPrivateText
:
function
(
content
)
{
var
self
=
this
;
var
self
=
this
;
// 私聊发送文本消息,发送表情同发送文本消息,只是会在对方客户端将表情文本进行解析成图片;
// 私聊发送文本消息,发送表情同发送文本消息,只是会在对方客户端将表情文本进行解析成图片;
var
userId
=
$
(
'.notice_left '
).
find
(
'.active'
).
attr
(
'userid'
);
var
userId
=
$
(
'.notice_left '
).
find
(
'.active'
).
attr
(
'userid'
);
var
id
=
this
.
conn
.
getUniqueId
();
var
id
=
this
.
conn
.
getUniqueId
();
var
msg
=
new
WebIM
.
message
(
'txt'
,
id
);
var
msg
=
new
WebIM
.
message
(
'txt'
,
id
);
var
emojiMessage
=
WebIM
.
utils
.
parseEmoji
(
content
);
//表情解析工具
var
emojiMessage
=
WebIM
.
utils
.
parseEmoji
(
content
);
//表情解析工具
var
ext
=
{};
if
(
obj
.
test
)
{
ext
=
{
'test'
:
'1'
}
};
console
.
log
(
ext
)
msg
.
set
({
msg
.
set
({
msg
:
content
,
// 消息内容;
msg
:
content
,
// 消息内容;
to
:
userId
,
// 接收消息对象;
to
:
userId
,
// 接收消息对象;
roomType
:
false
,
roomType
:
false
,
ext
:
ext
,
//用户自扩展的消息内容
success
:
function
(
id
,
serverMsgId
)
{
success
:
function
(
id
,
serverMsgId
)
{
$
(
'#'
+
userId
).
find
(
'.notice_item_content'
).
append
(
self
.
messageHtml
(
1
,
$
(
'#'
+
userId
).
find
(
'.notice_item_content'
).
append
(
self
.
messageHtml
(
1
,
emojiMessage
,
obj
));
emojiMessage
,
false
));
var
contentHeight
=
$
(
'#'
+
userId
).
find
(
'.notice_item_content'
)
var
contentHeight
=
$
(
'#'
+
userId
).
find
(
'.notice_item_content'
)
.
height
();
.
height
();
$
(
'#'
+
userId
).
find
(
'.notice_list'
).
scrollTop
(
contentHeight
);
$
(
'#'
+
userId
).
find
(
'.notice_list'
).
scrollTop
(
contentHeight
);
...
@@ -446,6 +422,31 @@ $(function () {
...
@@ -446,6 +422,31 @@ $(function () {
});
});
this
.
conn
.
send
(
msg
.
body
);
this
.
conn
.
send
(
msg
.
body
);
},
},
sendCmd
:
function
(
templateObj
)
{
var
self
=
this
;
var
userId
=
$
(
'.notice_left '
).
find
(
'.active'
).
attr
(
'userid'
);
var
id
=
this
.
conn
.
getUniqueId
();
var
msg
=
new
WebIM
.
message
(
'cmd'
,
id
);
msg
.
set
({
msg
:
'template'
,
to
:
userId
,
roomType
:
false
,
action
:
"template"
,
ext
:
templateObj
,
success
:
function
(
id
,
serverMsgId
)
{
$
(
'#'
+
userId
).
find
(
'.notice_item_content'
).
append
(
self
.
messageHtml
(
1
,
templateObj
,
true
));
var
contentHeight
=
$
(
'#'
+
userId
).
find
(
'.notice_item_content'
)
.
height
();
$
(
'#'
+
userId
).
find
(
'.notice_list'
).
scrollTop
(
contentHeight
);
},
fail
:
function
()
{
console
.
log
(
"Send Cmd failed"
);
}
});
this
.
conn
.
send
(
msg
.
body
);
},
sendPrivateImg
:
function
()
{
sendPrivateImg
:
function
()
{
// 私聊发送图片消息;
// 私聊发送图片消息;
var
self
=
this
;
var
self
=
this
;
...
@@ -459,7 +460,7 @@ $(function () {
...
@@ -459,7 +460,7 @@ $(function () {
file
:
file
,
file
:
file
,
to
:
'18664936975'
,
to
:
'18664936975'
,
roomType
:
false
,
roomType
:
false
,
chatType
:
'singleChat'
,
//
chatType: 'singleChat',
flashUpload
:
WebIM
.
flashUpload
,
flashUpload
:
WebIM
.
flashUpload
,
onFileUploadError
:
function
()
{
onFileUploadError
:
function
()
{
console
.
log
(
file
);
console
.
log
(
file
);
...
@@ -469,7 +470,7 @@ $(function () {
...
@@ -469,7 +470,7 @@ $(function () {
success
:
function
()
{
success
:
function
()
{
var
htmlStr
=
'<img src ="'
+
file
.
url
+
'" class="edit_img"/>'
;
var
htmlStr
=
'<img src ="'
+
file
.
url
+
'" class="edit_img"/>'
;
$
(
'#'
+
userId
).
find
(
'.notice_item_content'
).
append
(
self
.
messageHtml
(
1
,
$
(
'#'
+
userId
).
find
(
'.notice_item_content'
).
append
(
self
.
messageHtml
(
1
,
htmlStr
,
{}
));
htmlStr
,
false
));
var
contentHeight
=
$
(
'#'
+
userId
).
find
(
'.notice_item_content'
)
var
contentHeight
=
$
(
'#'
+
userId
).
find
(
'.notice_item_content'
)
.
height
();
.
height
();
$
(
'#'
+
userId
).
find
(
'.notice_list'
).
scrollTop
(
contentHeight
);
$
(
'#'
+
userId
).
find
(
'.notice_list'
).
scrollTop
(
contentHeight
);
...
...
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