Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
施宇
/
icsalesProgram
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
84f8399a
authored
Aug 26, 2019
by
施宇
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
1111
parent
55cddca5
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
87 additions
and
39 deletions
app.js
pages/tab/message/message.js
utils/api.js
utils/chat.js
app.js
View file @
84f8399a
...
...
@@ -15,7 +15,8 @@ App({
token
:
wx
.
getStorageSync
(
'access_token'
),
isIPX
:
false
,
//是否为iphone X
customerNum
:
"001"
,
customerName
:
"IC助手客服"
customerName
:
"IC助手客服"
,
isRelogin
:
true
,
//登入环信失败后是否重新登入,只允许重新登入一次
},
getImUser
:
chat
.
getImUser
,
addChatMember
:
function
(
id
,
userId
)
{
//id为环信id userId为账户id
...
...
pages/tab/message/message.js
View file @
84f8399a
...
...
@@ -30,12 +30,12 @@ Page({
/**
* 生命周期函数--监听页面加载
*/
onLoad
:
function
(
options
)
{
onLoad
:
function
(
options
)
{
if
(
judgeToken
(
true
))
{
let
me
=
this
;
let
my
=
wx
.
getStorageSync
(
"myUsername"
);
//监听未读消息数
disp
.
on
(
"em.xmpp.unreadspot"
,
function
(
message
)
{
disp
.
on
(
"em.xmpp.unreadspot"
,
function
(
message
)
{
if
(
getApp
().
globalData
.
customerNum
!=
my
)
{
me
.
getCustom
();
}
...
...
@@ -47,7 +47,7 @@ Page({
}
},
getCustom
:
function
()
{
getCustom
:
function
()
{
let
my
=
wx
.
getStorageSync
(
"myUsername"
);
let
companyName
=
wx
.
getStorageSync
(
"company_name"
)
||
''
;
let
userId
=
wx
.
getStorageSync
(
"user_id"
)
||
''
;
...
...
@@ -120,7 +120,7 @@ Page({
return
array
;
},
into_singleChatRoom
:
function
(
detail
)
{
into_singleChatRoom
:
function
(
detail
)
{
let
my
=
wx
.
getStorageSync
(
"myUsername"
);
let
nameList
=
{
myName
:
my
,
...
...
@@ -137,14 +137,14 @@ Page({
url
:
"/pages/detail/chat/index?username="
+
JSON
.
stringify
(
nameList
)
});
},
into_chatRoom
:
function
(
event
)
{
into_chatRoom
:
function
(
event
)
{
let
detail
=
event
.
currentTarget
.
dataset
.
item
;
this
.
into_singleChatRoom
(
detail
)
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady
:
function
()
{
onReady
:
function
()
{
},
...
...
@@ -152,7 +152,7 @@ Page({
* 生命周期函数--监听页面显示
*/
onShow
:
function
()
{
onShow
:
function
()
{
let
my
=
wx
.
getStorageSync
(
"myUsername"
);
let
token
=
wx
.
getStorageSync
(
'access_token'
)
||
''
;
let
im
=
wx
.
getStorageSync
(
'im'
)
||
''
;
...
...
@@ -180,36 +180,36 @@ Page({
/**
* 生命周期函数--监听页面隐藏
*/
onHide
:
function
()
{
onHide
:
function
()
{
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload
:
function
()
{
onUnload
:
function
()
{
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh
:
function
()
{
onPullDownRefresh
:
function
()
{
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom
:
function
()
{
onReachBottom
:
function
()
{
},
getSys
:
function
(
token
)
{
getSys
:
function
(
token
)
{
let
me
=
this
;
getData
(
apis
.
userSysmsg
,
'get'
,
{
token
:
token
,
"limit"
:
1
,
"page"
:
1
,
},
function
(
res
)
{
},
function
(
res
)
{
if
(
res
.
errcode
==
0
)
{
me
.
setData
({
count
:
res
.
data
.
act_unread_msg
+
res
.
data
.
sys_unread_msg
...
...
@@ -218,13 +218,13 @@ Page({
}
},
true
)
},
getAct
:
function
(
token
,
sysarr
)
{
getAct
:
function
(
token
,
sysarr
)
{
let
me
=
this
;
getData
(
apis
.
userActmsg
,
'get'
,
{
token
:
token
,
"limit"
:
1
,
"page"
:
1
,
},
function
(
res
)
{
},
function
(
res
)
{
if
(
res
.
errcode
==
0
)
{
let
actarr
=
res
.
data
[
'act_msg'
].
data
;
let
nowDate
=
Date
.
parse
(
new
Date
());
...
...
@@ -258,13 +258,13 @@ Page({
},
false
)
},
deleteChatItem
:
function
(
e
)
{
//拉黑
deleteChatItem
:
function
(
e
)
{
//拉黑
this
.
del_chat
(
e
,
2
)
},
deleteChat
:
function
(
e
)
{
//删除记录
deleteChat
:
function
(
e
)
{
//删除记录
this
.
del_chat
(
e
,
1
)
},
del_chat
:
function
(
event
,
type
)
{
del_chat
:
function
(
event
,
type
)
{
let
detail
=
event
.
currentTarget
.
dataset
.
item
;
let
your
=
detail
.
username
;
console
.
log
(
your
)
...
...
@@ -282,14 +282,14 @@ Page({
wx
.
showModal
({
title
:
title
,
confirmText
:
"确定"
,
success
:
function
(
res
)
{
success
:
function
(
res
)
{
if
(
res
.
confirm
)
{
if
(
type
==
1
)
{
getData
(
apis
.
addrecord
,
'GET'
,
{
"token"
:
token
,
"user_id"
:
id
,
status
:
3
},
function
(
res
)
{
},
function
(
res
)
{
if
(
res
.
errcode
===
0
)
{
let
member
=
wx
.
getStorageSync
(
'member'
);
let
index
=
member
.
indexOf
(
your
);
...
...
@@ -309,22 +309,31 @@ Page({
}
},
false
);
}
else
{
list
let
list
=
{
your
:
{
jid
:
WebIM
.
config
.
appkey
+
'_'
+
your
+
'@easemob.com'
,
name
:
your
,
order
:
1
,
},
//
your: {
//
jid: WebIM.config.appkey + '_' + your + '@easemob.com',
//
name: your,
// order: 5
,
//
},
};
list
[
your
]
=
{
jid
:
WebIM
.
config
.
appkey
+
'_'
+
your
+
'@easemob.com'
,
name
:
your
,
order
:
1
,
subscription
:
'both'
,
type
:
"jid"
}
WebIM
.
conn
.
addToBlackList
({
list
:
list
,
type
:
'jid'
,
success
:
function
()
{
success
:
function
()
{
console
.
log
(
'拉黑成功'
)
getData
(
apis
.
addrecord
,
'GET'
,
{
"token"
:
token
,
"user_id"
:
id
,
status
:
2
},
function
(
res
)
{
},
function
(
res
)
{
if
(
res
.
errcode
===
0
)
{
let
member
=
wx
.
getStorageSync
(
'member'
);
let
index
=
member
.
indexOf
(
your
);
...
...
@@ -344,7 +353,7 @@ Page({
}
},
false
);
},
error
:
function
()
{
error
:
function
()
{
wx
.
showToast
({
title
:
'加入黑名单失败'
,
icon
:
'none'
,
...
...
@@ -357,15 +366,15 @@ Page({
}
},
fail
:
function
(
err
)
{
}
fail
:
function
(
err
)
{
}
});
},
closeTip
:
function
()
{
closeTip
:
function
()
{
this
.
setData
({
isShowTip
:
false
})
},
toSys
:
function
()
{
toSys
:
function
()
{
wx
.
navigateTo
({
url
:
"/pages/list/notice/index"
});
...
...
utils/api.js
View file @
84f8399a
...
...
@@ -65,6 +65,10 @@ const apis = {
*/
authme
:
auth_url
+
'/auth/me'
,
/***
* 手动注册im账号
*/
authregistim
:
auth_url
+
'/auth/registIMUser'
,
/***
* 新增会员认证信息
*/
addAuth
:
user_url
+
'/user/addauth'
,
...
...
utils/chat.js
View file @
84f8399a
...
...
@@ -37,7 +37,18 @@ const onMessageError = (err) => {
return
true
;
}
const
getImUser
=
()
=>
{
let
token
=
wx
.
getStorageSync
(
'access_token'
)
||
''
let
token
=
wx
.
getStorageSync
(
'access_token'
)
||
''
;
let
imName
=
wx
.
getStorageSync
(
'myUsername'
)
||
''
;
let
imPassword
=
wx
.
getStorageSync
(
'myPassword'
)
||
''
;
if
(
imName
&&
imPassword
)
{
conn
.
open
({
apiUrl
:
WebIM
.
config
.
apiURL
,
user
:
imName
,
pwd
:
imPassword
,
appKey
:
WebIM
.
config
.
appkey
});
return
;
}
getData
(
apis
.
authme
,
'get'
,
{
"token"
:
token
,
},
function
(
res
)
{
...
...
@@ -46,7 +57,7 @@ const getImUser = () => {
wx
.
setStorageSync
(
'avatar'
,
res
.
data
.
avatar
);
wx
.
setStorageSync
(
'company_name'
,
res
.
data
.
company_name
);
wx
.
setStorageSync
(
"myUsername"
,
res
.
data
.
im_username
);
console
.
log
(
res
)
wx
.
setStorageSync
(
"myPassword"
,
res
.
data
.
im_password
);
conn
.
open
({
apiUrl
:
WebIM
.
config
.
apiURL
,
user
:
res
.
data
.
im_username
,
...
...
@@ -73,6 +84,20 @@ const addImUser = (message) => { //接收消息后进行用户的处理,以便
}
};
const
registerIm
=
()
=>
{
let
token
=
wx
.
getStorageSync
(
'access_token'
)
||
''
;
getData
(
apis
.
authregistim
+
'?source=1'
,
'post'
,
{},
function
(
res
)
{
if
(
res
.
errcode
==
0
)
{
getImUser
();
}
else
{
wx
.
showModal
({
title
:
'提示'
,
content
:
'聊天系统出现异常!'
,
showCancel
:
false
})
}
},
false
,
true
)
};
const
webimListen
=
()
=>
{
let
my
=
wx
.
getStorageSync
(
'myUsername'
)
||
''
;
WebIM
.
conn
.
listen
({
...
...
@@ -146,7 +171,7 @@ const webimListen = () => {
calcUnReadSpot
(
message
);
}
},
onBlacklistUpdate
:
function
(
list
)
{
//黑名单变动
onBlacklistUpdate
:
function
(
list
)
{
//黑名单变动
// 查询黑名单,将好友拉黑,将好友从黑名单移除都会回调这个函数,list则是黑名单现有的所有好友信息
console
.
log
(
list
);
},
...
...
@@ -160,10 +185,19 @@ const webimListen = () => {
if
(
curPage
.
route
==
"pages/detail/chat/index"
||
curPage
.
route
==
'pages/tab/message/message'
)
{
reloginIm
()
}
}
else
if
(
error
.
type
==
1
){
getImUser
()
}
else
{
}
else
if
(
error
.
type
==
1
)
{
if
(
getApp
().
globalData
.
isRelogin
)
{
getApp
().
globalData
.
isRelogin
=
false
;
console
.
log
(
'重新登录'
)
registerIm
()
}
else
{
wx
.
showModal
({
title
:
'提示'
,
content
:
'聊天系统登录失败!'
,
showCancel
:
false
})
}
}
else
{
wx
.
showModal
({
title
:
'提示'
,
content
:
'聊天系统出现异常!'
,
...
...
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