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