|
32 | 32 | </mu-appbar>
|
33 | 33 | </div>
|
34 | 34 |
|
35 |
| - <mu-refresh-control :refreshing="refreshing" :trigger="trigger" @refresh="refresh()"/> |
| 35 | + <!--<mu-refresh-control :refreshing="refreshing" :trigger="trigger" @refresh="refresh()"/>--> |
36 | 36 | <div style="margin-top: 50%;text-align: center" v-if="isAjax">
|
37 | 37 | <mu-circular-progress :size="40" :color="'474a4f'" :strokeWidth="5"/>
|
38 | 38 | </div>
|
39 |
| - <mu-list v-if="!isAjax&&businessCardList"> |
40 |
| - <div v-for="(value,key) in bcsSortList"> |
41 | 39 |
|
42 |
| - <mu-sub-header :ref="`key_${key}`">{{key}}</mu-sub-header> |
43 |
| - <business-card v-for="(item,index) in value" |
44 |
| - :key="index" |
45 |
| - :item="item"> |
46 |
| - </business-card> |
| 40 | + <div> |
| 41 | + <mu-list v-if="!isAjax&&businessCardList"> |
| 42 | + <ul id="list" ref="content"> |
| 43 | + <li v-for="(value,key) in bcsSortList" class="sort-item"> |
| 44 | + <div :id="key" class="sort-head" :ref="`key_${key}`"> |
| 45 | + <mu-sub-header>{{key}}</mu-sub-header> |
| 46 | + </div> |
| 47 | + <business-card v-for="(item,index) in value" |
| 48 | + :key="index" |
| 49 | + :item="item"> |
| 50 | + </business-card> |
| 51 | + </li> |
| 52 | + </ul> |
47 | 53 |
|
48 |
| - </div> |
49 |
| - </mu-list> |
| 54 | + <!--检索--> |
| 55 | + <div class="initial-bar" :style="{'height':barHeight+'px'}" ref="nav" @touchstart="handleTouchStart"> |
| 56 | + <ul class="initial-inner"> |
| 57 | + <li class="initial-item" @click.stop="toPs(i)" v-for="i in bcInitialList">{{i}}</li> |
| 58 | + </ul> |
| 59 | + </div> |
| 60 | + </mu-list> |
| 61 | + |
| 62 | + <div class="indicator" v-show="moving">{{ currentIndicator }}</div> |
| 63 | + </div> |
50 | 64 |
|
51 | 65 | <mu-dialog :open="delDialog" title="提示" @close="closeDel">
|
52 | 66 | 确定删除此条信息吗?
|
53 | 67 | <mu-flat-button slot="actions" @click="closeDel" default label="取消"/>
|
54 | 68 | <mu-flat-button slot="actions" primary @click="closeDel" label="确定"/>
|
55 | 69 | </mu-dialog>
|
56 |
| - |
57 |
| - <!--<div class="container-bottom">--> |
58 |
| - <!--<bottom-tab class="tab"></bottom-tab>--> |
59 |
| - <!--</div>--> |
60 |
| - |
61 |
| - <!--检索--> |
62 |
| - <div class="initial-bar"> |
63 |
| - <span @click.stop="toPs(i)" v-for="i in bcInitialList">{{i}}</span> |
64 |
| - </div> |
65 | 70 | </div>
|
66 | 71 | </template>
|
67 | 72 | <style lang="scss">
|
68 | 73 | .bc-box {
|
69 | 74 | position: relative;
|
70 |
| - padding-top: 10vh; |
| 75 | + /*padding-top: 10vh;*/ |
| 76 | + padding-top: 56px; |
71 | 77 | }
|
72 | 78 |
|
73 | 79 | .initial-bar {
|
74 | 80 | position: fixed;
|
75 |
| - top: 50%; |
| 81 | + /*top: 50%;*/ |
| 82 | + top: 56px; |
| 83 | + right: 0; |
| 84 | + bottom: 0; |
76 | 85 | font-size: 11px;
|
77 | 86 | line-height: 1.2;
|
78 |
| - right: 8px; |
79 |
| - width: 10px; |
80 |
| - -webkit-transform: translate3d(0, -50%, 0); |
81 |
| - transform: translate3d(0, -50%, 0); |
82 |
| - span { |
| 87 | + /*right: 8px;*/ |
| 88 | + width: 13px; |
| 89 | + background-color: #474a4f; |
| 90 | + max-height: 100%; |
| 91 | + display: -webkit-box; |
| 92 | + display: -ms-flexbox; |
| 93 | + display: flex; |
| 94 | + -webkit-box-orient: vertical; |
| 95 | + -webkit-box-direction: normal; |
| 96 | + -ms-flex-direction: column; |
| 97 | + flex-direction: column; |
| 98 | + -webkit-box-pack: center; |
| 99 | + -ms-flex-pack: center; |
| 100 | + justify-content: center; |
| 101 | + /*-webkit-transform: translate3d(0, -50%, 0);*/ |
| 102 | + /*transform: translate3d(0, -50%, 0);*/ |
| 103 | + z-index: 999; |
| 104 | + .initial-inner { |
| 105 | + display: -webkit-box; |
| 106 | + display: -ms-flexbox; |
| 107 | + display: flex; |
| 108 | + -webkit-box-orient: vertical; |
| 109 | + -webkit-box-direction: normal; |
| 110 | + -ms-flex-direction: column; |
| 111 | + flex-direction: column; |
| 112 | + margin: 0; |
| 113 | + max-height: 100%; |
| 114 | + } |
| 115 | + li { |
83 | 116 | display: block;
|
84 |
| - text-align: left; |
85 | 117 | font-size: 12px;
|
86 | 118 | font-weight: bold;
|
| 119 | + color: #fff; |
| 120 | + text-align: center; |
| 121 | + margin: 3px auto; |
87 | 122 | }
|
88 | 123 | }
|
89 | 124 |
|
| 125 | + .indicator { |
| 126 | + position: fixed; |
| 127 | + width: 50px; |
| 128 | + height: 50px; |
| 129 | + top: 50%; |
| 130 | + left: 50%; |
| 131 | + -webkit-transform: translate(-50%, -50%); |
| 132 | + transform: translate(-50%, -50%); |
| 133 | + text-align: center; |
| 134 | + line-height: 50px; |
| 135 | + background-color: rgba(0, 0, 0, .7); |
| 136 | + border-radius: 5px; |
| 137 | + color: #fff; |
| 138 | + font-size: 22px; |
| 139 | + z-index: 10000; |
| 140 | + } |
| 141 | +
|
90 | 142 | .mu-list {
|
91 | 143 | position: relative;
|
92 | 144 | overflow: hidden;
|
93 | 145 | -webkit-overflow-scrolling: touch;
|
94 | 146 | user-select: none;
|
| 147 | + margin-right: 13px; |
95 | 148 | .list-item {
|
96 | 149 | width: 100%;
|
97 | 150 | float: left;
|
|
166 | 219 | delDialog: false,
|
167 | 220 | refreshing: false,
|
168 | 221 | trigger: null,
|
169 |
| - group: '1' |
| 222 | + group: '1', |
| 223 | + barHeight: document.documentElement.clientHeight - 112, |
| 224 | + sections: [], |
| 225 | + indicatorTime: null, |
| 226 | + moving: false, |
| 227 | + firstSection: null, |
| 228 | + currentIndicator: '', |
| 229 | + navOffsetX: 0 |
170 | 230 | }
|
171 | 231 | },
|
172 | 232 | computed: {
|
173 | 233 | ...mapGetters(['nowMessageList', 'bcInitialList', 'bcsSortList']),
|
174 | 234 | ...mapState(['isAjax', 'businessCardList'])
|
175 | 235 | },
|
176 |
| - mounted() { |
177 |
| - this.trigger = this.$el |
| 236 | + created() { |
178 | 237 | },
|
179 | 238 | methods: {
|
180 | 239 | ...mapMutations(['removeMessage', 'showSearch']),
|
|
199 | 258 | },
|
200 | 259 | toPs(i) {
|
201 | 260 | window.scrollTo(0, this.$refs['key_' + i][0].offsetTop)
|
| 261 | + }, |
| 262 | + handleTouchStart(e) { |
| 263 | + let listItems = this.$refs.content.getElementsByTagName('li'); |
| 264 | + if (listItems.length > 0) { |
| 265 | + this.firstSection = listItems[0]; |
| 266 | + } |
| 267 | + this.sections = listItems; |
| 268 | +
|
| 269 | + if (e.target.tagName !== 'LI') { |
| 270 | + return; |
| 271 | + } |
| 272 | + this.navOffsetX = e.changedTouches[0].clientX; |
| 273 | + this.scrollList(e.changedTouches[0].clientY); |
| 274 | + if (this.indicatorTime) { |
| 275 | + clearTimeout(this.indicatorTime); |
| 276 | + } |
| 277 | + this.moving = true; |
| 278 | + window.addEventListener('touchmove', this.handleTouchMove); |
| 279 | + window.addEventListener('touchend', this.handleTouchEnd); |
| 280 | + }, |
| 281 | + handleTouchMove(e) { |
| 282 | + e.preventDefault(); |
| 283 | + this.scrollList(e.changedTouches[0].clientY); |
| 284 | + }, |
| 285 | + handleTouchEnd() { |
| 286 | + this.indicatorTime = setTimeout(() => { |
| 287 | + this.moving = false; |
| 288 | + this.currentIndicator = ''; |
| 289 | + }, 500); |
| 290 | + window.removeEventListener('touchmove', this.handleTouchMove); |
| 291 | + window.removeEventListener('touchend', this.handleTouchEnd); |
| 292 | + }, |
| 293 | + scrollList(y) { |
| 294 | + let currentItem = document.elementFromPoint(this.navOffsetX, y); |
| 295 | + if (!currentItem || !currentItem.classList.contains('initial-item')) { |
| 296 | + return; |
| 297 | + } |
| 298 | + this.currentIndicator = currentItem.innerText; |
| 299 | + let targets = []; |
| 300 | + for (let i = 0; i < this.sections.length; i++) { |
| 301 | + if (this.sections[i].firstChild.innerText.trim() === currentItem.innerText) { |
| 302 | + targets.push(this.sections[i]) |
| 303 | + } |
| 304 | + } |
| 305 | + let targetDOM; |
| 306 | +
|
| 307 | + if (targets.length > 0) { |
| 308 | + targetDOM = targets[0]; |
| 309 | + window.scrollTo(0, document.getElementById(currentItem.innerText).offsetTop) |
| 310 | + } |
202 | 311 | }
|
203 | 312 | },
|
204 |
| - created() { |
205 |
| -// this.$store.dispatch('getAllData', this).then(() => { |
206 |
| -// console.log('getAllData success'); |
207 |
| -// }) |
208 |
| -
|
| 313 | + mounted() { |
| 314 | + this.trigger = this.$el |
209 | 315 | }
|
210 | 316 | }
|
211 | 317 | </script>
|
0 commit comments