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
abb452f9
authored
Jul 29, 2019
by
施宇
Browse files
Options
_('Browse Files')
Download
Plain Diff
Merge branch 'master' of
http://119.23.72.7/shiyu/icsales
parents
1a6a63f1
ee390f72
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
256 additions
and
654 deletions
Application/Common/Conf/config_url.php
Application/Home/Controller/BaseController.class.php
Application/Home/Controller/CmsController.class.php
Application/Home/Controller/IndexController.class.php
Application/Home/View/QuotePrice/inquirydetail.html
Application/Home/View/public/navleft.html
dist/js/chat/index.js
dist/js/person/login.js
Application/Common/Conf/config_url.php
View file @
abb452f9
...
@@ -69,7 +69,7 @@ return array(
...
@@ -69,7 +69,7 @@ return array(
'uploadresult'
=>
'Home/Index/uploadresult'
,
'uploadresult'
=>
'Home/Index/uploadresult'
,
'integral'
=>
'Home/Index/integral'
,
'integral'
=>
'Home/Index/integral'
,
'notice'
=>
'Home/Index/notice'
,
'notice'
=>
'Home/Index/notice'
,
'chat'
=>
'Home/Index/chat'
'chat'
=>
'Home/Index/chat'
,
'hotgoods'
=>
'Home/Cms/getHotGoods'
,
),
),
);
);
\ No newline at end of file
Application/Home/Controller/BaseController.class.php
View file @
abb452f9
Application/Home/Controller/CmsController.class.php
0 → 100644
View file @
abb452f9
<?php
namespace
Home\Controller
;
use
Home\Controller\BaseController
;
class
CmsController
extends
BaseController
{
// 获取热门商品
public
function
getHotGoods
()
{
$datas
=
$this
->
apiBaseCache
(
'pc_hot_goods'
,
''
,
5
);
// 热门商品
return
$this
->
jsonReturn
(
0
,
''
,
$datas
[
'data'
]);
}
/**
* 统一格式返回
* @param integer $code [description]
* @param string $msg [description]
* @param array $extend [description]
* @return [type] [description]
*/
protected
function
jsonReturn
(
$code
=
0
,
$msg
=
''
,
$extend
=
array
())
{
$data
=
array
(
'err_code'
=>
$code
,
'err_msg'
=>
$msg
,
'data'
=>
$extend
,
);
if
(
isset
(
$_GET
[
'callback'
])
&&
!
empty
(
$_GET
[
'callback'
])){
echo
$_GET
[
'callback'
]
.
'('
.
json_encode
(
$data
)
.
')'
;
exit
;
}
else
{
echo
json_encode
(
$data
);
exit
;
}
}
}
\ No newline at end of file
Application/Home/Controller/IndexController.class.php
View file @
abb452f9
...
@@ -11,7 +11,7 @@ class IndexController extends BaseController
...
@@ -11,7 +11,7 @@ class IndexController extends BaseController
public
function
_initialize
()
public
function
_initialize
()
{
{
parent
::
_initialize
();
parent
::
_initialize
();
if
(
!
cookie
(
'token'
)
&&
ACTION_NAME
!=
'login'
&&
ACTION_NAME
!=
'register'
&&
ACTION_NAME
!=
'index'
&&
ACTION_NAME
!=
'indexsearch'
)
{
if
(
!
cookie
(
'token'
)
&&
ACTION_NAME
!=
'login'
&&
ACTION_NAME
!=
'register'
&&
ACTION_NAME
!=
'index'
&&
ACTION_NAME
!=
'indexsearch'
&&
ACTION_NAME
!=
'forget'
)
{
$this
->
redirect
(
'/login'
);
$this
->
redirect
(
'/login'
);
}
}
}
}
...
...
Application/Home/View/QuotePrice/inquirydetail.html
View file @
abb452f9
...
@@ -14,192 +14,138 @@
...
@@ -14,192 +14,138 @@
<div
class=
"right_content inquiry_detail_content"
>
<div
class=
"right_content inquiry_detail_content"
>
<div
class=
"content"
>
<div
class=
"content"
>
<div
class=
"nav_title"
>
<div
class=
"nav_title"
>
询报价 > 我的询价 > 询价详情 STM32F103ZET6
<span
class=
"fr"
>
2019-05-22 15:35
</span>
</div>
</div>
<div
class=
"goods_detail clr"
>
<div
class=
"goods_detail clr"
>
</div>
<img
src=
"__PUBLIC__/images/test.jpg"
alt=
""
class=
"fr"
>
<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=
" goods_desc boxsiz"
>
<div
class=
"title"
>
<div
class=
"title"
>
<
h3
class
=
"bold fl"
>
{{
d
.
goods_name
}}
<
/h3
>
<h3
class=
"bold fl"
>
STM32F103ZET6
</h3>
<div
class=
"fr"
>
<div
class=
"fr"
>
{{
#
if
(
d
[
'audit_status'
]
==
1
){
}}
<span
class=
"mark lineBlock"
></span><span
class=
"text"
>
展示中
</span>
{{
#
if
(
d
[
'status'
]
==
1
){
}}
</div>
<
span
class
=
"mark lineBlock zs"
><
/span><span class="text">展示中</
span
>
</div>
{{
#
}
else
{
}}
<div
class=
"desc inquiry_desc"
>
<
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"
>
<div
class=
"brand fl boxsiz ellipsis"
>
品牌:
<
span
>
{{
d
.
brand_name
}}
<
/span
>
品牌:
<span>
Texas InstrumentsTexas
</span>
</div>
</div>
<div
class=
"fz fl boxsiz ellipsis"
>
<div
class=
"fz fl boxsiz ellipsis"
>
封装:
<
span
>
{{
d
.
encap
}}
<
/span
>
封装:
<span>
LQFP-144
</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>
<
div
class
=
"num fl boxsiz ellipsis"
>
数量:
<
span
class
=
"bold"
>
{{
d
.
number
}}
PCS
<
/span></
div
>
<div
class=
"price fl boxsiz ellipsis "
>
接受价:
<span>
无
</span></div>
<
div
class
=
"hq fl boxsiz ellipsis"
>
货期:
<
span
>
{{
d
.
delivery_time
}}
<
/span></
div
>
<div
class=
"num fl boxsiz ellipsis"
>
数量:
<span
class=
"bold"
>
100,000 PCS
</span></div>
<
div
class
=
"bz fl boxsiz ellipsis"
>
备注:
<
span
>
{{
d
.
remark
||
'--'
}}
<
/span></
div
>
<div
class=
"hq fl boxsiz ellipsis"
>
货期:
<span>
现货
</span></div>
<div
class=
"bz fl boxsiz ellipsis"
>
备注:
<span>
有货的商家请尽快联系,谢谢!
</span></div>
</div>
</div>
</div>
</div>
</script
>
</div
>
<script
type=
"text/html"
id=
"bjTp
l"
>
<div
class=
"bj_detai
l"
>
<div
class=
"bj_title"
>
<div
class=
"bj_title"
>
<span
class=
"lineBlock"
></span>
<span
class=
"lineBlock"
></span>
<b>
收到的报价
</b>
<b>
收到的报价
</b>
<
b
class
=
"bj_num"
>
{{
d
.
length
}}
<
/b
>
<b
class=
"bj_num"
>
2
</b>
</div>
</div>
<div
class=
"bj_lists"
>
<div
class=
"bj_lists"
>
{{
#
layui
.
each
(
d
,
function
(
index
,
item
){
}}
<div
class=
"bj_item clr"
>
<div
class=
"bj_item clr"
>
<div
class=
"item_right fr boxsiz"
>
<div
class=
"item_right fr boxsiz"
>
<div
class=
"top"
>
<div
class=
"top"
>
<!--
<
div
class
=
"top_right icon iconfont iconjuxing2 fr"
><
/div> --
>
<div
class=
"top_right icon iconfont iconjuxing2 fr"
></div
>
<
div
class
=
"top_left boxsiz ellipsis"
style
=
"padding-right:0
"
>
<div
class=
"top_left boxsiz ellipsis
"
>
<span
class=
"lineBlock mark"
>
报价
</span>
<span
class=
"lineBlock mark"
>
报价
</span>
<
span
class
=
"name bold"
>
{{
item
.
company_name
||
'--'
}}
<
/span
>
<span
class=
"name bold"
>
深圳邦马特科技有限公司深圳邦马特科技有限公司
</span>
</div>
</div>
</div>
</div>
<div
class=
"center"
>
<div
class=
"center"
>
<
div
class
=
"center_left boxsiz clr"
style
=
"padding-right:0"
>
<div
class=
"center_left boxsiz clr"
>
{{
#
if
(
item
.
auth_type
!==
""
){
}}
<div
class=
"fl"
>
<span
class=
"icon iconfont iconjuxing10"
></span>
公司认证
</div>
<div
class=
"fl"
>
<div
class=
"fl"
>
<span
class=
"icon iconfont iconjuxing10"
></span>
<span
class=
"icon iconfont iconjuxing10"
></span>
{{
#
if
(
item
.
auth_type
==
0
){
}}
贸易商
未认证
</div>
{{
#
}
}}
<div
class=
"fl"
>
{{
#
if
(
item
.
auth_type
==
1
){
}}
<span
class=
"icon iconfont iconjuxing10"
></span>
个人认证
贸易商
{{
#
}
}}
</div>
{{
#
if
(
item
.
auth_type
==
2
){
}}
企业认证
{{
#
}
}}
<
/div
>
{{
#
}
}}
{{
#
if
(
item
.
company_type
!==
""
){
}}
<div
class=
"fl"
>
<div
class=
"fl"
>
<span
class=
"icon iconfont iconjuxing10"
></span>
<span
class=
"icon iconfont iconjuxing10"
></span>
{{
#
if
(
item
.
company_type
==
1
){
}}
贸易商
贸易商
{{
#
}
}}
</div>
{{
#
if
(
item
.
company_type
==
2
){
}}
<div
class=
"fl"
>
代理商
<span
class=
"icon iconfont iconjuxing10"
></span>
{{
#
}
}}
贸易商
{{
#
if
(
item
.
company_type
==
3
){
}}
</div>
原厂
{{
#
}
}}
</div>
{{
#
if
(
item
.
company_type
==
4
){
}}
<div
class=
"center_right ellipsis"
>
制造商
{{
#
}
}}
{{
#
if
(
item
.
company_type
==
5
){
}}
个人用户
{{
#
}
}}
<
/div
>
{{
#
}
}}
<
/div
>
<!--
<
div
class
=
"center_right ellipsis"
>
报价:
<span
class=
"bold"
>
21次
</span>
报价:
<span
class=
"bold"
>
21次
</span>
<
/div> --
>
</div
>
</div>
</div>
<div
class=
"bottom clr"
>
<div
class=
"bottom clr"
>
<
div
class
=
"gt_div fl btn btn_yellow"
imid
=
"{{item.im_username}}"
userid
=
"{{item.user_id}}"
avatar
=
"{{item.avatar}}
"
>
<div
class=
"gt_div fl btn btn_yellow
"
>
<span
class=
"icon iconfont iconjuxing7 va-m"
></span>
<span
class=
"icon iconfont iconjuxing7 va-m"
></span>
在线沟通
在线沟通
</div>
</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>
<span
class=
"icon iconfont iconjuxing23 va-m"
></span>
18271408714
18271408714
<
/div> --
>
</div
>
</div>
</div>
<div
class=
"time"
>
<div
class=
"time"
>
报价时间:
<
span
>
{{
layui
.
util
.
toDateString
(
d
.
add_time
*
1000
)}}
<
/span
>
报价时间:
<span>
2019-05-23 15:57
</span>
</div>
</div>
</div>
</div>
<
div
class
=
"item_left boxsiz"
style
=
"padding-right:474px;
"
>
<div
class=
"item_left boxsiz
"
>
<div
class=
"item_left_top"
>
<div
class=
"item_left_top"
>
<
h3
class
=
"bold fl ellipsis boxsiz goods_name"
>
{{
item
.
goods_name
}}
<
/h3
>
<h3
class=
"bold fl ellipsis boxsiz"
>
STM32F103ZET6
</h3>
<
div
class
=
"price fl bold ellipsis boxsiz"
>
<div
class=
"price fl bold ellipsis boxsiz"
>
¥67.9800
</div>
{{
#
if
(
item
.
currency
==
1
){
}}
¥
{{
#
}
else
{
}}
$
{{
#
}
}}
{{
item
.
price
}}
<
/div
>
</div>
</div>
<div
class=
"desc"
>
<div
class=
"desc"
>
<div
class=
"brand fl boxsiz ellipsis"
>
<div
class=
"brand fl boxsiz ellipsis"
>
品牌:
<
span
>
{{
item
.
brand_name
}}
品牌:
<span>
Texas Instruments
</span>
</span>
</div>
</div>
<div
class=
"fz fl boxsiz ellipsis"
>
<div
class=
"fz fl boxsiz ellipsis"
>
封装:
<
span
>
{{
item
.
encap
}}
<
/span
>
封装:
<span>
LQFP-144
</span>
</div>
</div>
<
div
class
=
"num fl boxsiz ellipsis"
>
数量:
<
span
class
=
"bold"
>
{{
item
.
number
}}
PCS
<
/span
>
<div
class=
"num fl boxsiz ellipsis"
>
数量:
<span
class=
"bold"
>
100,000
PCS
</span>
</div>
</div>
<
div
class
=
"hq fl boxsiz ellipsis"
>
货期:
<
span
>
{{
item
.
delivery_time
}}
<
/span></
div
>
<div
class=
"hq fl boxsiz ellipsis"
>
货期:
<span>
现货
</span></div>
<div
class=
"bz fl boxsiz ellipsis"
>
<div
class=
"bz fl boxsiz ellipsis"
>
备注:
<
span
>
{{
item
.
remark
||
'--'
}}
<
/span></
div
>
备注:
<span>
我们有大量的现货,随时都可以出库。我们有大量的现货,随时都可以出库。
</span></div>
</div>
</div>
</div>
</div>
</div>
</div>
{{
#
});
}}
</div>
</div>
{{
#
if
(
d
.
length
===
0
){
}}
<div
class=
"no_data"
style=
"display: none"
>
<
div
class
=
"no_data"
>
<img
src=
"__PUBLIC__/images/nodata.png"
alt=
""
>
<img
src=
"__PUBLIC__/images/nodata.png"
alt=
""
>
<p>
暂无报价信息
</p>
<p>
暂无报价信息
</p>
</div>
</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>
</script>
</body>
</body>
...
...
Application/Home/View/public/navleft.html
View file @
abb452f9
...
@@ -24,7 +24,7 @@
...
@@ -24,7 +24,7 @@
<span
class=
"li_right icon iconfont"
>
<span
class=
"li_right icon iconfont"
>
</a>
</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>
>
<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=
"
homeicsales
/inquiry"
>
我的询价
</a></dd>
<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 'quote') || (ACTION_NAME eq 'quotedetail')"
>
class="active"
</if>
>
<a
href=
"homeicsales/quote"
>
我的报价
</a></dd>
<dd
<
if
condition=
"(ACTION_NAME eq 'quote') || (ACTION_NAME eq 'quotedetail')"
>
class="active"
</if>
>
<a
href=
"homeicsales/quote"
>
我的报价
</a></dd>
</dl>
</dl>
</li>
</li>
...
...
dist/js/chat/index.js
View file @
abb452f9
...
@@ -3,168 +3,91 @@ $(function () {
...
@@ -3,168 +3,91 @@ $(function () {
conn
:
{},
conn
:
{},
orgName
:
"1113190618181018"
,
orgName
:
"1113190618181018"
,
appName
:
"icsales"
,
appName
:
"icsales"
,
defaultName
:
"18664936975"
,
templateObj
:
JSON
.
parse
(
Util
.
getCookie
(
'template'
)
||
"{}"
),
customerText
:
Util
.
getCookie
(
'customer'
)
||
""
,
isLoginSuccess
:
false
,
img
:
""
,
name
:
""
,
id
:
""
,
init
:
function
()
{
init
:
function
()
{
this
.
getUserInfo
();
this
.
ieFun
()
// this.ieFun();
this
.
connection
();
this
.
connection
();
this
.
connListen
();
this
.
connListen
();
this
.
login
();
this
.
bindFunction
();
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
},
},
deleteCookie
:
function
()
{
success
:
function
(
data
)
{
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
)
},
},
getHistoryUsers
:
function
(
name
,
password
)
{
error
:
function
()
{
//获取用户聊天的成员记录
layer
.
msg
(
'网络出现问题,请重试!'
);
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
);
},
},
rendChatSection
:
function
(
data
)
{
error
:
function
()
{
console
.
log
(
'获取成员'
)
layer
.
msg
(
'网络出现问题,请重试!'
);
this
.
addUser
({},
true
);
for
(
var
i
=
0
;
i
<
data
.
length
;
i
++
)
{
this
.
addUser
(
data
[
i
])
}
}
});
},
},
singleChat
:
function
()
{
defaultUser
:
function
()
{
if
(
JSON
.
stringify
(
this
.
templateObj
)
==
'{}'
)
{
//默认客服
$
(
".notice_classify[userid="
+
this
.
defaultName
+
"]"
).
click
();
var
message
=
{
}
else
{
from
:
"18664936975"
,
Util
.
delCookie
(
'template'
,
cookieHostname
);
data
:
''
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
);
},
},
customerChat
:
function
()
{
singleChat
:
function
()
{
if
(
Util
.
getCookie
(
'customer'
))
{
var
templateStr
=
Util
.
getCookie
(
'template'
);
Util
.
delCookie
(
'customer'
,
cookieHostname
);
var
templateObj
=
{};
$
(
".notice_classify[userid="
+
this
.
defaultName
+
"]"
).
attr
(
'isCustomer'
,
true
);
if
(
templateStr
)
{
templateObj
=
JSON
.
parse
(
templateStr
)
}
}
if
(
JSON
.
stringify
(
templateObj
)
!==
'{}'
)
{
var
message
=
{
},
from
:
templateObj
.
userId
,
addUser
:
function
(
obj
,
isDefault
,
isFirst
)
{
data
:
''
var
id
,
name
,
img
,
touserid
;
};
if
(
isDefault
)
{
this
.
receiveData
(
1
,
message
,
false
);
id
=
this
.
defaultName
;
$
(
".notice_classify[userid="
+
templateObj
.
userId
+
"]"
).
click
();
name
=
'IC助手客服'
;
this
.
sendCmd
(
templateObj
);
touserid
=
""
;
Util
.
delCookie
(
'template'
);
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
()
{
connection
:
function
()
{
WebIM
.
config
=
config
;
//建立聊天链接
//建立聊天链接
this
.
conn
=
WebIM
.
conn
=
new
WebIM
.
default
.
connection
({
this
.
conn
=
new
WebIM
.
connection
({
appKey
:
WebIM
.
config
.
appkey
,
isHttpDNS
:
WebIM
.
config
.
isHttpDNS
,
isMultiLoginSessions
:
WebIM
.
config
.
isMultiLoginSessions
,
isMultiLoginSessions
:
WebIM
.
config
.
isMultiLoginSessions
,
h
ost
:
WebIM
.
config
.
Host
,
h
ttps
:
typeof
WebIM
.
config
.
https
===
'boolean'
?
WebIM
.
config
.
https
:
location
.
protocol
===
https
:
WebIM
.
config
.
https
,
'https:'
,
url
:
WebIM
.
config
.
xmppURL
,
url
:
WebIM
.
config
.
xmppURL
,
apiUrl
:
WebIM
.
config
.
apiURL
,
isAutoLogin
:
true
,
isAutoLogin
:
true
,
heartBeatWait
:
WebIM
.
config
.
heartBeatWait
,
heartBeatWait
:
WebIM
.
config
.
heartBeatWait
,
autoReconnectNumMax
:
WebIM
.
config
.
autoReconnectNumMax
,
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
=
{
WebIM
.
Emoji
=
{
path
:
dist
+
'/faces/'
,
path
:
dist
+
'/faces/'
,
...
@@ -243,48 +166,47 @@ $(function () {
...
@@ -243,48 +166,47 @@ $(function () {
clock
+=
ss
;
clock
+=
ss
;
return
(
clock
);
return
(
clock
);
},
},
userHtml
:
function
(
num
,
obj
,
message
)
{
userHtml
:
function
(
num
,
user
,
message
)
{
//左边用户的dom拼接
//左边用户的dom拼接
if
(
num
==
0
)
{
if
(
num
==
0
)
{
return
'<img src="'
+
obj
.
img
+
'
" 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">'
+
obj
.
name
+
'</h3>'
+
'<h3 class="boxsiz ellipsis">'
+
user
+
'</h3>'
+
'</div>'
+
'</div>'
+
'<div class="message ellipsis">'
+
message
+
'</div>'
+
'<div class="message ellipsis">'
+
message
+
'</div>'
+
'</div>'
'</div>'
}
else
{
}
else
{
return
'<img src="'
+
obj
.
img
+
'
" 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">'
+
'<span class="num fr">'
+
num
+
'</span>'
+
'<span class="num fr">'
+
num
+
'</span>'
+
'<h3 class="boxsiz ellipsis">'
+
obj
.
name
+
'</h3>'
+
'<h3 class="boxsiz ellipsis">'
+
user
+
'</h3>'
+
'</div>'
+
'</div>'
+
'<div class="message ellipsis">'
+
message
+
'</div>'
+
'<div class="message ellipsis">'
+
message
+
'</div>'
+
'</div>'
'</div>'
}
}
},
},
messageHtml
:
function
(
leftOrRight
,
html
,
isTemplate
,
isHistory
,
time
)
{
messageHtml
:
function
(
leftOrRight
,
html
,
isTemplate
)
{
//右边消息的dom拼接 isTemplate 是否是模板
//右边消息的dom拼接 isTemplate 是否是模板
var
htmlp
=
'<p>'
+
html
.
message
+
'</p>'
;
var
htmlp
=
'<p>'
+
html
+
'</p>'
;
var
img
=
html
.
img
||
(
dist
+
'/images/default.jpg'
)
if
(
isTemplate
)
{
if
(
isTemplate
)
{
var
htmlp
=
'<div class="template lineBlock boxsiz">'
+
var
htmlp
=
'<div class="template lineBlock boxsiz">'
+
'<img src="
'
+
(
html
.
goodImage
||
dist
+
"/images/defaultgood.png"
)
+
'
" alt="">'
+
'<img src="
http://resic.liexin.com/images/test.jpg
" alt="">'
+
'<div class="template_right">'
+
'<div class="template_right">'
+
'<div class="template_right_top clr">'
+
'<div class="template_right_top clr">'
+
'<h3 class="bold fl">'
+
html
.
type
+
'</h3>'
+
'<h3 class="bold fl">'
+
html
.
type
+
'</h3>'
+
'<div class="price bold fr">'
+
html
.
price
+
'</div>'
+
'<div class="price bold fr">'
+
html
.
price
+
'</div>'
+
'</div>'
+
'</div>'
+
'<div class="template_right_bottom">'
+
'<div class="template_right_bottom">'
+
'<div class="desc1 clr">'
+
'<div class="desc1 clr">'
+
'<div class="brand fl">品牌:<i>'
+
html
.
brand
+
'</i></div>'
+
'<div class="brand fl">品牌:<i>'
+
html
.
brand
+
'</i></div>'
+
'<div class="hq fl">货期:<i>'
+
html
.
hq
+
'</i></div>'
+
'<div class="hq fl">货期:<i>'
+
html
.
hq
+
'</i></div>'
+
'</div>'
+
'</div>'
+
'<div class="desc2 clr">'
+
'<div class="desc2 clr">'
+
'<div class="num fl">数量:<i class="bold">'
+
html
.
num
+
'
</i></div>'
+
'<div class="num fl">数量:<i class="bold">'
+
html
.
num
+
'PCS
</i></div>'
+
'<div class="time fl">时间:<i>
'
+
html
.
time
+
'
</i></div>'
+
'<div class="time fl">时间:<i>
2019-05-23 15:57
</i></div>'
+
'</div>'
+
'</div>'
+
'</div>'
+
'</div>'
+
'</div>'
+
'</div>'
+
...
@@ -293,23 +215,22 @@ $(function () {
...
@@ -293,23 +215,22 @@ $(function () {
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="'
+
img
+
'
" alt="" class="fr user_logo">'
+
'<img src="'
+
dist
+
'/images/test.jpg
" alt="" class="fr user_logo">'
+
'<div class="notice_content">'
+
'<div class="notice_content">'
+
htmlp
+
htmlp
+
'<div>'
+
(
isHistory
?
time
:
this
.
curentTime
())
+
'</div>'
+
'<div>'
+
this
.
curentTime
()
+
'</div>'
+
'</div>'
+
'</div>'
'</div>'
}
else
{
}
else
{
return
''
return
''
}
}
}
else
{
//左边
}
else
{
//左边
if
(
html
)
{
if
(
html
)
{
return
'<div class = "notice_item left clr" > '
+
return
'<div class = "notice_item left clr" > '
+
'<img src="'
+
img
+
'
" alt="" class="fl user_logo">'
+
'<img src="'
+
dist
+
'/images/test.jpg
" alt="" class="fl user_logo">'
+
'<div class="notice_content">'
+
'<div class="notice_content">'
+
htmlp
+
htmlp
+
'<div>'
+
(
isHistory
?
time
:
this
.
curentTime
())
+
'</div>'
+
'<div>'
+
this
.
curentTime
()
+
'</div>'
+
'</div>'
+
'</div>'
'</div>'
}
else
{
}
else
{
return
''
return
''
...
@@ -322,126 +243,87 @@ $(function () {
...
@@ -322,126 +243,87 @@ $(function () {
var
regContent
=
""
;
var
regContent
=
""
;
var
htmlStr
=
""
;
var
htmlStr
=
""
;
var
self
=
this
;
var
self
=
this
;
var
emojiTxt
=
""
if
(
type
==
1
)
{
if
(
type
==
1
)
{
if
(
isTemplate
)
{
if
(
isTemplate
)
{
regContent
=
message
.
type
+
' '
+
message
.
price
;
regContent
=
message
.
ext
.
type
+
' '
+
message
.
ext
.
price
;
htmlStr
=
message
;
htmlStr
=
message
.
ext
;
}
else
{
}
else
{
regContent
=
message
.
message
;
regContent
=
message
.
data
;
htmlStr
=
message
;
htmlStr
=
message
.
data
;
}
}
}
else
if
(
type
==
2
)
{
}
else
if
(
type
==
2
)
{
regContent
=
'[图片]'
;
regContent
=
'[图片]'
;
htmlStr
=
{
htmlStr
=
'<img src ="'
+
message
.
url
+
'" class="edit_img"/>'
;
message
:
'<img src ="'
+
message
.
url
+
'" class="edit_img"/>'
,
name
:
message
.
name
,
img
:
message
.
img
,
id
:
message
.
id
}
}
else
{
}
else
{
var
data
=
message
.
message
;
var
data
=
message
.
data
;
for
(
var
i
=
0
,
l
=
data
.
length
;
i
<
l
;
i
++
)
{
for
(
var
i
=
0
,
l
=
data
.
length
;
i
<
l
;
i
++
)
{
if
(
data
[
i
].
type
==
'emoji'
)
{
if
(
data
[
i
].
type
==
'emoji'
)
{
regContent
+=
'[表情]'
;
regContent
+=
'[表情]'
;
emojiTxt
+=
'<img src ="'
+
data
[
i
].
data
+
'" width=25 height=25/>'
;
htmlStr
+=
'<img src ="'
+
data
[
i
].
data
+
'" width=25 height=25/>'
;
}
else
{
}
else
{
regContent
+=
data
[
i
].
data
;
regContent
+=
data
[
i
].
data
;
emojiTxt
+=
data
[
i
].
data
;
htmlStr
+=
data
[
i
].
data
;
}
}
};
};
htmlStr
=
{
message
:
emojiTxt
,
name
:
message
.
name
,
img
:
message
.
img
,
id
:
message
.
id
}
}
}
var
len
=
$
(
'.notice_classify'
).
length
;
var
len
=
$
(
'.notice_classify'
).
length
;
var
messageSigleStr
=
var
messageSigleStr
=
'<div class="title clr">'
+
'<div class="title clr">'
+
//
'<div class="fr btn btn_border">' +
'<div class="fr btn btn_border">'
+
//
'<span class="icon iconfont iconjuxing23"></span>' +
'<span class="icon iconfont iconjuxing23"></span>'
+
// '<i>' + message.to
+ '</i>' +
'<i>'
+
message
.
from
+
'</i>'
+
//
'</div>' +
'</div>'
+
'<h3 class="bold boxsiz">'
+
message
.
name
+
'</h3>'
+
'<h3 class="bold boxsiz">'
+
message
.
from
+
'</h3>'
+
'</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
,
message
,
isTemplate
)
+
self
.
messageHtml
(
2
,
htmlStr
,
isTemplate
)
+
'</div>'
+
'</div>'
+
'</div>'
+
'</div>'
+
'</div>'
;
'</div>'
;
if
(
!
len
)
{
if
(
!
len
)
{
//新用户
//新用户
Util
.
delCookie
(
'templateBoolean'
,
cookieHostname
);
var
userStr
=
'<div class="notice_classify active" userid="'
+
message
.
from
+
'">'
+
var
userStr
=
'<div class="notice_classify active" userid="'
+
message
.
from
+
'" firstClick="true" newMember="true" touserid='
+
message
.
touserid
+
'>'
+
self
.
userHtml
(
0
,
message
.
from
,
regContent
)
+
'</div>'
;
self
.
userHtml
(
0
,
message
,
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_classify[userid="
+
self
.
defaultName
+
"]"
).
after
(
userStr
);
$
(
'.notice_left_content'
).
append
(
userStr
);
// $('.notice_left_content').append(userStr);
$
(
'.chat_item_content'
).
append
(
messageStr
)
$
(
'.chat_item_content'
).
append
(
messageStr
)
}
else
{
}
else
{
$
(
'.notice_classify'
).
each
(
function
(
index
)
{
$
(
'.notice_classify'
).
each
(
function
(
index
)
{
var
userId
=
$
(
this
).
attr
(
'userid'
);
var
userId
=
$
(
this
).
attr
(
'userid'
);
var
isNowChat
=
$
(
'.notice_classify'
).
eq
(
index
).
hasClass
(
'active'
);
var
isNowChat
=
$
(
'.notice_classify'
).
eq
(
index
).
hasClass
(
'active'
);
var
firstClick
=
$
(
this
).
attr
(
'firstClick'
);
if
(
userId
==
message
.
from
)
{
if
(
userId
==
message
.
from
)
{
//已有用户
//已有用户
if
(
isNowChat
)
{
if
(
isNowChat
)
{
//当前用户
//当前用户
$
(
this
).
html
(
self
.
userHtml
(
0
,
message
,
regContent
));
$
(
this
).
html
(
self
.
userHtml
(
0
,
message
.
from
,
regContent
));
if
(
Util
.
getCookie
(
'templateBoolean'
))
{
Util
.
delCookie
(
'templateBoolean'
,
cookieHostname
);
}
else
{
$
(
'#'
+
userId
).
find
(
'.notice_item_content'
).
append
(
self
.
messageHtml
(
2
,
$
(
'#'
+
userId
).
find
(
'.notice_item_content'
).
append
(
self
.
messageHtml
(
2
,
htmlStr
,
isTemplate
));
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'
)
var
contentHeight
=
$
(
'#'
+
userId
).
find
(
'.notice_item_content'
)
.
height
();
.
height
();
$
(
'#'
+
userId
).
find
(
'.notice_list'
).
scrollTop
(
contentHeight
);
$
(
'#'
+
userId
).
find
(
'.notice_list'
).
scrollTop
(
contentHeight
);
},
200
)
})
}
}
else
{
}
else
{
//非当前用户
//非当前用户
Util
.
delCookie
(
'templateBoolean'
,
cookieHostname
);
var
num
=
Number
(
$
(
this
).
find
(
'.num'
).
text
());
var
num
=
Number
(
$
(
this
).
find
(
'.num'
).
text
());
$
(
this
).
html
(
self
.
userHtml
(
num
+
1
,
message
,
regContent
));
$
(
this
).
html
(
self
.
userHtml
(
num
+
1
,
message
.
from
,
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
,
$
(
'#'
+
userId
).
find
(
'.notice_item_content'
).
append
(
self
.
messageHtml
(
2
,
htmlStr
,
isTemplate
));
htmlStr
,
isTemplate
));
}
}
}
return
false
;
return
false
;
}
else
{
}
else
{
if
(
index
==
len
-
1
)
{
if
(
index
==
len
-
1
)
{
//新用户
//新用户
Util
.
delCookie
(
'templateBoolean'
,
cookieHostname
);
var
userStr
=
'<div class="notice_classify" userid="'
+
var
userStr
=
'<div class="notice_classify" userid="'
+
message
.
from
+
'"
newMember="true" touserid='
+
message
.
touserid
+
'
>'
+
message
.
from
+
'">'
+
self
.
userHtml
(
1
,
message
,
regContent
)
+
'</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>'
$
(
".notice_classify[userid="
+
self
.
defaultName
+
"]"
).
after
(
userStr
);
$
(
'.notice_left_content'
).
append
(
userStr
);
$
(
'.chat_item_content'
).
append
(
messageStr
)
$
(
'.chat_item_content'
).
append
(
messageStr
)
}
}
}
}
...
@@ -453,50 +335,19 @@ $(function () {
...
@@ -453,50 +335,19 @@ $(function () {
// listern,添加回调函数;
// listern,添加回调函数;
self
.
conn
.
listen
({
self
.
conn
.
listen
({
onOpened
:
function
(
message
)
{
onOpened
:
function
(
message
)
{
console
.
log
(
'登入成功'
)
self
.
defaultUser
();
self
.
isLoginSuccess
=
true
;
self
.
customerChat
();
self
.
singleChat
();
self
.
singleChat
();
},
},
onTextMessage
:
function
(
message
)
{
onTextMessage
:
function
(
message
)
{
self
.
receiveData
(
1
,
{
self
.
receiveData
(
1
,
message
,
false
)
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
)
{
onEmojiMessage
:
function
(
message
)
{
self
.
receiveData
(
3
,
{
self
.
receiveData
(
3
,
message
,
false
)
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
)
{
onCmdMessage
:
function
(
message
)
{
console
.
log
(
message
)
// console.log('CMD');
self
.
receiveData
(
1
,
{
self
.
receiveData
(
1
,
message
,
true
)
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
)
{
onPictureMessage
:
function
(
message
)
{
var
options
=
{
var
options
=
{
...
@@ -504,14 +355,7 @@ $(function () {
...
@@ -504,14 +355,7 @@ $(function () {
};
};
options
.
onFileDownloadComplete
=
function
()
{
options
.
onFileDownloadComplete
=
function
()
{
// 图片下载成功;
// 图片下载成功;
self
.
receiveData
(
2
,
{
self
.
receiveData
(
2
,
message
,
false
)
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
)
};
};
...
@@ -519,7 +363,7 @@ $(function () {
...
@@ -519,7 +363,7 @@ $(function () {
// 图片下载失败
// 图片下载失败
// console.log('Image download failed!');
// console.log('Image download failed!');
};
};
WebIM
.
default
.
utils
.
download
.
call
(
self
.
conn
,
options
);
// 意义待查;
WebIM
.
utils
.
download
.
call
(
self
.
conn
,
options
);
// 意义待查;
},
//收到图片消息;
},
//收到图片消息;
...
@@ -531,26 +375,24 @@ $(function () {
...
@@ -531,26 +375,24 @@ $(function () {
},
//本机网络掉线;
},
//本机网络掉线;
onError
:
function
(
message
)
{
onError
:
function
(
message
)
{
// console.log('Error', WebIM.utils.stringify(message));
// console.log('Error', WebIM.utils.stringify(message));
console
.
log
(
'onError: '
,
message
);
console
.
log
(
"Error: "
+
WebIM
.
utils
.
stringify
(
message
));
// layer.msg('聊天系统出错');
},
//失败回调;
},
//失败回调;
});
});
},
},
login
:
function
(
user
,
password
)
{
login
:
function
()
{
// open,登录;
// open,登录;
var
options
=
{
var
options
=
{
apiUrl
:
WebIM
.
config
.
apiURL
,
apiUrl
:
WebIM
.
config
.
apiURL
,
user
:
user
,
user
:
"18589050841"
,
pwd
:
password
,
pwd
:
"123456"
,
appKey
:
WebIM
.
config
.
appkey
appKey
:
WebIM
.
config
.
appkey
};
};
try
{
try
{
this
.
conn
.
open
(
options
);
this
.
conn
.
open
(
options
);
}
catch
(
e
)
{
}
catch
(
e
)
{
console
.
log
(
e
);
console
.
log
(
WebIM
.
config
.
apiURL
)
layer
.
msg
(
'登入失败'
);
// alert('open fail' + e.message)
this
.
deleteCookie
();
}
}
},
},
...
@@ -558,165 +400,84 @@ $(function () {
...
@@ -558,165 +400,84 @@ $(function () {
var
self
=
this
;
var
self
=
this
;
// 私聊发送文本消息,发送表情同发送文本消息,只是会在对方客户端将表情文本进行解析成图片;
// 私聊发送文本消息,发送表情同发送文本消息,只是会在对方客户端将表情文本进行解析成图片;
var
userId
=
$
(
'.notice_left '
).
find
(
'.active'
).
attr
(
'userid'
);
var
userId
=
$
(
'.notice_left '
).
find
(
'.active'
).
attr
(
'userid'
);
var
touserid
=
$
(
'.notice_left '
).
find
(
'.active'
).
attr
(
'touserid'
);
var
id
=
this
.
conn
.
getUniqueId
();
var
id
=
this
.
conn
.
getUniqueId
();
var
msg
=
new
WebIM
.
default
.
message
(
'txt'
,
id
);
var
msg
=
new
WebIM
.
message
(
'txt'
,
id
);
var
emojiMessage
=
WebIM
.
default
.
utils
.
parseEmoji
(
content
);
//表情解析工具
var
emojiMessage
=
WebIM
.
utils
.
parseEmoji
(
content
);
//表情解析工具
var
ext
=
{
timer
:
self
.
curentTime
(),
id
:
self
.
id
,
name
:
self
.
name
,
img
:
self
.
img
,
touserid
:
touserid
};
msg
.
set
({
msg
.
set
({
msg
:
content
,
// 消息内容;
msg
:
content
,
// 消息内容;
to
:
userId
,
// 接收消息对象;
to
:
userId
,
// 接收消息对象;
ext
:
ext
,
roomType
:
false
,
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
,
message
:
emojiMessage
,
emojiMessage
,
false
));
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'
)
var
contentHeight
=
$
(
'#'
+
userId
).
find
(
'.notice_item_content'
)
.
height
();
.
height
();
$
(
'#'
+
userId
).
find
(
'.notice_list'
).
scrollTop
(
contentHeight
);
$
(
'#'
+
userId
).
find
(
'.notice_list'
).
scrollTop
(
contentHeight
);
},
200
)
})
}
$
(
'#chat_textarea'
).
val
(
''
);
$
(
'#chat_textarea'
).
val
(
''
);
},
},
fail
:
function
(
e
)
{
fail
:
function
()
{
console
.
log
(
"Send private text failed"
,
e
);
console
.
log
(
"Send private text failed"
);
layer
.
msg
(
'消息发送失败'
);
}
}
});
});
// console.log(msg.body)
this
.
conn
.
send
(
msg
.
body
);
this
.
conn
.
send
(
msg
.
body
);
},
},
sendCmd
:
function
(
templateObj
)
{
sendCmd
:
function
(
templateObj
)
{
var
self
=
this
;
var
self
=
this
;
var
userId
=
$
(
'.notice_left '
).
find
(
'.active'
).
attr
(
'userid'
);
var
userId
=
$
(
'.notice_left '
).
find
(
'.active'
).
attr
(
'userid'
);
var
touserid
=
$
(
'.notice_left '
).
find
(
'.active'
).
attr
(
'touserid'
);
var
id
=
this
.
conn
.
getUniqueId
();
var
id
=
this
.
conn
.
getUniqueId
();
var
msg
=
new
WebIM
.
default
.
message
(
'cmd'
,
id
);
var
msg
=
new
WebIM
.
message
(
'cmd'
,
id
);
var
params
=
$
.
extend
({},
templateObj
,
{
timer
:
self
.
curentTime
(),
name
:
self
.
name
,
id
:
self
.
id
,
img
:
self
.
img
,
touserid
:
touserid
});
msg
.
set
({
msg
.
set
({
msg
:
'template'
,
msg
:
'template'
,
to
:
userId
,
to
:
userId
,
roomType
:
false
,
action
:
"template"
,
action
:
"template"
,
ext
:
params
,
ext
:
templateObj
,
success
:
function
()
{
success
:
function
(
id
,
serverMsgId
)
{
self
.
addChatMember
(
templateObj
.
targetId
);
$
(
'#'
+
userId
).
find
(
'.notice_item_content'
).
append
(
self
.
messageHtml
(
1
,
$
(
'#'
+
userId
).
find
(
'.notice_item_content'
).
append
(
self
.
messageHtml
(
1
,
params
,
true
));
templateObj
,
true
));
var
imgLen
=
$
(
'#'
+
userId
).
find
(
'img'
).
length
;
if
(
!
imgLen
)
{
setTimeout
(
function
()
{
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
);
},
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
()
{
fail
:
function
()
{
console
.
log
(
"Send Cmd failed"
);
console
.
log
(
"Send Cmd failed"
);
layer
.
msg
(
'消息发送失败'
);
}
}
});
});
this
.
conn
.
send
(
msg
.
body
);
this
.
conn
.
send
(
msg
.
body
);
Util
.
delCookie
(
'templateBoolean'
,
cookieHostname
);
},
},
sendPrivateImg
:
function
()
{
sendPrivateImg
:
function
()
{
// 私聊发送图片消息;
// 私聊发送图片消息;
var
self
=
this
;
var
self
=
this
;
var
id
=
this
.
conn
.
getUniqueId
();
var
id
=
this
.
conn
.
getUniqueId
();
var
msg
=
new
WebIM
.
default
.
message
(
'img'
,
id
);
var
msg
=
new
WebIM
.
message
(
'img'
,
id
);
var
input
=
$
(
'#img_upload'
)[
0
];
// 选择图片的input;
var
input
=
$
(
'#img_upload'
)[
0
];
// 选择图片的input;
var
file
=
WebIM
.
default
.
utils
.
getFileUrl
(
input
);
// 将图片转化为二进制文件;
var
file
=
WebIM
.
utils
.
getFileUrl
(
input
);
// 将图片转化为二进制文件;
var
userId
=
$
(
'.notice_left'
).
find
(
'.active'
).
attr
(
'userid'
);
var
userId
=
$
(
'.notice_left'
).
find
(
'.active'
).
attr
(
'userid'
);
var
touserid
=
$
(
'.notice_left '
).
find
(
'.active'
).
attr
(
'touserid'
);
var
option
=
{
var
option
=
{
apiUrl
:
WebIM
.
config
.
apiURL
,
apiUrl
:
WebIM
.
config
.
apiURL
,
file
:
file
,
file
:
file
,
to
:
userId
,
to
:
'18664936975'
,
ext
:
{
roomType
:
false
,
timer
:
self
.
curentTime
(),
// chatType: 'singleChat',
id
:
self
.
id
,
name
:
self
.
name
,
img
:
self
.
img
,
touserid
:
touserid
},
flashUpload
:
WebIM
.
flashUpload
,
flashUpload
:
WebIM
.
flashUpload
,
onFileUploadError
:
function
()
{
onFileUploadError
:
function
()
{
console
.
log
(
file
);
console
.
log
(
'失败'
)
console
.
log
(
'失败'
)
},
},
onFileUploadComplete
:
function
()
{
onFileUploadComplete
:
function
()
{},
console
.
log
(
'消息上传成功'
)
},
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
,
message
:
htmlStr
,
htmlStr
,
false
));
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'
)
var
contentHeight
=
$
(
'#'
+
userId
).
find
(
'.notice_item_content'
)
.
height
();
.
height
();
$
(
'#'
+
userId
).
find
(
'.notice_list'
).
scrollTop
(
contentHeight
);
$
(
'#'
+
userId
).
find
(
'.notice_list'
).
scrollTop
(
contentHeight
);
},
200
)
})
}
$
(
'#img_upload'
).
val
(
''
);
$
(
'#img_upload'
).
val
(
''
);
},
},
fail
:
function
()
{
console
.
log
(
"Send Image failed"
);
layer
.
msg
(
'消息发送失败'
);
}
};
};
msg
.
set
(
option
);
msg
.
set
(
option
);
console
.
log
(
msg
.
body
)
this
.
conn
.
send
(
msg
.
body
);
this
.
conn
.
send
(
msg
.
body
);
},
},
...
@@ -762,166 +523,18 @@ $(function () {
...
@@ -762,166 +523,18 @@ $(function () {
})
})
$
(
'.notice_left'
).
on
(
'click'
,
'.notice_classify'
,
function
()
{
$
(
'.notice_left'
).
on
(
'click'
,
'.notice_classify'
,
function
()
{
var
id
=
$
(
this
).
attr
(
'userid'
);
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'
);
$
(
'#'
+
id
).
addClass
(
'active'
).
siblings
(
'.chat_item'
).
removeClass
(
'active'
);
$
(
this
).
find
(
'.num'
).
remove
();
$
(
this
).
find
(
'.num'
).
remove
();
$
(
this
).
addClass
(
'active'
).
siblings
(
'.notice_classify'
).
removeClass
(
'active'
);
$
(
this
).
addClass
(
'active'
).
siblings
(
'.notice_classify'
).
removeClass
(
'active'
);
if
(
isCustomer
)
{
var
contentHeight
=
$
(
'#'
+
id
).
find
(
'.notice_item_content'
).
height
();
$
(
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
);
$
(
'#'
+
id
).
find
(
'.notice_list'
).
scrollTop
(
contentHeight
);
},
200
)
}
}
});
});
$
(
'.notice_right '
).
on
(
'click'
,
'.edit_img'
,
function
()
{
$
(
'.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
();
chatObj
.
init
();
})
})
\ No newline at end of file
dist/js/person/login.js
View file @
abb452f9
...
@@ -108,6 +108,8 @@
...
@@ -108,6 +108,8 @@
$mobile
.
parent
(
'.input-wrap'
).
addClass
(
'error'
);
$mobile
.
parent
(
'.input-wrap'
).
addClass
(
'error'
);
$
(
".error-text"
).
show
().
find
(
"span"
).
text
(
'请填写手机号'
);
return
false
;
return
false
;
}
}
...
@@ -116,6 +118,8 @@
...
@@ -116,6 +118,8 @@
$password
.
parent
().
parent
(
'.input-wrap'
).
addClass
(
'error'
);
$password
.
parent
().
parent
(
'.input-wrap'
).
addClass
(
'error'
);
$
(
".error-text"
).
show
().
find
(
"span"
).
text
(
'请填写密码'
);
return
false
;
return
false
;
}
}
...
...
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