cb-biz-ui 1.1.4
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/README.md +44 -0
- package/components/cb-address-list/cb-address-list.vue +133 -0
- package/components/cb-cart-bar/cb-cart-bar.vue +52 -0
- package/components/cb-cart-bar-button/cb-cart-bar-button.vue +36 -0
- package/components/cb-cart-bar-icon/cb-cart-bar-icon.vue +48 -0
- package/components/cb-category/cb-category.vue +163 -0
- package/components/cb-delivery-address/cb-delivery-address.vue +48 -0
- package/components/cb-discount-coupon/cb-discount-coupon.vue +124 -0
- package/components/cb-discount-coupon/interface.d.ts +32 -0
- package/components/cb-discount-coupon/utils.ts +23 -0
- package/components/cb-drag-list/cb-drag-list.vue +868 -0
- package/components/cb-drag-list/drag.wxs +366 -0
- package/components/cb-form-classify/cb-form-classify.vue +208 -0
- package/components/cb-form-select/cb-form-select.vue +250 -0
- package/components/cb-goods-card/cb-goods-card.vue +251 -0
- package/components/cb-goods-sku/cb-goods-sku.vue +270 -0
- package/components/cb-header/cb-header.vue +113 -0
- package/components/cb-inventory/cb-inventory.vue +161 -0
- package/components/cb-manage-goods-item/cb-manage-goods-item.vue +95 -0
- package/components/cb-money-input/cb-money-input.vue +90 -0
- package/components/cb-offline-stores-coupon/cb-offline-stores-coupon.vue +96 -0
- package/components/cb-offline-stores-coupon/interface.d.ts +29 -0
- package/components/cb-offline-stores-coupon/utils.ts +10 -0
- package/components/cb-order-card/cb-order-card.vue +187 -0
- package/components/cb-order-goods/cb-order-goods.vue +64 -0
- package/components/cb-order-info/cb-order-info.vue +112 -0
- package/components/cb-order-remark/cb-order-remark.vue +121 -0
- package/components/cb-shipping-coupon/cb-shipping-coupon.vue +112 -0
- package/components/cb-shipping-coupon/interface.d.ts +32 -0
- package/components/cb-shipping-coupon/utils.ts +23 -0
- package/components/cb-shopping-cart/cb-shopping-cart.vue +230 -0
- package/components/cb-shopping-cart-tabbar/cb-shopping-cart-tabbar.vue +147 -0
- package/components/cb-sort-icon/cb-sort-icon.vue +70 -0
- package/components/cb-store-location/cb-store-location.vue +85 -0
- package/components/cb-unit-select/cb-unit-select.vue +161 -0
- package/components/cb-vertical-nav/cb-vertical-nav.vue +102 -0
- package/components/interface/types.d.ts +246 -0
- package/index.js +39 -0
- package/index.scss +23 -0
- package/libs/config/index.js +20 -0
- package/libs/css/address-list.scss +143 -0
- package/libs/css/cart-bar-icon.scss +34 -0
- package/libs/css/category.scss +83 -0
- package/libs/css/common.scss +0 -0
- package/libs/css/delivery-address.scss +46 -0
- package/libs/css/discount-coupon.scss +237 -0
- package/libs/css/form-classify.scss +98 -0
- package/libs/css/form-select.scss +98 -0
- package/libs/css/global/color.scss +156 -0
- package/libs/css/global/common.scss +0 -0
- package/libs/css/global/style.h5.scss +8 -0
- package/libs/css/global/style.mp.scss +0 -0
- package/libs/css/global/style.nvue.scss +3 -0
- package/libs/css/global/style.vue.scss +0 -0
- package/libs/css/goods-card.scss +154 -0
- package/libs/css/inventory.scss +74 -0
- package/libs/css/manage-goods-item.scss +76 -0
- package/libs/css/offline-stores-coupon.scss +133 -0
- package/libs/css/order-goods.scss +63 -0
- package/libs/css/order-info.scss +89 -0
- package/libs/css/order-remark.scss +68 -0
- package/libs/css/shipping-coupon.scss +151 -0
- package/libs/css/shopping-cart.scss +50 -0
- package/libs/css/sort-icon.scss +34 -0
- package/libs/css/store-location.scss +66 -0
- package/libs/css/theme.json +10 -0
- package/libs/css/unit-select.scss +62 -0
- package/libs/css/vertical-nav.scss +27 -0
- package/libs/utils/deep-clone.js +36 -0
- package/libs/utils/deep-merge.js +37 -0
- package/libs/utils/guid.js +42 -0
- package/libs/utils/index.js +6 -0
- package/libs/utils/time-format.js +54 -0
- package/libs/utils/validate.js +238 -0
- package/package.json +24 -0
- package/theme.scss +39 -0
|
@@ -0,0 +1,366 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
var scrollTop = {}; //滚动条位置
|
|
4
|
+
// 排序列表
|
|
5
|
+
var sortList={};
|
|
6
|
+
var isMove = false; //是否可拖动 长按事件控制切换这个状态
|
|
7
|
+
var touchTimer = false; //长按事件定时器
|
|
8
|
+
// 当页面有多个当前组件时,guid用来识别当前的列表的。因为一个页面内多个组件的wxs作用域相同。
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
function setScrollTop(tmpGuid) {
|
|
12
|
+
if (typeof scrollTop[tmpGuid] == "undefined") {
|
|
13
|
+
scrollTop[tmpGuid] = 0;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function scroll(event, instance) {
|
|
18
|
+
var dataView = instance.selectComponent('#dataView');
|
|
19
|
+
var viewData = dataView.getDataset();
|
|
20
|
+
setScrollTop(viewData.guid)
|
|
21
|
+
scrollTop[viewData.guid] = event.detail.scrollTop;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function initVar(state, instance) {
|
|
25
|
+
var dataView = instance.selectComponent('#dataView');
|
|
26
|
+
var viewData = dataView.getDataset();
|
|
27
|
+
// 读取配置项
|
|
28
|
+
// 获取scroll-view id
|
|
29
|
+
config = All_Config[viewData.guid];
|
|
30
|
+
|
|
31
|
+
setScrollTop(config.guid);
|
|
32
|
+
state.initscrollTop = scrollTop[config.guid];
|
|
33
|
+
|
|
34
|
+
}
|
|
35
|
+
function getRowSort(findId,instance){
|
|
36
|
+
for (var i = 0; i < sortList[config.guid].length; i++) {
|
|
37
|
+
if(sortList[config.guid][i].id==findId){
|
|
38
|
+
currentRowView = sortList[config.guid][i].rowView;
|
|
39
|
+
return sortList[config.guid][i].lastSort;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
var shadowRowBoxView=null;
|
|
44
|
+
var shadowRowView = null;
|
|
45
|
+
var currentRowView=null;
|
|
46
|
+
var rowSort=0;
|
|
47
|
+
var sorting = false;
|
|
48
|
+
function touchstart(event, instance) {
|
|
49
|
+
if(sorting){
|
|
50
|
+
return ;
|
|
51
|
+
}
|
|
52
|
+
sorting = true;
|
|
53
|
+
// 兼容setTimeout
|
|
54
|
+
if(typeof setTimeout ==="undefined" && typeof instance.setTimeout !== 'undefined'){
|
|
55
|
+
setTimeout = instance.setTimeout;
|
|
56
|
+
clearTimeout = instance.clearTimeout;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
isMove = false;
|
|
60
|
+
var rowData = event.instance.getDataset();
|
|
61
|
+
var state = instance.getState();
|
|
62
|
+
if (event.touches.length == 1) {
|
|
63
|
+
state.point = event.touches[0];
|
|
64
|
+
|
|
65
|
+
state.islongTap = true;
|
|
66
|
+
state.rowData = rowData;
|
|
67
|
+
//读取数据
|
|
68
|
+
initVar(state, instance);
|
|
69
|
+
}
|
|
70
|
+
var rowStyle = event.instance.getComputedStyle(['height']);
|
|
71
|
+
config.rowHeight = parseFloat(rowStyle.height); //获取行高
|
|
72
|
+
// 计算shadowRow.style.top
|
|
73
|
+
|
|
74
|
+
rowSort = getRowSort(rowData.id,instance);
|
|
75
|
+
var shadowRowTop = rowSort * config.rowHeight;
|
|
76
|
+
shadowRowTop = shadowRowTop - scrollTop[config.guid];
|
|
77
|
+
// 加载shadowRow数据
|
|
78
|
+
instance.callMethod("loadShadowRow", {
|
|
79
|
+
rowSort: rowSort
|
|
80
|
+
});
|
|
81
|
+
state.shadowRowTop = shadowRowTop;
|
|
82
|
+
// 设置shadowRow初始位置
|
|
83
|
+
shadowRowBoxView = instance.selectComponent('#shadowRowBox');
|
|
84
|
+
shadowRowBoxView.setStyle({
|
|
85
|
+
'top': shadowRowTop + 'px'
|
|
86
|
+
})
|
|
87
|
+
shadowRowView = instance.selectComponent('#shadowRow')
|
|
88
|
+
//长按事件
|
|
89
|
+
if (config.longTouch) {
|
|
90
|
+
touchTimer && clearTimeout(touchTimer);
|
|
91
|
+
touchTimer = setTimeout(function() {
|
|
92
|
+
longpress(event, instance);
|
|
93
|
+
}, config.longTouchTime)
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
function longpress(event, instance) {
|
|
98
|
+
if (config.longTouch) {
|
|
99
|
+
isMove = true;
|
|
100
|
+
moveRow(instance, 0)
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
function touchmove(event, instance) {
|
|
105
|
+
var state = instance.getState();
|
|
106
|
+
var rowData = event.instance.getDataset();
|
|
107
|
+
var movePoint = event.touches[0];
|
|
108
|
+
var initPoint = state.point;
|
|
109
|
+
var moveY = movePoint.pageY - initPoint.pageY;
|
|
110
|
+
if (config.longTouch) {
|
|
111
|
+
if (Math.abs(moveY) > 10) {
|
|
112
|
+
clearTimeout(touchTimer);
|
|
113
|
+
}
|
|
114
|
+
if (!isMove) {
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
moveRow(instance, moveY);
|
|
119
|
+
//阻止滚动页面
|
|
120
|
+
if (event.preventDefault) {
|
|
121
|
+
event.preventDefault();
|
|
122
|
+
}
|
|
123
|
+
return false;
|
|
124
|
+
}
|
|
125
|
+
function touchend(event, instance) {
|
|
126
|
+
if (config.longTouch) {
|
|
127
|
+
clearTimeout(touchTimer);
|
|
128
|
+
}
|
|
129
|
+
if (lastCommand != "stop") {
|
|
130
|
+
lastCommand = "stop";
|
|
131
|
+
config.autoScroll && instance.callMethod("pageScroll", {
|
|
132
|
+
'guid': config.guid,
|
|
133
|
+
'command': "stop"
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
var state = instance.getState();
|
|
137
|
+
// 把隐藏的行重新显示
|
|
138
|
+
resetRowStyle(instance,state.rowData.id)
|
|
139
|
+
// 隐藏ShadowRow
|
|
140
|
+
resetShadowRowStyle(instance,state.offset)
|
|
141
|
+
if (typeof state.offset !== "undefined" && rowSort != state.offset && state.offset != null) {
|
|
142
|
+
var sortArray=[];
|
|
143
|
+
for (var i = 0; i < sortList[config.guid].length; i++) {
|
|
144
|
+
sortList[config.guid][i].lastSort = sortList[config.guid][i].newSort;
|
|
145
|
+
sortArray.push(sortList[config.guid][i].newSort);
|
|
146
|
+
sortList[config.guid][i].rowView.removeClass('ani');
|
|
147
|
+
}
|
|
148
|
+
instance.callMethod("sort", {
|
|
149
|
+
index: rowSort,
|
|
150
|
+
offset: state.offset,
|
|
151
|
+
sortArray:sortArray
|
|
152
|
+
});
|
|
153
|
+
} else {
|
|
154
|
+
sorting = false;
|
|
155
|
+
triggerFeedbackGenerator(instance); //震动反馈
|
|
156
|
+
return false;
|
|
157
|
+
}
|
|
158
|
+
state.offset = null;
|
|
159
|
+
oldOffset = null;
|
|
160
|
+
sorting = false;
|
|
161
|
+
triggerFeedbackGenerator(instance); //震动反馈
|
|
162
|
+
return false;
|
|
163
|
+
}
|
|
164
|
+
// 重置列表行
|
|
165
|
+
function resetRowStyle(instance,id) {
|
|
166
|
+
currentRowView.removeClass('hide');
|
|
167
|
+
}
|
|
168
|
+
// 重置拖拽行
|
|
169
|
+
function resetShadowRowStyle(instance,offset) {
|
|
170
|
+
shadowRowBoxView.removeClass('show');
|
|
171
|
+
shadowRowBoxView.addClass('hide');
|
|
172
|
+
shadowRowBoxView.setStyle({});
|
|
173
|
+
}
|
|
174
|
+
var lastCommand = '';
|
|
175
|
+
|
|
176
|
+
// move Row
|
|
177
|
+
function moveRow(instance, moveY) {
|
|
178
|
+
var state = instance.getState();
|
|
179
|
+
|
|
180
|
+
// 显示shadowRowBox
|
|
181
|
+
shadowRowBoxView.removeClass('hide');
|
|
182
|
+
shadowRowBoxView.hasClass('show') || shadowRowBoxView.addClass('show');
|
|
183
|
+
// 移动shadowRowBox里面的shadowRow
|
|
184
|
+
shadowRowView.setStyle({
|
|
185
|
+
'transform': 'translate3d(0,' + moveY + 'px,10px)',
|
|
186
|
+
'-webkit-transform': 'translate3d(0,' + moveY + 'px,10px)'
|
|
187
|
+
});
|
|
188
|
+
// 隐藏列表对应行
|
|
189
|
+
currentRowView.hasClass('hide') || currentRowView.addClass('hide');
|
|
190
|
+
currentRowView.removeClass('ani')
|
|
191
|
+
var listClientY = state.shadowRowTop + moveY + config.rowHeight/2;
|
|
192
|
+
var tmpscrollListTop = scrollTop[config.guid];
|
|
193
|
+
|
|
194
|
+
// 拖拽至边缘滚动视图 距离顶部距离1.5行高触发上滚动 下滚动同理
|
|
195
|
+
var callMethodData = {
|
|
196
|
+
guid: config.guid,
|
|
197
|
+
command: listClientY < config.ListHeight * 0.2 ? "up" : listClientY > config.ListHeight - (config.ListHeight * 0.2) ? "down" :
|
|
198
|
+
"stop",
|
|
199
|
+
scrollTop: tmpscrollListTop,
|
|
200
|
+
}
|
|
201
|
+
// 把滚动指令发给逻辑层
|
|
202
|
+
if (lastCommand != callMethodData.command) {
|
|
203
|
+
lastCommand = callMethodData.command;
|
|
204
|
+
config.autoScroll && instance.callMethod("pageScroll", callMethodData);
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
var moveOffset = moveY + scrollTop[config.guid] - state.initscrollTop;
|
|
208
|
+
var offset = calcOffset(rowSort, moveOffset);
|
|
209
|
+
if (offset <= 2 || offset >= config.listLength - 2) {
|
|
210
|
+
callMethodData.command = 'stop';
|
|
211
|
+
}
|
|
212
|
+
// 为减少卡顿,微信小程序端,在滚动视图期间不进行列表位置交换
|
|
213
|
+
if (config.autoScroll && (!config.isAppH5) && callMethodData.command != 'stop') {
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
216
|
+
oldOffset = oldOffset == null ? rowSort : oldOffset;
|
|
217
|
+
if (offset < 0 || offset >= config.listLength) {
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
if (offset == oldOffset) {
|
|
221
|
+
return;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
oldOffset = offset;
|
|
225
|
+
state.offset = offset;
|
|
226
|
+
//触发change事件 并交换列表位置
|
|
227
|
+
instance.callMethod("change", {
|
|
228
|
+
index: rowSort,
|
|
229
|
+
moveTo: state.offset
|
|
230
|
+
});
|
|
231
|
+
for (var i = 0; i < sortList[config.guid].length; i++) {
|
|
232
|
+
var sort = sortList[config.guid][i].lastSort;
|
|
233
|
+
var newSort = sortList[config.guid][i].newSort;
|
|
234
|
+
if ((sort >= offset && sort <= rowSort) || (sort <= offset && sort >= rowSort)) {
|
|
235
|
+
if(sort == rowSort) {
|
|
236
|
+
newSort = offset;
|
|
237
|
+
}else{
|
|
238
|
+
newSort = sort < rowSort ? sort+1 : sort-1;
|
|
239
|
+
}
|
|
240
|
+
}else{
|
|
241
|
+
newSort = sort;
|
|
242
|
+
}
|
|
243
|
+
if(sortList[config.guid][i].newSort == newSort){
|
|
244
|
+
continue;
|
|
245
|
+
}
|
|
246
|
+
sortList[config.guid][i].newSort = newSort;
|
|
247
|
+
var translateY = (sortList[config.guid][i].newSort-sortList[config.guid][i].sort) * 100;
|
|
248
|
+
sortList[config.guid][i].rowView.hasClass('ani') || sortList[config.guid][i].rowView.addClass('ani');
|
|
249
|
+
sortList[config.guid][i].rowView.setStyle({
|
|
250
|
+
'transform': 'translate3d(0,' + translateY + '%,0)',
|
|
251
|
+
'-webkit-transform': 'translate3d(0,' + translateY + '%,0)'
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
triggerFeedbackGenerator(instance); //震动反馈
|
|
255
|
+
}
|
|
256
|
+
//计算偏移index
|
|
257
|
+
var oldOffset = null;
|
|
258
|
+
function calcOffset(initSort, moveY) {
|
|
259
|
+
var offset = initSort + parseInt(moveY / config.rowHeight); //偏移 行高的倍数
|
|
260
|
+
var rest = moveY % config.rowHeight;
|
|
261
|
+
if (rest > 0) {
|
|
262
|
+
offset = offset + (rest / config.rowHeight >= 0.6 ? 1 : 0);
|
|
263
|
+
if (offset < oldOffset) {
|
|
264
|
+
offset = rest / config.rowHeight <= 0.4 ? offset : oldOffset;
|
|
265
|
+
}
|
|
266
|
+
} else
|
|
267
|
+
{
|
|
268
|
+
offset = offset + (rest / config.rowHeight <= -0.6 ? -1 : 0);
|
|
269
|
+
if (offset > oldOffset) {
|
|
270
|
+
offset = rest / config.rowHeight >= -0.4 ? offset : oldOffset;
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
return offset;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
//触感反馈
|
|
277
|
+
//wxs 不支持条件编译,所以用此方法判断
|
|
278
|
+
var isiOSAPP = typeof plus != "undefined" && plus.os.name == 'iOS';
|
|
279
|
+
var UISelectionFeedbackGenerator;
|
|
280
|
+
var impact
|
|
281
|
+
|
|
282
|
+
if (isiOSAPP) {
|
|
283
|
+
UISelectionFeedbackGenerator = plus.ios.importClass("UISelectionFeedbackGenerator");
|
|
284
|
+
impact = new UISelectionFeedbackGenerator();
|
|
285
|
+
impact.init();
|
|
286
|
+
}
|
|
287
|
+
function triggerFeedbackGenerator(instance) {
|
|
288
|
+
if (!config.feedbackGenerator) {
|
|
289
|
+
//关闭触感反馈
|
|
290
|
+
return;
|
|
291
|
+
}
|
|
292
|
+
if (isiOSAPP) {
|
|
293
|
+
//异步,避免与点击事件冲突
|
|
294
|
+
setTimeout(function(){
|
|
295
|
+
impact.selectionChanged();
|
|
296
|
+
},0)
|
|
297
|
+
} else {
|
|
298
|
+
if (typeof plus != "undefined") {
|
|
299
|
+
plus.device.vibrate(12)
|
|
300
|
+
} else {
|
|
301
|
+
instance.callMethod("vibrate");
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
var All_Config={};
|
|
306
|
+
var config = {};
|
|
307
|
+
function receiveData(e,state, instance){
|
|
308
|
+
var data = JSON.parse(e);
|
|
309
|
+
var tmp_config = {};
|
|
310
|
+
var hasGuid = false;
|
|
311
|
+
var sortArray=[];
|
|
312
|
+
for(var i=0;i<data.length;i++){
|
|
313
|
+
var arr = data[i];
|
|
314
|
+
switch (arr[0]){
|
|
315
|
+
case "sortArray":
|
|
316
|
+
sortArray = arr[1];
|
|
317
|
+
break;
|
|
318
|
+
default:
|
|
319
|
+
if(arr[0]=='guid'){
|
|
320
|
+
hasGuid = true;
|
|
321
|
+
}
|
|
322
|
+
tmp_config[arr[0]] = arr[1];
|
|
323
|
+
break;
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
if(!hasGuid){
|
|
327
|
+
return;
|
|
328
|
+
}
|
|
329
|
+
var isUpdateList = false;
|
|
330
|
+
if(typeof All_Config[tmp_config.guid] == "undefined" ||typeof All_Config[tmp_config.guid].lastInitTime == "undefined" || All_Config[tmp_config.guid].lastInitTime!=tmp_config.lastInitTime){
|
|
331
|
+
isUpdateList = true;
|
|
332
|
+
}
|
|
333
|
+
All_Config[tmp_config.guid] = tmp_config;
|
|
334
|
+
if(isUpdateList){
|
|
335
|
+
updateSortList(tmp_config.guid, instance,sortArray);
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
// 更新guid对应的排序列表
|
|
339
|
+
function updateSortList(guid, instance,sortArray) {
|
|
340
|
+
|
|
341
|
+
sortList[guid]=[];
|
|
342
|
+
var pageSortList = instance.selectAllComponents('.hm-row');
|
|
343
|
+
for (var i = 0; i < pageSortList.length; i++){
|
|
344
|
+
var tmp_row = {id:pageSortList[i].getDataset().id,sort:i,lastSort:parseInt(pageSortList[i].getDataset().sort),newSort:i,rowView:pageSortList[i]};
|
|
345
|
+
if(sortArray.length>0){
|
|
346
|
+
tmp_row.lastSort = sortArray[i];
|
|
347
|
+
tmp_row.newSort = tmp_row.lastSort;
|
|
348
|
+
}
|
|
349
|
+
sortList[guid].push(tmp_row);
|
|
350
|
+
var translateY = (tmp_row.lastSort-tmp_row.sort) * 100;
|
|
351
|
+
tmp_row.rowView.setStyle({
|
|
352
|
+
'transform': 'translate3d(0,' + translateY + '%,0)',
|
|
353
|
+
'-webkit-transform': 'translate3d(0,' + translateY + '%,0)'
|
|
354
|
+
});
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
}
|
|
358
|
+
// 输出
|
|
359
|
+
module.exports = {
|
|
360
|
+
receiveData:receiveData,
|
|
361
|
+
scroll: scroll,
|
|
362
|
+
longpress: longpress,
|
|
363
|
+
touchstart: touchstart,
|
|
364
|
+
touchmove: touchmove,
|
|
365
|
+
touchend: touchend
|
|
366
|
+
}
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view
|
|
3
|
+
class="form-select"
|
|
4
|
+
:style="{
|
|
5
|
+
padding: getPadding,
|
|
6
|
+
background: getBgColor
|
|
7
|
+
}"
|
|
8
|
+
>
|
|
9
|
+
<view class="form-select_center" @tap="popup">
|
|
10
|
+
<view class="content">
|
|
11
|
+
<view
|
|
12
|
+
class="label"
|
|
13
|
+
:style="{
|
|
14
|
+
width: labelCenter ? labelWidth + 'rpx' : ''
|
|
15
|
+
}"
|
|
16
|
+
>{{ label }}
|
|
17
|
+
|
|
18
|
+
<view
|
|
19
|
+
class="asterisk"
|
|
20
|
+
v-if="asterisk"
|
|
21
|
+
:style="{ color: '#EB0909', right: asteriskRight + 'rpx' }"
|
|
22
|
+
>*</view
|
|
23
|
+
>
|
|
24
|
+
</view>
|
|
25
|
+
<view class="placeholder" v-if="!getValue()">{{ placeholder }}</view>
|
|
26
|
+
<view class="form-value">{{ getValue() }}</view>
|
|
27
|
+
</view>
|
|
28
|
+
<view
|
|
29
|
+
class="ui-cell__arrow"
|
|
30
|
+
:style="{ borderColor: getArrowColor, right: arrowRight + 'rpx' }"
|
|
31
|
+
v-if="arrow"
|
|
32
|
+
></view>
|
|
33
|
+
</view>
|
|
34
|
+
<view
|
|
35
|
+
v-if="bottomBorder"
|
|
36
|
+
:style="{
|
|
37
|
+
background: getBorderColor,
|
|
38
|
+
left: left + 'rpx',
|
|
39
|
+
right: right + 'rpx'
|
|
40
|
+
}"
|
|
41
|
+
class="border-bottom"
|
|
42
|
+
></view>
|
|
43
|
+
<ui-bottom-popup
|
|
44
|
+
:radius="false"
|
|
45
|
+
:zIndex="1002"
|
|
46
|
+
:maskZIndex="1001"
|
|
47
|
+
:show="popupShow"
|
|
48
|
+
@close="popup"
|
|
49
|
+
>
|
|
50
|
+
<view class="popup-box">
|
|
51
|
+
<view class="title">{{ placeholder }}</view>
|
|
52
|
+
<ui-cascade-selection
|
|
53
|
+
height="300px"
|
|
54
|
+
:itemList="props.list"
|
|
55
|
+
@complete="complete"
|
|
56
|
+
:defaultItemList="props.value"
|
|
57
|
+
></ui-cascade-selection>
|
|
58
|
+
|
|
59
|
+
<view class="tools">
|
|
60
|
+
<ui-form-button
|
|
61
|
+
width="200rpx"
|
|
62
|
+
height="70rpx"
|
|
63
|
+
color="#07C160"
|
|
64
|
+
background="rgba(0, 0, 0, 0.05)"
|
|
65
|
+
size="30"
|
|
66
|
+
borderWidth="0"
|
|
67
|
+
@click="close"
|
|
68
|
+
>取消</ui-form-button
|
|
69
|
+
>
|
|
70
|
+
<view style="width: 32rpx"></view>
|
|
71
|
+
<ui-form-button
|
|
72
|
+
width="200rpx"
|
|
73
|
+
height="70rpx"
|
|
74
|
+
color="#fff"
|
|
75
|
+
background="#07C160"
|
|
76
|
+
size="30"
|
|
77
|
+
borderWidth="0"
|
|
78
|
+
@click="confirm"
|
|
79
|
+
>完成</ui-form-button
|
|
80
|
+
>
|
|
81
|
+
</view>
|
|
82
|
+
</view>
|
|
83
|
+
</ui-bottom-popup>
|
|
84
|
+
</view>
|
|
85
|
+
</template>
|
|
86
|
+
<script setup lang="ts">
|
|
87
|
+
import { computed, reactive, ref, watch } from 'vue';
|
|
88
|
+
import { loopGetObjectValue } from '../../libs/utils/index.js';
|
|
89
|
+
|
|
90
|
+
interface listType {
|
|
91
|
+
text: string;
|
|
92
|
+
value: string | number;
|
|
93
|
+
children: listType[];
|
|
94
|
+
}
|
|
95
|
+
interface IProps {
|
|
96
|
+
label: string;
|
|
97
|
+
placeholder: string;
|
|
98
|
+
arrowColor?: string;
|
|
99
|
+
arrow?: boolean;
|
|
100
|
+
arrowRight?: number | string;
|
|
101
|
+
padding?: string;
|
|
102
|
+
background?: string;
|
|
103
|
+
asterisk?: boolean;
|
|
104
|
+
asteriskRight?: number;
|
|
105
|
+
labelCenter?: boolean;
|
|
106
|
+
labelWidth?: number | string;
|
|
107
|
+
bottomBorder?: boolean;
|
|
108
|
+
borderColor?: string;
|
|
109
|
+
left?: number | string;
|
|
110
|
+
right?: number | string;
|
|
111
|
+
list: listType[];
|
|
112
|
+
value?: string[];
|
|
113
|
+
disabled?: boolean;
|
|
114
|
+
}
|
|
115
|
+
const props = withDefaults(defineProps<IProps>(), {
|
|
116
|
+
label: '',
|
|
117
|
+
placeholder: '请选择',
|
|
118
|
+
arrow: true,
|
|
119
|
+
arrowColor: '',
|
|
120
|
+
arrowRight: 30,
|
|
121
|
+
asterisk: false,
|
|
122
|
+
asteriskRight: 6,
|
|
123
|
+
labelCenter: false,
|
|
124
|
+
labelWidth: 160,
|
|
125
|
+
bottomBorder: true,
|
|
126
|
+
borderColor: '',
|
|
127
|
+
left: 30,
|
|
128
|
+
right: 0,
|
|
129
|
+
list: [],
|
|
130
|
+
disabled: false
|
|
131
|
+
});
|
|
132
|
+
const emit = defineEmits<{
|
|
133
|
+
(e: 'confirm', item: listType): void;
|
|
134
|
+
}>();
|
|
135
|
+
|
|
136
|
+
const popupShow = ref(false);
|
|
137
|
+
const actived = ref<listType>();
|
|
138
|
+
|
|
139
|
+
const getArrowColor = computed(() => {
|
|
140
|
+
return (
|
|
141
|
+
props.arrowColor ||
|
|
142
|
+
loopGetObjectValue(['uiListCell', 'arrowColor'], uni.$ui) ||
|
|
143
|
+
'#c0c0c0'
|
|
144
|
+
);
|
|
145
|
+
});
|
|
146
|
+
const getPadding = computed(() => {
|
|
147
|
+
return (
|
|
148
|
+
props.padding ||
|
|
149
|
+
loopGetObjectValue(['uiFormItem', 'padding'], uni.$ui) ||
|
|
150
|
+
'26rpx 30rpx'
|
|
151
|
+
);
|
|
152
|
+
});
|
|
153
|
+
const getBgColor = computed(() => {
|
|
154
|
+
return (
|
|
155
|
+
props.background ||
|
|
156
|
+
loopGetObjectValue(['uiFormItem', 'background'], uni.$ui) ||
|
|
157
|
+
'#fff'
|
|
158
|
+
);
|
|
159
|
+
});
|
|
160
|
+
const getBorderColor = computed(() => {
|
|
161
|
+
return (
|
|
162
|
+
props.borderColor ||
|
|
163
|
+
loopGetObjectValue(['uiFormItem', 'borderColor'], uni.$ui) ||
|
|
164
|
+
'#eaeef1'
|
|
165
|
+
);
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
const popup = () => {
|
|
169
|
+
if (props.disabled) return;
|
|
170
|
+
popupShow.value = !popupShow.value;
|
|
171
|
+
};
|
|
172
|
+
|
|
173
|
+
const close = () => {
|
|
174
|
+
popupShow.value = false;
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
const confirm = () => {
|
|
178
|
+
if (!actived.value) {
|
|
179
|
+
uni.showToast({
|
|
180
|
+
title: '请选择',
|
|
181
|
+
icon: 'none'
|
|
182
|
+
});
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
emit('confirm', actived.value);
|
|
186
|
+
close();
|
|
187
|
+
};
|
|
188
|
+
|
|
189
|
+
const complete = (e) => {
|
|
190
|
+
console.log(e);
|
|
191
|
+
actived.value = e;
|
|
192
|
+
};
|
|
193
|
+
|
|
194
|
+
const getValue = () => {
|
|
195
|
+
if (!props?.value?.length) {
|
|
196
|
+
return '';
|
|
197
|
+
}
|
|
198
|
+
return props.value.join('/');
|
|
199
|
+
};
|
|
200
|
+
|
|
201
|
+
watch(
|
|
202
|
+
() => props.list,
|
|
203
|
+
(value, oldValue) => {}
|
|
204
|
+
);
|
|
205
|
+
</script>
|
|
206
|
+
<style scoped lang="scss">
|
|
207
|
+
@import '../../libs/css/form-classify.scss';
|
|
208
|
+
</style>
|