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 c3a2e015
authored
Oct 08, 2021
by
xinla
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
聊天工具栏搜索问题
1 parent
71c3163d
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
79 additions
and
95 deletions
linkwe-mobile/src/utils/request.js
linkwe-mobile/src/views/chat/List.vue
linkwe-mobile/src/views/chat/index.vue
linkwe-mobile/vue.config.js
linkwe-mobile/src/utils/request.js
View file @
c3a2e01
...
...
@@ -5,9 +5,9 @@ function createAxios(baseURL) {
const
instance
=
axios
.
create
({
baseURL
,
headers
:
{
Auth_token
:
''
,
Auth_token
:
''
},
timeout
:
10000
,
timeout
:
10000
})
// 请求拦截
instance
.
interceptors
.
request
.
use
(
...
...
@@ -57,7 +57,7 @@ function createAxios(baseURL) {
data
,
statusText
,
status
,
request
:
{
responseText
,
responseURL
}
,
request
:
{
responseText
,
responseURL
}
}
=
errorInfo
// let info = {
// type: 'ajax',
...
...
@@ -77,4 +77,4 @@ function createAxios(baseURL) {
// const httpRequest = createAxios()
export
default
createAxios
(
process
.
env
.
VUE_APP_BASE_API
)
export
default
createAxios
(
process
.
env
.
NODE_ENV
===
'development'
?
'/api'
:
process
.
env
.
VUE_APP_BASE_API
)
linkwe-mobile/src/views/chat/List.vue
View file @
c3a2e01
<
script
>
import
{
getMaterialList
,
getCollectionList
,
addCollection
,
cancleCollection
,
getMaterialMediaId
,
}
from
'@/api/chat'
import
{
getMaterialList
,
getCollectionList
,
addCollection
,
cancleCollection
,
getMaterialMediaId
}
from
'@/api/chat'
export
default
{
components
:
{},
props
:
{
sideId
:
{
type
:
String
,
default
:
''
,
default
:
''
},
// mediaType 0 图片(image)、1 语音(voice)、2 视频(video),3 普通文件(file) 4 文本 5 海报
mediaType
:
{
type
:
String
,
default
:
'0'
,
default
:
'0'
},
userId
:
{
type
:
String
,
default
:
''
,
default
:
''
},
keyword
:
{
type
:
String
,
default
:
''
,
}
,
default
:
''
}
},
data
()
{
return
{
...
...
@@ -43,14 +37,14 @@ export default {
'2'
:
'视频'
,
'3'
:
'普通文件'
,
'4'
:
'文本'
,
'5'
:
'海报'
,
}
,
'5'
:
'海报'
}
}
},
watch
:
{
userId
()
{
this
.
getList
(
1
)
}
,
}
},
computed
:
{},
created
()
{
...
...
@@ -60,10 +54,15 @@ export default {
mounted
()
{},
methods
:
{
getList
(
page
)
{
let
pageNum
=
page
||
this
.
pageNum
++
this
.
loading
=
true
this
.
finished
=
false
let
pageNum
=
page
||
this
.
pageNum
let
pageSize
=
this
.
pageSize
let
keyword
=
this
.
keyword
page
==
1
&&
(
this
.
list
=
[])
if
(
pageNum
==
1
)
{
this
.
list
=
[]
this
.
pageNum
=
1
}
;(
this
.
sideId
?
getMaterialList
({
userId
:
this
.
userId
,
...
...
@@ -71,7 +70,7 @@ export default {
mediaType
:
this
.
mediaType
,
pageSize
,
pageNum
,
keyword
,
keyword
})
:
getCollectionList
({
userId
:
this
.
userId
,
pageSize
,
pageNum
,
keyword
})
)
...
...
@@ -90,6 +89,11 @@ export default {
// 数据全部加载完成
if
(
this
.
list
.
length
>=
+
total
)
{
this
.
finished
=
true
}
else
{
this
.
pageNum
++
}
if
(
this
.
list
.
length
==
0
)
{
this
.
pageNum
=
1
}
})
.
catch
(()
=>
{
...
...
@@ -106,7 +110,7 @@ export default {
this
.
$toast
.
loading
({
message
:
'正在发送...'
,
duration
:
0
,
forbidClick
:
true
,
forbidClick
:
true
})
let
entry
=
undefined
let
_this
=
this
...
...
@@ -115,11 +119,7 @@ export default {
entry
=
res
.
entry
//返回进入H5页面的入口类型,目前 contact_profile、single_chat_tools、group_chat_tools
let
mes
=
{}
try
{
if
(
!
[
'single_chat_tools'
,
'group_chat_tools'
,
'normal'
].
includes
(
entry
)
)
{
if
(
!
[
'single_chat_tools'
,
'group_chat_tools'
,
'normal'
].
includes
(
entry
))
{
// _this.$toast.clear()
_this
.
$toast
(
'入口错误:'
+
entry
)
return
...
...
@@ -133,13 +133,13 @@ export default {
2
:
'video'
,
3
:
'file'
,
4
:
'text'
,
5
:
'news'
,
5
:
'news'
}
switch
(
data
.
mediaType
)
{
case
'4'
:
default
:
mes
.
text
=
{
content
:
data
.
content
,
//文本内容
content
:
data
.
content
//文本内容
}
break
case
'0'
:
...
...
@@ -148,7 +148,7 @@ export default {
let
dataMediaId
=
{
url
:
data
.
materialUrl
,
type
:
msgtype
[
data
.
mediaType
],
name
:
data
.
materialName
,
name
:
data
.
materialName
}
let
resMaterialId
=
await
getMaterialMediaId
(
dataMediaId
)
if
(
!
resMaterialId
.
data
)
{
...
...
@@ -156,7 +156,7 @@ export default {
return
}
mes
[
msgtype
[
data
.
mediaType
]]
=
{
mediaid
:
resMaterialId
.
data
.
media_id
,
//
mediaid
:
resMaterialId
.
data
.
media_id
//
}
break
case
'5'
:
...
...
@@ -164,7 +164,7 @@ export default {
link
:
''
,
//H5消息页面url 必填
title
:
''
,
//H5消息标题
desc
:
''
,
//H5消息摘要
imgUrl
:
''
,
//H5消息封面图片URL
imgUrl
:
''
//H5消息封面图片URL
}
break
// case '6':
...
...
@@ -203,23 +203,19 @@ export default {
// collection 是否收藏 0未收藏 1 已收藏
;(
data
.
collection
==
1
?
cancleCollection
:
addCollection
)({
userId
:
this
.
userId
,
materialId
:
data
.
materialId
,
materialId
:
data
.
materialId
}).
then
(()
=>
{
data
.
collection
=
[
1
,
0
][
data
.
collection
]
this
.
$toast
(
'操作成功'
)
})
}
,
}
,
}
}
}
</
script
>
<
template
>
<div>
<van-pull-refresh
v-model=
"refreshing"
success-text=
"刷新成功"
@
refresh=
"getList(1)"
>
<van-pull-refresh
v-model=
"refreshing"
success-text=
"刷新成功"
@
refresh=
"getList(1)"
>
<van-list
v-model=
"loading"
:finished=
"finished"
...
...
@@ -231,19 +227,9 @@ export default {
<div
v-for=
"(item, index) in list"
class=
"list"
:key=
"index"
>
<div
class=
"content bfc-o"
>
<!-- 图片 -->
<van-image
v-if=
"item.mediaType == 0"
width=
"80"
height=
"80"
:src=
"item.materialUrl"
/>
<van-image
v-if=
"item.mediaType == 0"
width=
"80"
height=
"80"
:src=
"item.materialUrl"
/>
<!-- 视频 -->
<van-image
v-if=
"item.mediaType == 2"
width=
"80"
height=
"80"
:src=
"item.coverUrl"
/>
<van-image
v-if=
"item.mediaType == 2"
width=
"80"
height=
"80"
:src=
"item.coverUrl"
/>
<span
class=
"title"
>
{{
item
.
mediaType
==
4
?
item
.
content
:
item
.
materialName
}}
</span>
...
...
linkwe-mobile/src/views/chat/index.vue
View file @
c3a2e01
...
...
@@ -11,7 +11,7 @@ export default {
list
:
[],
loading
:
false
,
finished
:
false
,
show
:
false
,
show
:
false
// userId: this.$store.state.userId,
}
},
...
...
@@ -19,7 +19,7 @@ export default {
computed
:
{
userId
()
{
return
this
.
$store
.
state
.
userId
}
,
}
},
beforeCreate
()
{},
created
()
{
...
...
@@ -30,40 +30,38 @@ export default {
methods
:
{
getList
()
{
getTypeList
().
then
(({
rows
,
total
})
=>
{
this
.
list
=
rows
this
.
userId
&&
this
.
list
.
push
({
sideName
:
'我的'
})
rows
&&
this
.
list
.
push
(...
rows
)
})
},
search
()
{
this
.
$refs
[
'list'
+
this
.
active
]
.
getList
(
1
)
search
(
pageNum
)
{
this
.
$refs
[
'list'
+
this
.
active
]
&&
this
.
$refs
[
'list'
+
this
.
active
][
0
].
getList
(
pageNum
)
},
add
()
{},
},
cancel
()
{
this
.
$nextTick
(()
=>
this
.
search
(
1
))
},
add
()
{}
}
}
</
script
>
<
template
>
<div>
<van-search
v-model=
"keyword"
show-action
placeholder=
"请输入搜索关键词"
@
search=
"search"
>
<van-search
v-model=
"keyword"
show-action
placeholder=
"请输入搜索关键词"
@
cancel=
"cancel"
@
search=
"search(1)"
>
<!--
<template
#
action
>
<van-icon
name=
"plus"
@
click=
"add"
/>
</
template
>
-->
</van-search>
<van-tabs
v-model=
"active"
>
<van-tab
v-if=
"!!userId"
title=
"我的"
>
<
!-- <
van-tab v-if="!!userId" title="我的">
<List ref="list0" :userId="userId" :keyword="keyword"></List>
</van-tab>
<van-tab
:title=
"item.sideName"
v-for=
"(item, index) in list"
:key=
"index"
>
</van-tab> -->
<van-tab
:title=
"item.sideName"
v-for=
"(item, index) in list"
:key=
"index"
>
<List
:ref=
"'list' +
(index + 1)
"
:ref=
"'list' +
index
"
:sideId=
"item.sideId"
:mediaType=
"item.mediaType"
:userId=
"userId"
...
...
linkwe-mobile/vue.config.js
View file @
c3a2e01
...
...
@@ -30,28 +30,28 @@ module.exports = {
open
:
true
,
proxy
:
{
// detail: https://cli.vuejs.org/config/#devserver-proxy
[
'
http
'
]:
{
[
'
/api
'
]:
{
target
:
process
.
env
.
VUE_APP_BASE_API
,
changeOrigin
:
true
,
//
pathRewrite: {
// ['^' + process.env.VUE_APP_BASE_API
]: ''
//
}
}
,
pathRewrite
:
{
[
'^/api'
]:
''
}
}
},
disableHostCheck
:
true
,
disableHostCheck
:
true
},
pluginOptions
:
{
'style-resources-loader'
:
{
preProcessor
:
'less'
,
patterns
:
[
path
.
resolve
(
__dirname
,
'./src/styles/varibles.less'
)]
,
}
,
patterns
:
[
path
.
resolve
(
__dirname
,
'./src/styles/varibles.less'
)]
}
},
configureWebpack
:
{
resolve
:
{
alias
:
{
'@'
:
resolve
(
'src'
)
,
}
,
}
,
'@'
:
resolve
(
'src'
)
}
}
},
chainWebpack
(
config
)
{
config
.
plugin
(
'preload'
).
tap
(()
=>
[
...
...
@@ -59,8 +59,8 @@ module.exports = {
rel
:
'preload'
,
// to ignore runtime.js
fileBlacklist
:
[
/
\.
map$/
,
/hot-update
\.
js$/
,
/runtime
\.
.*
\.
js$/
],
include
:
'initial'
,
}
,
include
:
'initial'
}
])
config
.
when
(
process
.
env
.
NODE_ENV
!==
'development'
,
(
config
)
=>
{
...
...
@@ -70,8 +70,8 @@ module.exports = {
.
use
(
'script-ext-html-webpack-plugin'
,
[
{
// `runtime` must same as runtimeChunk name. default is `runtime`
inline
:
/runtime
\.
.*
\.
js$/
,
}
,
inline
:
/runtime
\.
.*
\.
js$/
}
])
.
end
()
...
...
@@ -88,24 +88,24 @@ module.exports = {
name
:
'chunk-libs'
,
test
:
/
[\\/]
node_modules
[\\/]
/
,
priority
:
10
,
chunks
:
'initial'
,
// only package third parties that are initially dependent
chunks
:
'initial'
// only package third parties that are initially dependent
},
elementUI
:
{
name
:
'chunk-vant'
,
// split vant into a single package
priority
:
20
,
// the weight needs to be larger than libs and app or it will be packaged into libs or app
test
:
/
[\\/]
node_modules
[\\/]
_
?
vant
(
.*
)
/
,
// in order to adapt to cnpm
test
:
/
[\\/]
node_modules
[\\/]
_
?
vant
(
.*
)
/
// in order to adapt to cnpm
},
commons
:
{
name
:
'chunk-commons'
,
test
:
resolve
(
'src/components'
),
// can customize your rules
minChunks
:
3
,
// minimum common number
priority
:
5
,
reuseExistingChunk
:
true
,
}
,
}
,
reuseExistingChunk
:
true
}
}
})
config
.
optimization
.
runtimeChunk
(
'single'
)
})
}
,
}
}
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