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
95b474ec
authored
Oct 18, 2019
by
施宇
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
小程序bug修复
parent
1288ffab
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
45 additions
and
27 deletions
app.js
components/chat/inputbar/suit/image/image.js
components/chat/inputbar/suit/main/main.js
pages/form/bj/index.js
pages/form/good/index.js
pages/form/xj/index.js
pages/tab/message/message.js
utils/chat.js
app.js
View file @
95b474ec
...
...
@@ -10,10 +10,12 @@ import {
}
from
'./utils/api.js'
;
App
({
globalData
:
{
isAddCustomer
:
false
,
//是否添加了客服
auth
:
wx
.
getStorageSync
(
'auth'
),
//是否授权
token
:
wx
.
getStorageSync
(
'access_token'
),
isIPX
:
false
,
//是否为iphone X
customerNum
:
"001"
,
//客服
customerNum
:
"001"
,
//客服的im账号
customerUserId
:
'36'
,
//客服的userId
customerName
:
"芯掌柜客服"
,
//客服名称
isRelogin
:
true
,
//登入环信失败后是否重新登入,只允许重新登入一次
bus
:
bus
,
//页面之间的监听
...
...
@@ -21,17 +23,20 @@ App({
},
getImUser
:
chat
.
getImUser
,
conn
:
chat
.
conn
,
addChatMember
:
function
(
id
,
userId
)
{
//id为环信id userId为账户id
addChatMember
:
function
(
id
,
userId
,
isCustomer
)
{
//id为环信id userId为账户id
let
token
=
wx
.
getStorageSync
(
'access_token'
)
||
''
;
this
.
addChatMemberStorage
(
id
);
let
me
=
this
;
if
(
!
isCustomer
){
this
.
addChatMemberStorage
(
id
);
}
getData
(
apis
.
addrecord
,
'GET'
,
{
"token"
:
token
,
"user_id"
:
userId
},
function
(
res
)
{
if
(
res
.
errcode
===
0
)
{
if
(
isCustomer
){
me
.
globalData
.
isAddCustomer
=
true
}
}
else
{
console
.
log
(
'添加聊天成员失败'
)
}
...
...
components/chat/inputbar/suit/image/image.js
View file @
95b474ec
...
...
@@ -81,6 +81,7 @@ Component({
let
userId
=
wx
.
getStorageSync
(
'user_id'
);
let
companyName
=
wx
.
getStorageSync
(
'company_name'
);
let
avatar
=
wx
.
getStorageSync
(
'avatar'
);
let
touserid
=
me
.
data
.
username
.
id
==
userId
?
me
.
data
.
username
.
touserid
:
me
.
data
.
username
.
id
;
msg
.
set
({
apiUrl
:
WebIM
.
config
.
apiURL
,
body
:
file
,
...
...
@@ -90,7 +91,7 @@ Component({
id
:
userId
,
name
:
companyName
,
img
:
avatar
,
touserid
:
me
.
data
.
username
.
id
==
userId
?
me
.
data
.
username
.
touserid
:
me
.
data
.
username
.
id
,
touserid
:
touser
id
,
name1
:
me
.
data
.
username
.
name
==
companyName
?
me
.
data
.
username
.
name1
:
me
.
data
.
username
.
name
,
img1
:
me
.
data
.
username
.
name
==
companyName
?
me
.
data
.
username
.
img1
:
me
.
data
.
username
.
img
,
timer
:
WebIM
.
time
()
...
...
@@ -99,6 +100,13 @@ Component({
chatType
:
me
.
data
.
chatType
,
success
:
function
(
argument
)
{
console
.
log
(
'发送图片成功'
)
if
(
me
.
data
.
username
.
your
==
getApp
().
globalData
.
customerNum
)
{
//是客服就将客服加到接口的聊天列表里面
if
(
getApp
().
globalData
.
isAddCustomer
)
{
return
}
else
{
getApp
().
addChatMember
(
me
.
data
.
username
.
your
,
touserid
,
true
);
}
}
// disp.fire('em.chat.sendSuccess', id);
},
fail
:
function
(){
...
...
components/chat/inputbar/suit/main/main.js
View file @
95b474ec
...
...
@@ -70,7 +70,6 @@ Component({
});
return
};
let
me
=
this
;
let
customer
=
wx
.
getStorageSync
(
'customer'
)
||
''
;
if
(
customer
)
{
wx
.
removeStorageSync
(
'customer'
);
...
...
@@ -81,9 +80,11 @@ Component({
if
(
!
this
.
data
.
userMessage
.
trim
())
{
return
;
}
let
me
=
this
;
let
id
=
WebIM
.
conn
.
getUniqueId
();
let
msg
=
new
WebIM
.
message
(
msgType
.
TEXT
,
id
);
let
userId
=
wx
.
getStorageSync
(
'user_id'
);
let
touserid
=
this
.
data
.
username
.
id
==
userId
?
this
.
data
.
username
.
touserid
:
this
.
data
.
username
.
id
;
//前者是拿接收的数据,后者是拿发送的数据
let
companyName
=
wx
.
getStorageSync
(
'company_name'
);
let
avatar
=
wx
.
getStorageSync
(
'avatar'
);
msg
.
set
({
...
...
@@ -94,7 +95,7 @@ Component({
id
:
userId
,
name
:
companyName
,
img
:
avatar
,
touserid
:
t
his
.
data
.
username
.
id
==
userId
?
this
.
data
.
username
.
touserid
:
this
.
data
.
username
.
id
,
//前者是拿接收的数据,后者是拿发送的数据
touserid
:
t
ouserid
,
name1
:
this
.
data
.
username
.
name
==
companyName
?
this
.
data
.
username
.
name1
:
this
.
data
.
username
.
name
,
img1
:
this
.
data
.
username
.
name
==
companyName
?
this
.
data
.
username
.
img1
:
this
.
data
.
username
.
img
,
timer
:
WebIM
.
time
()
...
...
@@ -103,6 +104,14 @@ Component({
chatType
:
this
.
data
.
chatType
,
success
(
id
,
serverMsgId
)
{
console
.
log
(
'发送消息成功'
)
if
(
me
.
data
.
username
.
your
==
getApp
().
globalData
.
customerNum
){
//是客服就将客服加到接口的聊天列表里面
if
(
getApp
().
globalData
.
isAddCustomer
){
return
}
else
{
getApp
().
addChatMember
(
me
.
data
.
username
.
your
,
touserid
,
true
);
}
}
// disp.fire('em.chat.sendSuccess', id, me.data.userMessage);
},
fail
(
id
,
serverMsgId
)
{
...
...
@@ -147,7 +156,6 @@ Component({
isTemplate
:
'1'
,
custom
:
"custom"
});
console
.
log
(
params
)
msg
.
set
({
msg
:
''
,
from
:
me
.
data
.
username
.
myName
,
...
...
@@ -156,16 +164,14 @@ Component({
ext
:
params
,
success
:
function
()
{
console
.
log
(
'发送模板成功'
)
// getApp().addChatMember(me.data.username.your)
// disp.fire('em.chat.sendSuccess', id);
if
(
index
==
-
1
)
{
//表示未缓存
getApp
().
addChatMember
(
me
.
data
.
username
.
your
,
touserid
);
}
},
fail
:
function
()
{
console
.
log
(
'发送模板失败'
);
}
});
if
(
index
==
-
1
)
{
//表示未缓存
getApp
().
addChatMember
(
me
.
data
.
username
.
your
,
touserid
);
}
WebIM
.
conn
.
send
(
msg
.
body
);
this
.
triggerEvent
(
"newTextMsg"
,
{
...
...
pages/form/bj/index.js
View file @
95b474ec
...
...
@@ -70,7 +70,7 @@ Page({
let
me
=
this
;
let
token
=
wx
.
getStorageSync
(
'access_token'
);
let
url
;
obj
.
hq
==
1
?
obj
.
delivery_time
=
'现货'
:
obj
.
delivery_time
=
obj
.
day
+
'天'
;
obj
.
hq
==
1
?
obj
.
delivery_time
=
'现货'
:
obj
.
delivery_time
=
obj
.
day
;
obj
.
currency
=
this
.
data
.
currency
==
0
?
1
:
2
;
obj
.
token
=
token
;
if
(
me
.
data
.
type
==
1
)
{
...
...
@@ -135,11 +135,10 @@ Page({
})
}
if
(
delivery_time
!=
'现货'
)
{
let
day
=
delivery_time
.
replace
(
'天'
,
''
);
this
.
setData
({
hq
:
"2"
,
isShowTime
:
true
,
day
:
d
ay
day
:
d
elivery_time
})
}
},
...
...
pages/form/good/index.js
View file @
95b474ec
...
...
@@ -84,11 +84,10 @@ Page({
imgUrl
:
infoObj
.
goods_images
});
if
(
infoObj
.
delivery_time
!==
'现货'
)
{
let
day
=
infoObj
.
delivery_time
.
replace
(
'天'
,
''
);
this
.
setData
({
isShowTime
:
2
,
hq
:
2
,
day
:
day
day
:
infoObj
.
delivery_time
});
}
...
...
@@ -134,7 +133,7 @@ Page({
let
me
=
this
;
let
token
=
wx
.
getStorageSync
(
'access_token'
);
let
url
=
""
;
obj
.
hq
==
1
?
obj
.
delivery_time
=
'现货'
:
obj
.
delivery_time
=
obj
.
day
+
'天'
;
obj
.
hq
==
1
?
obj
.
delivery_time
=
'现货'
:
obj
.
delivery_time
=
obj
.
day
;
obj
.
currency
=
this
.
data
.
currency
==
0
?
1
:
2
;
obj
.
goods_images
=
this
.
data
.
imgUrl
||
''
;
obj
.
token
=
token
;
...
...
pages/form/xj/index.js
View file @
95b474ec
...
...
@@ -66,7 +66,7 @@ Page({
postData
:
function
(
obj
)
{
let
me
=
this
;
let
token
=
wx
.
getStorageSync
(
'access_token'
);
obj
.
hq
==
1
?
obj
.
delivery_time
=
'现货'
:
obj
.
delivery_time
=
obj
.
day
+
'天'
;
obj
.
hq
==
1
?
obj
.
delivery_time
=
'现货'
:
obj
.
delivery_time
=
obj
.
day
;
obj
.
currency
=
this
.
data
.
currency
==
0
?
1
:
2
;
obj
.
goods_images
=
this
.
data
.
imgUrl
||
''
;
obj
.
token
=
token
;
...
...
pages/tab/message/message.js
View file @
95b474ec
...
...
@@ -76,7 +76,7 @@ Page({
name
:
getApp
().
globalData
.
customerName
,
name1
:
companyName
,
id
:
userId
,
touserid
:
''
,
touserid
:
getApp
().
globalData
.
customerUserId
,
img
:
''
,
img1
:
avatar
},
...
...
utils/chat.js
View file @
95b474ec
...
...
@@ -92,11 +92,11 @@ const addImUser = (message) => { //接收消息后进行用户的处理,以便
let
members
=
wx
.
getStorageSync
(
'member'
)
||
''
;
let
index
=
members
.
indexOf
(
fromImId
);
if
(
index
==
-
1
)
{
//表示未缓存
if
(
fromImId
==
getApp
().
globalData
.
customerNum
)
{
//如果是客服就不调用接口添加}
//
if (fromImId == getApp().globalData.customerNum) { //如果是客服就不调用接口添加}
getApp
().
addChatMemberStorage
(
fromImId
);
}
else
{
getApp
().
addChatMember
(
fromImId
,
fromUserId
);
}
//
} else {
//
getApp().addChatMember(fromImId, fromUserId);
//
}
}
};
...
...
@@ -160,6 +160,7 @@ const webimListen = () => {
WebIM
.
conn
.
close
();
},
onTextMessage
(
message
)
{
console
.
log
(
message
)
if
(
isBlack
(
message
.
from
)){
return
;
}
...
...
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