1
1
<template >
2
2
<div class =' container' >
3
3
<div class =' header' >
4
- <div :class =' { active: tab==="all" }' @click.stop =' changeTab($event)' data-tab =' all' >全部</div >
5
- <div :class =' { active: tab==="good" }' @click.stop =' changeTab($event)' data-tab =' good' >精华</div >
6
- <div :class =' { active: tab==="share" }' @click.stop =' changeTab($event)' data-tab =' share' >分享</div >
7
- <div :class =' { active: tab==="job" }' @click.stop =' changeTab($event)' data-tab =' job' >招聘</div >
8
- <div :class =' { active: tab==="ask" }' @click.stop =' changeTab($event)' data-tab =' ask' >问答</div >
4
+ <div :class =' { active: tab==="all" }' @click.stop =' changeTab($event)' data-tab =' all' :data-offset = ' 0 ' >全部</div >
5
+ <div :class =' { active: tab==="good" }' @click.stop =' changeTab($event)' data-tab =' good' :data-offset = ' 1 ' >精华</div >
6
+ <div :class =' { active: tab==="share" }' @click.stop =' changeTab($event)' data-tab =' share' :data-offset = ' 2 ' >分享</div >
7
+ <div :class =' { active: tab==="job" }' @click.stop =' changeTab($event)' data-tab =' job' :data-offset = ' 3 ' >招聘</div >
8
+ <div :class =' { active: tab==="ask" }' @click.stop =' changeTab($event)' data-tab =' ask' :data-offset = ' 4 ' >问答</div >
9
9
</div >
10
- <div v-for =' (listItem,listIndex) in list' :key =' listIndex' v-show =" listItem===tab" >
11
- <scroll-view scroll-y class =' scroll-container' @scrolltolower =' getMore' >
12
- <div v-for =' item in cardData[listItem]' :key =' item.id' >
13
- <card :item =' item' ></card >
14
- </div >
15
- </scroll-view >
10
+ <div class =" containers" :animation =' animation' >
11
+ <div v-for =' (listItem,listIndex) in list' :key =' listIndex' >
12
+ <scroll-view scroll-y class =' scroll-container' @scrolltolower =' getMore' >
13
+ <div v-for =' item in cardData[listItem]' :key =' item.id' >
14
+ <card :item =' item' ></card >
15
+ </div >
16
+ </scroll-view >
17
+ </div >
16
18
</div >
17
19
</div >
18
20
</template >
@@ -34,12 +36,8 @@ export default {
34
36
ask: []
35
37
},
36
38
isLoading: false ,
37
- list: [" all" , " good" , " share" , " job" , " ask" ]
38
- // all: [],
39
- // good: [],
40
- // share: [],
41
- // job: [],
42
- // ask: []
39
+ list: [" all" , " good" , " share" , " job" , " ask" ],
40
+ animation: {}
43
41
};
44
42
},
45
43
components: {
@@ -64,8 +62,6 @@ export default {
64
62
if (res .data .success ) {
65
63
if (this .cardData [tab].length > 0 && page === 0 ) {
66
64
// 下拉刷新
67
- console .log (" 新的" , res .data .data , tab);
68
-
69
65
this .cardData [tab] = res .data .data ;
70
66
// res.data.data;
71
67
} else {
@@ -89,13 +85,23 @@ export default {
89
85
},
90
86
changeTab (e ) {
91
87
const currentTab = e .target .dataset .tab ;
88
+ const offset = e .target .dataset .offset ;
92
89
this .tab = currentTab;
93
90
this .page = 0 ;
94
91
this .getData (currentTab, 0 );
92
+ this .animation = wx
93
+ .createAnimation ({
94
+ duration: 1000 ,
95
+ timingFunction: " ease"
96
+ })
97
+ .left (` -${ offset * 100 } vw` )
98
+ .step ()
99
+ .export ();
95
100
}
96
101
}
97
102
};
98
103
</script >
104
+
99
105
<style lang="scss" scoped>
100
106
.container {
101
107
background-color : rgb (245 , 245 , 249 );
@@ -111,11 +117,15 @@ export default {
111
117
line-height : 86 rpx;
112
118
}
113
119
}
114
- .scroll-container {
115
- height : 90vh ;
120
+ .containers {
121
+ display : flex ;
122
+ position : relative ;
123
+ .scroll-container {
124
+ height : 90vh ;
125
+ width : 100vw ;
126
+ }
116
127
}
117
128
}
118
-
119
129
.header .header > div + .header > div {
120
130
border-left : 2 rpx solid white ;
121
131
}
0 commit comments