uview-plus 3.4.54 → 3.4.56

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
@@ -1,3 +1,11 @@
1
+ ## 3.4.56(2025-07-21)
2
+ fix: 去除多余hotCity参数
3
+
4
+ ## 3.4.55(2025-07-21)
5
+ feat: 新增city-locate城市定位选择组件
6
+
7
+ feat: 优化index-list组件索引
8
+
1
9
  ## 3.4.54(2025-07-18)
2
10
  feat: dropdown组件的highlight方法支持同时高亮多个菜单项
3
11
 
@@ -0,0 +1,161 @@
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
+ cityList:{
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
+ name: '深圳',
68
+ value: 'shenzhen'
69
+ },
70
+ {
71
+ name: '杭州',
72
+ value: 'hangzhou'
73
+ }]
74
+ ]
75
+ }
76
+ },
77
+ locationType: {
78
+ type: String,
79
+ default: 'wgs84'
80
+ },
81
+ currentCity: {
82
+ type: String,
83
+ default: ''
84
+ },
85
+ nameKey: {
86
+ type: String,
87
+ default: 'name'
88
+ }
89
+ },
90
+ computed:{
91
+ },
92
+ watch:{
93
+ currentCity(val) {
94
+ this.locationCity = val;
95
+ }
96
+ },
97
+ data(){
98
+ return{
99
+ locationCity: '定位中....'
100
+ }
101
+ },
102
+ emits: ['location-success', 'select-city'],
103
+ methods:{
104
+ // 获取城市
105
+ selectedCity(city){
106
+ this.locationCity = city[this.nameKey];
107
+ this.$emit('select-city', {
108
+ locationCity: this.locationCity
109
+ });
110
+ },
111
+ // 定位操作
112
+ location(){
113
+ let That = this;
114
+ uni.getLocation({
115
+ type: this.locationType,
116
+ geocode:true,
117
+ success(res){
118
+ console.log(res);
119
+ That.locationCity = res.address && res.address.city;
120
+ That.$emit('location-success', {
121
+ ...res,
122
+ locationCity: That.locationCity
123
+ });
124
+ },
125
+ fail(){
126
+ That.locationCity = "定位失败,请点击重试"
127
+ }
128
+ });
129
+ },
130
+ },
131
+ // 页面挂载后进行异步操作
132
+ created(){
133
+ },
134
+ mounted(){
135
+ this.location();
136
+ }
137
+ }
138
+ </script>
139
+
140
+ <style lang="scss">
141
+ .list__item {
142
+ padding: 8px 1px;
143
+ }
144
+ .u-current-city-title {
145
+ color: grey;
146
+ margin-bottom: 5px;
147
+ }
148
+ .u-current-city-item {
149
+ height: 30px;
150
+ }
151
+ .hot-city-list {
152
+ display: flex !important;
153
+ flex-direction: row !important;
154
+ padding: 12px 0;
155
+ .hot-city-item {
156
+ padding: 6px 12px;
157
+ margin: 5px;
158
+ border: 1px solid #ededed;
159
+ }
160
+ }
161
+ </style>
@@ -13,7 +13,7 @@ export default {
13
13
  text: '',
14
14
  color: '#606266',
15
15
  size: 14,
16
- bgColor: '#dedede',
16
+ bgColor: '#f1f1f1',
17
17
  height: 32
18
18
  }
19
19
  }
@@ -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
- indexListItem.id = this.text.charCodeAt(0)
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
- this.scrollIntoView = `u-index-item-${this.uIndexList[currentIndex].charCodeAt(0)}`
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
@@ -2,7 +2,7 @@
2
2
  "id": "uview-plus",
3
3
  "name": "uview-plus",
4
4
  "displayName": "零云®uview-plus3.0重磅发布,全面的Vue3鸿蒙移动组件库。",
5
- "version": "3.4.54",
5
+ "version": "3.4.56",
6
6
  "description": "零云®uview-plus已兼容vue3,全面的组件和便捷的工具会让您信手拈来,如鱼得水。",
7
7
  "keywords": [
8
8
  "uview",