uview-plus 3.4.54 → 3.4.55
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/changelog.md
CHANGED
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view class="u-city-locate">
|
|
3
|
+
<up-index-list :indexList="indexList">
|
|
4
|
+
<template #header>
|
|
5
|
+
<view class="u-current-city-wrap">
|
|
6
|
+
<view class="u-current-city-title">定位城市</view>
|
|
7
|
+
<view class="u-current-city-item" @tap="location">
|
|
8
|
+
<view class="u-location-city">{{locationCity}}</view>
|
|
9
|
+
</view>
|
|
10
|
+
</view>
|
|
11
|
+
</template>
|
|
12
|
+
<template :key="index" v-for="(item, index) in cityList">
|
|
13
|
+
<!-- #ifdef APP-NVUE -->
|
|
14
|
+
<up-index-anchor :text="indexList[index]"></up-index-anchor>
|
|
15
|
+
<!-- #endif -->
|
|
16
|
+
<up-index-item>
|
|
17
|
+
<!-- #ifndef APP-NVUE -->
|
|
18
|
+
<up-index-anchor :text="indexList[index]"></up-index-anchor>
|
|
19
|
+
<!-- #endif -->
|
|
20
|
+
<view class="hot-city-list" v-if="index == 0">
|
|
21
|
+
<view class="" v-for="(item1, index1) in item" @tap="selectedCity(item1)">
|
|
22
|
+
<view class="hot-city-item">{{ item1[nameKey] }}</view>
|
|
23
|
+
</view>
|
|
24
|
+
</view>
|
|
25
|
+
<view v-else class="item-list" v-for="(item1, index1) in item" :key="index1">
|
|
26
|
+
<view class="list__item" @tap="selectedCity(item1)">
|
|
27
|
+
<text class="list__item__city-name">{{item1[nameKey]}}</text>
|
|
28
|
+
</view>
|
|
29
|
+
<up-line></up-line>
|
|
30
|
+
</view>
|
|
31
|
+
</up-index-item>
|
|
32
|
+
</template>
|
|
33
|
+
<template #footer>
|
|
34
|
+
<view class="u-safe-area-inset--bottom">
|
|
35
|
+
<text class="list__footer"></text>
|
|
36
|
+
</view>
|
|
37
|
+
</template>
|
|
38
|
+
</up-index-list>
|
|
39
|
+
</view>
|
|
40
|
+
</template>
|
|
41
|
+
|
|
42
|
+
<script>
|
|
43
|
+
export default{
|
|
44
|
+
name: 'u-city-locate',
|
|
45
|
+
props:{
|
|
46
|
+
indexList: {
|
|
47
|
+
type: Array,
|
|
48
|
+
default: ['城市']
|
|
49
|
+
},
|
|
50
|
+
hotCity:{
|
|
51
|
+
type: Array,
|
|
52
|
+
default: () => {
|
|
53
|
+
return [
|
|
54
|
+
{
|
|
55
|
+
name: '北京',
|
|
56
|
+
value: 'beijing'
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
name: '上海',
|
|
60
|
+
value: 'shanghai'
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
name: '广州',
|
|
64
|
+
value: 'guangzhou'
|
|
65
|
+
},
|
|
66
|
+
]
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
cityList:{
|
|
70
|
+
type: Array,
|
|
71
|
+
default: () => {
|
|
72
|
+
return [
|
|
73
|
+
[{
|
|
74
|
+
name: '北京',
|
|
75
|
+
value: 'beijing'
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
name: '上海',
|
|
79
|
+
value: 'shanghai'
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
name: '广州',
|
|
83
|
+
value: 'guangzhou'
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
name: '深圳',
|
|
87
|
+
value: 'shenzhen'
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
name: '杭州',
|
|
91
|
+
value: 'hangzhou'
|
|
92
|
+
}]
|
|
93
|
+
]
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
locationType: {
|
|
97
|
+
type: String,
|
|
98
|
+
default: 'wgs84'
|
|
99
|
+
},
|
|
100
|
+
currentCity: {
|
|
101
|
+
type: String,
|
|
102
|
+
default: ''
|
|
103
|
+
},
|
|
104
|
+
nameKey: {
|
|
105
|
+
type: String,
|
|
106
|
+
default: 'name'
|
|
107
|
+
}
|
|
108
|
+
},
|
|
109
|
+
computed:{
|
|
110
|
+
},
|
|
111
|
+
watch:{
|
|
112
|
+
currentCity(val) {
|
|
113
|
+
this.locationCity = val;
|
|
114
|
+
}
|
|
115
|
+
},
|
|
116
|
+
data(){
|
|
117
|
+
return{
|
|
118
|
+
locationCity: '定位中....'
|
|
119
|
+
}
|
|
120
|
+
},
|
|
121
|
+
emits: ['location-success', 'select-city'],
|
|
122
|
+
methods:{
|
|
123
|
+
// 获取城市
|
|
124
|
+
selectedCity(city){
|
|
125
|
+
this.locationCity = city[this.nameKey];
|
|
126
|
+
this.$emit('select-city', {
|
|
127
|
+
locationCity: this.locationCity
|
|
128
|
+
});
|
|
129
|
+
},
|
|
130
|
+
// 定位操作
|
|
131
|
+
location(){
|
|
132
|
+
let That = this;
|
|
133
|
+
uni.getLocation({
|
|
134
|
+
type: this.locationType,
|
|
135
|
+
geocode:true,
|
|
136
|
+
success(res){
|
|
137
|
+
console.log(res);
|
|
138
|
+
That.locationCity = res.address && res.address.city;
|
|
139
|
+
That.$emit('location-success', {
|
|
140
|
+
...res,
|
|
141
|
+
locationCity: That.locationCity
|
|
142
|
+
});
|
|
143
|
+
},
|
|
144
|
+
fail(){
|
|
145
|
+
That.locationCity = "定位失败,请点击重试"
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
},
|
|
149
|
+
},
|
|
150
|
+
// 页面挂载后进行异步操作
|
|
151
|
+
created(){
|
|
152
|
+
},
|
|
153
|
+
mounted(){
|
|
154
|
+
this.location();
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
</script>
|
|
158
|
+
|
|
159
|
+
<style lang="scss">
|
|
160
|
+
.list__item {
|
|
161
|
+
padding: 8px 1px;
|
|
162
|
+
}
|
|
163
|
+
.u-current-city-title {
|
|
164
|
+
color: grey;
|
|
165
|
+
margin-bottom: 5px;
|
|
166
|
+
}
|
|
167
|
+
.u-current-city-item {
|
|
168
|
+
height: 30px;
|
|
169
|
+
}
|
|
170
|
+
.hot-city-list {
|
|
171
|
+
display: flex !important;
|
|
172
|
+
flex-direction: row !important;
|
|
173
|
+
padding: 12px 0;
|
|
174
|
+
.hot-city-item {
|
|
175
|
+
padding: 6px 12px;
|
|
176
|
+
margin: 5px;
|
|
177
|
+
border: 1px solid #ededed;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
</style>
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
fontSize: addUnit(size),
|
|
18
18
|
color: color
|
|
19
19
|
}"
|
|
20
|
-
>{{ text }}</text>
|
|
20
|
+
>{{ text.name || text }}</text>
|
|
21
21
|
</view>
|
|
22
22
|
<!-- #ifdef APP-NVUE -->
|
|
23
23
|
</header>
|
|
@@ -70,7 +70,11 @@
|
|
|
70
70
|
return error('u-index-anchor必须要搭配u-index-item组件使用')
|
|
71
71
|
}
|
|
72
72
|
// 设置u-index-item的id为anchor的text标识符,因为非nvue下滚动列表需要依赖scroll-view滚动到元素的特性
|
|
73
|
-
|
|
73
|
+
if (typeof this.text == 'string') {
|
|
74
|
+
indexListItem.id = this.text.charCodeAt(0)
|
|
75
|
+
} else {
|
|
76
|
+
indexListItem.id = this.text.name.charCodeAt(0)
|
|
77
|
+
}
|
|
74
78
|
// #endif
|
|
75
79
|
}
|
|
76
80
|
},
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
<text
|
|
67
67
|
class="u-index-list__letter__item__index"
|
|
68
68
|
:style="{color: activeIndex === index ? '#fff' : inactiveColor}"
|
|
69
|
-
>{{ item }}</text>
|
|
69
|
+
>{{ item.key || item }}</text>
|
|
70
70
|
</view>
|
|
71
71
|
</view>
|
|
72
72
|
<u-transition
|
|
@@ -87,7 +87,7 @@
|
|
|
87
87
|
width: addUnit(indicatorHeight)
|
|
88
88
|
}"
|
|
89
89
|
>
|
|
90
|
-
<text class="u-index-list__indicator__text">{{ uIndexList[activeIndex] }}</text>
|
|
90
|
+
<text class="u-index-list__indicator__text">{{ uIndexList[activeIndex].key || uIndexList[activeIndex] }}</text>
|
|
91
91
|
</view>
|
|
92
92
|
</u-transition>
|
|
93
93
|
</view>
|
|
@@ -392,7 +392,11 @@
|
|
|
392
392
|
this.$emit('select', this.uIndexList[currentIndex])
|
|
393
393
|
// #ifndef APP-NVUE || MP-WEIXIN
|
|
394
394
|
// 在非nvue中,由于anchor和item都在u-index-item中,所以需要对index-item进行偏移
|
|
395
|
-
|
|
395
|
+
if (typeof this.uIndexList[currentIndex] == 'string') {
|
|
396
|
+
this.scrollIntoView = `u-index-item-${this.uIndexList[currentIndex].charCodeAt(0)}`
|
|
397
|
+
} else {
|
|
398
|
+
this.scrollIntoView = `u-index-item-${this.uIndexList[currentIndex].name.charCodeAt(0)}`
|
|
399
|
+
}
|
|
396
400
|
// #endif
|
|
397
401
|
|
|
398
402
|
// #ifdef MP-WEIXIN
|
package/package.json
CHANGED