Skip to content

Commit a1011f1

Browse files
committed
update: 导入部分nvue-uni
1 parent cea42bb commit a1011f1

13 files changed

Lines changed: 598 additions & 477 deletions

File tree

Lines changed: 107 additions & 148 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,30 @@
11
<template>
2-
<view class="uni-indexed-list">
3-
<scroll-view :scroll-into-view="scrollViewId" :style="{ height: winHeight + 'px' }" class="uni-indexed-list__scroll" scroll-y>
4-
<view v-for="(list, idx) in lists" :key="idx" :id="'uni-indexed-list-' + list.key">
5-
<view v-if="loaded || list.itemIndex < 15" class="uni-indexed-list__title-wrapper">
6-
<text v-if="list.items && list.items.length > 0" class="uni-indexed-list__title">{{ list.key }}</text>
7-
</view>
8-
<view v-if="(loaded || list.itemIndex < 15) && list.items && list.items.length > 0" class="uni-indexed-list__list">
9-
<view v-for="(item, index) in list.items" :key="index" class="uni-indexed-list__item" hover-class="uni-indexed-list__item--hover">
10-
<view v-if="loaded || item.itemIndex < 15" class="uni-indexed-list__item-container" @click="onClick(idx, index)">
11-
<view class="uni-indexed-list__item-border" :class="{'uni-indexed-list__item-border--last':index===list.items.length-1}">
12-
<view v-if="showSelect" style="margin-right: 20rpx;">
13-
<uni-icons :type="item.checked ? 'checkbox-filled' : 'circle'" :color="item.checked ? '#007aff' : '#aaa'" size="24" />
14-
</view>
15-
<text class="uni-indexed-list__item-content">{{ item.name }}</text>
2+
<view class="uni-indexed">
3+
<scroll-view :scroll-into-view="scrollViewId" :style="{ height: winHeight + 'px' }" class="uni-indexed__list" scroll-y>
4+
<block v-for="(list, idx) in lists" :key="idx">
5+
<view v-if="list.items && list.items.length > 0" :id="'uni-indexed-list-' + list.key" class="uni-indexed__list-title">{{ list.key }}</view>
6+
<view v-if="list.items && list.items.length > 0" class="uni-list">
7+
<view v-for="(item, index) in list.items" :key="index" class="uni-list-item" hover-class="uni-list-item--hover">
8+
<view class="uni-list-item__container" @click="onClick(idx, index)">
9+
<view v-if="showSelect" style="margin-right: 20upx;">
10+
<uni-icons :type="item.checked ? 'checkbox-filled' : 'circle'" :color="item.checked ? '#007aff' : '#aaa'" size="24" />
1611
</view>
12+
<view class="uni-list-item__content">{{ item.name }}</view>
1713
</view>
1814
</view>
1915
</view>
20-
</view>
16+
</block>
2117
</scroll-view>
22-
<view :class="touchmove ? 'uni-indexed-list__menu--active' : ''" :style="{ height: winHeight + 'px' }" class="uni-indexed-list__menu" @touchstart="touchStart" @touchmove.stop.prevent="touchMove" @touchend="touchEnd">
23-
<view v-for="(list, key) in lists" :key="key" class="uni-indexed-list__menu-item">
24-
<text class="uni-indexed-list__menu-text" :class="touchmoveIndex == key ? 'uni-indexed-list__menu-text--active' : ''">{{ list.key }}</text>
25-
</view>
26-
</view>
27-
<view v-if="touchmove" class="uni-indexed-list__alert-wrapper">
28-
<text class="uni-indexed-list__alert">{{ lists[touchmoveIndex].key }}</text>
18+
<view :class="touchmove ? 'active' : ''" :style="{ height: winHeight + 'px' }" class="uni-indexed__menu" @touchstart="touchStart" @touchmove.stop.prevent="touchMove" @touchend="touchEnd">
19+
<text v-for="(list, key) in lists" :key="key" :class="touchmoveIndex == key ? 'active' : ''" :style="{ height: itemHeight + 'px', lineHeight: itemHeight + 'px' }" class="uni-indexed__menu-item">
20+
{{ list.key }}
21+
</text>
2922
</view>
23+
<view v-if="touchmove" class="uni-indexed--alert">{{ lists[touchmoveIndex].key }}</view>
3024
</view>
3125
</template>
3226
<script>
33-
function throttle(func, delay) {
34-
var prev = Date.now();
35-
return function() {
36-
var context = this;
37-
var args = arguments;
38-
var now = Date.now();
39-
if (now - prev >= delay) {
40-
func.apply(context, args);
41-
prev = Date.now();
42-
}
43-
}
44-
}
45-
import uniIcons from '@/components/uni-icons/uni-icons.vue'
27+
import uniIcons from '../uni-icons/uni-icons.vue'
4628
export default {
4729
name: 'UniIndexedList',
4830
components: {
@@ -67,9 +49,7 @@
6749
touchmoveIndex: -1,
6850
itemHeight: 0,
6951
winHeight: 0,
70-
scrollViewId: '',
71-
touchmoveTimeout: '',
72-
loaded: false
52+
scrollViewId: ''
7353
}
7454
},
7555
watch: {
@@ -80,11 +60,8 @@
8060
deep: true
8161
}
8262
},
83-
mounted() {
63+
created() {
8464
this.setList()
85-
setTimeout(() => {
86-
this.loaded = true
87-
}, 300);
8865
},
8966
methods: {
9067
setList() {
@@ -97,26 +74,21 @@
9774
// return;
9875
// }
9976
// console.log(this.options)
100-
let index = 0;
10177
this.lists = this.options.map(value => {
10278
// console.log(value)
103-
let indexBefore = index
10479
let items = value.data.map(item => {
10580
let obj = {}
10681
// for (let key in item) {
10782
obj['key'] = value.letter
10883
obj['name'] = item
109-
obj['itemIndex'] = index
110-
index++
11184
// }
11285
obj.checked = item.checked ? item.checked : false
11386
return obj
11487
})
11588
return {
11689
title: value.letter,
11790
key: value.letter,
118-
items: items,
119-
itemIndex: indexBefore
91+
items: items
12092
}
12193
})
12294
// console.log(this.lists)
@@ -172,149 +144,136 @@
172144
}
173145
}
174146
</script>
175-
<style scoped>
176-
.uni-indexed-list__list {
177-
background-color: #ffffff;
178-
/* #ifndef APP-NVUE */
147+
<style>
148+
@charset "UTF-8";
149+
150+
.uni-list {
151+
background-color: #fff;
152+
position: relative;
153+
width: 100%;
179154
display: flex;
180-
/* #endif */
181-
flex-direction: column;
182-
border-top-style: solid;
183-
border-top-width: 1px;
184-
border-top-color: #e5e5e5;
155+
flex-direction: column
185156
}
186157
187-
.uni-indexed-list__item {
188-
font-size: 32rpx;
189-
/* #ifndef APP-NVUE */
190-
display: flex;
191-
/* #endif */
192-
flex: 1;
193-
flex-direction: row;
194-
justify-content: space-between;
195-
align-items: center;
158+
.uni-list::after {
159+
position: absolute;
160+
z-index: 10;
161+
right: 0;
162+
bottom: 0;
163+
left: 0;
164+
height: 1px;
165+
content: '';
166+
-webkit-transform: scaleY(.5);
167+
transform: scaleY(.5);
168+
background-color: #e5e5e5
196169
}
197170
198-
.uni-indexed-list__item-container {
199-
padding-left: 30rpx;
200-
flex: 1;
171+
.uni-list::before {
172+
position: absolute;
173+
z-index: 10;
174+
right: 0;
175+
top: 0;
176+
left: 0;
177+
height: 1px;
178+
content: '';
179+
-webkit-transform: scaleY(.5);
180+
transform: scaleY(.5);
181+
background-color: #e5e5e5
182+
}
183+
184+
.uni-list-item {
185+
font-size: 32upx;
201186
position: relative;
202-
/* #ifndef APP-NVUE */
203187
display: flex;
204-
box-sizing: border-box;
205-
/* #endif */
206-
flex-direction: row;
188+
flex-direction: column;
207189
justify-content: space-between;
208-
align-items: center;
190+
align-items: center
209191
}
210192
211-
.uni-indexed-list__item-border {
193+
.uni-list-item__container {
194+
padding: 24upx 30upx;
195+
width: 100%;
196+
box-sizing: border-box;
212197
flex: 1;
213198
position: relative;
214-
/* #ifndef APP-NVUE */
215199
display: flex;
216-
box-sizing: border-box;
217-
/* #endif */
218200
flex-direction: row;
219201
justify-content: space-between;
220-
align-items: center;
221-
height: 50px;
222-
padding: 30rpx;
223-
padding-left: 0;
224-
border-bottom-style: solid;
225-
border-bottom-width: 1px;
226-
border-bottom-color: #e5e5e5;
227-
}
228-
229-
.uni-indexed-list__item-border--last {
230-
border-bottom-width: 0px;
202+
align-items: center
231203
}
232204
233-
.uni-indexed-list__item-content {
234-
flex: 1;
235-
font-size: 14px;
205+
.uni-list-item__container:after {
206+
position: absolute;
207+
z-index: 3;
208+
right: 0;
209+
bottom: 0;
210+
left: 30upx;
211+
height: 1px;
212+
content: '';
213+
-webkit-transform: scaleY(.5);
214+
transform: scaleY(.5);
215+
background-color: #e5e5e5
236216
}
237217
238-
.uni-indexed-list {
239-
/* #ifndef APP-NVUE */
218+
.uni-indexed {
240219
display: flex;
241-
/* #endif */
242-
flex-direction: row;
220+
flex-direction: row
243221
}
244222
245-
.uni-indexed-list__scroll {
223+
.uni-indexed__list {
246224
flex: 1;
225+
height: 100vh
247226
}
248227
249-
.uni-indexed-list__title-wrapper {
250-
/* #ifndef APP-NVUE */
251-
display: flex;
252-
width: 100%;
253-
/* #endif */
228+
.uni-indexed__list-title {
229+
padding: 10upx 24upx;
230+
line-height: 1.5;
254231
background-color: #f7f7f7;
232+
font-size: 24upx
255233
}
256234
257-
.uni-indexed-list__title {
258-
padding: 6px 12px;
259-
line-height: 24px;
260-
font-size: 24rpx;
261-
}
262-
263-
.uni-indexed-list__menu {
264-
width: 24px;
265-
background-color: lightgrey;
266-
/* #ifndef APP-NVUE */
235+
.uni-indexed__menu {
236+
width: 46upx;
237+
height: 100vh;
238+
background-color: #d3d3d3;
267239
display: flex;
268-
/* #endif */
269-
flex-direction: column;
240+
flex-direction: column
270241
}
271242
272-
.uni-indexed-list__menu-item {
273-
/* #ifndef APP-NVUE */
274-
display: flex;
275-
/* #endif */
276-
flex: 1;
277-
align-items: center;
278-
justify-content: center;
243+
.uni-indexed__menu.active {
244+
background-color: #c8c8c8
279245
}
280246
281-
.uni-indexed-list__menu-text {
282-
line-height: 20px;
283-
font-size: 12px;
284-
text-align: center;
285-
color: #aaa;
247+
.uni-indexed__menu.active .uni-indexed__menu-item {
248+
color: #333
286249
}
287250
288-
.uni-indexed-list__menu--active {
289-
background-color: rgb(200, 200, 200);
251+
.uni-indexed__menu.active .uni-indexed__menu-item.active {
252+
color: #007aff
290253
}
291254
292-
.uni-indexed-list__menu-text--active {
293-
color: #007aff;
255+
.uni-indexed__menu-item {
256+
color: #aaa;
257+
font-size: 22upx;
258+
text-align: center
294259
}
295260
296-
.uni-indexed-list__alert-wrapper {
261+
.uni-indexed--alert {
297262
position: absolute;
298-
left: 0;
299-
top: 0;
300-
right: 0;
301-
bottom: 0;
302-
/* #ifndef APP-NVUE */
303-
display: flex;
304-
/* #endif */
305-
flex-direction: row;
263+
display: inline-flex;
306264
align-items: center;
307265
justify-content: center;
308-
}
309-
310-
.uni-indexed-list__alert {
311-
width: 80px;
312-
height: 80px;
313-
border-radius: 80px;
266+
z-index: 20;
267+
width: 160upx;
268+
height: 160upx;
269+
left: 50%;
270+
top: 50%;
271+
margin-left: -80upx;
272+
margin-top: -80upx;
273+
border-radius: 80upx;
314274
text-align: center;
315-
line-height: 80px;
316-
font-size: 35px;
275+
font-size: 70upx;
317276
color: #fff;
318-
background-color: rgba(0, 0, 0, 0.5);
277+
background-color: rgba(0, 0, 0, .5)
319278
}
320279
</style>

0 commit comments

Comments
 (0)