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 87360c67
authored
Jan 17, 2021
by
xinlaa
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
移动侧边栏
1 parent
4f7ce453
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
166 additions
and
69 deletions
linkwe-mobile/public/index.html
linkwe-mobile/src/App.vue
linkwe-mobile/src/api/chat.js
linkwe-mobile/src/api/common.js
linkwe-mobile/src/utils/request.js
linkwe-mobile/src/views/chat/List.vue
linkwe-mobile/src/views/chat/index.vue
linkwe-mobile/public/index.html
View file @
87360c6
...
@@ -8,6 +8,7 @@
...
@@ -8,6 +8,7 @@
<link
rel=
"icon"
href=
"<%= BASE_URL %>favicon.ico"
>
<link
rel=
"icon"
href=
"<%= BASE_URL %>favicon.ico"
>
<title>
<
%= htmlWebpackPlugin.options.title %>
</title>
<title>
<
%= htmlWebpackPlugin.options.title %>
</title>
<script
src=
"./jweixin-1.2.0.js"
></script>
<script
src=
"./jweixin-1.2.0.js"
></script>
<script
src=
"https://open.work.weixin.qq.com/wwopen/js/jwxwork-1.0.0.js"
></script>
</head>
</head>
<body>
<body>
...
...
linkwe-mobile/src/App.vue
View file @
87360c6
...
@@ -4,26 +4,82 @@ export default {
...
@@ -4,26 +4,82 @@ export default {
name
:
'App'
,
name
:
'App'
,
data
()
{
data
()
{
return
{
return
{
timestamp
:
''
,
appId
:
'ww38152475d1bca752'
,
nonceStr
:
''
,
agentId
:
'1000003'
,
signature
:
''
,
}
}
},
},
created
()
{
created
()
{
//
调取服务端signature
//
this.wxConfig()
},
},
watch
:
{
watch
:
{
// 通过config接口注入权限验证配置
// 通过config接口注入权限验证配置
// 所有需要使用JS-SDK的页面必须先注入配置信息,否则将无法调用(同一个url仅需调用一次,对于变化url的SPA(single-page application)的web app可在每次url变化时进行调用)
// 所有需要使用JS-SDK的页面必须先注入配置信息,否则将无法调用(同一个url仅需调用一次,对于变化url的SPA(single-page application)的web app可在每次url变化时进行调用)
$router
()
{
$route
()
{
wx
.
config
({
this
.
wxConfig
()
beta
:
true
,
// 必须这么写,否则wx.invoke调用形式的jsapi会有问题
},
debug
:
true
,
// 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
},
appId
:
'123456'
,
// 必填,企业微信的corpID
methods
:
{
timestamp
:
this
.
timestamp
,
// 必填,生成签名的时间戳
wxConfig
()
{
nonceStr
:
this
.
nonceStr
,
// 必填,生成签名的随机串
getAgentTicket
(
window
.
location
.
href
.
split
(
'#'
)[
0
]).
then
(({
data
})
=>
{
signature
:
this
.
signature
,
// 必填,签名,见 附录-JS-SDK使用权限签名算法
let
{
timestamp
,
nonceStr
,
signature
}
=
data
jsApiList
:
[],
// 必填,需要使用的JS接口列表,凡是要调用的接口都需要传进来
wx
.
agentConfig
({
corpid
:
this
.
appId
,
// 必填,企业微信的corpid,必须与当前登录的企业一致
agentid
:
this
.
agentId
,
// 必填,企业微信的应用id (e.g. 1000247)
timestamp
,
// 必填,生成签名的时间戳
nonceStr
,
// 必填,生成签名的随机串
signature
,
// 必填,签名,见附录-JS-SDK使用权限签名算法
jsApiList
:
[
'sendChatMessage'
],
//必填
success
:
(
res
)
=>
{
// 回调
},
fail
:
(
res
)
=>
{
if
(
res
.
errMsg
.
indexOf
(
'function not exist'
)
>
-
1
)
{
alert
(
'版本过低请升级'
)
}
},
})
})
},
_wxConfig
()
{
// 获取企业的jsapi_ticket
getAppTicket
(
window
.
location
.
href
).
then
(({
data
})
=>
{
let
{
timestamp
,
nonceStr
,
signature
}
=
data
wx
.
config
({
beta
:
true
,
// 必须这么写,否则wx.invoke调用形式的jsapi会有问题
debug
:
true
,
// 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
appId
:
this
.
appId
,
// 必填,企业微信的corpID
timestamp
,
// 必填,生成签名的时间戳
nonceStr
,
// 必填,生成签名的随机串
signature
,
// 必填,签名,见 附录-JS-SDK使用权限签名算法
jsApiList
:
[
'getContext'
,
'sendChatMessage'
],
// 必填,需要使用的JS接口列表,凡是要调用的接口都需要传进来
})
wx
.
ready
(()
=>
{
// config信息验证后会执行ready方法,所有接口调用都必须在config接口获得结果之后,config是一个客户端的异步操作,所以如果需要在页面加载时就调用相关接口,则须把相关接口放在ready函数中调用来确保正确执行。对于用户触发时才调用的接口,则可以直接调用,不需要放在ready函数中。
getAgentTicket
(
window
.
location
.
href
).
then
(({
data
})
=>
{
let
{
timestamp
,
nonceStr
,
signature
}
=
data
wx
.
agentConfig
({
corpid
:
this
.
appId
,
// 必填,企业微信的corpid,必须与当前登录的企业一致
agentid
:
this
.
agentId
,
// 必填,企业微信的应用id (e.g. 1000247)
timestamp
,
// 必填,生成签名的时间戳
nonceStr
,
// 必填,生成签名的随机串
signature
,
// 必填,签名,见附录-JS-SDK使用权限签名算法
jsApiList
:
[
'sendChatMessage'
],
//必填
success
:
(
res
)
=>
{
// 回调
},
fail
:
(
res
)
=>
{
if
(
res
.
errMsg
.
indexOf
(
'function not exist'
)
>
-
1
)
{
alert
(
'版本过低请升级'
)
}
},
})
})
})
wx
.
error
(
function
(
res
)
{
console
.
error
(
res
)
// config信息验证失败会执行error函数,如签名过期导致验证失败,具体错误信息可以打开config的debug模式查看,也可以在返回的res参数中查看,对于SPA可以在这里更新签名。
})
})
})
},
},
},
},
...
...
linkwe-mobile/src/api/chat.js
View file @
87360c6
...
@@ -5,12 +5,9 @@ const service = window.CONFIG.services.wecom + '/chat'
...
@@ -5,12 +5,9 @@ const service = window.CONFIG.services.wecom + '/chat'
* 侧边栏列表
* 侧边栏列表
* @param {*} params
* @param {*} params
*/
*/
export
function
getTypeList
(
params
)
{
export
function
getTypeList
()
{
return
request
({
return
request
({
url
:
service
+
'/side/list'
,
url
:
service
+
'/side/h5List'
,
params
:
{
h5
:
1
,
},
})
})
}
}
...
...
linkwe-mobile/src/api/common.js
View file @
87360c6
import
request
from
'@/utils/request'
import
request
from
'@/utils/request'
const
service
=
window
.
CONFIG
.
services
.
wecom
+
'/ticket'
import
config
from
'@/config'
const
service
=
config
.
services
.
wecom
+
'/ticket'
/**
/**
* 获取应用的jsapi_ticket
* 获取应用的jsapi_ticket
...
@@ -28,46 +29,11 @@ export function getAppTicket(url) {
...
@@ -28,46 +29,11 @@ export function getAppTicket(url) {
}
}
/**
/**
* 收藏列表(h5我的)
* 获取企业的jsapi_ticket
* @param {*} userId
* @param {*} url 页面url
*/
export
function
getCollectionList
(
userId
)
{
return
request
({
url
:
service
+
'/collection/list'
,
params
:
{
userId
,
},
})
}
/**
* 添加收藏
* @param {*} data
* {
materialId:素材id
userId:用户id
}
*/
export
function
addCollection
(
data
)
{
return
request
({
url
:
service
+
'/collection/addCollection'
,
method
:
'post'
,
data
,
})
}
/**
* 侧边栏抓取素材
* @param {*} data
* {
materialId:素材id
userId:用户id
}
*/
*/
export
function
cancleCollection
(
data
)
{
export
function
getLoginUserId
(
)
{
return
request
({
return
request
({
url
:
service
+
'/collection/cancleCollection'
,
url
:
'/system/user/findCurrentLoginUser'
,
method
:
'put'
,
data
,
})
})
}
}
linkwe-mobile/src/utils/request.js
View file @
87360c6
...
@@ -24,8 +24,8 @@ function createAxios(baseURL) {
...
@@ -24,8 +24,8 @@ function createAxios(baseURL) {
// console.log('res: ' + res)
// console.log('res: ' + res)
const
{
data
,
status
}
=
res
const
{
data
,
status
}
=
res
// code 0:成功,-1/其它:错误
// code 0:成功,-1/其它:错误
if
(
status
===
200
&&
data
.
code
===
0
)
{
if
(
status
===
200
&&
data
.
code
===
20
0
)
{
return
JSON
.
stringify
(
data
.
result
)
?
data
.
result
:
data
.
data
return
data
}
else
if
(
data
.
code
===
201
)
{
}
else
if
(
data
.
code
===
201
)
{
// Message.error({
// Message.error({
// content: `产品已存在`,
// content: `产品已存在`,
...
...
linkwe-mobile/src/views/chat/List.vue
View file @
87360c6
...
@@ -32,7 +32,10 @@ export default {
...
@@ -32,7 +32,10 @@ export default {
methods
:
{
methods
:
{
getList
()
{
getList
()
{
this
.
loading
=
true
this
.
loading
=
true
;(
this
.
userId
?
getCollectionList
:
getMaterialList
)()
;(
this
.
sideId
?
getMaterialList
(
this
.
sideId
)
:
getCollectionList
(
this
.
userId
)
)
.
then
(({
rows
,
total
})
=>
{
.
then
(({
rows
,
total
})
=>
{
this
.
list
=
rows
this
.
list
=
rows
this
.
loading
=
false
this
.
loading
=
false
...
@@ -51,7 +54,67 @@ export default {
...
@@ -51,7 +54,67 @@ export default {
isCollected
(
id
)
{
isCollected
(
id
)
{
return
this
.
collectList
.
includes
(
id
)
return
this
.
collectList
.
includes
(
id
)
},
},
send
()
{},
send
(
data
)
{
let
entry
=
undefined
wx
.
invoke
(
'getContext'
,
{},
function
(
res
)
{
if
(
res
.
err_msg
==
'getContext:ok'
)
{
entry
=
res
.
entry
//返回进入H5页面的入口类型,目前有normal、contact_profile、single_chat_tools、group_chat_tools
if
(
!
[
'single_chat_tools'
,
'group_chat_tools'
].
includes
(
entry
))
{
return
}
// mediaType 0 图片(image)、1 语音(voice)、2 视频(video),3 普通文件(file) 4 文本 5 海报
// msgtype 文本(“text”),图片(“image”),视频(“video”),文件(“file”),H5(“news”)和小程序(“miniprogram”)
let
mes
=
{}
let
msgtype
=
{
0
:
'image'
,
2
:
'video'
,
3
:
'file'
,
4
:
'text'
,
5
:
'news'
,
}
switch
(
data
.
mediaType
)
{
case
'4'
:
default
:
mes
.
text
=
{
content
:
data
.
content
,
//文本内容
}
break
case
'0'
:
case
'2'
:
case
'3'
:
mes
[
msgtype
[
data
.
mediaType
]]
=
{
mediaid
:
data
.
materialId
,
//
}
break
case
'5'
:
mes
.
news
=
{
link
:
''
,
//H5消息页面url 必填
title
:
''
,
//H5消息标题
desc
:
''
,
//H5消息摘要
imgUrl
:
''
,
//H5消息封面图片URL
}
break
// case '6':
// mes.miniprogram = {
// appid: 'wx8bd80126147df384', //小程序的appid
// title: 'this is title', //小程序消息的title
// imgUrl:
// 'https://search-operate.cdn.bcebos.com/d054b8892a7ab572cb296d62ec7f97b6.png', //小程序消息的封面图。必须带http或者https协议头,否则报错 $apiName$:fail invalid imgUrl
// page: '/index/page.html', //小程序消息打开后的路径,注意要以.html作为后缀,否则在微信端打开会提示找不到页面
// }
// break
}
mes
.
msgtype
=
msgtype
[
data
.
mediaType
]
wx
.
invoke
(
'sendChatMessage'
,
mes
,
function
(
res
)
{
if
(
res
.
err_msg
==
'sendChatMessage:ok'
)
{
//发送成功
}
})
}
else
{
//错误处理
}
})
},
collect
(
materialId
)
{
collect
(
materialId
)
{
;(
this
.
isCollected
(
materialId
)
?
cancleCollection
:
addCollection
)({
;(
this
.
isCollected
(
materialId
)
?
cancleCollection
:
addCollection
)({
userId
,
userId
,
...
@@ -73,13 +136,13 @@ export default {
...
@@ -73,13 +136,13 @@ 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"
>
dsdsds
</div>
<div
class=
"title"
>
{{
item
.
content
}}
</div>
<div
class=
"info"
>
<div
class=
"info"
>
素材库
{{
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"
>
发送
</div>
<div
class=
"action"
@
click=
"send
(item)
"
>
发送
</div>
<div
class=
"action"
@
click=
"collect(item.id)"
>
<div
class=
"action"
@
click=
"collect(item.id)"
>
{{
isCollected
(
item
.
id
)
?
'已'
:
''
}}
收藏
{{
isCollected
(
item
.
id
)
?
'已'
:
''
}}
收藏
</div>
</div>
...
...
linkwe-mobile/src/views/chat/index.vue
View file @
87360c6
<
script
>
<
script
>
import
{
getLoginUserId
}
from
'@/api/common'
import
{
getTypeList
}
from
'@/api/chat'
import
{
getTypeList
}
from
'@/api/chat'
import
List
from
'./List'
import
List
from
'./List'
export
default
{
export
default
{
...
@@ -7,17 +8,19 @@ export default {
...
@@ -7,17 +8,19 @@ export default {
data
()
{
data
()
{
return
{
return
{
keywords
:
''
,
keywords
:
''
,
active
:
2
,
active
:
0
,
list
:
[],
list
:
[],
loading
:
false
,
loading
:
false
,
finished
:
false
,
finished
:
false
,
show
:
false
,
show
:
false
,
userId
:
''
,
}
}
},
},
watch
:
{},
watch
:
{},
computed
:
{},
computed
:
{},
created
()
{
created
()
{
this
.
getList
()
this
.
getList
()
this
.
getUserId
()
},
},
mounted
()
{},
mounted
()
{},
methods
:
{
methods
:
{
...
@@ -26,6 +29,11 @@ export default {
...
@@ -26,6 +29,11 @@ export default {
this
.
list
=
rows
this
.
list
=
rows
})
})
},
},
getUserId
()
{
getLoginUserId
().
then
(({
data
})
=>
{
this
.
userId
=
data
})
},
search
()
{},
search
()
{},
add
()
{},
add
()
{},
},
},
...
@@ -45,10 +53,16 @@ export default {
...
@@ -45,10 +53,16 @@ export default {
</
template
>
-->
</
template
>
-->
</van-search>
</van-search>
<van-tabs
v-model=
"active"
>
<van-tabs
v-model=
"active"
>
<van-tab
title=
"标签 1"
>
<van-tab
title=
"我的"
>
<List></List>
<List
:userId=
"userId"
></List>
</van-tab>
<van-tab
:title=
"item.sideName"
v-for=
"(item, index) in list"
:key=
"index"
>
<List
:sideId=
"item.sideId"
:userId=
"userId"
></List>
</van-tab>
</van-tab>
<van-tab
title=
"标签 2"
><List></List></van-tab>
</van-tabs>
</van-tabs>
<!-- <van-dialog
<!-- <van-dialog
...
...
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