Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
江名洋
/
linkwe-scrm
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit f7e8951e
authored
Feb 03, 2021
by
xinla
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
移动聊天侧边栏调试
1 parent
8cb1bc92
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
49 additions
and
15 deletions
linkwe-mobile/src/App.vue
linkwe-mobile/src/api/chat.js
linkwe-mobile/src/api/common.js
linkwe-mobile/src/views/chat/List.vue
linkwe-mobile/src/views/chat/index.vue
linkwe-mobile/src/App.vue
View file @
f7e8951
...
@@ -4,7 +4,7 @@ export default {
...
@@ -4,7 +4,7 @@ export default {
name
:
'App'
,
name
:
'App'
,
data
()
{
data
()
{
return
{
return
{
appId
:
'
appId
'
,
appId
:
'
ww24262ce93851488f
'
,
agentId
:
'1000005'
,
agentId
:
'1000005'
,
}
}
},
},
...
@@ -23,16 +23,19 @@ export default {
...
@@ -23,16 +23,19 @@ export default {
getAgentTicket
(
window
.
location
.
href
.
split
(
'#'
)[
0
]).
then
(({
data
})
=>
{
getAgentTicket
(
window
.
location
.
href
.
split
(
'#'
)[
0
]).
then
(({
data
})
=>
{
let
{
timestamp
,
nonceStr
,
signature
}
=
data
let
{
timestamp
,
nonceStr
,
signature
}
=
data
wx
.
agentConfig
({
wx
.
agentConfig
({
debug
:
true
,
corpid
:
this
.
appId
,
// 必填,企业微信的corpid,必须与当前登录的企业一致
corpid
:
this
.
appId
,
// 必填,企业微信的corpid,必须与当前登录的企业一致
agentid
:
this
.
agentId
,
// 必填,企业微信的应用id (e.g. 1000247)
agentid
:
this
.
agentId
,
// 必填,企业微信的应用id (e.g. 1000247)
timestamp
,
// 必填,生成签名的时间戳
timestamp
,
// 必填,生成签名的时间戳
nonceStr
,
// 必填,生成签名的随机串
nonceStr
,
// 必填,生成签名的随机串
signature
,
// 必填,签名,见附录-JS-SDK使用权限签名算法
signature
,
// 必填,签名,见附录-JS-SDK使用权限签名算法
jsApiList
:
[
'sendChatMessage'
],
//必填
jsApiList
:
[
'sendChatMessage'
,
'getContext'
],
//必填
success
:
(
res
)
=>
{
success
:
(
res
)
=>
{
// 回调
// 回调
this
.
$toast
(
'agentId成功:'
)
},
},
fail
:
(
res
)
=>
{
fail
:
(
res
)
=>
{
this
.
$toast
(
'agentId失败:'
+
JSON
.
stringify
(
res
))
if
(
res
.
errMsg
.
indexOf
(
'function not exist'
)
>
-
1
)
{
if
(
res
.
errMsg
.
indexOf
(
'function not exist'
)
>
-
1
)
{
alert
(
'版本过低请升级'
)
alert
(
'版本过低请升级'
)
}
}
...
...
linkwe-mobile/src/api/chat.js
View file @
f7e8951
...
@@ -45,6 +45,9 @@ export function addCollection(data) {
...
@@ -45,6 +45,9 @@ export function addCollection(data) {
return
request
({
return
request
({
url
:
service
+
'/collection/addCollection'
,
url
:
service
+
'/collection/addCollection'
,
method
:
'post'
,
method
:
'post'
,
// headers: {
// 'Content-Type': 'application/x-www-form-urlencoded',
// },
data
,
data
,
})
})
}
}
...
...
linkwe-mobile/src/api/common.js
View file @
f7e8951
...
@@ -11,6 +11,7 @@ export function getAgentTicket(url) {
...
@@ -11,6 +11,7 @@ export function getAgentTicket(url) {
url
:
service
+
'/ticket/getAgentTicket'
,
url
:
service
+
'/ticket/getAgentTicket'
,
params
:
{
params
:
{
url
,
url
,
agentId
:
'1000005'
,
},
},
})
})
}
}
...
...
linkwe-mobile/src/views/chat/List.vue
View file @
f7e8951
...
@@ -12,6 +12,10 @@ export default {
...
@@ -12,6 +12,10 @@ export default {
type
:
String
,
type
:
String
,
default
:
'0'
,
default
:
'0'
,
},
},
mediaType
:
{
type
:
String
,
default
:
'0'
,
},
userId
:
{
userId
:
{
type
:
String
,
type
:
String
,
default
:
''
,
default
:
''
,
...
@@ -26,8 +30,8 @@ export default {
...
@@ -26,8 +30,8 @@ export default {
loading
:
false
,
loading
:
false
,
finished
:
false
,
finished
:
false
,
error
:
false
,
error
:
false
,
page
Size
:
1
,
page
Num
:
1
,
page
Num
:
10
,
page
Size
:
10
,
list
:
[],
list
:
[],
collectList
:
[],
collectList
:
[],
}
}
...
@@ -47,14 +51,20 @@ export default {
...
@@ -47,14 +51,20 @@ export default {
page
==
1
&&
(
this
.
list
=
[])
page
==
1
&&
(
this
.
list
=
[])
this
.
loading
=
true
this
.
loading
=
true
;(
this
.
sideId
;(
this
.
sideId
?
getMaterialList
({
sideId
:
this
.
sideId
,
pageSize
,
pageNum
,
keyword
})
?
getMaterialList
({
sideId
:
this
.
sideId
,
mediaType
:
this
.
mediaType
,
pageSize
,
pageNum
,
keyword
,
})
:
getCollectionList
({
userId
:
this
.
userId
,
pageSize
,
pageNum
,
keyword
})
:
getCollectionList
({
userId
:
this
.
userId
,
pageSize
,
pageNum
,
keyword
})
)
)
.
then
(({
rows
,
total
})
=>
{
.
then
(({
rows
,
total
})
=>
{
this
.
list
.
push
(...
rows
)
this
.
list
.
push
(...
rows
)
this
.
loading
=
false
this
.
loading
=
false
// 数据全部加载完成
// 数据全部加载完成
if
(
this
.
list
.
length
>=
total
)
{
if
(
this
.
list
.
length
>=
+
total
)
{
this
.
finished
=
true
this
.
finished
=
true
}
}
})
})
...
@@ -73,10 +83,14 @@ export default {
...
@@ -73,10 +83,14 @@ export default {
},
},
send
(
data
)
{
send
(
data
)
{
let
entry
=
undefined
let
entry
=
undefined
let
_this
=
this
wx
.
invoke
(
'getContext'
,
{},
function
(
res
)
{
wx
.
invoke
(
'getContext'
,
{},
function
(
res
)
{
if
(
res
.
err_msg
==
'getContext:ok'
)
{
if
(
res
.
err_msg
==
'getContext:ok'
)
{
entry
=
res
.
entry
//返回进入H5页面的入口类型,目前有normal、contact_profile、single_chat_tools、group_chat_tools
entry
=
res
.
entry
//返回进入H5页面的入口类型,目前有normal、contact_profile、single_chat_tools、group_chat_tools
if
(
!
[
'single_chat_tools'
,
'group_chat_tools'
].
includes
(
entry
))
{
if
(
!
[
'single_chat_tools'
,
'group_chat_tools'
,
'normal'
].
includes
(
entry
)
)
{
_this
.
$toast
(
'入口错误:'
+
entry
)
return
return
}
}
// mediaType 0 图片(image)、1 语音(voice)、2 视频(video),3 普通文件(file) 4 文本 5 海报
// mediaType 0 图片(image)、1 语音(voice)、2 视频(video),3 普通文件(file) 4 文本 5 海报
...
@@ -114,7 +128,7 @@ export default {
...
@@ -114,7 +128,7 @@ export default {
// case '6':
// case '6':
// mes.miniprogram = {
// mes.miniprogram = {
// appid: 'wx8bd80126147df384', //小程序的appid
// appid: 'wx8bd80126147df384', //小程序的appid
// title: 'this is title', //小程序消息的title
// title: '
_
this is title', //小程序消息的title
// imgUrl:
// imgUrl:
// 'https://search-operate.cdn.bcebos.com/d054b8892a7ab572cb296d62ec7f97b6.png', //小程序消息的封面图。必须带http或者https协议头,否则报错 $apiName$:fail invalid imgUrl
// 'https://search-operate.cdn.bcebos.com/d054b8892a7ab572cb296d62ec7f97b6.png', //小程序消息的封面图。必须带http或者https协议头,否则报错 $apiName$:fail invalid imgUrl
// page: '/index/page.html', //小程序消息打开后的路径,注意要以.html作为后缀,否则在微信端打开会提示找不到页面
// page: '/index/page.html', //小程序消息打开后的路径,注意要以.html作为后缀,否则在微信端打开会提示找不到页面
...
@@ -122,13 +136,19 @@ export default {
...
@@ -122,13 +136,19 @@ export default {
// break
// break
}
}
mes
.
msgtype
=
msgtype
[
data
.
mediaType
]
mes
.
msgtype
=
msgtype
[
data
.
mediaType
]
wx
.
invoke
(
'sendChatMessage'
,
mes
,
function
(
res
)
{
_this
.
$dialog
({
message
:
'mes:'
+
JSON
.
stringify
(
mes
)
})
if
(
res
.
err_msg
==
'sendChatMessage:ok'
)
{
wx
.
invoke
(
'sendChatMessage'
,
mes
,
function
(
resSend
)
{
if
(
resSend
.
err_msg
==
'sendChatMessage:ok'
)
{
//发送成功
//发送成功
_this
.
$toast
(
'发送成功'
)
}
else
{
//错误处理
_this
.
$dialog
({
message
:
'发送失败:'
+
JSON
.
stringify
(
resSend
)
})
}
}
})
})
}
else
{
}
else
{
//错误处理
//错误处理
_this
.
$dialog
({
message
:
'进入失败:'
+
JSON
.
stringify
(
res
)
})
}
}
})
})
},
},
...
@@ -140,6 +160,7 @@ export default {
...
@@ -140,6 +160,7 @@ export default {
this
.
isCollected
(
materialId
)
this
.
isCollected
(
materialId
)
?
this
.
isCollected
.
splice
(
this
.
isCollected
.
indexOf
(
materialId
),
1
)
?
this
.
isCollected
.
splice
(
this
.
isCollected
.
indexOf
(
materialId
),
1
)
:
this
.
isCollected
.
push
(
materialId
)
:
this
.
isCollected
.
push
(
materialId
)
this
.
$toast
(
'操作成功'
)
})
})
},
},
},
},
...
@@ -157,15 +178,21 @@ export default {
...
@@ -157,15 +178,21 @@ export default {
@
load=
"getList()"
@
load=
"getList()"
>
>
<div
v-for=
"(item, index) in list"
class=
"list"
:key=
"index"
>
<div
v-for=
"(item, index) in list"
class=
"list"
:key=
"index"
>
<div
class=
"title"
>
{{
item
.
content
}}
</div>
<div
class=
"title"
>
{{
item
.
mediaType
==
4
?
item
.
content
:
item
.
materialName
}}
</div>
<div
class=
"info"
>
<div
class=
"info"
>
{{
item
.
content
}}
{{
item
.
content
}}
<span>
2020/2/4
</span>
<span>
2020/2/4
</span>
<div
class=
"fr flex"
>
<div
class=
"fr flex"
>
<div
class=
"action"
@
click=
"send(item)"
>
发送
</div>
<div
class=
"action"
@
click=
"send(item)"
>
发送
</div>
<div
v-if=
"!!userId"
class=
"action"
@
click=
"collect(item.id)"
>
<div
{{
isCollected
(
item
.
id
)
?
'已'
:
''
}}
收藏
v-if=
"!!userId"
class=
"action"
@
click=
"collect(item.materialId)"
>
{{
isCollected
(
item
.
materialId
)
?
'已'
:
''
}}
收藏
</div>
</div>
</div>
</div>
</div>
</div>
...
...
linkwe-mobile/src/views/chat/index.vue
View file @
f7e8951
2
<
script
>
<
script
>
import
{
getUserInfo
}
from
'@/api/common'
import
{
getUserInfo
}
from
'@/api/common'
import
{
getTypeList
}
from
'@/api/chat'
import
{
getTypeList
}
from
'@/api/chat'
...
@@ -51,7 +50,7 @@ export default {
...
@@ -51,7 +50,7 @@ export default {
getUserInfo
(
auth_code
)
getUserInfo
(
auth_code
)
.
then
(({
data
})
=>
{
.
then
(({
data
})
=>
{
this
.
userId
=
data
.
userId
this
.
userId
=
data
.
userId
this
.
$toast
(
'userId:'
+
this
.
userId
)
//
this.$toast('userId:' + this.userId)
})
})
.
catch
((
err
)
=>
{
.
catch
((
err
)
=>
{
Dialog
.
confirm
({
Dialog
.
confirm
({
...
@@ -100,6 +99,7 @@ export default {
...
@@ -100,6 +99,7 @@ export default {
<List
<List
:ref=
"'list' + (index + 1)"
:ref=
"'list' + (index + 1)"
:sideId=
"item.sideId"
:sideId=
"item.sideId"
:mediaType=
"item.mediaType"
:userId=
"userId"
:userId=
"userId"
:keyword=
"keyword"
:keyword=
"keyword"
></List>
></List>
...
...
Write
Preview
Markdown
is supported
Attach a file
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 post a comment