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
ea59284c
authored
Jul 30, 2019
by
梁建民
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
恢复继来的锅
parent
4a6e206f
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
653 additions
and
228 deletions
Application/Home/View/QuotePrice/inquirydetail.html
Application/Home/View/Search/index.html
Application/Home/View/public/navleft.html
dist/js/chat/index.js
dist/js/global/api.js
dist/js/home/index.js
Application/Home/View/QuotePrice/inquirydetail.html
View file @
ea59284c
...
...
@@ -14,138 +14,192 @@
<div
class=
"right_content inquiry_detail_content"
>
<div
class=
"content"
>
<div
class=
"nav_title"
>
询报价 > 我的询价 > 询价详情 STM32F103ZET6
<span
class=
"fr"
>
2019-05-22 15:35
</span>
</div>
<div
class=
"goods_detail clr"
>
<img
src=
"__PUBLIC__/images/test.jpg"
alt=
""
class=
"fr"
>
</div>
<div
class=
"bj_detail"
>
</div>
<div
class=
"pagination-with"
id=
"pagination"
style=
"text-align: right;margin-top: 25px;display:none"
></div>
</div>
</div>
</div>
</div>
<include
file=
"public/foot"
/>
<script
src=
"__PUBLIC__/js/quoteprice/inquirydetail.js"
></script>
<script
type=
"text/html"
id=
"navTpl"
>
<!--
导航的详情
-->
询报价
>
我的询价
>
询价详情
{{
d
.
goods_name
}}
<
span
class
=
"fr"
>
{{
layui
.
util
.
toDateString
(
d
.
add_time
*
1000
)}}
<
/span
>
</script>
<script
type=
"text/html"
id=
"detailTpl"
>
<!--
商品详情
-->
{{
#
if
(
d
[
'goods_images'
]){
}}
<
img
src
=
"{{d.goods_images}}"
alt
=
""
class
=
"fr xj_img"
>
{{
#
}
else
{
}}
<
img
src
=
"__PUBLIC__/images/defaultgood.png"
alt
=
""
class
=
"fr xj_img"
>
{{
#
}
}}
<
div
class
=
" goods_desc boxsiz"
>
<
div
class
=
"title"
>
<h3
class=
"bold fl"
>
STM32F103ZET6
</h3>
<
h3
class
=
"bold fl"
>
{{
d
.
goods_name
}}
<
/h3
>
<
div
class
=
"fr"
>
<span
class=
"mark lineBlock"
></span><span
class=
"text"
>
展示中
</span>
</div>
</div>
<div
class=
"desc inquiry_desc"
>
{{
#
if
(
d
[
'audit_status'
]
==
1
){
}}
{{
#
if
(
d
[
'status'
]
==
1
){
}}
<
span
class
=
"mark lineBlock zs"
><
/span><span class="text">展示中</
span
>
{{
#
}
else
{
}}
<
span
class
=
"mark lineBlock xj"
><
/span><span class="text">已下架</
span
>
{{
#
}
}}
{{
#
}
else
{
}}
<
span
class
=
"mark lineBlock jy"
><
/span><span class="text">禁用中</
span
>
{{
#
}
}}
<
/div
>
<
/div
>
<
div
class
=
"desc inquiry_desc"
style
=
"margin-right:224px"
>
<
div
class
=
"brand fl boxsiz ellipsis"
>
品牌:
<span>
Texas InstrumentsTexas
</span>
品牌:
<
span
>
{{
d
.
brand_name
}}
<
/span
>
<
/div
>
<
div
class
=
"fz fl boxsiz ellipsis"
>
封装:
<span>
LQFP-144
</span>
</div>
<div
class=
"price fl boxsiz ellipsis "
>
接受价:
<span>
无
</span></div>
<div
class=
"num fl boxsiz ellipsis"
>
数量:
<span
class=
"bold"
>
100,000 PCS
</span></div>
<div
class=
"hq fl boxsiz ellipsis"
>
货期:
<span>
现货
</span></div>
<div
class=
"bz fl boxsiz ellipsis"
>
备注:
<span>
有货的商家请尽快联系,谢谢!
</span></div>
封装:
<
span
>
{{
d
.
encap
}}
<
/span
>
<
/div
>
<
div
class
=
"price fl boxsiz"
>
接受价:
{{
#
if
(
!
d
.
price
){
}}
<
span
>
无
<
/span
>
{{
#
}
else
{
}}
<
span
class
=
"red"
>
{{
#
if
(
d
.
currency
==
1
){
}}
¥
{{
#
}
else
{
}}
$
{{
#
}
}}
{{
d
.
price
}}
<
/span
>
{{
#
}
}}
<
/div
>
<
div
class
=
"num fl boxsiz ellipsis"
>
数量:
<
span
class
=
"bold"
>
{{
d
.
number
}}
PCS
<
/span></
div
>
<
div
class
=
"hq fl boxsiz ellipsis"
>
货期:
<
span
>
{{
d
.
delivery_time
}}
<
/span></
div
>
<
div
class
=
"bz fl boxsiz ellipsis"
>
备注:
<
span
>
{{
d
.
remark
||
'--'
}}
<
/span></
div
>
<
/div
>
<
/div
>
<div
class=
"bj_detail"
>
</script>
<script
type=
"text/html"
id=
"bjTpl"
>
<
div
class
=
"bj_title"
>
<
span
class
=
"lineBlock"
><
/span
>
<
b
>
收到的报价
<
/b
>
<b
class=
"bj_num"
>
2
</b>
<
b
class
=
"bj_num"
>
{{
d
.
length
}}
<
/b
>
<
/div
>
<
div
class
=
"bj_lists"
>
{{
#
layui
.
each
(
d
,
function
(
index
,
item
){
}}
<
div
class
=
"bj_item clr"
>
<
div
class
=
"item_right fr boxsiz"
>
<
div
class
=
"top"
>
<div
class=
"top_right icon iconfont iconjuxing2 fr"
></div
>
<div
class=
"top_left boxsiz ellipsis
"
>
<!--
<
div
class
=
"top_right icon iconfont iconjuxing2 fr"
><
/div> --
>
<
div
class
=
"top_left boxsiz ellipsis"
style
=
"padding-right:0
"
>
<
span
class
=
"lineBlock mark"
>
报价
<
/span
>
<span
class=
"name bold"
>
深圳邦马特科技有限公司深圳邦马特科技有限公司
</span>
<
span
class
=
"name bold"
>
{{
item
.
company_name
||
'--'
}}
<
/span
>
<
/div
>
<
/div
>
<
div
class
=
"center"
>
<div
class=
"center_left boxsiz clr"
>
<div
class=
"fl"
>
<span
class=
"icon iconfont iconjuxing10"
></span>
公司认证
</div>
<
div
class
=
"center_left boxsiz clr"
style
=
"padding-right:0"
>
{{
#
if
(
item
.
auth_type
!==
""
){
}}
<
div
class
=
"fl"
>
<
span
class
=
"icon iconfont iconjuxing10"
><
/span
>
贸易商
</div>
<div
class=
"fl"
>
<span
class=
"icon iconfont iconjuxing10"
></span>
贸易商
</div>
{{
#
if
(
item
.
auth_type
==
0
){
}}
未认证
{{
#
}
}}
{{
#
if
(
item
.
auth_type
==
1
){
}}
个人认证
{{
#
}
}}
{{
#
if
(
item
.
auth_type
==
2
){
}}
企业认证
{{
#
}
}}
<
/div
>
{{
#
}
}}
{{
#
if
(
item
.
company_type
!==
""
){
}}
<
div
class
=
"fl"
>
<
span
class
=
"icon iconfont iconjuxing10"
><
/span
>
{{
#
if
(
item
.
company_type
==
1
){
}}
贸易商
</div>
<div
class=
"fl"
>
<span
class=
"icon iconfont iconjuxing10"
></span>
贸易商
</div>
</div>
<div
class=
"center_right ellipsis"
>
{{
#
}
}}
{{
#
if
(
item
.
company_type
==
2
){
}}
代理商
{{
#
}
}}
{{
#
if
(
item
.
company_type
==
3
){
}}
原厂
{{
#
}
}}
{{
#
if
(
item
.
company_type
==
4
){
}}
制造商
{{
#
}
}}
{{
#
if
(
item
.
company_type
==
5
){
}}
个人用户
{{
#
}
}}
<
/div
>
{{
#
}
}}
<
/div
>
<!--
<
div
class
=
"center_right ellipsis"
>
报价:
<
span
class
=
"bold"
>
21
次
<
/span
>
</div
>
<
/div> --
>
<
/div
>
<
div
class
=
"bottom clr"
>
<div
class=
"gt_div fl btn btn_yellow
"
>
<
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
>
<div
class=
"phone_div fl btn btn_border"
>
<!--
<
div
class
=
"phone_div fl btn btn_border"
>
<
span
class
=
"icon iconfont iconjuxing23 va-m"
><
/span
>
18271408714
</div
>
<
/div> --
>
<
/div
>
<
div
class
=
"time"
>
报价时间:
<span>
2019-05-23 15:57
</span>
报价时间:
<
span
>
{{
layui
.
util
.
toDateString
(
d
.
add_time
*
1000
)}}
<
/span
>
<
/div
>
<
/div
>
<div
class=
"item_left boxsiz
"
>
<
div
class
=
"item_left boxsiz"
style
=
"padding-right:474px;
"
>
<
div
class
=
"item_left_top"
>
<h3
class=
"bold fl ellipsis boxsiz"
>
STM32F103ZET6
</h3>
<div
class=
"price fl bold ellipsis boxsiz"
>
¥67.9800
</div>
<
h3
class
=
"bold fl ellipsis boxsiz goods_name"
>
{{
item
.
goods_name
}}
<
/h3
>
<
div
class
=
"price fl bold ellipsis boxsiz"
>
{{
#
if
(
item
.
currency
==
1
){
}}
¥
{{
#
}
else
{
}}
$
{{
#
}
}}
{{
item
.
price
}}
<
/div
>
<
/div
>
<
div
class
=
"desc"
>
<
div
class
=
"brand fl boxsiz ellipsis"
>
品牌:
<span>
Texas Instruments
品牌:
<
span
>
{{
item
.
brand_name
}}
<
/span
>
<
/div
>
<
div
class
=
"fz fl boxsiz ellipsis"
>
封装:
<span>
LQFP-144
</span>
封装:
<
span
>
{{
item
.
encap
}}
<
/span
>
<
/div
>
<div
class=
"num fl boxsiz ellipsis"
>
数量:
<span
class=
"bold"
>
100,000
PCS
</span>
<
div
class
=
"num fl boxsiz ellipsis"
>
数量:
<
span
class
=
"bold"
>
{{
item
.
number
}}
PCS
<
/span
>
<
/div
>
<div
class=
"hq fl boxsiz ellipsis"
>
货期:
<span>
现货
</span></div>
<
div
class
=
"hq fl boxsiz ellipsis"
>
货期:
<
span
>
{{
item
.
delivery_time
}}
<
/span></
div
>
<
div
class
=
"bz fl boxsiz ellipsis"
>
备注:
<span>
我们有大量的现货,随时都可以出库。我们有大量的现货,随时都可以出库。
</span></div>
备注:
<
span
>
{{
item
.
remark
||
'--'
}}
<
/span></
div
>
<
/div
>
<
/div
>
<
/div
>
{{
#
});
}}
<
/div
>
<div
class=
"no_data"
style=
"display: none"
>
{{
#
if
(
d
.
length
===
0
){
}}
<
div
class
=
"no_data"
>
<
img
src
=
"__PUBLIC__/images/nodata.png"
alt
=
""
>
<
p
>
暂无报价信息
<
/p
>
<
/div
>
</div>
</div>
</div>
</div>
</div>
<include
file=
"public/foot"
/>
<script>
$
(
'.gt_div '
).
on
(
'click'
,
function
()
{
var
obj
=
{
userId
:
'18271408717'
,
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'
})
{{
#
}
}}
</script>
</body>
...
...
Application/Home/View/Search/index.html
View file @
ea59284c
...
...
@@ -105,7 +105,7 @@
--
{{
#
}
}}
<
/span
>
<
div
class
=
"fl name ellipsis"
>
{{
item
.
company
_name
||
'--
'
}}
<
/div
>
<
div
class
=
"fl name ellipsis"
>
{{
item
.
company
||
'
'
}}
<
/div
>
<
/div
>
<
/div
>
{{
#
});
}}
...
...
Application/Home/View/public/navleft.html
View file @
ea59284c
...
...
@@ -24,7 +24,7 @@
<span
class=
"li_right icon iconfont"
>
</a>
<dl
<
if
condition=
"(ACTION_NAME eq 'inquiry') || (ACTION_NAME eq 'releaseinquiry') || (ACTION_NAME eq 'inquirydetail') || (ACTION_NAME eq 'quote') || (ACTION_NAME eq 'quotedetail')"
>
style="display:block"
</if>
>
<dd
<
if
condition=
"(ACTION_NAME eq 'inquiry') || (ACTION_NAME eq 'releaseinquiry') || (ACTION_NAME eq 'inquirydetail')"
>
class="active"
</if>
>
<a
href=
"/inquiry"
>
我的询价
</a></dd>
<dd
<
if
condition=
"(ACTION_NAME eq 'inquiry') || (ACTION_NAME eq 'releaseinquiry') || (ACTION_NAME eq 'inquirydetail')"
>
class="active"
</if>
>
<a
href=
"
homeicsales
/inquiry"
>
我的询价
</a></dd>
<dd
<
if
condition=
"(ACTION_NAME eq 'quote') || (ACTION_NAME eq 'quotedetail')"
>
class="active"
</if>
>
<a
href=
"homeicsales/quote"
>
我的报价
</a></dd>
</dl>
</li>
...
...
dist/js/chat/index.js
View file @
ea59284c
...
...
@@ -3,91 +3,168 @@ $(function () {
conn
:
{},
orgName
:
"1113190618181018"
,
appName
:
"icsales"
,
defaultName
:
"18664936975"
,
templateObj
:
JSON
.
parse
(
Util
.
getCookie
(
'template'
)
||
"{}"
),
customerText
:
Util
.
getCookie
(
'customer'
)
||
""
,
isLoginSuccess
:
false
,
img
:
""
,
name
:
""
,
id
:
""
,
init
:
function
()
{
this
.
ieFun
()
this
.
getUserInfo
();
// this.ieFun();
this
.
connection
();
this
.
connListen
();
this
.
login
();
this
.
bindFunction
();
var
data
=
JSON
.
stringify
({
"grant_type"
:
"client_credentials"
,
"client_id"
:
"YXA6UWJlUJGNEemA0XUSlr6mDA"
,
"client_secret"
:
"YXA6n8pckF065e7FPtukjJHAoa-4G74"
},
)
$
.
ajax
({
type
:
'post'
,
url
:
'http://a1.easemob.com/1113190618181018/icsales/token'
,
data
:
data
,
contentType
:
"application/json"
,
success
:
function
(
data
)
{
var
token
=
data
.
access_token
;
$
.
ajax
({
type
:
'get'
,
url
:
'http://a1.easemob.com/1113190618181018/icsales/chatmessages/2019062513'
,
headers
:
{
Authorization
:
'Bearer '
+
token
},
success
:
function
(
data
)
{
deleteCookie
:
function
()
{
Util
.
delCookie
(
'template'
,
cookieHostname
);
Util
.
delCookie
(
'templateBoolean'
,
cookieHostname
);
Util
.
delCookie
(
'customer'
,
cookieHostname
);
},
getUserInfo
:
function
()
{
//获取用户的基本信息
var
self
=
this
;
IcController
.
getData
(
apis
.
authme
,
'GET'
,
{
"token"
:
Util
.
getCookie
(
'token'
)
||
''
,
},
function
(
res
)
{
if
(
res
.
err_code
==
0
)
{
self
.
img
=
res
.
data
.
avatar
;
self
.
name
=
res
.
data
.
company_name
||
'--'
;
self
.
id
=
res
.
data
.
user_id
+
''
;
self
.
getHistoryUsers
(
res
.
data
.
im_username
,
res
.
data
.
im_password
);
}
else
{
console
.
log
(
'获取用户名失败'
);
layer
.
msg
(
'聊天系统出错'
);
self
.
deleteCookie
()
}
},
true
,
false
)
},
error
:
function
()
{
layer
.
msg
(
'网络出现问题,请重试!'
);
getHistoryUsers
:
function
(
name
,
password
)
{
//获取用户聊天的成员记录
var
self
=
this
;
IcController
.
getData
(
apis
.
listrecord
,
'GET'
,
{
"token"
:
Util
.
getCookie
(
'token'
)
||
''
,
},
function
(
res
)
{
if
(
res
.
errcode
===
0
)
{
self
.
rendChatSection
(
res
.
data
);
self
.
login
(
name
,
password
);
}
else
{
layer
.
msg
(
'获取历史纪录失败'
);
self
.
deleteCookie
()
}
});
},
addChatMember
:
function
(
id
)
{
IcController
.
getData
(
apis
.
addrecord
,
'GET'
,
{
"token"
:
Util
.
getCookie
(
'token'
)
||
''
,
"user_id"
:
id
},
function
(
res
)
{
if
(
res
.
errcode
===
0
)
{
}
else
{
console
.
log
(
'添加聊天成员失败'
)
}
},
false
);
},
error
:
function
()
{
layer
.
msg
(
'网络出现问题,请重试!'
);
rendChatSection
:
function
(
data
)
{
console
.
log
(
'获取成员'
)
this
.
addUser
({},
true
);
for
(
var
i
=
0
;
i
<
data
.
length
;
i
++
)
{
this
.
addUser
(
data
[
i
])
}
});
},
defaultUser
:
function
()
{
//默认客服
var
message
=
{
from
:
"18664936975"
,
data
:
''
singleChat
:
function
()
{
if
(
JSON
.
stringify
(
this
.
templateObj
)
==
'{}'
)
{
$
(
".notice_classify[userid="
+
this
.
defaultName
+
"]"
).
click
();
}
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
();
}
this
.
receiveData
(
1
,
message
,
false
);
},
singleChat
:
function
()
{
var
templateStr
=
Util
.
getCookie
(
'template'
);
var
templateObj
=
{};
if
(
templateStr
)
{
templateObj
=
JSON
.
parse
(
templateStr
)
customerChat
:
function
()
{
if
(
Util
.
getCookie
(
'customer'
))
{
Util
.
delCookie
(
'customer'
,
cookieHostname
);
$
(
".notice_classify[userid="
+
this
.
defaultName
+
"]"
).
attr
(
'isCustomer'
,
true
);
}
if
(
JSON
.
stringify
(
templateObj
)
!==
'{}'
)
{
var
message
=
{
from
:
templateObj
.
userId
,
data
:
''
};
this
.
receiveData
(
1
,
message
,
false
);
$
(
".notice_classify[userid="
+
templateObj
.
userId
+
"]"
).
click
();
this
.
sendCmd
(
templateObj
);
Util
.
delCookie
(
'template'
);
},
addUser
:
function
(
obj
,
isDefault
,
isFirst
)
{
var
id
,
name
,
img
,
touserid
;
if
(
isDefault
)
{
id
=
this
.
defaultName
;
name
=
'IC助手客服'
;
touserid
=
""
;
img
=
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"
);
}
else
{
id
=
obj
.
im_username
;
name
=
obj
.
company_name
||
'--'
;
touserid
=
obj
.
user_id
;
img
=
obj
.
avatar
||
(
dist
+
"/images/default.jpg"
)
}
}
var
userLen
=
$
(
'.chat_item_content'
).
find
(
'#'
+
id
).
length
;
if
(
userLen
)
{
//用户存在
return
;
}
else
{
//用户不存在
var
lefthtml
=
'<div class="notice_classify" userid="'
+
id
+
'" firstClick="true" touserid='
+
touserid
+
'>'
+
this
.
userHtml
(
0
,
{
name
:
name
,
id
:
id
,
img
:
img
},
''
)
+
'</div>'
;;
var
righthtml
=
'<div class="chat_item" id="'
+
id
+
'">'
+
'<div class="title clr">'
+
// '<div class="fr btn btn_border">' +
// '<span class="icon iconfont iconjuxing23"></span>' +
// '<i>' + id + '</i>' +
// '</div>' +
'<h3 class="bold boxsiz">'
+
name
+
'</h3>'
+
'</div>'
+
'<div class="notice_list boxsiz">'
+
'<div class="notice_item_content">'
+
'</div>'
+
'</div>'
+
'</div>'
+
'</div>'
;
$
(
'.notice_left_content'
).
append
(
lefthtml
);
$
(
'.chat_item_content'
).
append
(
righthtml
)
}
},
connection
:
function
()
{
WebIM
.
config
=
config
;
//建立聊天链接
this
.
conn
=
new
WebIM
.
connection
({
this
.
conn
=
WebIM
.
conn
=
new
WebIM
.
default
.
connection
({
appKey
:
WebIM
.
config
.
appkey
,
isHttpDNS
:
WebIM
.
config
.
isHttpDNS
,
isMultiLoginSessions
:
WebIM
.
config
.
isMultiLoginSessions
,
h
ttps
:
typeof
WebIM
.
config
.
https
===
'boolean'
?
WebIM
.
config
.
https
:
location
.
protocol
===
'https:'
,
h
ost
:
WebIM
.
config
.
Host
,
https
:
WebIM
.
config
.
https
,
url
:
WebIM
.
config
.
xmppURL
,
apiUrl
:
WebIM
.
config
.
apiURL
,
isAutoLogin
:
true
,
heartBeatWait
:
WebIM
.
config
.
heartBeatWait
,
autoReconnectNumMax
:
WebIM
.
config
.
autoReconnectNumMax
,
autoReconnectInterval
:
WebIM
.
config
.
autoReconnectInterval
autoReconnectInterval
:
WebIM
.
config
.
autoReconnectInterval
,
isStropheLog
:
WebIM
.
config
.
isStropheLog
,
delivery
:
WebIM
.
config
.
delivery
});
// 初始化上传组件 fileInputId对应页面上的file组件id
WebIM
.
flashUpload
=
UploadShim
({
fileInputId
:
'image'
},
this
.
conn
).
flashUpload
;
//增加表情
WebIM
.
Emoji
=
{
path
:
dist
+
'/faces/'
,
...
...
@@ -166,47 +243,48 @@ $(function () {
clock
+=
ss
;
return
(
clock
);
},
userHtml
:
function
(
num
,
user
,
message
)
{
userHtml
:
function
(
num
,
obj
,
message
)
{
//左边用户的dom拼接
if
(
num
==
0
)
{
return
'<img src="'
+
dist
+
'/images/test.jpg
" alt="" class="user_logo">'
+
return
'<img src="'
+
obj
.
img
+
'
" alt="" class="user_logo">'
+
'<div class="user_right">'
+
'<div class="clr">'
+
'<h3 class="boxsiz ellipsis">'
+
user
+
'</h3>'
+
'<h3 class="boxsiz ellipsis">'
+
obj
.
name
+
'</h3>'
+
'</div>'
+
'<div class="message ellipsis">'
+
message
+
'</div>'
+
'</div>'
}
else
{
return
'<img src="'
+
dist
+
'/images/test.jpg
" alt="" class="user_logo">'
+
return
'<img src="'
+
obj
.
img
+
'
" alt="" class="user_logo">'
+
'<div class="user_right">'
+
'<div class="clr">'
+
'<span class="num fr">'
+
num
+
'</span>'
+
'<h3 class="boxsiz ellipsis">'
+
user
+
'</h3>'
+
'<h3 class="boxsiz ellipsis">'
+
obj
.
name
+
'</h3>'
+
'</div>'
+
'<div class="message ellipsis">'
+
message
+
'</div>'
+
'</div>'
}
},
messageHtml
:
function
(
leftOrRight
,
html
,
isTemplate
)
{
messageHtml
:
function
(
leftOrRight
,
html
,
isTemplate
,
isHistory
,
time
)
{
//右边消息的dom拼接 isTemplate 是否是模板
var
htmlp
=
'<p>'
+
html
+
'</p>'
;
var
htmlp
=
'<p>'
+
html
.
message
+
'</p>'
;
var
img
=
html
.
img
||
(
dist
+
'/images/default.jpg'
)
if
(
isTemplate
)
{
var
htmlp
=
'<div class="template lineBlock boxsiz">'
+
'<img src="
http://resic.liexin.com/images/test.jpg
" alt="">'
+
'<img src="
'
+
(
html
.
goodImage
||
dist
+
"/images/defaultgood.png"
)
+
'
" alt="">'
+
'<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>'
+
'<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 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 class="num fl">数量:<i class="bold">'
+
html
.
num
+
'
</i></div>'
+
'<div class="time fl">时间:<i>
'
+
html
.
time
+
'
</i></div>'
+
'</div>'
+
'</div>'
+
'</div>'
+
...
...
@@ -215,22 +293,23 @@ $(function () {
if
(
leftOrRight
==
1
)
{
//右边
if
(
html
)
{
return
'<div class="notice_item right clr">'
+
'<img src="'
+
dist
+
'/images/test.jpg
" alt="" class="fr user_logo">'
+
'<img src="'
+
img
+
'
" alt="" class="fr user_logo">'
+
'<div class="notice_content">'
+
htmlp
+
'<div>'
+
this
.
curentTime
()
+
'</div>'
+
'<div>'
+
(
isHistory
?
time
:
this
.
curentTime
())
+
'</div>'
+
'</div>'
+
'</div>'
}
else
{
return
''
}
}
else
{
//左边
if
(
html
)
{
return
'<div class = "notice_item left clr" > '
+
'<img src="'
+
dist
+
'/images/test.jpg
" alt="" class="fl user_logo">'
+
'<img src="'
+
img
+
'
" alt="" class="fl user_logo">'
+
'<div class="notice_content">'
+
htmlp
+
'<div>'
+
this
.
curentTime
()
+
'</div>'
+
'<div>'
+
(
isHistory
?
time
:
this
.
curentTime
())
+
'</div>'
+
'</div>'
+
'</div>'
}
else
{
return
''
...
...
@@ -243,87 +322,126 @@ $(function () {
var
regContent
=
""
;
var
htmlStr
=
""
;
var
self
=
this
;
var
emojiTxt
=
""
if
(
type
==
1
)
{
if
(
isTemplate
)
{
regContent
=
message
.
ext
.
type
+
' '
+
message
.
ext
.
price
;
htmlStr
=
message
.
ext
;
regContent
=
message
.
type
+
' '
+
message
.
price
;
htmlStr
=
message
;
}
else
{
regContent
=
message
.
data
;
htmlStr
=
message
.
data
;
regContent
=
message
.
message
;
htmlStr
=
message
;
}
}
else
if
(
type
==
2
)
{
regContent
=
'[图片]'
;
htmlStr
=
'<img src ="'
+
message
.
url
+
'" class="edit_img"/>'
;
htmlStr
=
{
message
:
'<img src ="'
+
message
.
url
+
'" class="edit_img"/>'
,
name
:
message
.
name
,
img
:
message
.
img
,
id
:
message
.
id
}
}
else
{
var
data
=
message
.
data
;
var
data
=
message
.
message
;
for
(
var
i
=
0
,
l
=
data
.
length
;
i
<
l
;
i
++
)
{
if
(
data
[
i
].
type
==
'emoji'
)
{
regContent
+=
'[表情]'
;
htmlStr
+=
'<img src ="'
+
data
[
i
].
data
+
'" width=25 height=25/>'
;
emojiTxt
+=
'<img src ="'
+
data
[
i
].
data
+
'" width=25 height=25/>'
;
}
else
{
regContent
+=
data
[
i
].
data
;
htmlStr
+=
data
[
i
].
data
;
emojiTxt
+=
data
[
i
].
data
;
}
};
htmlStr
=
{
message
:
emojiTxt
,
name
:
message
.
name
,
img
:
message
.
img
,
id
:
message
.
id
}
}
var
len
=
$
(
'.notice_classify'
).
length
;
var
messageSigleStr
=
'<div class="title clr">'
+
'<div class="fr btn btn_border">'
+
'<span class="icon iconfont iconjuxing23"></span>'
+
'<i>'
+
message
.
from
+
'</i>'
+
'</div>'
+
'<h3 class="bold boxsiz">'
+
message
.
from
+
'</h3>'
+
//
'<div class="fr btn btn_border">' +
//
'<span class="icon iconfont iconjuxing23"></span>' +
// '<i>' + message.to
+ '</i>' +
//
'</div>' +
'<h3 class="bold boxsiz">'
+
message
.
name
+
'</h3>'
+
'</div>'
+
'<div class="notice_list boxsiz">'
+
'<div class="notice_item_content">'
+
self
.
messageHtml
(
2
,
htmlStr
,
isTemplate
)
+
self
.
messageHtml
(
2
,
message
,
isTemplate
)
+
'</div>'
+
'</div>'
+
'</div>'
;
if
(
!
len
)
{
//新用户
var
userStr
=
'<div class="notice_classify active" userid="'
+
message
.
from
+
'">'
+
self
.
userHtml
(
0
,
message
.
from
,
regContent
)
+
'</div>'
;
Util
.
delCookie
(
'templateBoolean'
,
cookieHostname
);
var
userStr
=
'<div class="notice_classify active" userid="'
+
message
.
from
+
'" firstClick="true" newMember="true" touserid='
+
message
.
touserid
+
'>'
+
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="
+
self
.
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
.
from
,
regContent
));
$
(
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
imgLen
=
$
(
'#'
+
userId
).
find
(
'img'
).
length
;
if
(
!
imgLen
)
{
setTimeout
(
function
()
{
var
contentHeight
=
$
(
'#'
+
userId
).
find
(
'.notice_item_content'
)
.
height
();
$
(
'#'
+
userId
).
find
(
'.notice_list'
).
scrollTop
(
contentHeight
);
},
200
)
}
else
{
$
(
'#'
+
userId
).
find
(
'img:last'
).
load
(
function
()
{
setTimeout
(
function
()
{
var
contentHeight
=
$
(
'#'
+
userId
).
find
(
'.notice_item_content'
)
.
height
();
$
(
'#'
+
userId
).
find
(
'.notice_list'
).
scrollTop
(
contentHeight
);
},
200
)
})
}
}
else
{
//非当前用户
Util
.
delCookie
(
'templateBoolean'
,
cookieHostname
);
var
num
=
Number
(
$
(
this
).
find
(
'.num'
).
text
());
$
(
this
).
html
(
self
.
userHtml
(
num
+
1
,
message
.
from
,
regContent
));
$
(
this
).
html
(
self
.
userHtml
(
num
+
1
,
message
,
regContent
));
var
html
=
$
(
this
).
clone
();
$
(
this
).
remove
();
$
(
".notice_classify[userid="
+
self
.
defaultName
+
"]"
).
after
(
html
);
if
(
!
firstClick
)
{
$
(
'#'
+
userId
).
find
(
'.notice_item_content'
).
append
(
self
.
messageHtml
(
2
,
htmlStr
,
isTemplate
));
}
}
return
false
;
}
else
{
if
(
index
==
len
-
1
)
{
//新用户
Util
.
delCookie
(
'templateBoolean'
,
cookieHostname
);
var
userStr
=
'<div class="notice_classify" userid="'
+
message
.
from
+
'">'
+
self
.
userHtml
(
1
,
message
.
from
,
regContent
)
+
'</div>'
;
message
.
from
+
'"
newMember="true" touserid='
+
message
.
touserid
+
'
>'
+
self
.
userHtml
(
1
,
message
,
regContent
)
+
'</div>'
;
var
messageStr
=
'<div class="chat_item" id="'
+
message
.
from
+
'">'
+
messageSigleStr
+
'</div>'
$
(
'.notice_left_content'
).
append
(
userStr
);
messageSigleStr
+
'</div>'
;
$
(
".notice_classify[userid="
+
self
.
defaultName
+
"]"
).
after
(
userStr
);
$
(
'.chat_item_content'
).
append
(
messageStr
)
}
}
...
...
@@ -335,19 +453,50 @@ $(function () {
// listern,添加回调函数;
self
.
conn
.
listen
({
onOpened
:
function
(
message
)
{
self
.
defaultUser
();
console
.
log
(
'登入成功'
)
self
.
isLoginSuccess
=
true
;
self
.
customerChat
();
self
.
singleChat
();
},
onTextMessage
:
function
(
message
)
{
self
.
receiveData
(
1
,
message
,
false
)
self
.
receiveData
(
1
,
{
name
:
message
.
ext
.
name
||
'--'
,
id
:
message
.
ext
.
id
,
img
:
message
.
ext
.
img
||
(
dist
+
"/images/default.jpg"
),
message
:
message
.
data
,
from
:
message
.
from
,
touserid
:
message
.
ext
.
touserid
},
false
)
},
//收到文本消息;
onEmojiMessage
:
function
(
message
)
{
self
.
receiveData
(
3
,
message
,
false
)
self
.
receiveData
(
3
,
{
name
:
message
.
ext
.
name
||
'--'
,
id
:
message
.
ext
.
id
,
img
:
message
.
ext
.
img
||
(
dist
+
"/images/default.jpg"
),
message
:
message
.
data
,
from
:
message
.
from
,
touserid
:
message
.
ext
.
touserid
},
false
)
},
//收到表情消息;
onCmdMessage
:
function
(
message
)
{
// console.log('CMD');
self
.
receiveData
(
1
,
message
,
true
)
console
.
log
(
message
)
self
.
receiveData
(
1
,
{
name
:
message
.
ext
.
name
||
'--'
,
id
:
message
.
ext
.
id
,
img
:
message
.
ext
.
img
||
(
dist
+
"/images/default.jpg"
),
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
,
touserid
:
message
.
ext
.
touserid
},
true
);
self
.
addChatMember
(
message
.
ext
.
id
)
},
//收到命令消息;
onPictureMessage
:
function
(
message
)
{
var
options
=
{
...
...
@@ -355,7 +504,14 @@ $(function () {
};
options
.
onFileDownloadComplete
=
function
()
{
// 图片下载成功;
self
.
receiveData
(
2
,
message
,
false
)
self
.
receiveData
(
2
,
{
name
:
message
.
ext
.
name
||
'--'
,
id
:
message
.
ext
.
id
,
img
:
message
.
ext
.
img
||
(
dist
+
"/images/default.jpg"
),
from
:
message
.
from
,
url
:
message
.
url
,
touserid
:
message
.
ext
.
touserid
},
false
)
};
...
...
@@ -363,7 +519,7 @@ $(function () {
// 图片下载失败
// console.log('Image download failed!');
};
WebIM
.
utils
.
download
.
call
(
self
.
conn
,
options
);
// 意义待查;
WebIM
.
default
.
utils
.
download
.
call
(
self
.
conn
,
options
);
// 意义待查;
},
//收到图片消息;
...
...
@@ -375,24 +531,26 @@ $(function () {
},
//本机网络掉线;
onError
:
function
(
message
)
{
// console.log('Error', WebIM.utils.stringify(message));
console
.
log
(
"Error: "
+
WebIM
.
utils
.
stringify
(
message
));
console
.
log
(
'onError: '
,
message
);
// layer.msg('聊天系统出错');
},
//失败回调;
});
},
login
:
function
()
{
login
:
function
(
user
,
password
)
{
// open,登录;
var
options
=
{
apiUrl
:
WebIM
.
config
.
apiURL
,
user
:
"18589050841"
,
pwd
:
"123456"
,
user
:
user
,
pwd
:
password
,
appKey
:
WebIM
.
config
.
appkey
};
try
{
this
.
conn
.
open
(
options
);
}
catch
(
e
)
{
console
.
log
(
WebIM
.
config
.
apiURL
)
// alert('open fail' + e.message)
console
.
log
(
e
);
layer
.
msg
(
'登入失败'
);
this
.
deleteCookie
();
}
},
...
...
@@ -400,84 +558,165 @@ $(function () {
var
self
=
this
;
// 私聊发送文本消息,发送表情同发送文本消息,只是会在对方客户端将表情文本进行解析成图片;
var
userId
=
$
(
'.notice_left '
).
find
(
'.active'
).
attr
(
'userid'
);
var
touserid
=
$
(
'.notice_left '
).
find
(
'.active'
).
attr
(
'touserid'
);
var
id
=
this
.
conn
.
getUniqueId
();
var
msg
=
new
WebIM
.
message
(
'txt'
,
id
);
var
emojiMessage
=
WebIM
.
utils
.
parseEmoji
(
content
);
//表情解析工具
var
msg
=
new
WebIM
.
default
.
message
(
'txt'
,
id
);
var
emojiMessage
=
WebIM
.
default
.
utils
.
parseEmoji
(
content
);
//表情解析工具
var
ext
=
{
timer
:
self
.
curentTime
(),
id
:
self
.
id
,
name
:
self
.
name
,
img
:
self
.
img
,
touserid
:
touserid
};
msg
.
set
({
msg
:
content
,
// 消息内容;
to
:
userId
,
// 接收消息对象;
roomType
:
false
,
ext
:
ext
,
success
:
function
(
id
,
serverMsgId
)
{
$
(
'#'
+
userId
).
find
(
'.notice_item_content'
).
append
(
self
.
messageHtml
(
1
,
emojiMessage
,
false
));
$
(
'#'
+
userId
).
find
(
'.notice_item_content'
).
append
(
self
.
messageHtml
(
1
,
{
message
:
emojiMessage
,
name
:
self
.
name
,
img
:
self
.
img
,
id
:
self
.
id
},
false
));
var
imgLen
=
$
(
'#'
+
userId
).
find
(
'img'
).
length
;
if
(
!
imgLen
)
{
setTimeout
(
function
()
{
var
contentHeight
=
$
(
'#'
+
userId
).
find
(
'.notice_item_content'
)
.
height
();
$
(
'#'
+
userId
).
find
(
'.notice_list'
).
scrollTop
(
contentHeight
);
},
200
)
}
else
{
$
(
'#'
+
userId
).
find
(
'img:last'
).
load
(
function
()
{
setTimeout
(
function
()
{
var
contentHeight
=
$
(
'#'
+
userId
).
find
(
'.notice_item_content'
)
.
height
();
$
(
'#'
+
userId
).
find
(
'.notice_list'
).
scrollTop
(
contentHeight
);
},
200
)
})
}
$
(
'#chat_textarea'
).
val
(
''
);
},
fail
:
function
()
{
console
.
log
(
"Send private text failed"
);
fail
:
function
(
e
)
{
console
.
log
(
"Send private text failed"
,
e
);
layer
.
msg
(
'消息发送失败'
);
}
});
// console.log(msg.body)
this
.
conn
.
send
(
msg
.
body
);
},
sendCmd
:
function
(
templateObj
)
{
var
self
=
this
;
var
userId
=
$
(
'.notice_left '
).
find
(
'.active'
).
attr
(
'userid'
);
var
touserid
=
$
(
'.notice_left '
).
find
(
'.active'
).
attr
(
'touserid'
);
var
id
=
this
.
conn
.
getUniqueId
();
var
msg
=
new
WebIM
.
message
(
'cmd'
,
id
);
var
msg
=
new
WebIM
.
default
.
message
(
'cmd'
,
id
);
var
params
=
$
.
extend
({},
templateObj
,
{
timer
:
self
.
curentTime
(),
name
:
self
.
name
,
id
:
self
.
id
,
img
:
self
.
img
,
touserid
:
touserid
});
msg
.
set
({
msg
:
'template'
,
to
:
userId
,
roomType
:
false
,
action
:
"template"
,
ext
:
templateObj
,
success
:
function
(
id
,
serverMsgId
)
{
ext
:
params
,
success
:
function
()
{
self
.
addChatMember
(
templateObj
.
targetId
);
$
(
'#'
+
userId
).
find
(
'.notice_item_content'
).
append
(
self
.
messageHtml
(
1
,
templateObj
,
true
));
params
,
true
));
var
imgLen
=
$
(
'#'
+
userId
).
find
(
'img'
).
length
;
if
(
!
imgLen
)
{
setTimeout
(
function
()
{
var
contentHeight
=
$
(
'#'
+
userId
).
find
(
'.notice_item_content'
)
.
height
();
$
(
'#'
+
userId
).
find
(
'.notice_list'
).
scrollTop
(
contentHeight
);
},
200
)
}
else
{
$
(
'#'
+
userId
).
find
(
'img:last'
).
load
(
function
()
{
setTimeout
(
function
()
{
var
contentHeight
=
$
(
'#'
+
userId
).
find
(
'.notice_item_content'
)
.
height
();
$
(
'#'
+
userId
).
find
(
'.notice_list'
).
scrollTop
(
contentHeight
);
},
200
)
})
}
},
fail
:
function
()
{
console
.
log
(
"Send Cmd failed"
);
layer
.
msg
(
'消息发送失败'
);
}
});
this
.
conn
.
send
(
msg
.
body
);
Util
.
delCookie
(
'templateBoolean'
,
cookieHostname
);
},
sendPrivateImg
:
function
()
{
// 私聊发送图片消息;
var
self
=
this
;
var
id
=
this
.
conn
.
getUniqueId
();
var
msg
=
new
WebIM
.
message
(
'img'
,
id
);
var
msg
=
new
WebIM
.
default
.
message
(
'img'
,
id
);
var
input
=
$
(
'#img_upload'
)[
0
];
// 选择图片的input;
var
file
=
WebIM
.
utils
.
getFileUrl
(
input
);
// 将图片转化为二进制文件;
var
file
=
WebIM
.
default
.
utils
.
getFileUrl
(
input
);
// 将图片转化为二进制文件;
var
userId
=
$
(
'.notice_left'
).
find
(
'.active'
).
attr
(
'userid'
);
var
touserid
=
$
(
'.notice_left '
).
find
(
'.active'
).
attr
(
'touserid'
);
var
option
=
{
apiUrl
:
WebIM
.
config
.
apiURL
,
file
:
file
,
to
:
'18664936975'
,
roomType
:
false
,
// chatType: 'singleChat',
to
:
userId
,
ext
:
{
timer
:
self
.
curentTime
(),
id
:
self
.
id
,
name
:
self
.
name
,
img
:
self
.
img
,
touserid
:
touserid
},
flashUpload
:
WebIM
.
flashUpload
,
onFileUploadError
:
function
()
{
console
.
log
(
file
);
console
.
log
(
'失败'
)
},
onFileUploadComplete
:
function
()
{},
onFileUploadComplete
:
function
()
{
console
.
log
(
'消息上传成功'
)
},
success
:
function
()
{
var
htmlStr
=
'<img src ="'
+
file
.
url
+
'" class="edit_img"/>'
;
$
(
'#'
+
userId
).
find
(
'.notice_item_content'
).
append
(
self
.
messageHtml
(
1
,
htmlStr
,
false
));
$
(
'#'
+
userId
).
find
(
'.notice_item_content'
).
append
(
self
.
messageHtml
(
1
,
{
message
:
htmlStr
,
name
:
self
.
name
,
img
:
self
.
img
,
id
:
self
.
id
},
false
));
var
imgLen
=
$
(
'#'
+
userId
).
find
(
'img'
).
length
;
if
(
!
imgLen
)
{
setTimeout
(
function
()
{
var
contentHeight
=
$
(
'#'
+
userId
).
find
(
'.notice_item_content'
)
.
height
();
$
(
'#'
+
userId
).
find
(
'.notice_list'
).
scrollTop
(
contentHeight
);
},
200
)
}
else
{
$
(
'#'
+
userId
).
find
(
'img:last'
).
load
(
function
()
{
setTimeout
(
function
()
{
var
contentHeight
=
$
(
'#'
+
userId
).
find
(
'.notice_item_content'
)
.
height
();
$
(
'#'
+
userId
).
find
(
'.notice_list'
).
scrollTop
(
contentHeight
);
},
200
)
})
}
$
(
'#img_upload'
).
val
(
''
);
},
fail
:
function
()
{
console
.
log
(
"Send Image failed"
);
layer
.
msg
(
'消息发送失败'
);
}
};
msg
.
set
(
option
);
console
.
log
(
msg
.
body
)
this
.
conn
.
send
(
msg
.
body
);
},
...
...
@@ -523,18 +762,166 @@ $(function () {
})
$
(
'.notice_left'
).
on
(
'click'
,
'.notice_classify'
,
function
()
{
var
id
=
$
(
this
).
attr
(
'userid'
);
var
isTemplate
=
$
(
this
).
attr
(
'isTemplate'
);
var
isCustomer
=
$
(
this
).
attr
(
'iscustomer'
);
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'
);
var
contentHeight
=
$
(
'#'
+
id
).
find
(
'.notice_item_content'
).
height
();
if
(
isCustomer
)
{
$
(
this
).
removeAttr
(
'iscustomer'
);
if
(
self
.
isLoginSuccess
)
{
//登入成功 获取聊天记录
self
.
getHistoryData
(
id
,
false
,
true
)
}
else
{
layer
.
msg
(
'聊天系统出错'
);
return
;
}
return
;
}
if
(
isTemplate
)
{
$
(
this
).
removeAttr
(
'isTemplate'
);
$
(
this
).
removeAttr
(
'firstClick'
);
if
(
self
.
isLoginSuccess
)
{
//登入成功 获取聊天记录
self
.
getHistoryData
(
id
,
true
)
}
else
{
layer
.
msg
(
'聊天系统出错'
);
return
;
}
}
else
{
if
(
newMember
)
{
setTimeout
(
function
()
{
var
contentHeight
=
$
(
'#'
+
id
).
find
(
'.notice_item_content'
)
.
height
();
$
(
'#'
+
id
).
find
(
'.notice_list'
).
scrollTop
(
contentHeight
);
},
200
)
return
}
if
(
firstClick
)
{
$
(
this
).
removeAttr
(
'firstClick'
);
if
(
self
.
isLoginSuccess
)
{
//登入成功 获取聊天记录
self
.
getHistoryData
(
id
);
}
else
{
layer
.
msg
(
'聊天系统出错'
);
return
;
}
}
else
{
setTimeout
(
function
()
{
var
contentHeight
=
$
(
'#'
+
id
).
find
(
'.notice_item_content'
)
.
height
();
$
(
'#'
+
id
).
find
(
'.notice_list'
).
scrollTop
(
contentHeight
);
},
200
)
}
}
});
$
(
'.notice_right '
).
on
(
'click'
,
'.edit_img'
,
function
()
{
})
},
getHistoryData
:
function
(
id
,
isTemplate
,
isCustomer
)
{
var
self
=
this
;
this
.
conn
.
fetchHistoryMessages
({
queue
:
id
,
count
:
'50'
,
success
:
function
(
data
)
{
self
.
rendHistoryMessage
(
id
,
data
,
isTemplate
)
if
(
isTemplate
)
{
self
.
sendCmd
(
self
.
templateObj
);
}
if
(
isCustomer
)
{
if
(
self
.
customerText
)
{
self
.
sendPrivateText
(
self
.
customerText
)
}
else
{
return
}
}
},
fail
:
function
(
e
)
{
console
.
log
(
e
)
layer
.
msg
(
'获取历史纪录失败'
);
if
(
isTemplate
)
{
self
.
sendCmd
(
self
.
templateObj
);
}
if
(
isCustomer
)
{
if
(
self
.
customerText
)
{
self
.
sendPrivateText
(
self
.
customerText
)
}
else
{
return
}
}
}
})
},
rendHistoryMessage
:
function
(
id
,
data
,
isTemplate
)
{
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
,
{
message
:
data
[
i
].
data
,
name
:
data
[
i
].
ext
.
name
,
img
:
data
[
i
].
ext
.
img
,
id
:
data
[
i
].
ext
.
id
},
false
,
true
,
data
[
i
].
ext
.
timer
);
}
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
,
{
message
:
emojiTxt
,
name
:
data
[
i
].
ext
.
name
,
img
:
data
[
i
].
ext
.
img
,
id
:
data
[
i
].
ext
.
id
},
false
,
true
,
data
[
i
].
ext
.
timer
);
}
}
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
,
id
:
data
[
i
].
ext
.
id
},
false
,
true
,
data
[
i
].
ext
.
timer
);
}
else
if
(
data
[
i
].
action
==
'template'
)
{
//模板
chatCon
+=
this
.
messageHtml
(
rightOrLeft
,
data
[
i
].
ext
,
true
,
true
,
data
[
i
].
ext
.
timer
);
}
}
$
(
'#'
+
id
).
find
(
'.notice_item_content'
).
prepend
(
chatCon
);
if
(
!
isTemplate
)
{
var
imgLen
=
$
(
'#'
+
id
).
find
(
'img'
).
length
;
if
(
!
imgLen
)
{
setTimeout
(
function
()
{
var
contentHeight
=
$
(
'#'
+
id
).
find
(
'.notice_item_content'
)
.
height
();
$
(
'#'
+
id
).
find
(
'.notice_list'
).
scrollTop
(
contentHeight
);
},
200
)
}
else
{
$
(
'#'
+
id
).
find
(
'img:last'
).
load
(
function
()
{
setTimeout
(
function
()
{
var
contentHeight
=
$
(
'#'
+
id
).
find
(
'.notice_item_content'
)
.
height
();
$
(
'#'
+
id
).
find
(
'.notice_list'
).
scrollTop
(
contentHeight
);
},
200
)
})
}
}
},
};
chatObj
.
init
();
})
\ No newline at end of file
dist/js/global/api.js
View file @
ea59284c
...
...
@@ -181,11 +181,7 @@
/**
* 标记会员通知(已读)
*/
userMarkmsg
:
user_url
+
'/user/markmsg'
,
/***
* 热门搜索
*/
hotgoods
:
home_url
+
'/hotgoods'
userMarkmsg
:
user_url
+
'/user/markmsg'
};
if
(
typeof
define
===
"function"
&&
define
.
amd
)
{
return
apis
;
...
...
dist/js/home/index.js
View file @
ea59284c
...
...
@@ -4,19 +4,6 @@ $(function () {
this
.
bindFun
();
this
.
getXbData
(
1
);
this
.
getNewXj
();
this
.
getHot
();
},
getHot
:
function
(){
IcController
.
getData
(
apis
.
hotgoods
,
'GET'
,
{},
function
(
res
)
{
if
(
res
.
errcode
===
0
)
{
}
else
{
}
})
},
getXbData
:
function
(
type
)
{
//1报价 2询价
var
url
;
...
...
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