Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
uni-starter
提交
22a19d8b
U
uni-starter
项目概览
DCloud
/
uni-starter
通知
4666
Star
228
Fork
210
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
3
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-starter
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
3
Issue
3
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
22a19d8b
编写于
4月 07, 2021
作者:
芊
芊里
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
列表及搜索页完成
上级
09d69f69
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
63 addition
and
33 deletion
+63
-33
pages.json
pages.json
+7
-1
pages/list/list.vue
pages/list/list.vue
+3
-8
pages/list/news-list.vue
pages/list/news-list.vue
+37
-17
pages/search/search.nvue
pages/search/search.nvue
+16
-7
未找到文件。
pages.json
浏览文件 @
22a19d8b
...
...
@@ -5,6 +5,12 @@
"navigationStyle"
:
"custom"
,
"enablePullDownRefresh"
:
true
}
},{
"path"
:
"pages/list/news-list"
,
"style"
:
{
"navigationStyle"
:
"custom"
,
"enablePullDownRefresh"
:
true
}
},
{
"path"
:
"pages/grid/grid"
,
...
...
@@ -30,7 +36,7 @@
},
{
"path"
:
"pages/search/search"
,
"style"
:
{
"navigation
BarTitleText"
:
"
"
"navigation
Style"
:
"custom
"
}
},
{
"path"
:
"pages/list/detail"
,
...
...
pages/list/list.vue
浏览文件 @
22a19d8b
<
template
>
<view
style=
"overflow: hidden;"
>
<!-- 页面主列表 -->
<news-list
ref=
"newsList"
:
search
Text=
"searchText"
></news-list>
<news-list
ref=
"newsList"
:
canSearch=
"canSearch"
:current
Text=
"searchText"
></news-list>
</view>
</
template
>
<
script
>
import
newsList
from
'
./news-list.vue
'
;
import
newsSearchTitle
from
'
./news-search-title.vue
'
;
export
default
{
components
:{
newsList
,
newsSearchTitle
newsList
},
data
()
{
return
{
searchText
:
''
,
formData
:
{
waterfall
:
false
,
// 布局方向切换
status
:
'
loading
'
,
// 加载状态
},
canSearch
:
true
};
},
onShow
(
options
)
{
...
...
pages/list/news-list.vue
浏览文件 @
22a19d8b
...
...
@@ -8,10 +8,9 @@
-->
<view
style=
"overflow: hidden;"
>
<view
class=
"search-box"
>
<status-bar></status-bar>
<status-bar
class=
"status-bar"
></status-bar>
<view
class=
"search-container-bar"
>
<uni-search-bar
ref=
"searchBar"
style=
"flex:1;"
radius=
"100"
v-model=
"searchText"
@
search-click=
"searchClick"
cancelButton=
"none"
disabled
/>
<uni-search-bar
ref=
"searchBar"
style=
"flex:1;"
radius=
"100"
v-model=
"searchText"
@
click.native=
"searchClick"
cancelButton=
"none"
disabled
/>
</view>
</view>
<view
class=
"list"
>
...
...
@@ -28,7 +27,7 @@
<uni-list
:class=
"
{ 'uni-list--waterfall': options.waterfall }">
<!-- 通过 uni-list--waterfall 类决定页面布局方向 -->
<!-- to 属性携带参数跳转详情页面,当前只为参考 -->
<uni-list-item
:border=
"!options.waterfall"
class=
"uni-list-item--waterfall"
title=
"自定义商品列表"
<uni-list-item
:border=
"!options.waterfall"
:to=
"'./detail?id='+item._id+'&title='+item.title"
class=
"uni-list-item--waterfall"
title=
"自定义商品列表"
v-for=
"item in data"
:key=
"item._id"
>
<!-- 通过header插槽定义列表左侧图片 -->
<template
v-slot:header
>
...
...
@@ -67,14 +66,18 @@
statusBar
},
props
:{
search
Text
:{
current
Text
:{
type
:
String
,
default
:
''
},
canSearch
:{
type
:
Boolean
,
default
:
false
}
},
data
()
{
return
{
// searchText:
'',
searchText
:
this
.
currentText
||
''
,
formData
:
{
waterfall
:
false
,
// 布局方向切换
status
:
'
loading
'
,
// 加载状态
...
...
@@ -86,6 +89,21 @@
field
:
'
author{username, _id}, user_id,_id,avatar,title,excerpt,last_modify_date, comment_count, like_count
'
,
tipShow
:
false
// 是否显示顶部提示框
};
},
/**
* 作为页面出现时的生命周期
*/
onShow
(
options
)
{
this
.
searchText
=
getApp
().
globalData
.
searchText
;
},
/**
* 下拉刷新回调函数
*/
onPullDownRefresh
()
{
this
.
refresh
();
},
onReachBottom
()
{
this
.
loadMore
();
},
methods
:
{
/**
...
...
@@ -119,16 +137,17 @@
}
},
searchClick
()
{
uni
.
hideKeyboard
();
uni
.
navigateTo
({
url
:
'
/pages/search/search
'
,
animationType
:
'
fade-in
'
});
}
},
watch
:
{
searchText
(
value
)
{
this
.
search
(
value
);
uni
.
hideKeyboard
();
if
(
this
.
canSearch
){
uni
.
navigateTo
({
url
:
'
/pages/search/search
'
,
animationType
:
'
fade-in
'
});
}
else
{
uni
.
navigateBack
();
}
}
},
computed
:
{
...
...
@@ -277,7 +296,8 @@
/* #endif */
flex-direction
:
row
;
justify-content
:
center
;
align-items
:
center
;
align-items
:
center
;
width
:
750rpx
;
}
/* #ifndef APP-NVUE */
...
...
pages/search/search.nvue
浏览文件 @
22a19d8b
<template>
<view class="container">
<view class="status-bar" :style="{height:statusBarHeight}"></view>
<view class="search-container">
<!-- 搜索框 -->
<view class="search-container-bar">
...
...
@@ -8,7 +9,7 @@
<!-- #endif -->
<!-- :cancelText="keyBoardPopup ? '取消' : '搜索'" -->
<uni-search-bar ref="searchBar" style="flex:1;" radius="100" v-model="searchText" :focus="focus" :placeholder="hotWorld"
clearButton="auto" cancelButton="always" @clear="clear" @confirm="confirm" @cancel="
cancel
" />
clearButton="auto" cancelButton="always" @clear="clear" @confirm="confirm" @cancel="
backPage
" />
</view>
</view>
<view class="search-body">
...
...
@@ -61,7 +62,7 @@
</view>
</view>
<!-- 搜索联想 -->
<view class="search-associative" v-if="associativeShow">
<view class="search-associative"
:style="{marginTop:statusBarHeight}"
v-if="associativeShow">
<uni-list>
<template v-for="(item,index) in associativeList">
<uni-list-item :key="item._id" :ellipsis="1" :title="item.title" @click="associativeClick(item)" show-extra-icon
...
...
@@ -133,7 +134,7 @@
return {
mallGoodsDbName,
searchLogDbName,
statusBarHeight:'0px',
localSearchList: uni.getStorageSync(localSearchListKey),
localSearchListDel: false,
netHotListIsHide: false,
...
...
@@ -158,6 +159,9 @@
this.searchText = getApp().globalData.searchText;
},
onLoad() {
this.statusBarHeight = `${uni.getSystemInfoSync().statusBarHeight}px`;
},
methods: {
clear(res) {
console.log("res: ", res);
...
...
@@ -290,10 +294,12 @@
},
loadList(text = '') {
getApp().globalData.searchText = text;
// uni.navigateBack()
uni.switchTab({
url:'../list/list'
uni.navigateTo({
url:'../list/news-list'
})
},
backPage(){
uni.navigateBack();
}
},
computed: {
...
...
@@ -330,8 +336,11 @@
<style lang="scss" scoped>
$search-bar-height:52px;
$word-container_header-height:72rpx;
.status-bar{
background-color: #fff;
}
.container {
padding-top: var(--status-bar-height);
/* #ifndef APP-NVUE */
height: 100%;
/* #endif */
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录