Commit ffdeb51034ebbf38ad310c6d10baa872a08cce8c
1 parent
a37709dd
Exists in
develop
and in
1 other branch
feat: 下拉刷新
Showing
2 changed files
with
22 additions
and
22 deletions
Show diff stats
pages.json
1 | 1 | { |
2 | 2 | "pages": [ //pages数组中第一项表示应用启动页,参考:https://uniapp.dcloud.io/collocation/pages |
3 | 3 | { |
4 | - "path": "pages/market/index" | |
5 | - // "style": { | |
6 | - // "navigationBarTitleText": "首页" | |
7 | - // } | |
4 | + "path": "pages/market/index", | |
5 | + "style": { | |
6 | + "enablePullDownRefresh": true | |
7 | + } | |
8 | 8 | }, { |
9 | 9 | "path": "pages/market/newsDetails", |
10 | 10 | "style": { |
... | ... | @@ -88,4 +88,4 @@ |
88 | 88 | "navigationBarBackgroundColor": "#ffffff", |
89 | 89 | "backgroundColor": "#ffffff" |
90 | 90 | } |
91 | 91 | -} |
92 | +} | |
92 | 93 | \ No newline at end of file | ... | ... |
pages/market/index.vue
... | ... | @@ -4,7 +4,7 @@ |
4 | 4 | <u-search placeholder="搜索感兴趣的内容" v-model="keyword" :show-action="false" margin="30rpx 34rpx 15rpx 34rpx" |
5 | 5 | borderColor="rgb(230, 230, 230)" height="74rpx" bgColor="#F5F6FA" @search="search"></u-search> |
6 | 6 | <u-tabs :list="tabList" :activeStyle="{'color': '#cf000d','font-weight':'bold'}" lineWidth="30rpx" |
7 | - lineHeight="4rpx" lineColor="#cf000d" @click="tabChange"></u-tabs> | |
7 | + lineHeight="4rpx" lineColor="#cf000d" :current="current" @click="tabChange"></u-tabs> | |
8 | 8 | </u-sticky> |
9 | 9 | <u-empty mode="data" icon="http://cdn.uviewui.com/uview/empty/data.png" v-if="NewsList.length <= 0"></u-empty> |
10 | 10 | <newsList v-for="(item,index) in NewsList" :key="index" :newItem="item" v-else></newsList> |
... | ... | @@ -33,25 +33,18 @@ |
33 | 33 | current: 0, |
34 | 34 | tabList: [{ |
35 | 35 | name: "全部", |
36 | - key: -1 | |
37 | 36 | }, { |
38 | 37 | name: "宏观经济", |
39 | - key: 0 | |
40 | 38 | }, { |
41 | 39 | name: "产业政策", |
42 | - key: 1 | |
43 | 40 | }, { |
44 | 41 | name: "行业动态", |
45 | - key: 2 | |
46 | 42 | }, { |
47 | 43 | name: "友商动态", |
48 | - key: 3 | |
49 | 44 | }, { |
50 | 45 | name: "用户资讯", |
51 | - key: 4 | |
52 | 46 | }, { |
53 | 47 | name: "国际能源", |
54 | - key: 5 | |
55 | 48 | }], |
56 | 49 | NewsList: [], |
57 | 50 | queryParameter: { |
... | ... | @@ -66,6 +59,12 @@ |
66 | 59 | onLoad() { |
67 | 60 | this.initData() |
68 | 61 | }, |
62 | + onPullDownRefresh() { | |
63 | + this.keyword = "" | |
64 | + this.current = 0; | |
65 | + this.initData() | |
66 | + uni.stopPullDownRefresh() | |
67 | + }, | |
69 | 68 | methods: { |
70 | 69 | initData() { |
71 | 70 | // this.updateList() |
... | ... | @@ -79,32 +78,33 @@ |
79 | 78 | }, |
80 | 79 | search() { |
81 | 80 | console.log("搜索"); |
82 | - if (this.keyword) { | |
81 | + // if (this.keyword) { | |
83 | 82 | this.updateList({ |
84 | 83 | keyword: this.keyword |
85 | 84 | }) |
86 | - } | |
85 | + // } | |
87 | 86 | }, |
88 | 87 | updateList() { |
89 | 88 | let Params |
90 | 89 | if (this.keyword && this.current !== -1) { |
91 | 90 | Params = {keyword: this.keyword,plateName: this.current} |
92 | - } else if (this.keyword) { | |
91 | + } else if (this.keyword !== "") { | |
93 | 92 | Params = {keyword: this.keyword,} |
94 | - } else if (this.current !== -1) { | |
95 | - Params = {plateName: this.current} | |
93 | + } else if (this.current !== 0) { | |
94 | + Params = {plateName: this.current - 1} | |
96 | 95 | } |
97 | 96 | getInfoMarketInformationlist(Params).then(res => { |
98 | - console.log(res); | |
97 | + // console.log(res); | |
99 | 98 | if (res.code === 200) { |
100 | 99 | this.NewsList = res.rows |
101 | - console.log(this.NewsList); | |
100 | + // console.log(this.NewsList); | |
102 | 101 | } |
103 | 102 | }) |
104 | 103 | }, |
105 | 104 | tabChange(e) { |
106 | 105 | console.log(e); |
107 | - this.current = e.key | |
106 | + this.current = e.index | |
107 | + console.log(this.current); | |
108 | 108 | this.updateList() |
109 | 109 | } |
110 | 110 | } |
... | ... | @@ -113,4 +113,4 @@ |
113 | 113 | |
114 | 114 | <style lang="scss" scoped> |
115 | 115 | |
116 | -</style> | |
117 | 116 | \ No newline at end of file |
117 | +</style> | ... | ... |