|
| 1 | +<style lang="scss"> |
| 2 | +#index { |
| 3 | + position: fixed; |
| 4 | + bottom: 0; |
| 5 | + right: 0; |
| 6 | + left: 0; |
| 7 | + top: 0; |
| 8 | + transform: translateY(0); |
| 9 | + transition: transform 0.4s ease; |
| 10 | +
|
| 11 | + &.active { |
| 12 | + transform: translateY(-120px); |
| 13 | + } |
| 14 | +
|
| 15 | + .carousel { |
| 16 | + width: 100%; |
| 17 | + height: 120px; |
| 18 | +
|
| 19 | + .c-item { |
| 20 | + display: block; |
| 21 | + height: 120px; |
| 22 | + background-position: center; |
| 23 | + background-repeat: no-repeat; |
| 24 | + background-size: cover; |
| 25 | + } |
| 26 | +
|
| 27 | + .v-switcher { |
| 28 | + &-header { |
| 29 | + &-wrap { |
| 30 | + box-sizing: border-box; |
| 31 | + position: absolute; |
| 32 | + right: 10px; |
| 33 | + bottom: 10px; |
| 34 | + height: 35px; |
| 35 | + z-index: 1; |
| 36 | + width: 150px; |
| 37 | + border-bottom: none; |
| 38 | + } |
| 39 | +
|
| 40 | + &-item { |
| 41 | + margin-left: 8px; |
| 42 | + width: 18px; |
| 43 | + height: 18px; |
| 44 | + border-bottom-width: 0; |
| 45 | + cursor: default; |
| 46 | + padding: 0; |
| 47 | + border-radius: 50%; |
| 48 | + background-color: #fff; |
| 49 | +
|
| 50 | + &.is-active { |
| 51 | + background-color: palevioletred; |
| 52 | + } |
| 53 | + } |
| 54 | + } |
| 55 | + } |
| 56 | + } |
| 57 | +
|
| 58 | + .content { |
| 59 | + height: 100%; |
| 60 | + box-sizing: border-box; |
| 61 | +
|
| 62 | + .v-switcher-header-anchor { |
| 63 | + height: 2px; |
| 64 | + bottom: 0; |
| 65 | + background-color: palevioletred; |
| 66 | + } |
| 67 | +
|
| 68 | + .v-switcher-header-item { |
| 69 | + padding: 0 20px; |
| 70 | + } |
| 71 | +
|
| 72 | + .ul-wrap { |
| 73 | + margin: 0; |
| 74 | + padding: 0; |
| 75 | +
|
| 76 | + .hoz-wrap { |
| 77 | + width: 100%; |
| 78 | + height: 150px; |
| 79 | + overflow: hidden; |
| 80 | + } |
| 81 | +
|
| 82 | + .item-wrap { |
| 83 | + display: inline-block; |
| 84 | + white-space: nowrap; |
| 85 | + overflow-x: auto; |
| 86 | + overflow-y: hidden; |
| 87 | + height: 110%; |
| 88 | + padding-bottom: 10%; |
| 89 | + box-sizing: content-box; |
| 90 | + width: 100%; |
| 91 | + -webkit-overflow-scrolling: touch; |
| 92 | +
|
| 93 | + .item { |
| 94 | + height: 150px; |
| 95 | + line-height: 150px; |
| 96 | + font-size: 24px; |
| 97 | + display: inline-block; |
| 98 | + text-align: center; |
| 99 | + padding: 0 10px; |
| 100 | + width: 120px; |
| 101 | + white-space: nowrap; |
| 102 | + } |
| 103 | + } |
| 104 | + } |
| 105 | + } |
| 106 | +
|
| 107 | + .flow-loader-state { |
| 108 | + text-align: center; |
| 109 | + height: 40px; |
| 110 | + line-height: 40px; |
| 111 | + } |
| 112 | +} |
| 113 | +</style> |
| 114 | + |
| 115 | +<template> |
| 116 | + <div id="index" :class="{ 'active': isActive }"> |
| 117 | + <div class="carousel"> |
| 118 | + <v-switcher :headers="headers1" :swipe="true" :autoplay="2000" align="end" :header-height="18"> |
| 119 | + <a |
| 120 | + v-for="(item, index) in headers1" |
| 121 | + :key="index" |
| 122 | + :slot="`${index}`" |
| 123 | + :style="{ backgroundColor: getRandomColor() }" |
| 124 | + class="c-item" |
| 125 | + href="javascript:;" |
| 126 | + > |
| 127 | + {{ item.title }} |
| 128 | + </a> |
| 129 | + </v-switcher> |
| 130 | + </div> |
| 131 | + <div class="content"> |
| 132 | + <v-switcher |
| 133 | + :headers="headers2" |
| 134 | + :swipe="true" |
| 135 | + :sticky="true" |
| 136 | + :anchor-padding="20" |
| 137 | + @change="handleTabSwitch" |
| 138 | + > |
| 139 | + <template slot="header-after"> |
| 140 | + <button @click="handleBtnClick">筛选</button> |
| 141 | + </template> |
| 142 | + <v-scroller |
| 143 | + v-for="(item, index) in headers2" |
| 144 | + ref="scroll" |
| 145 | + :key="index" |
| 146 | + :event-step="30" |
| 147 | + :slot="`${index}`" |
| 148 | + @top="handlePullDown" |
| 149 | + @scroll="handleScroll" |
| 150 | + @scroll-down="handlePullUp" |
| 151 | + @bottom="handleLoadMore" |
| 152 | + @refresh="handleRefresh" |
| 153 | + > |
| 154 | + <ul class="ul-wrap"> |
| 155 | + <li class="hoz-wrap"> |
| 156 | + <div class="item-wrap" @touchstart.stop @touchmove.stop> |
| 157 | + <div |
| 158 | + v-for="item in 10" |
| 159 | + :key="item" |
| 160 | + :style="{ backgroundColor: getRandomColor() }" |
| 161 | + @click="click++" |
| 162 | + class="item" |
| 163 | + >{{ item }} - {{ click }}</div> |
| 164 | + </div> |
| 165 | + </li> |
| 166 | + <flow-loader |
| 167 | + ref="loader" |
| 168 | + func="getListByPage" |
| 169 | + type="page" |
| 170 | + :auto="0" |
| 171 | + :query="{ |
| 172 | + id: item, |
| 173 | + count: 10 |
| 174 | + }" |
| 175 | + :callback="handleCallback" |
| 176 | + > |
| 177 | + <vue-flow-render |
| 178 | + ref="render" |
| 179 | + :remain="30" |
| 180 | + :total="count" |
| 181 | + slot-scope="{ flow, count }" |
| 182 | + > |
| 183 | + <ItemComponent |
| 184 | + v-for="(item, index) in flow" |
| 185 | + :key="item.id" |
| 186 | + :item="item" |
| 187 | + :index="index" |
| 188 | + :style="{ height: '110px' }" |
| 189 | + /> |
| 190 | + </vue-flow-render> |
| 191 | + </flow-loader> |
| 192 | + </ul> |
| 193 | + </v-scroller> |
| 194 | + </v-switcher> |
| 195 | + </div> |
| 196 | + </div> |
| 197 | +</template> |
| 198 | + |
| 199 | +<script> |
| 200 | +import ItemComponent from '../components/Item' |
| 201 | +
|
| 202 | +export default { |
| 203 | + name: 'Index', |
| 204 | + components: { |
| 205 | + ItemComponent |
| 206 | + }, |
| 207 | + data () { |
| 208 | + const headers2 = [ |
| 209 | + 'tab-0', |
| 210 | + 'tab-1', |
| 211 | + 'tab-2奥术大师', |
| 212 | + 'tab', |
| 213 | + 'tab-4答', |
| 214 | + 'tab-5', |
| 215 | + 'tab-6阿斯达稍等', |
| 216 | + 'tab-7', |
| 217 | + 'tab-8奥术大', |
| 218 | + 'tab-9' |
| 219 | + ] |
| 220 | + return { |
| 221 | + click: 0, |
| 222 | + isActive: false, |
| 223 | + headers1: [ |
| 224 | + { |
| 225 | + text: '', |
| 226 | + title: '成名必备!' |
| 227 | + }, |
| 228 | + { |
| 229 | + text: '', |
| 230 | + title: '花泽香菜,甜美来袭!' |
| 231 | + }, |
| 232 | + { |
| 233 | + text: '', |
| 234 | + title: '鸡鸣紫陌曙光寒,水转皇州春色阑' |
| 235 | + }, |
| 236 | + { |
| 237 | + text: '', |
| 238 | + title: '请查收您的追番清单!' |
| 239 | + }, |
| 240 | + { |
| 241 | + text: '', |
| 242 | + title: '欢迎来到天生制造狂的世界' |
| 243 | + } |
| 244 | + ], |
| 245 | + headers2, |
| 246 | + activeIndex: 0 |
| 247 | + } |
| 248 | + }, |
| 249 | + methods: { |
| 250 | + getRandomColor () { |
| 251 | + var colors = [ |
| 252 | + 'rgba(21,174,103,.5)', |
| 253 | + 'rgba(245,163,59,.5)', |
| 254 | + 'rgba(255,230,135,.5)', |
| 255 | + 'rgba(194,217,78,.5)', |
| 256 | + 'rgba(195,123,177,.5)', |
| 257 | + 'rgba(125,205,244,.5)' |
| 258 | + ] |
| 259 | + return colors[~~(Math.random() * colors.length)] |
| 260 | + }, |
| 261 | + handlePullDown () { |
| 262 | + this.isActive = false |
| 263 | + }, |
| 264 | + handlePullUp () { |
| 265 | + this.isActive = true |
| 266 | + }, |
| 267 | + handleTabSwitch (index) { |
| 268 | + this.activeIndex = index |
| 269 | + this.$nextTick(() => { |
| 270 | + this.$refs.loader[index].initData() |
| 271 | + }) |
| 272 | + }, |
| 273 | + handleCallback () { |
| 274 | + this.$nextTick(() => { |
| 275 | + const index = this.activeIndex |
| 276 | + this.$refs.render[index].setWrap(this.$refs.scroll[index].$el) |
| 277 | + }) |
| 278 | + }, |
| 279 | + handleLoadMore () { |
| 280 | + this.$refs.loader[this.activeIndex].loadMore() |
| 281 | + }, |
| 282 | + handleScroll ({ offsetTop, isUp }) { |
| 283 | + this.$refs.render[this.activeIndex].scroll(offsetTop, isUp) |
| 284 | + }, |
| 285 | + handleBtnClick () { |
| 286 | + alert('筛选') |
| 287 | + }, |
| 288 | + handleRefresh () { |
| 289 | + this.isActive = false |
| 290 | + } |
| 291 | + } |
| 292 | +} |
| 293 | +</script> |
0 commit comments