@10yun/cv-mobile-ui 0.5.30 → 0.5.32
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/package.json +5 -1
- package/ui-cv/components/cv-btn-base/cv-btn-base.vue +1 -1
- package/uview-plus/README.md +1 -1
- package/uview-plus/components/u-action-sheet/u-action-sheet.vue +8 -8
- package/uview-plus/components/u-album/u-album.vue +1 -1
- package/uview-plus/components/u-alert/u-alert.vue +5 -5
- package/uview-plus/components/u-app-update/u-app-update.vue +2 -2
- package/uview-plus/components/u-avatar/u-avatar.vue +2 -2
- package/uview-plus/components/u-avatar-group/u-avatar-group.vue +79 -3
- package/uview-plus/components/u-back-top/u-back-top.vue +4 -4
- package/uview-plus/components/u-badge/u-badge.vue +1 -1
- package/uview-plus/components/u-button/u-button.vue +8 -8
- package/uview-plus/components/u-button-wu/u-button-wu.vue +9 -9
- package/uview-plus/components/u-calendar/u-calendar.vue +5 -6
- package/uview-plus/components/u-car-keyboard/u-car-keyboard.vue +2 -2
- package/uview-plus/components/u-card/u-card.vue +139 -3
- package/uview-plus/components/u-cell/u-cell.vue +4 -4
- package/uview-plus/components/u-cell-group/u-cell-group.vue +2 -2
- package/uview-plus/components/u-checkbox/u-checkbox.vue +4 -4
- package/uview-plus/components/u-checkbox-group/u-checkbox-group.vue +1 -1
- package/uview-plus/components/u-code/u-code.vue +1 -1
- package/uview-plus/components/u-code-input/u-code-input.vue +1 -1
- package/uview-plus/components/u-col/u-col.vue +1 -1
- package/uview-plus/components/u-collapse/u-collapse.vue +2 -2
- package/uview-plus/components/u-collapse-item/u-collapse-item.vue +218 -3
- package/uview-plus/components/u-column-notice/u-column-notice.vue +3 -3
- package/uview-plus/components/u-copy/u-copy.vue +68 -1
- package/uview-plus/components/u-count-down/u-count-down.vue +1 -1
- package/uview-plus/components/u-count-to/u-count-to.vue +1 -1
- package/uview-plus/components/u-datetime-picker/u-datetime-picker.vue +3 -3
- package/uview-plus/components/u-divider/u-divider.vue +3 -3
- package/uview-plus/components/u-dropdown/u-dropdown.vue +3 -3
- package/uview-plus/components/u-dropdown-item/u-dropdown-item.vue +1 -1
- package/uview-plus/components/u-empty/u-empty.vue +3 -3
- package/uview-plus/components/u-form/u-form.vue +243 -1
- package/uview-plus/components/u-form-item/u-form-item.vue +4 -4
- package/uview-plus/components/u-gap/u-gap.vue +1 -1
- package/uview-plus/components/u-grid/u-grid.vue +1 -1
- package/uview-plus/components/u-grid-item/u-grid-item.vue +1 -1
- package/uview-plus/components/u-icon/u-icon.vue +1 -1
- package/uview-plus/components/u-icon/u-icon2.vue +1 -1
- package/uview-plus/components/u-image/u-image.vue +5 -5
- package/uview-plus/components/u-image-wu/u-image-wu.vue +5 -5
- package/uview-plus/components/u-index-anchor/u-index-anchor.vue +1 -1
- package/uview-plus/components/u-index-list/u-index-list.vue +2 -2
- package/uview-plus/components/u-input/u-input.vue +4 -4
- package/uview-plus/components/u-keyboard/u-keyboard.vue +6 -6
- package/uview-plus/components/u-lazy-load/u-lazy-load.vue +257 -3
- package/uview-plus/components/u-line/u-line.vue +1 -1
- package/uview-plus/components/u-line-progress/u-line-progress.vue +1 -1
- package/uview-plus/components/u-link/u-link.vue +1 -1
- package/uview-plus/components/u-list/u-list.vue +1 -1
- package/uview-plus/components/u-list-item/u-list-item.vue +1 -1
- package/uview-plus/components/u-loading-icon/u-loading-icon.vue +191 -3
- package/uview-plus/components/u-loading-page/u-loading-page.vue +4 -4
- package/uview-plus/components/u-loadmore/u-loadmore.vue +4 -4
- package/uview-plus/components/u-mask/u-mask.vue +120 -113
- package/uview-plus/components/u-message-input/u-message-input.vue +1 -1
- package/uview-plus/components/u-modal/u-modal.vue +6 -6
- package/uview-plus/components/u-navbar/u-navbar.vue +4 -4
- package/uview-plus/components/u-navbar-mini/u-navbar-mini.vue +2 -2
- package/uview-plus/components/u-navbar-wu/u-navbar-wu.vue +4 -4
- package/uview-plus/components/u-no-network/u-no-network.vue +5 -5
- package/uview-plus/components/u-notice-bar/u-notice-bar.vue +5 -5
- package/uview-plus/components/u-notify/u-notify.vue +6 -6
- package/uview-plus/components/u-number-box/u-number-box.vue +9 -3
- package/uview-plus/components/u-number-keyboard/u-number-keyboard.vue +1 -1
- package/uview-plus/components/u-overlay/u-overlay.vue +3 -3
- package/uview-plus/components/u-picker/u-picker.vue +5 -5
- package/uview-plus/components/u-popup/u-popup.vue +8 -8
- package/uview-plus/components/u-popup-wu/u-popup-wu.vue +7 -7
- package/uview-plus/components/u-qrcode/u-qrcode.vue +275 -3
- package/uview-plus/components/u-radio/u-radio.vue +4 -4
- package/uview-plus/components/u-radio-group/u-radio-group.vue +1 -1
- package/uview-plus/components/u-rate/u-rate.vue +5 -5
- package/uview-plus/components/u-read-more/u-read-more.vue +126 -3
- package/uview-plus/components/u-row/u-row.vue +1 -1
- package/uview-plus/components/u-row-notice/u-row-notice.vue +3 -3
- package/uview-plus/components/u-safe-bottom/u-safe-bottom.vue +48 -3
- package/uview-plus/components/u-search/u-search.vue +4 -4
- package/uview-plus/components/u-select/u-select.vue +175 -3
- package/uview-plus/components/u-skeleton/u-skeleton.vue +3 -3
- package/uview-plus/components/u-sku-wu/u-sku-wu.vue +4 -4
- package/uview-plus/components/u-status-bar/u-status-bar.vue +1 -1
- package/uview-plus/components/u-steps/u-steps.vue +1 -1
- package/uview-plus/components/u-steps-item/u-steps-item.vue +7 -7
- package/uview-plus/components/u-sticky/u-sticky.vue +1 -1
- package/uview-plus/components/u-subsection/u-subsection.vue +1 -1
- package/uview-plus/components/u-swipe-action/u-swipe-action.vue +1 -1
- package/uview-plus/components/u-swipe-action-item/u-swipe-action-item.vue +3 -3
- package/uview-plus/components/u-swiper/u-swiper.vue +1 -1
- package/uview-plus/components/u-swiper-indicator/u-swiper-indicator.vue +1 -1
- package/uview-plus/components/u-switch/u-switch.vue +2 -2
- package/uview-plus/components/u-tabbar/u-tabbar.vue +2 -2
- package/uview-plus/components/u-tabbar-item/u-tabbar-item.vue +9 -4
- package/uview-plus/components/u-table/u-table.vue +1 -1
- package/uview-plus/components/u-tabs/u-tabs.vue +3 -3
- package/uview-plus/components/u-tag/u-tag.vue +5 -5
- package/uview-plus/components/u-text/u-text.vue +159 -3
- package/uview-plus/components/u-toast/u-toast.vue +8 -8
- package/uview-plus/components/u-tooltip/u-tooltip.vue +6 -6
- package/uview-plus/components/u-upload/u-upload.vue +10 -10
- package/uview-plus/components/u-waterfall/u-waterfall.vue +221 -3
- package/uview-plus/index.js +4 -2
- package/uview-plus/libs/ctocode/image.js +17 -0
- package/uview-plus/libs/ctocode/index.js +150 -0
- package/uview-plus/libs/ctocode/map.js +38 -0
- package/uview-plus/libs/function/index-wu.js +6 -34
- package/uview-plus/package.json +3 -3
- package/uview-plus/readme-wu.md +1 -1
- package/uview-plus/libs/function/cc.js +0 -66
|
@@ -1,3 +1,221 @@
|
|
|
1
|
-
<template>
|
|
2
1
|
<view class="u-waterfall">
|
|
3
2
|
<view ref="u-left-column" id="u-left-column" class="u-column">
|
|
4
3
|
<slot name="left" :leftList="leftList"></slot>
|
|
5
4
|
</view>
|
|
6
5
|
<view ref="u-right-column" id="u-right-column" class="u-column">
|
|
7
6
|
<slot name="right" :rightList="rightList"></slot>
|
|
8
7
|
</view>
|
|
9
8
|
</view>
|
|
10
9
|
* waterfall 瀑布流
|
|
11
10
|
* @description 这是一个瀑布流形式的组件,内容分为左右两列,结合uview的懒加载组件效果更佳。相较于某些只是奇偶数左右分别,或者没有利用vue作用域插槽的做法,uview的瀑布流实现了真正的 组件化,搭配LazyLoad 懒加载和loadMore 加载更多组件,让您开箱即用,眼前一亮。
|
|
12
11
|
* @tutorial https://uview-plus.jiangruyi.com/components/waterfall.html
|
|
13
12
|
* @property {Array} flow-list 用于渲染的数据
|
|
14
13
|
* @property {String Number} add-time 单条数据添加到队列的时间间隔,单位ms,见上方注意事项说明(默认200)
|
|
15
14
|
* @example <u-waterfall :flowList="flowList"></u-waterfall>
|
|
16
15
|
*/
|
|
17
16
|
name: 'u-waterfall',
|
|
18
17
|
props: {
|
|
19
18
|
// #ifdef VUE2
|
|
20
19
|
value: {
|
|
21
20
|
// 瀑布流数据
|
|
22
21
|
type: Array,
|
|
23
22
|
required: true,
|
|
24
23
|
default: function () {
|
|
25
24
|
return [];
|
|
26
25
|
}
|
|
27
26
|
},
|
|
28
27
|
// #endif
|
|
29
28
|
// #ifdef VUE3
|
|
30
29
|
modelValue: {
|
|
31
30
|
// 瀑布流数据
|
|
32
31
|
type: Array,
|
|
33
32
|
required: true,
|
|
34
33
|
default: function () {
|
|
35
34
|
return [];
|
|
36
35
|
}
|
|
37
36
|
},
|
|
38
37
|
// #endif
|
|
39
38
|
// 每次向结构插入数据的时间间隔,间隔越长,越能保证两列高度相近,但是对用户体验越不好
|
|
40
39
|
// 单位ms
|
|
41
40
|
addTime: {
|
|
42
41
|
type: [Number, String],
|
|
43
42
|
default: 200
|
|
44
43
|
},
|
|
45
44
|
// id值,用于清除某一条数据时,根据此idKey名称找到并移除,如数据为{idx: 22, name: 'lisa'}
|
|
46
45
|
// 那么该把idKey设置为idx
|
|
47
46
|
idKey: {
|
|
48
47
|
type: String,
|
|
49
48
|
default: 'id'
|
|
50
49
|
}
|
|
51
50
|
},
|
|
52
51
|
mixins: [mpMixin, mixin],
|
|
53
52
|
data() {
|
|
54
53
|
return {
|
|
55
54
|
leftList: [],
|
|
56
55
|
rightList: [],
|
|
57
56
|
tempList: [],
|
|
58
57
|
children: []
|
|
59
58
|
};
|
|
60
59
|
},
|
|
61
60
|
watch: {
|
|
62
61
|
copyFlowList(nVal, oVal) {
|
|
63
62
|
if (!nVal || nVal.length == 0) {
|
|
64
63
|
this.clear(false);
|
|
65
64
|
// console.log('clear');
|
|
66
65
|
} else {
|
|
67
66
|
// 取差值,即这一次数组变化新增的部分
|
|
68
67
|
let startIndex = Array.isArray(oVal) && oVal.length > 0 ? oVal.length : 0;
|
|
69
68
|
// 拼接上原有数据
|
|
70
69
|
this.tempList = this.tempList.concat(this.cloneData(nVal.slice(startIndex)));
|
|
71
70
|
this.splitData();
|
|
72
71
|
}
|
|
73
72
|
}
|
|
74
73
|
},
|
|
75
74
|
mounted() {
|
|
76
75
|
this.tempList = this.cloneData(this.copyFlowList);
|
|
77
76
|
this.splitData();
|
|
78
77
|
},
|
|
79
78
|
computed: {
|
|
80
79
|
// 破坏flowList变量的引用,否则watch的结果新旧值是一样的
|
|
81
80
|
copyFlowList() {
|
|
82
81
|
// #ifdef VUE3
|
|
83
82
|
if (!this.modelValue || this.modelValue.length == 0) {
|
|
84
83
|
this.clear(false);
|
|
85
84
|
// console.log('clear');
|
|
86
85
|
return [];
|
|
87
86
|
} else {
|
|
88
87
|
return this.cloneData(this.modelValue);
|
|
89
88
|
}
|
|
90
89
|
// #endif
|
|
91
90
|
// #ifdef VUE2
|
|
92
91
|
return this.cloneData(this.value);
|
|
93
92
|
// #endif
|
|
94
93
|
}
|
|
95
94
|
},
|
|
96
95
|
emits: ['update:modelValue'],
|
|
97
96
|
methods: {
|
|
98
97
|
async splitData() {
|
|
99
98
|
if (!this.tempList.length) return;
|
|
100
99
|
let leftRect = await this.$uGetRect('#u-left-column');
|
|
101
100
|
let rightRect = await this.$uGetRect('#u-right-column');
|
|
102
101
|
// 如果左边小于或等于右边,就添加到左边,否则添加到右边
|
|
103
102
|
let item = this.tempList[0];
|
|
104
103
|
// 解决多次快速上拉后,可能数据会乱的问题,因为经过上面的两个await节点查询阻塞一定时间,加上后面的定时器干扰
|
|
105
104
|
// 数组可能变成[],导致此item值可能为undefined
|
|
106
105
|
if (!item) return;
|
|
107
106
|
if (leftRect.height < rightRect.height) {
|
|
108
107
|
this.leftList.push(item);
|
|
109
108
|
} else if (leftRect.height > rightRect.height) {
|
|
110
109
|
this.rightList.push(item);
|
|
111
110
|
} else {
|
|
112
111
|
// 这里是为了保证第一和第二张添加时,左右都能有内容
|
|
113
112
|
// 因为添加第一张,实际队列的高度可能还是0,这时需要根据队列元素长度判断下一个该放哪边
|
|
114
113
|
if (this.leftList.length <= this.rightList.length) {
|
|
115
114
|
this.leftList.push(item);
|
|
116
115
|
} else {
|
|
117
116
|
this.rightList.push(item);
|
|
118
117
|
}
|
|
119
118
|
}
|
|
120
119
|
// 移除临时列表的第一项
|
|
121
120
|
this.tempList.splice(0, 1);
|
|
122
121
|
// 如果临时数组还有数据,继续循环
|
|
123
122
|
if (this.tempList.length) {
|
|
124
123
|
setTimeout(() => {
|
|
125
124
|
this.splitData();
|
|
126
125
|
}, this.addTime);
|
|
127
126
|
}
|
|
128
127
|
},
|
|
129
128
|
// 复制而不是引用对象和数组
|
|
130
129
|
cloneData(data) {
|
|
131
130
|
return JSON.parse(JSON.stringify(data));
|
|
132
131
|
},
|
|
133
132
|
// 清空数据列表
|
|
134
133
|
clear(bak = true) {
|
|
135
134
|
this.leftList = [];
|
|
136
135
|
this.rightList = [];
|
|
137
136
|
// 同时清除父组件列表中的数据
|
|
138
137
|
if (bak) {
|
|
139
138
|
// #ifdef VUE2
|
|
140
139
|
this.$emit('input', []);
|
|
141
140
|
// #endif
|
|
142
141
|
// #ifdef VUE3
|
|
143
142
|
this.$emit('update:modelValue', []);
|
|
144
143
|
// #endif
|
|
145
144
|
}
|
|
146
145
|
this.tempList = [];
|
|
147
146
|
},
|
|
148
147
|
// 清除某一条指定的数据,根据id实现
|
|
149
148
|
remove(id) {
|
|
150
149
|
// 如果findIndex找不到合适的条件,就会返回-1
|
|
151
150
|
let index = -1;
|
|
152
151
|
index = this.leftList.findIndex((val) => val[this.idKey] == id);
|
|
153
152
|
if (index != -1) {
|
|
154
153
|
// 如果index不等于-1,说明已经找到了要找的id,根据index索引删除这一条数据
|
|
155
154
|
this.leftList.splice(index, 1);
|
|
156
155
|
} else {
|
|
157
156
|
// 同理于上方面的方法
|
|
158
157
|
index = this.rightList.findIndex((val) => val[this.idKey] == id);
|
|
159
158
|
if (index != -1) this.rightList.splice(index, 1);
|
|
160
159
|
}
|
|
161
160
|
// 同时清除父组件的数据中的对应id的条目
|
|
162
161
|
// #ifdef VUE2
|
|
163
162
|
index = this.value.findIndex((val) => val[this.idKey] == id);
|
|
164
163
|
if (index != -1) this.$emit('input', this.value.splice(index, 1));
|
|
165
164
|
// #endif
|
|
166
165
|
// #ifdef VUE3
|
|
167
166
|
index = this.modelValue.findIndex((val) => val[this.idKey] == id);
|
|
168
167
|
if (index != -1) this.$emit('update:modelValue', this.modelValue.splice(index, 1));
|
|
169
168
|
// #endif
|
|
170
169
|
},
|
|
171
170
|
// 修改某条数据的某个属性
|
|
172
171
|
modify(id, key, value) {
|
|
173
172
|
// 如果findIndex找不到合适的条件,就会返回-1
|
|
174
173
|
let index = -1;
|
|
175
174
|
index = this.leftList.findIndex((val) => val[this.idKey] == id);
|
|
176
175
|
if (index != -1) {
|
|
177
176
|
// 如果index不等于-1,说明已经找到了要找的id,修改对应key的值
|
|
178
177
|
this.leftList[index][key] = value;
|
|
179
178
|
} else {
|
|
180
179
|
// 同理于上方面的方法
|
|
181
180
|
index = this.rightList.findIndex((val) => val[this.idKey] == id);
|
|
182
181
|
if (index != -1) this.rightList[index][key] = value;
|
|
183
182
|
}
|
|
184
183
|
// 修改父组件的数据中的对应id的条目
|
|
185
184
|
// #ifdef VUE2
|
|
186
185
|
index = this.value.findIndex((val) => val[this.idKey] == id);
|
|
187
186
|
// #endif
|
|
188
187
|
// #ifdef VUE3
|
|
189
188
|
index = this.modelValue.findIndex((val) => val[this.idKey] == id);
|
|
190
189
|
// #endif
|
|
191
190
|
if (index != -1) {
|
|
192
191
|
// 首先复制一份value的数据
|
|
193
192
|
// #ifdef VUE2
|
|
194
193
|
let data = this.cloneData(this.value);
|
|
195
194
|
// #endif
|
|
196
195
|
// #ifdef VUE3
|
|
197
196
|
let data = this.cloneData(this.modelValue);
|
|
198
197
|
// #endif
|
|
199
198
|
// 修改对应索引的key属性的值为value
|
|
200
199
|
data[index][key] = value;
|
|
201
200
|
// 修改父组件通过v-model绑定的变量的值
|
|
202
201
|
// #ifdef VUE2
|
|
203
202
|
this.$emit('input', data);
|
|
204
203
|
// #endif
|
|
205
204
|
// #ifdef VUE3
|
|
206
205
|
this.$emit('update:modelValue', data);
|
|
207
206
|
// #endif
|
|
208
207
|
}
|
|
209
208
|
}
|
|
210
209
|
}
|
|
211
|
-
|
|
212
|
-
|
|
210
|
+
<template>
|
|
211
|
+
<view class="u-waterfall">
|
|
212
|
+
<view ref="u-left-column" id="u-left-column" class="u-column">
|
|
213
|
+
<slot name="left" :leftList="leftList"></slot>
|
|
214
|
+
</view>
|
|
215
|
+
<view ref="u-right-column" id="u-right-column" class="u-column">
|
|
216
|
+
<slot name="right" :rightList="rightList"></slot>
|
|
217
|
+
</view>
|
|
218
|
+
</view>
|
|
219
|
+
</template>
|
|
220
|
+
<script>
|
|
221
|
+
/**
|
|
222
|
+
* waterfall 瀑布流
|
|
223
|
+
* @description 这是一个瀑布流形式的组件,内容分为左右两列,结合uview的懒加载组件效果更佳。相较于某些只是奇偶数左右分别,或者没有利用vue作用域插槽的做法,uview的瀑布流实现了真正的 组件化,搭配LazyLoad 懒加载和loadMore 加载更多组件,让您开箱即用,眼前一亮。
|
|
224
|
+
* @tutorial https://uview-plus.jiangruyi.com/components/waterfall.html
|
|
225
|
+
* @property {Array} flow-list 用于渲染的数据
|
|
226
|
+
* @property {String Number} add-time 单条数据添加到队列的时间间隔,单位ms,见上方注意事项说明(默认200)
|
|
227
|
+
* @example <up-waterfall :flowList="flowList"></up-waterfall>
|
|
228
|
+
*/
|
|
229
|
+
import { mpMixin } from '../../libs/mixin/mpMixin';
|
|
230
|
+
import { mixin } from '../../libs/mixin/mixin';
|
|
231
|
+
export default {
|
|
232
|
+
name: 'u-waterfall',
|
|
233
|
+
props: {
|
|
234
|
+
// #ifdef VUE2
|
|
235
|
+
value: {
|
|
236
|
+
// 瀑布流数据
|
|
237
|
+
type: Array,
|
|
238
|
+
required: true,
|
|
239
|
+
default: function () {
|
|
240
|
+
return [];
|
|
241
|
+
}
|
|
242
|
+
},
|
|
243
|
+
// #endif
|
|
244
|
+
// #ifdef VUE3
|
|
245
|
+
modelValue: {
|
|
246
|
+
// 瀑布流数据
|
|
247
|
+
type: Array,
|
|
248
|
+
required: true,
|
|
249
|
+
default: function () {
|
|
250
|
+
return [];
|
|
251
|
+
}
|
|
252
|
+
},
|
|
253
|
+
// #endif
|
|
254
|
+
// 每次向结构插入数据的时间间隔,间隔越长,越能保证两列高度相近,但是对用户体验越不好
|
|
255
|
+
// 单位ms
|
|
256
|
+
addTime: {
|
|
257
|
+
type: [Number, String],
|
|
258
|
+
default: 200
|
|
259
|
+
},
|
|
260
|
+
// id值,用于清除某一条数据时,根据此idKey名称找到并移除,如数据为{idx: 22, name: 'lisa'}
|
|
261
|
+
// 那么该把idKey设置为idx
|
|
262
|
+
idKey: {
|
|
263
|
+
type: String,
|
|
264
|
+
default: 'id'
|
|
265
|
+
}
|
|
266
|
+
},
|
|
267
|
+
mixins: [mpMixin, mixin],
|
|
268
|
+
data() {
|
|
269
|
+
return {
|
|
270
|
+
leftList: [],
|
|
271
|
+
rightList: [],
|
|
272
|
+
tempList: [],
|
|
273
|
+
children: []
|
|
274
|
+
};
|
|
275
|
+
},
|
|
276
|
+
watch: {
|
|
277
|
+
copyFlowList(nVal, oVal) {
|
|
278
|
+
if (!nVal || nVal.length == 0) {
|
|
279
|
+
this.clear(false);
|
|
280
|
+
// console.log('clear');
|
|
281
|
+
} else {
|
|
282
|
+
// 取差值,即这一次数组变化新增的部分
|
|
283
|
+
let startIndex = Array.isArray(oVal) && oVal.length > 0 ? oVal.length : 0;
|
|
284
|
+
// 拼接上原有数据
|
|
285
|
+
this.tempList = this.tempList.concat(this.cloneData(nVal.slice(startIndex)));
|
|
286
|
+
this.splitData();
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
},
|
|
290
|
+
mounted() {
|
|
291
|
+
this.tempList = this.cloneData(this.copyFlowList);
|
|
292
|
+
this.splitData();
|
|
293
|
+
},
|
|
294
|
+
computed: {
|
|
295
|
+
// 破坏flowList变量的引用,否则watch的结果新旧值是一样的
|
|
296
|
+
copyFlowList() {
|
|
297
|
+
// #ifdef VUE3
|
|
298
|
+
if (!this.modelValue || this.modelValue.length == 0) {
|
|
299
|
+
this.clear(false);
|
|
300
|
+
// console.log('clear');
|
|
301
|
+
return [];
|
|
302
|
+
} else {
|
|
303
|
+
return this.cloneData(this.modelValue);
|
|
304
|
+
}
|
|
305
|
+
// #endif
|
|
306
|
+
// #ifdef VUE2
|
|
307
|
+
return this.cloneData(this.value);
|
|
308
|
+
// #endif
|
|
309
|
+
}
|
|
310
|
+
},
|
|
311
|
+
emits: ['update:modelValue'],
|
|
312
|
+
methods: {
|
|
313
|
+
async splitData() {
|
|
314
|
+
if (!this.tempList.length) return;
|
|
315
|
+
let leftRect = await this.$uGetRect('#u-left-column');
|
|
316
|
+
let rightRect = await this.$uGetRect('#u-right-column');
|
|
317
|
+
// 如果左边小于或等于右边,就添加到左边,否则添加到右边
|
|
318
|
+
let item = this.tempList[0];
|
|
319
|
+
// 解决多次快速上拉后,可能数据会乱的问题,因为经过上面的两个await节点查询阻塞一定时间,加上后面的定时器干扰
|
|
320
|
+
// 数组可能变成[],导致此item值可能为undefined
|
|
321
|
+
if (!item) return;
|
|
322
|
+
if (leftRect.height < rightRect.height) {
|
|
323
|
+
this.leftList.push(item);
|
|
324
|
+
} else if (leftRect.height > rightRect.height) {
|
|
325
|
+
this.rightList.push(item);
|
|
326
|
+
} else {
|
|
327
|
+
// 这里是为了保证第一和第二张添加时,左右都能有内容
|
|
328
|
+
// 因为添加第一张,实际队列的高度可能还是0,这时需要根据队列元素长度判断下一个该放哪边
|
|
329
|
+
if (this.leftList.length <= this.rightList.length) {
|
|
330
|
+
this.leftList.push(item);
|
|
331
|
+
} else {
|
|
332
|
+
this.rightList.push(item);
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
// 移除临时列表的第一项
|
|
336
|
+
this.tempList.splice(0, 1);
|
|
337
|
+
// 如果临时数组还有数据,继续循环
|
|
338
|
+
if (this.tempList.length) {
|
|
339
|
+
setTimeout(() => {
|
|
340
|
+
this.splitData();
|
|
341
|
+
}, this.addTime);
|
|
342
|
+
}
|
|
343
|
+
},
|
|
344
|
+
// 复制而不是引用对象和数组
|
|
345
|
+
cloneData(data) {
|
|
346
|
+
return JSON.parse(JSON.stringify(data));
|
|
347
|
+
},
|
|
348
|
+
// 清空数据列表
|
|
349
|
+
clear(bak = true) {
|
|
350
|
+
this.leftList = [];
|
|
351
|
+
this.rightList = [];
|
|
352
|
+
// 同时清除父组件列表中的数据
|
|
353
|
+
if (bak) {
|
|
354
|
+
// #ifdef VUE2
|
|
355
|
+
this.$emit('input', []);
|
|
356
|
+
// #endif
|
|
357
|
+
// #ifdef VUE3
|
|
358
|
+
this.$emit('update:modelValue', []);
|
|
359
|
+
// #endif
|
|
360
|
+
}
|
|
361
|
+
this.tempList = [];
|
|
362
|
+
},
|
|
363
|
+
// 清除某一条指定的数据,根据id实现
|
|
364
|
+
remove(id) {
|
|
365
|
+
// 如果findIndex找不到合适的条件,就会返回-1
|
|
366
|
+
let index = -1;
|
|
367
|
+
index = this.leftList.findIndex((val) => val[this.idKey] == id);
|
|
368
|
+
if (index != -1) {
|
|
369
|
+
// 如果index不等于-1,说明已经找到了要找的id,根据index索引删除这一条数据
|
|
370
|
+
this.leftList.splice(index, 1);
|
|
371
|
+
} else {
|
|
372
|
+
// 同理于上方面的方法
|
|
373
|
+
index = this.rightList.findIndex((val) => val[this.idKey] == id);
|
|
374
|
+
if (index != -1) this.rightList.splice(index, 1);
|
|
375
|
+
}
|
|
376
|
+
// 同时清除父组件的数据中的对应id的条目
|
|
377
|
+
// #ifdef VUE2
|
|
378
|
+
index = this.value.findIndex((val) => val[this.idKey] == id);
|
|
379
|
+
if (index != -1) this.$emit('input', this.value.splice(index, 1));
|
|
380
|
+
// #endif
|
|
381
|
+
// #ifdef VUE3
|
|
382
|
+
index = this.modelValue.findIndex((val) => val[this.idKey] == id);
|
|
383
|
+
if (index != -1) this.$emit('update:modelValue', this.modelValue.splice(index, 1));
|
|
384
|
+
// #endif
|
|
385
|
+
},
|
|
386
|
+
// 修改某条数据的某个属性
|
|
387
|
+
modify(id, key, value) {
|
|
388
|
+
// 如果findIndex找不到合适的条件,就会返回-1
|
|
389
|
+
let index = -1;
|
|
390
|
+
index = this.leftList.findIndex((val) => val[this.idKey] == id);
|
|
391
|
+
if (index != -1) {
|
|
392
|
+
// 如果index不等于-1,说明已经找到了要找的id,修改对应key的值
|
|
393
|
+
this.leftList[index][key] = value;
|
|
394
|
+
} else {
|
|
395
|
+
// 同理于上方面的方法
|
|
396
|
+
index = this.rightList.findIndex((val) => val[this.idKey] == id);
|
|
397
|
+
if (index != -1) this.rightList[index][key] = value;
|
|
398
|
+
}
|
|
399
|
+
// 修改父组件的数据中的对应id的条目
|
|
400
|
+
// #ifdef VUE2
|
|
401
|
+
index = this.value.findIndex((val) => val[this.idKey] == id);
|
|
402
|
+
// #endif
|
|
403
|
+
// #ifdef VUE3
|
|
404
|
+
index = this.modelValue.findIndex((val) => val[this.idKey] == id);
|
|
405
|
+
// #endif
|
|
406
|
+
if (index != -1) {
|
|
407
|
+
// 首先复制一份value的数据
|
|
408
|
+
// #ifdef VUE2
|
|
409
|
+
let data = this.cloneData(this.value);
|
|
410
|
+
// #endif
|
|
411
|
+
// #ifdef VUE3
|
|
412
|
+
let data = this.cloneData(this.modelValue);
|
|
413
|
+
// #endif
|
|
414
|
+
// 修改对应索引的key属性的值为value
|
|
415
|
+
data[index][key] = value;
|
|
416
|
+
// 修改父组件通过v-model绑定的变量的值
|
|
417
|
+
// #ifdef VUE2
|
|
418
|
+
this.$emit('input', data);
|
|
419
|
+
// #endif
|
|
420
|
+
// #ifdef VUE3
|
|
421
|
+
this.$emit('update:modelValue', data);
|
|
422
|
+
// #endif
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
};
|
|
427
|
+
</script>
|
|
428
|
+
<style scoped>
|
|
429
|
+
@import './style.css';
|
|
430
|
+
</style>
|
package/uview-plus/index.js
CHANGED
|
@@ -50,7 +50,7 @@ export * from './libs/function/colorGradient.js';
|
|
|
50
50
|
/**
|
|
51
51
|
* 自定义方法
|
|
52
52
|
*/
|
|
53
|
-
import
|
|
53
|
+
import * as ctocode from './libs/ctocode/index.js';
|
|
54
54
|
|
|
55
55
|
/**
|
|
56
56
|
* @description 修改uView内置属性值
|
|
@@ -88,7 +88,7 @@ const $u = {
|
|
|
88
88
|
...index,
|
|
89
89
|
color,
|
|
90
90
|
platform,
|
|
91
|
-
...
|
|
91
|
+
...ctocode
|
|
92
92
|
};
|
|
93
93
|
|
|
94
94
|
export const mount$u = function () {
|
|
@@ -149,10 +149,12 @@ const install = (Vue, upuiParams = '') => {
|
|
|
149
149
|
// 同时挂载到uni和Vue.prototype中
|
|
150
150
|
// $u挂载到uni对象上
|
|
151
151
|
uni.$u = $u;
|
|
152
|
+
uni.$up = $u;
|
|
152
153
|
|
|
153
154
|
// #ifndef APP-NVUE
|
|
154
155
|
// 只有vue,挂载到Vue.prototype才有意义,因为nvue中全局Vue.prototype和Vue.mixin是无效的
|
|
155
156
|
Vue.config.globalProperties.$u = $u;
|
|
157
|
+
Vue.config.globalProperties.$up = $u;
|
|
156
158
|
Vue.mixin(mixin);
|
|
157
159
|
// #endif
|
|
158
160
|
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @action 检测图片协议,主要用于检测海报图片协议。
|
|
3
|
+
* @param {String} imgPath 图片地址。
|
|
4
|
+
*/
|
|
5
|
+
export function checkImgHttp(imgPath) {
|
|
6
|
+
let newPath = '';
|
|
7
|
+
let pathArr = imgPath.split('://');
|
|
8
|
+
// #ifdef H5
|
|
9
|
+
let ishttps = 'https:' == window.location.protocol ? true : false;
|
|
10
|
+
ishttps ? (pathArr[0] = 'https') : (pathArr[0] = 'http');
|
|
11
|
+
// #endif
|
|
12
|
+
// #ifdef MP-WEIXIN
|
|
13
|
+
pathArr[0] = 'https';
|
|
14
|
+
// #endif
|
|
15
|
+
newPath = pathArr.join('://');
|
|
16
|
+
return newPath;
|
|
17
|
+
}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { toast } from '../function/index.js';
|
|
2
|
+
import { colorToRgba } from '../function/colorGradient.js';
|
|
3
|
+
export function cc_toast(title, duration = 1600) {
|
|
4
|
+
toast(title, duration);
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* 判断是否为空
|
|
8
|
+
*/
|
|
9
|
+
export function isAllEmpty(value) {
|
|
10
|
+
switch (typeof value) {
|
|
11
|
+
case 'undefined':
|
|
12
|
+
return true;
|
|
13
|
+
case 'string':
|
|
14
|
+
if (value.replace(/(^[ \t\n\r]*)|([ \t\n\r]*$)/g, '').length == 0) return true;
|
|
15
|
+
break;
|
|
16
|
+
case 'boolean':
|
|
17
|
+
if (!value) return true;
|
|
18
|
+
break;
|
|
19
|
+
case 'number':
|
|
20
|
+
if (value === 0 || isNaN(value)) return true;
|
|
21
|
+
break;
|
|
22
|
+
case 'object':
|
|
23
|
+
if (value === null || value.length === 0) return true;
|
|
24
|
+
for (const i in value) {
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
return true;
|
|
28
|
+
}
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
async function copyToClipboard(text, callSucc, callError) {
|
|
33
|
+
try {
|
|
34
|
+
await navigator.clipboard.writeText(text);
|
|
35
|
+
console.log('文本已复制到剪贴板');
|
|
36
|
+
callSucc('复制成功');
|
|
37
|
+
return true;
|
|
38
|
+
} catch (err) {
|
|
39
|
+
console.error('无法复制文本: ', err);
|
|
40
|
+
callError('复制失败');
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* 拨打电话
|
|
46
|
+
* @param {Number} phone
|
|
47
|
+
*/
|
|
48
|
+
export function cc_call_phone(phone) {
|
|
49
|
+
let phoneStr = phone.toString();
|
|
50
|
+
uni.makePhoneCall({
|
|
51
|
+
phoneNumber: phoneStr,
|
|
52
|
+
fail(err) {
|
|
53
|
+
console.log('makePhoneCall出错', err);
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* 复制
|
|
59
|
+
* @param {*} param0
|
|
60
|
+
*/
|
|
61
|
+
// export function cc_copy(content, callback) {
|
|
62
|
+
export function cc_copy(data) {
|
|
63
|
+
if (typeof data == 'string') {
|
|
64
|
+
uni.setClipboardData({
|
|
65
|
+
data: data,
|
|
66
|
+
success: () => {
|
|
67
|
+
cc_toast('复制成功');
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
} else if (typeof data == 'object') {
|
|
71
|
+
let { content, success, error } = data;
|
|
72
|
+
console.log(content);
|
|
73
|
+
content = typeof content === 'string' ? content : content.toString(); // 复制内容,必须字符串,数字需要转换为字符串
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* 小程序端 和 app端的复制逻辑
|
|
77
|
+
*/
|
|
78
|
+
//#ifndef H5
|
|
79
|
+
uni.setClipboardData({
|
|
80
|
+
data: content,
|
|
81
|
+
success: function () {
|
|
82
|
+
success && success('复制成功');
|
|
83
|
+
console.log('success');
|
|
84
|
+
},
|
|
85
|
+
fail: function () {
|
|
86
|
+
success && success('复制失败');
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
//#endif
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* H5端的复制逻辑
|
|
93
|
+
*/
|
|
94
|
+
// #ifdef H5
|
|
95
|
+
copyToClipboard(content, success, error);
|
|
96
|
+
// #endif
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* px转rpx
|
|
102
|
+
*/
|
|
103
|
+
export function cc_pxToRpx() {
|
|
104
|
+
let scale = uni.upx2px(100) / 100;
|
|
105
|
+
return px / scale;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
*
|
|
109
|
+
* @param {*} rgba
|
|
110
|
+
* @returns
|
|
111
|
+
*/
|
|
112
|
+
export function cc_rgbaToRgb(rgba) {
|
|
113
|
+
if (rgba && rgba.startsWith('rgba')) {
|
|
114
|
+
// 检查输入是否为合法的RGBA格式
|
|
115
|
+
const rgbaValues = rgba.substring(rgba.indexOf('(') + 1, rgba.lastIndexOf(')')).split(',');
|
|
116
|
+
const rgbValues = rgbaValues.slice(0, 3); // 获取红色、绿色和蓝色通道的值
|
|
117
|
+
return `rgb(${rgbValues.join(',')})`; // 将三个通道的值合并为RGB颜色值
|
|
118
|
+
} else {
|
|
119
|
+
return rgba; // 如果输入的不是合法的RGBA格式,直接返回原值
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
export function cc_colorParseRgba(color, alpha) {
|
|
123
|
+
let color_rba = cc_rgbaToRgb(color);
|
|
124
|
+
return colorToRgba(color_rba, alpha);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* 处理富文本里的图片宽度自适应
|
|
129
|
+
* 1.去掉img标签里的style、width、height属性
|
|
130
|
+
* 2.img标签添加style属性:max-width:100%;height:auto
|
|
131
|
+
* 3.修改所有style里的width属性为max-width:100%
|
|
132
|
+
* 4.去掉<br/>标签
|
|
133
|
+
* @param html
|
|
134
|
+
* @returns {void|string|*}
|
|
135
|
+
*/
|
|
136
|
+
export function cc_formatRichText(html) {
|
|
137
|
+
let newContent = html.replace(/<img[^>]*>/gi, function (match, capture) {
|
|
138
|
+
match = match.replace(/style="[^"]+"/gi, '').replace(/style='[^']+'/gi, '');
|
|
139
|
+
match = match.replace(/width="[^"]+"/gi, '').replace(/width='[^']+'/gi, '');
|
|
140
|
+
match = match.replace(/height="[^"]+"/gi, '').replace(/height='[^']+'/gi, '');
|
|
141
|
+
return match;
|
|
142
|
+
});
|
|
143
|
+
newContent = newContent.replace(/style="[^"]+"/gi, function (match, capture) {
|
|
144
|
+
match = match.replace(/width:[^;]+;/gi, 'width:100%;').replace(/width:[^;]+;/gi, 'width:100%;');
|
|
145
|
+
return match;
|
|
146
|
+
});
|
|
147
|
+
newContent = newContent.replace(/<br[^>]*\/>/gi, '');
|
|
148
|
+
newContent = newContent.replace(/\<img/gi, '<img style="max-width:100%;height:auto;display:block;margin:10px 0;"');
|
|
149
|
+
return newContent;
|
|
150
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @action 坐标转换,腾讯地图转换成百度地图坐标
|
|
3
|
+
* @param {String} lng 腾讯经度(pointy)
|
|
4
|
+
* @param {String} lat 腾讯纬度(pointx)
|
|
5
|
+
* @return {Array} 经度,纬度
|
|
6
|
+
*/
|
|
7
|
+
export function qqMapToBdMap(lng, lat) {
|
|
8
|
+
if (lng == null || lng == '' || lat == null || lat == '') return [lng, lat];
|
|
9
|
+
|
|
10
|
+
var x_pi = 3.14159265358979324;
|
|
11
|
+
var x = parseFloat(lng);
|
|
12
|
+
var y = parseFloat(lat);
|
|
13
|
+
var z = Math.sqrt(x * x + y * y) + 0.00002 * Math.sin(y * x_pi);
|
|
14
|
+
var theta = Math.atan2(y, x) + 0.000003 * Math.cos(x * x_pi);
|
|
15
|
+
var lng = (z * Math.cos(theta) + 0.0065).toFixed(5);
|
|
16
|
+
var lat = (z * Math.sin(theta) + 0.006).toFixed(5);
|
|
17
|
+
return [lng, lat];
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* @action 坐标转换,百度地图坐标转换成腾讯地图坐标
|
|
22
|
+
* @param {String} lng 腾讯经度(pointy)
|
|
23
|
+
* @param {String} lat 腾讯纬度(pointx)
|
|
24
|
+
* @return {Array} 经度,纬度
|
|
25
|
+
*/
|
|
26
|
+
export function bdMapToQQMap(lng, lat) {
|
|
27
|
+
if (lng == null || lng == '' || lat == null || lat == '') return [lng, lat];
|
|
28
|
+
|
|
29
|
+
var x_pi = 3.14159265358979324;
|
|
30
|
+
var x = parseFloat(lng) - 0.0065;
|
|
31
|
+
var y = parseFloat(lat) - 0.006;
|
|
32
|
+
var z = Math.sqrt(x * x + y * y) - 0.00002 * Math.sin(y * x_pi);
|
|
33
|
+
var theta = Math.atan2(y, x) - 0.000003 * Math.cos(x * x_pi);
|
|
34
|
+
var lng = (z * Math.cos(theta)).toFixed(7);
|
|
35
|
+
var lat = (z * Math.sin(theta)).toFixed(7);
|
|
36
|
+
|
|
37
|
+
return [lng, lat];
|
|
38
|
+
}
|