@kengic/uni 0.3.2-beta.10
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 +1 -0
- package/dist/index.css +1 -0
- package/dist/kengic-uni.js +5 -0
- package/dist/src/consts/i18n/en.d.ts +45 -0
- package/dist/src/consts/i18n/index.d.ts +90 -0
- package/dist/src/consts/i18n/zh_CN.d.ts +45 -0
- package/dist/src/consts/index.d.ts +1 -0
- package/dist/src/index.d.ts +2 -0
- package/dist/src/utils/index.d.ts +1 -0
- package/dist/src/utils/kg.util.d.ts +5 -0
- package/dist/uni-ui/index.ts +11 -0
- package/dist/uni-ui/uni-badge/uni-badge.vue +253 -0
- package/dist/uni-ui/uni-breadcrumb/uni-breadcrumb.vue +41 -0
- package/dist/uni-ui/uni-breadcrumb-item/uni-breadcrumb-item.vue +121 -0
- package/dist/uni-ui/uni-calendar/calendar.js +546 -0
- package/dist/uni-ui/uni-calendar/i18n/en.json +12 -0
- package/dist/uni-ui/uni-calendar/i18n/index.js +8 -0
- package/dist/uni-ui/uni-calendar/i18n/zh-Hans.json +12 -0
- package/dist/uni-ui/uni-calendar/i18n/zh-Hant.json +12 -0
- package/dist/uni-ui/uni-calendar/uni-calendar-item.vue +187 -0
- package/dist/uni-ui/uni-calendar/uni-calendar.vue +566 -0
- package/dist/uni-ui/uni-calendar/util.js +360 -0
- package/dist/uni-ui/uni-card/uni-card.vue +281 -0
- package/dist/uni-ui/uni-col/uni-col.vue +317 -0
- package/dist/uni-ui/uni-collapse/uni-collapse.vue +147 -0
- package/dist/uni-ui/uni-collapse-item/uni-collapse-item.vue +402 -0
- package/dist/uni-ui/uni-combox/uni-combox.vue +294 -0
- package/dist/uni-ui/uni-countdown/i18n/en.json +6 -0
- package/dist/uni-ui/uni-countdown/i18n/index.js +8 -0
- package/dist/uni-ui/uni-countdown/i18n/zh-Hans.json +6 -0
- package/dist/uni-ui/uni-countdown/i18n/zh-Hant.json +6 -0
- package/dist/uni-ui/uni-countdown/uni-countdown.vue +267 -0
- package/dist/uni-ui/uni-data-checkbox/uni-data-checkbox.vue +821 -0
- package/dist/uni-ui/uni-data-picker/keypress.js +45 -0
- package/dist/uni-ui/uni-data-picker/uni-data-picker.vue +551 -0
- package/dist/uni-ui/uni-data-pickerview/uni-data-picker.js +622 -0
- package/dist/uni-ui/uni-data-pickerview/uni-data-pickerview.vue +323 -0
- package/dist/uni-ui/uni-data-select/uni-data-select.vue +517 -0
- package/dist/uni-ui/uni-dateformat/date-format.js +200 -0
- package/dist/uni-ui/uni-dateformat/uni-dateformat.vue +88 -0
- package/dist/uni-ui/uni-datetime-picker/calendar-item.vue +177 -0
- package/dist/uni-ui/uni-datetime-picker/calendar.vue +928 -0
- package/dist/uni-ui/uni-datetime-picker/i18n/en.json +22 -0
- package/dist/uni-ui/uni-datetime-picker/i18n/index.js +8 -0
- package/dist/uni-ui/uni-datetime-picker/i18n/zh-Hans.json +22 -0
- package/dist/uni-ui/uni-datetime-picker/i18n/zh-Hant.json +22 -0
- package/dist/uni-ui/uni-datetime-picker/time-picker.vue +934 -0
- package/dist/uni-ui/uni-datetime-picker/uni-datetime-picker.vue +1026 -0
- package/dist/uni-ui/uni-datetime-picker/util.js +403 -0
- package/dist/uni-ui/uni-drawer/keypress.js +45 -0
- package/dist/uni-ui/uni-drawer/uni-drawer.vue +181 -0
- package/dist/uni-ui/uni-easyinput/common.js +56 -0
- package/dist/uni-ui/uni-easyinput/uni-easyinput.vue +660 -0
- package/dist/uni-ui/uni-fab/uni-fab.vue +491 -0
- package/dist/uni-ui/uni-fav/i18n/en.json +4 -0
- package/dist/uni-ui/uni-fav/i18n/index.js +8 -0
- package/dist/uni-ui/uni-fav/i18n/zh-Hans.json +4 -0
- package/dist/uni-ui/uni-fav/i18n/zh-Hant.json +4 -0
- package/dist/uni-ui/uni-fav/uni-fav.vue +161 -0
- package/dist/uni-ui/uni-file-picker/choose-and-upload-file.js +224 -0
- package/dist/uni-ui/uni-file-picker/uni-file-picker.vue +667 -0
- package/dist/uni-ui/uni-file-picker/upload-file.vue +325 -0
- package/dist/uni-ui/uni-file-picker/upload-image.vue +292 -0
- package/dist/uni-ui/uni-file-picker/utils.js +109 -0
- package/dist/uni-ui/uni-forms/uni-forms.vue +398 -0
- package/dist/uni-ui/uni-forms/utils.js +293 -0
- package/dist/uni-ui/uni-forms/validate.js +486 -0
- package/dist/uni-ui/uni-forms-item/uni-forms-item.vue +601 -0
- package/dist/uni-ui/uni-goods-nav/i18n/en.json +6 -0
- package/dist/uni-ui/uni-goods-nav/i18n/index.js +8 -0
- package/dist/uni-ui/uni-goods-nav/i18n/zh-Hans.json +6 -0
- package/dist/uni-ui/uni-goods-nav/i18n/zh-Hant.json +6 -0
- package/dist/uni-ui/uni-goods-nav/uni-goods-nav.vue +229 -0
- package/dist/uni-ui/uni-grid/uni-grid.vue +143 -0
- package/dist/uni-ui/uni-grid-item/uni-grid-item.vue +129 -0
- package/dist/uni-ui/uni-group/uni-group.vue +134 -0
- package/dist/uni-ui/uni-icons/icons.js +1169 -0
- package/dist/uni-ui/uni-icons/uni-icons.vue +96 -0
- package/dist/uni-ui/uni-icons/uniicons.css +663 -0
- package/dist/uni-ui/uni-icons/uniicons.ttf +0 -0
- package/dist/uni-ui/uni-indexed-list/uni-indexed-list-item.vue +144 -0
- package/dist/uni-ui/uni-indexed-list/uni-indexed-list.vue +367 -0
- package/dist/uni-ui/uni-link/uni-link.vue +128 -0
- package/dist/uni-ui/uni-list/uni-list.vue +123 -0
- package/dist/uni-ui/uni-list/uni-refresh.vue +65 -0
- package/dist/uni-ui/uni-list/uni-refresh.wxs +87 -0
- package/dist/uni-ui/uni-list-ad/uni-list-ad.vue +107 -0
- package/dist/uni-ui/uni-list-chat/uni-list-chat.scss +58 -0
- package/dist/uni-ui/uni-list-chat/uni-list-chat.vue +593 -0
- package/dist/uni-ui/uni-list-item/uni-list-item.vue +534 -0
- package/dist/uni-ui/uni-load-more/i18n/en.json +5 -0
- package/dist/uni-ui/uni-load-more/i18n/index.js +8 -0
- package/dist/uni-ui/uni-load-more/i18n/zh-Hans.json +5 -0
- package/dist/uni-ui/uni-load-more/i18n/zh-Hant.json +5 -0
- package/dist/uni-ui/uni-load-more/uni-load-more.vue +399 -0
- package/dist/uni-ui/uni-nav-bar/uni-nav-bar.vue +357 -0
- package/dist/uni-ui/uni-nav-bar/uni-status-bar.vue +24 -0
- package/dist/uni-ui/uni-notice-bar/uni-notice-bar.vue +426 -0
- package/dist/uni-ui/uni-number-box/uni-number-box.vue +221 -0
- package/dist/uni-ui/uni-pagination/i18n/en.json +5 -0
- package/dist/uni-ui/uni-pagination/i18n/es.json +5 -0
- package/dist/uni-ui/uni-pagination/i18n/fr.json +5 -0
- package/dist/uni-ui/uni-pagination/i18n/index.js +12 -0
- package/dist/uni-ui/uni-pagination/i18n/zh-Hans.json +5 -0
- package/dist/uni-ui/uni-pagination/i18n/zh-Hant.json +5 -0
- package/dist/uni-ui/uni-pagination/uni-pagination.vue +465 -0
- package/dist/uni-ui/uni-popup/i18n/en.json +7 -0
- package/dist/uni-ui/uni-popup/i18n/index.js +9 -0
- package/dist/uni-ui/uni-popup/i18n/zh-Hans.json +7 -0
- package/dist/uni-ui/uni-popup/i18n/zh-Hant.json +7 -0
- package/dist/uni-ui/uni-popup/keypress.js +45 -0
- package/dist/uni-ui/uni-popup/popup.js +23 -0
- package/dist/uni-ui/uni-popup/uni-popup.vue +464 -0
- package/dist/uni-ui/uni-popup-dialog/keypress.js +45 -0
- package/dist/uni-ui/uni-popup-dialog/uni-popup-dialog.vue +275 -0
- package/dist/uni-ui/uni-popup-message/uni-popup-message.vue +143 -0
- package/dist/uni-ui/uni-popup-share/uni-popup-share.vue +187 -0
- package/dist/uni-ui/uni-rate/uni-rate.vue +365 -0
- package/dist/uni-ui/uni-row/uni-row.vue +190 -0
- package/dist/uni-ui/uni-scss/changelog.md +8 -0
- package/dist/uni-ui/uni-scss/index.scss +1 -0
- package/dist/uni-ui/uni-scss/package.json +82 -0
- package/dist/uni-ui/uni-scss/readme.md +4 -0
- package/dist/uni-ui/uni-scss/styles/index.scss +7 -0
- package/dist/uni-ui/uni-scss/styles/setting/_border.scss +3 -0
- package/dist/uni-ui/uni-scss/styles/setting/_color.scss +66 -0
- package/dist/uni-ui/uni-scss/styles/setting/_radius.scss +55 -0
- package/dist/uni-ui/uni-scss/styles/setting/_space.scss +56 -0
- package/dist/uni-ui/uni-scss/styles/setting/_styles.scss +167 -0
- package/dist/uni-ui/uni-scss/styles/setting/_text.scss +24 -0
- package/dist/uni-ui/uni-scss/styles/setting/_variables.scss +146 -0
- package/dist/uni-ui/uni-scss/styles/tools/functions.scss +19 -0
- package/dist/uni-ui/uni-scss/theme.scss +31 -0
- package/dist/uni-ui/uni-scss/variables.scss +62 -0
- package/dist/uni-ui/uni-search-bar/i18n/en.json +4 -0
- package/dist/uni-ui/uni-search-bar/i18n/index.js +8 -0
- package/dist/uni-ui/uni-search-bar/i18n/zh-Hans.json +4 -0
- package/dist/uni-ui/uni-search-bar/i18n/zh-Hant.json +4 -0
- package/dist/uni-ui/uni-search-bar/uni-search-bar.vue +298 -0
- package/dist/uni-ui/uni-section/uni-section.vue +167 -0
- package/dist/uni-ui/uni-segmented-control/uni-segmented-control.vue +145 -0
- package/dist/uni-ui/uni-steps/uni-steps.vue +269 -0
- package/dist/uni-ui/uni-swipe-action/uni-swipe-action.vue +60 -0
- package/dist/uni-ui/uni-swipe-action-item/bindingx.js +302 -0
- package/dist/uni-ui/uni-swipe-action-item/isPC.js +12 -0
- package/dist/uni-ui/uni-swipe-action-item/mpalipay.js +195 -0
- package/dist/uni-ui/uni-swipe-action-item/mpother.js +260 -0
- package/dist/uni-ui/uni-swipe-action-item/mpwxs.js +84 -0
- package/dist/uni-ui/uni-swipe-action-item/render.js +270 -0
- package/dist/uni-ui/uni-swipe-action-item/uni-swipe-action-item.vue +347 -0
- package/dist/uni-ui/uni-swipe-action-item/wx.wxs +341 -0
- package/dist/uni-ui/uni-swiper-dot/uni-swiper-dot.vue +218 -0
- package/dist/uni-ui/uni-table/uni-table.vue +455 -0
- package/dist/uni-ui/uni-tag/uni-tag.vue +252 -0
- package/dist/uni-ui/uni-tbody/uni-tbody.vue +29 -0
- package/dist/uni-ui/uni-td/uni-td.vue +90 -0
- package/dist/uni-ui/uni-th/filter-dropdown.vue +511 -0
- package/dist/uni-ui/uni-th/uni-th.vue +285 -0
- package/dist/uni-ui/uni-thead/uni-thead.vue +129 -0
- package/dist/uni-ui/uni-title/uni-title.vue +171 -0
- package/dist/uni-ui/uni-tooltip/uni-tooltip.vue +68 -0
- package/dist/uni-ui/uni-tr/table-checkbox.vue +179 -0
- package/dist/uni-ui/uni-tr/uni-tr.vue +171 -0
- package/dist/uni-ui/uni-transition/createAnimation.js +131 -0
- package/dist/uni-ui/uni-transition/uni-transition.vue +281 -0
- package/package.json +90 -0
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
const MIN_DISTANCE = 10;
|
|
2
|
+
export default {
|
|
3
|
+
showWatch(newVal, oldVal, ownerInstance, instance, self) {
|
|
4
|
+
var state = self.state
|
|
5
|
+
var $el = ownerInstance.$el || ownerInstance.$vm && ownerInstance.$vm.$el
|
|
6
|
+
if (!$el) return
|
|
7
|
+
this.getDom(instance, ownerInstance, self)
|
|
8
|
+
if (newVal && newVal !== 'none') {
|
|
9
|
+
this.openState(newVal, instance, ownerInstance, self)
|
|
10
|
+
return
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
if (state.left) {
|
|
14
|
+
this.openState('none', instance, ownerInstance, self)
|
|
15
|
+
}
|
|
16
|
+
this.resetTouchStatus(instance, self)
|
|
17
|
+
},
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* 开始触摸操作
|
|
21
|
+
* @param {Object} e
|
|
22
|
+
* @param {Object} ins
|
|
23
|
+
*/
|
|
24
|
+
touchstart(e, ownerInstance, self) {
|
|
25
|
+
let instance = e.instance;
|
|
26
|
+
let disabled = instance.getDataset().disabled
|
|
27
|
+
let state = self.state;
|
|
28
|
+
this.getDom(instance, ownerInstance, self)
|
|
29
|
+
// fix by mehaotian, TODO 兼容 app-vue 获取dataset为字符串 , h5 获取 为 undefined 的问题,待框架修复
|
|
30
|
+
disabled = this.getDisabledType(disabled)
|
|
31
|
+
if (disabled) return
|
|
32
|
+
// 开始触摸时移除动画类
|
|
33
|
+
instance.requestAnimationFrame(function() {
|
|
34
|
+
instance.removeClass('ani');
|
|
35
|
+
ownerInstance.callMethod('closeSwipe');
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
// 记录上次的位置
|
|
39
|
+
state.x = state.left || 0
|
|
40
|
+
// 计算滑动开始位置
|
|
41
|
+
this.stopTouchStart(e, ownerInstance, self)
|
|
42
|
+
},
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* 开始滑动操作
|
|
46
|
+
* @param {Object} e
|
|
47
|
+
* @param {Object} ownerInstance
|
|
48
|
+
*/
|
|
49
|
+
touchmove(e, ownerInstance, self) {
|
|
50
|
+
let instance = e.instance;
|
|
51
|
+
// 删除之后已经那不到实例了
|
|
52
|
+
if (!instance) return;
|
|
53
|
+
let disabled = instance.getDataset().disabled
|
|
54
|
+
let state = self.state
|
|
55
|
+
// fix by mehaotian, TODO 兼容 app-vue 获取dataset为字符串 , h5 获取 为 undefined 的问题,待框架修复
|
|
56
|
+
disabled = this.getDisabledType(disabled)
|
|
57
|
+
if (disabled) return
|
|
58
|
+
// 是否可以滑动页面
|
|
59
|
+
this.stopTouchMove(e, self);
|
|
60
|
+
if (state.direction !== 'horizontal') {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
if (e.preventDefault) {
|
|
64
|
+
// 阻止页面滚动
|
|
65
|
+
e.preventDefault()
|
|
66
|
+
}
|
|
67
|
+
let x = state.x + state.deltaX
|
|
68
|
+
this.move(x, instance, ownerInstance, self)
|
|
69
|
+
},
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* 结束触摸操作
|
|
73
|
+
* @param {Object} e
|
|
74
|
+
* @param {Object} ownerInstance
|
|
75
|
+
*/
|
|
76
|
+
touchend(e, ownerInstance, self) {
|
|
77
|
+
let instance = e.instance;
|
|
78
|
+
let disabled = instance.getDataset().disabled
|
|
79
|
+
let state = self.state
|
|
80
|
+
// fix by mehaotian, TODO 兼容 app-vue 获取dataset为字符串 , h5 获取 为 undefined 的问题,待框架修复
|
|
81
|
+
disabled = this.getDisabledType(disabled)
|
|
82
|
+
|
|
83
|
+
if (disabled) return
|
|
84
|
+
// 滑动过程中触摸结束,通过阙值判断是开启还是关闭
|
|
85
|
+
// fixed by mehaotian 定时器解决点击按钮,touchend 触发比 click 事件时机早的问题 ,主要是 ios13
|
|
86
|
+
this.moveDirection(state.left, instance, ownerInstance, self)
|
|
87
|
+
|
|
88
|
+
},
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* 设置移动距离
|
|
92
|
+
* @param {Object} value
|
|
93
|
+
* @param {Object} instance
|
|
94
|
+
* @param {Object} ownerInstance
|
|
95
|
+
*/
|
|
96
|
+
move(value, instance, ownerInstance, self) {
|
|
97
|
+
value = value || 0
|
|
98
|
+
let state = self.state
|
|
99
|
+
let leftWidth = state.leftWidth
|
|
100
|
+
let rightWidth = state.rightWidth
|
|
101
|
+
// 获取可滑动范围
|
|
102
|
+
state.left = this.range(value, -rightWidth, leftWidth);
|
|
103
|
+
instance.requestAnimationFrame(function() {
|
|
104
|
+
instance.setStyle({
|
|
105
|
+
transform: 'translateX(' + state.left + 'px)',
|
|
106
|
+
'-webkit-transform': 'translateX(' + state.left + 'px)'
|
|
107
|
+
})
|
|
108
|
+
})
|
|
109
|
+
|
|
110
|
+
},
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* 获取元素信息
|
|
114
|
+
* @param {Object} instance
|
|
115
|
+
* @param {Object} ownerInstance
|
|
116
|
+
*/
|
|
117
|
+
getDom(instance, ownerInstance, self) {
|
|
118
|
+
var state = self.state
|
|
119
|
+
var $el = ownerInstance.$el || ownerInstance.$vm && ownerInstance.$vm.$el
|
|
120
|
+
var leftDom = $el.querySelector('.button-group--left')
|
|
121
|
+
var rightDom = $el.querySelector('.button-group--right')
|
|
122
|
+
|
|
123
|
+
state.leftWidth = leftDom.offsetWidth || 0
|
|
124
|
+
state.rightWidth = rightDom.offsetWidth || 0
|
|
125
|
+
state.threshold = instance.getDataset().threshold
|
|
126
|
+
},
|
|
127
|
+
|
|
128
|
+
getDisabledType(value) {
|
|
129
|
+
return (typeof(value) === 'string' ? JSON.parse(value) : value) || false;
|
|
130
|
+
},
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* 获取范围
|
|
134
|
+
* @param {Object} num
|
|
135
|
+
* @param {Object} min
|
|
136
|
+
* @param {Object} max
|
|
137
|
+
*/
|
|
138
|
+
range(num, min, max) {
|
|
139
|
+
return Math.min(Math.max(num, min), max);
|
|
140
|
+
},
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* 移动方向判断
|
|
145
|
+
* @param {Object} left
|
|
146
|
+
* @param {Object} value
|
|
147
|
+
* @param {Object} ownerInstance
|
|
148
|
+
* @param {Object} ins
|
|
149
|
+
*/
|
|
150
|
+
moveDirection(left, ins, ownerInstance, self) {
|
|
151
|
+
var state = self.state
|
|
152
|
+
var threshold = state.threshold
|
|
153
|
+
var position = state.position
|
|
154
|
+
var isopen = state.isopen || 'none'
|
|
155
|
+
var leftWidth = state.leftWidth
|
|
156
|
+
var rightWidth = state.rightWidth
|
|
157
|
+
if (state.deltaX === 0) {
|
|
158
|
+
this.openState('none', ins, ownerInstance, self)
|
|
159
|
+
return
|
|
160
|
+
}
|
|
161
|
+
if ((isopen === 'none' && rightWidth > 0 && -left > threshold) || (isopen !== 'none' && rightWidth > 0 &&
|
|
162
|
+
rightWidth +
|
|
163
|
+
left < threshold)) {
|
|
164
|
+
// right
|
|
165
|
+
this.openState('right', ins, ownerInstance, self)
|
|
166
|
+
} else if ((isopen === 'none' && leftWidth > 0 && left > threshold) || (isopen !== 'none' && leftWidth > 0 &&
|
|
167
|
+
leftWidth - left < threshold)) {
|
|
168
|
+
// left
|
|
169
|
+
this.openState('left', ins, ownerInstance, self)
|
|
170
|
+
} else {
|
|
171
|
+
// default
|
|
172
|
+
this.openState('none', ins, ownerInstance, self)
|
|
173
|
+
}
|
|
174
|
+
},
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* 开启状态
|
|
179
|
+
* @param {Boolean} type
|
|
180
|
+
* @param {Object} ins
|
|
181
|
+
* @param {Object} ownerInstance
|
|
182
|
+
*/
|
|
183
|
+
openState(type, ins, ownerInstance, self) {
|
|
184
|
+
let state = self.state
|
|
185
|
+
let leftWidth = state.leftWidth
|
|
186
|
+
let rightWidth = state.rightWidth
|
|
187
|
+
let left = ''
|
|
188
|
+
state.isopen = state.isopen ? state.isopen : 'none'
|
|
189
|
+
switch (type) {
|
|
190
|
+
case "left":
|
|
191
|
+
left = leftWidth
|
|
192
|
+
break
|
|
193
|
+
case "right":
|
|
194
|
+
left = -rightWidth
|
|
195
|
+
break
|
|
196
|
+
default:
|
|
197
|
+
left = 0
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
// && !state.throttle
|
|
201
|
+
|
|
202
|
+
if (state.isopen !== type) {
|
|
203
|
+
state.throttle = true
|
|
204
|
+
ownerInstance.callMethod('change', {
|
|
205
|
+
open: type
|
|
206
|
+
})
|
|
207
|
+
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
state.isopen = type
|
|
211
|
+
// 添加动画类
|
|
212
|
+
ins.requestAnimationFrame(() => {
|
|
213
|
+
ins.addClass('ani');
|
|
214
|
+
this.move(left, ins, ownerInstance, self)
|
|
215
|
+
})
|
|
216
|
+
},
|
|
217
|
+
|
|
218
|
+
|
|
219
|
+
getDirection(x, y) {
|
|
220
|
+
if (x > y && x > MIN_DISTANCE) {
|
|
221
|
+
return 'horizontal';
|
|
222
|
+
}
|
|
223
|
+
if (y > x && y > MIN_DISTANCE) {
|
|
224
|
+
return 'vertical';
|
|
225
|
+
}
|
|
226
|
+
return '';
|
|
227
|
+
},
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* 重置滑动状态
|
|
231
|
+
* @param {Object} event
|
|
232
|
+
*/
|
|
233
|
+
resetTouchStatus(instance, self) {
|
|
234
|
+
let state = self.state;
|
|
235
|
+
state.direction = '';
|
|
236
|
+
state.deltaX = 0;
|
|
237
|
+
state.deltaY = 0;
|
|
238
|
+
state.offsetX = 0;
|
|
239
|
+
state.offsetY = 0;
|
|
240
|
+
},
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* 设置滑动开始位置
|
|
244
|
+
* @param {Object} event
|
|
245
|
+
*/
|
|
246
|
+
stopTouchStart(event, ownerInstance, self) {
|
|
247
|
+
let instance = event.instance;
|
|
248
|
+
let state = self.state
|
|
249
|
+
this.resetTouchStatus(instance, self);
|
|
250
|
+
var touch = event.touches[0];
|
|
251
|
+
state.startX = touch.clientX;
|
|
252
|
+
state.startY = touch.clientY;
|
|
253
|
+
},
|
|
254
|
+
|
|
255
|
+
/**
|
|
256
|
+
* 滑动中,是否禁止打开
|
|
257
|
+
* @param {Object} event
|
|
258
|
+
*/
|
|
259
|
+
stopTouchMove(event, self) {
|
|
260
|
+
let instance = event.instance;
|
|
261
|
+
let state = self.state;
|
|
262
|
+
let touch = event.touches[0];
|
|
263
|
+
|
|
264
|
+
state.deltaX = touch.clientX - state.startX;
|
|
265
|
+
state.deltaY = touch.clientY - state.startY;
|
|
266
|
+
state.offsetY = Math.abs(state.deltaY);
|
|
267
|
+
state.offsetX = Math.abs(state.deltaX);
|
|
268
|
+
state.direction = state.direction || this.getDirection(state.offsetX, state.offsetY);
|
|
269
|
+
}
|
|
270
|
+
}
|
|
@@ -0,0 +1,347 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<!-- 在微信小程序 app vue端 h5 使用wxs 实现-->
|
|
3
|
+
<!-- #ifdef APP-VUE || MP-WEIXIN || H5 -->
|
|
4
|
+
<view class="uni-swipe">
|
|
5
|
+
<!-- #ifdef MP-WEIXIN || VUE3 -->
|
|
6
|
+
<view class="uni-swipe_box" :change:prop="wxsswipe.showWatch" :prop="is_show" :data-threshold="threshold"
|
|
7
|
+
:data-disabled="disabled" @touchstart="wxsswipe.touchstart" @touchmove="wxsswipe.touchmove"
|
|
8
|
+
@touchend="wxsswipe.touchend">
|
|
9
|
+
<!-- #endif -->
|
|
10
|
+
<!-- #ifndef MP-WEIXIN || VUE3 -->
|
|
11
|
+
<view class="uni-swipe_box" :change:prop="renderswipe.showWatch" :prop="is_show" :data-threshold="threshold"
|
|
12
|
+
:data-disabled="disabled+''" @touchstart="renderswipe.touchstart" @touchmove="renderswipe.touchmove"
|
|
13
|
+
@touchend="renderswipe.touchend">
|
|
14
|
+
<!-- #endif -->
|
|
15
|
+
<!-- 在微信小程序 app vue端 h5 使用wxs 实现-->
|
|
16
|
+
<view class="uni-swipe_button-group button-group--left">
|
|
17
|
+
<slot name="left">
|
|
18
|
+
<view v-for="(item,index) in leftOptions" :key="index" :style="{
|
|
19
|
+
backgroundColor: item.style && item.style.backgroundColor ? item.style.backgroundColor : '#C7C6CD'
|
|
20
|
+
}" class="uni-swipe_button button-hock" @touchstart="appTouchStart"
|
|
21
|
+
@touchend="appTouchEnd($event,index,item,'left')"
|
|
22
|
+
@click.stop="onClickForPC(index,item,'left')">
|
|
23
|
+
<text class="uni-swipe_button-text"
|
|
24
|
+
:style="{color: item.style && item.style.color ? item.style.color : '#FFFFFF',fontSize: item.style && item.style.fontSize ? item.style.fontSize : '16px'}">{{ item.text }}</text>
|
|
25
|
+
</view>
|
|
26
|
+
</slot>
|
|
27
|
+
</view>
|
|
28
|
+
<view class="uni-swipe_text--center">
|
|
29
|
+
<slot></slot>
|
|
30
|
+
</view>
|
|
31
|
+
<view class="uni-swipe_button-group button-group--right">
|
|
32
|
+
<slot name="right">
|
|
33
|
+
<view v-for="(item,index) in rightOptions" :key="index" :style="{
|
|
34
|
+
backgroundColor: item.style && item.style.backgroundColor ? item.style.backgroundColor : '#C7C6CD'
|
|
35
|
+
}" class="uni-swipe_button button-hock" @touchstart="appTouchStart"
|
|
36
|
+
@touchend="appTouchEnd($event,index,item,'right')"
|
|
37
|
+
@click.stop="onClickForPC(index,item,'right')"><text class="uni-swipe_button-text"
|
|
38
|
+
:style="{color: item.style && item.style.color ? item.style.color : '#FFFFFF',fontSize: item.style && item.style.fontSize ? item.style.fontSize : '16px'}">{{ item.text }}</text>
|
|
39
|
+
</view>
|
|
40
|
+
</slot>
|
|
41
|
+
</view>
|
|
42
|
+
</view>
|
|
43
|
+
</view>
|
|
44
|
+
<!-- #endif -->
|
|
45
|
+
<!-- app nvue端 使用 bindingx -->
|
|
46
|
+
<!-- #ifdef APP-NVUE -->
|
|
47
|
+
<view ref="selector-box--hock" class="uni-swipe" @horizontalpan="touchstart" @touchend="touchend">
|
|
48
|
+
<view ref='selector-left-button--hock' class="uni-swipe_button-group button-group--left">
|
|
49
|
+
<slot name="left">
|
|
50
|
+
<view v-for="(item,index) in leftOptions" :key="index" :style="{
|
|
51
|
+
backgroundColor: item.style && item.style.backgroundColor ? item.style.backgroundColor : '#C7C6CD'
|
|
52
|
+
}" class="uni-swipe_button button-hock" @click.stop="onClick(index,item,'left')"><text
|
|
53
|
+
class="uni-swipe_button-text"
|
|
54
|
+
:style="{color: item.style && item.style.color ? item.style.color : '#FFFFFF', fontSize: item.style && item.style.fontSize ? item.style.fontSize : '16px'}">{{ item.text }}</text>
|
|
55
|
+
</view>
|
|
56
|
+
</slot>
|
|
57
|
+
</view>
|
|
58
|
+
<view ref='selector-right-button--hock' class="uni-swipe_button-group button-group--right">
|
|
59
|
+
<slot name="right">
|
|
60
|
+
<view v-for="(item,index) in rightOptions" :key="index" :style="{
|
|
61
|
+
backgroundColor: item.style && item.style.backgroundColor ? item.style.backgroundColor : '#C7C6CD'
|
|
62
|
+
}" class="uni-swipe_button button-hock" @click.stop="onClick(index,item,'right')"><text
|
|
63
|
+
class="uni-swipe_button-text"
|
|
64
|
+
:style="{color: item.style && item.style.color ? item.style.color : '#FFFFFF',fontSize: item.style && item.style.fontSize ? item.style.fontSize : '16px'}">{{ item.text }}</text>
|
|
65
|
+
</view>
|
|
66
|
+
</slot>
|
|
67
|
+
</view>
|
|
68
|
+
<view ref='selector-content--hock' class="uni-swipe_box">
|
|
69
|
+
<slot></slot>
|
|
70
|
+
</view>
|
|
71
|
+
</view>
|
|
72
|
+
<!-- #endif -->
|
|
73
|
+
<!-- 其他平台使用 js ,长列表性能可能会有影响-->
|
|
74
|
+
<!-- #ifdef MP-ALIPAY || MP-BAIDU || MP-TOUTIAO || MP-QQ -->
|
|
75
|
+
<view class="uni-swipe">
|
|
76
|
+
<view class="uni-swipe_box" @touchstart="touchstart" @touchmove="touchmove" @touchend="touchend"
|
|
77
|
+
:style="{transform:moveLeft}" :class="{ani:ani}">
|
|
78
|
+
<view class="uni-swipe_button-group button-group--left" :class="[elClass]">
|
|
79
|
+
<slot name="left">
|
|
80
|
+
<view v-for="(item,index) in leftOptions" :key="index" :style="{
|
|
81
|
+
backgroundColor: item.style && item.style.backgroundColor ? item.style.backgroundColor : '#C7C6CD',
|
|
82
|
+
fontSize: item.style && item.style.fontSize ? item.style.fontSize : '16px'
|
|
83
|
+
}" class="uni-swipe_button button-hock" @touchstart="appTouchStart"
|
|
84
|
+
@touchend="appTouchEnd($event,index,item,'left')"><text class="uni-swipe_button-text"
|
|
85
|
+
:style="{color: item.style && item.style.color ? item.style.color : '#FFFFFF',}">{{ item.text }}</text>
|
|
86
|
+
</view>
|
|
87
|
+
</slot>
|
|
88
|
+
</view>
|
|
89
|
+
<slot></slot>
|
|
90
|
+
<view class="uni-swipe_button-group button-group--right" :class="[elClass]">
|
|
91
|
+
<slot name="right">
|
|
92
|
+
<view v-for="(item,index) in rightOptions" :key="index" :style="{
|
|
93
|
+
backgroundColor: item.style && item.style.backgroundColor ? item.style.backgroundColor : '#C7C6CD',
|
|
94
|
+
fontSize: item.style && item.style.fontSize ? item.style.fontSize : '16px'
|
|
95
|
+
}" @touchstart="appTouchStart" @touchend="appTouchEnd($event,index,item,'right')"
|
|
96
|
+
class="uni-swipe_button button-hock"><text class="uni-swipe_button-text"
|
|
97
|
+
:style="{color: item.style && item.style.color ? item.style.color : '#FFFFFF',}">{{ item.text }}</text>
|
|
98
|
+
</view>
|
|
99
|
+
</slot>
|
|
100
|
+
</view>
|
|
101
|
+
</view>
|
|
102
|
+
</view>
|
|
103
|
+
<!-- #endif -->
|
|
104
|
+
|
|
105
|
+
</template>
|
|
106
|
+
<script src='wx.wxs' module="wxsswipe" lang="wxs"></script>
|
|
107
|
+
|
|
108
|
+
<script module="renderswipe" lang="renderjs">
|
|
109
|
+
import render from './render.js'
|
|
110
|
+
export default {
|
|
111
|
+
mounted(e, ins, owner) {
|
|
112
|
+
this.state = {}
|
|
113
|
+
},
|
|
114
|
+
methods: {
|
|
115
|
+
showWatch(newVal, oldVal, ownerInstance, instance) {
|
|
116
|
+
render.showWatch(newVal, oldVal, ownerInstance, instance, this)
|
|
117
|
+
},
|
|
118
|
+
touchstart(e, ownerInstance) {
|
|
119
|
+
render.touchstart(e, ownerInstance, this)
|
|
120
|
+
},
|
|
121
|
+
touchmove(e, ownerInstance) {
|
|
122
|
+
render.touchmove(e, ownerInstance, this)
|
|
123
|
+
},
|
|
124
|
+
touchend(e, ownerInstance) {
|
|
125
|
+
render.touchend(e, ownerInstance, this)
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
</script>
|
|
130
|
+
<script>
|
|
131
|
+
import mpwxs from './mpwxs'
|
|
132
|
+
import bindingx from './bindingx.js'
|
|
133
|
+
import mpother from './mpother'
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* SwipeActionItem 滑动操作子组件
|
|
137
|
+
* @description 通过滑动触发选项的容器
|
|
138
|
+
* @tutorial https://ext.dcloud.net.cn/plugin?id=181
|
|
139
|
+
* @property {Boolean} show = [left|right|none] 开启关闭组件,auto-close = false 时生效
|
|
140
|
+
* @property {Boolean} disabled = [true|false] 是否禁止滑动
|
|
141
|
+
* @property {Boolean} autoClose = [true|false] 滑动打开当前组件,是否关闭其他组件
|
|
142
|
+
* @property {Number} threshold 滑动缺省值
|
|
143
|
+
* @property {Array} leftOptions 左侧选项内容及样式
|
|
144
|
+
* @property {Array} rgihtOptions 右侧选项内容及样式
|
|
145
|
+
* @event {Function} click 点击选项按钮时触发事件,e = {content,index} ,content(点击内容)、index(下标)
|
|
146
|
+
* @event {Function} change 组件打开或关闭时触发,left\right\none
|
|
147
|
+
*/
|
|
148
|
+
|
|
149
|
+
export default {
|
|
150
|
+
mixins: [mpwxs, bindingx, mpother],
|
|
151
|
+
emits: ['click', 'change'],
|
|
152
|
+
props: {
|
|
153
|
+
// 控制开关
|
|
154
|
+
show: {
|
|
155
|
+
type: String,
|
|
156
|
+
default: 'none'
|
|
157
|
+
},
|
|
158
|
+
|
|
159
|
+
// 禁用
|
|
160
|
+
disabled: {
|
|
161
|
+
type: Boolean,
|
|
162
|
+
default: false
|
|
163
|
+
},
|
|
164
|
+
|
|
165
|
+
// 是否自动关闭
|
|
166
|
+
autoClose: {
|
|
167
|
+
type: Boolean,
|
|
168
|
+
default: true
|
|
169
|
+
},
|
|
170
|
+
|
|
171
|
+
// 滑动缺省距离
|
|
172
|
+
threshold: {
|
|
173
|
+
type: Number,
|
|
174
|
+
default: 20
|
|
175
|
+
},
|
|
176
|
+
|
|
177
|
+
// 左侧按钮内容
|
|
178
|
+
leftOptions: {
|
|
179
|
+
type: Array,
|
|
180
|
+
default () {
|
|
181
|
+
return []
|
|
182
|
+
}
|
|
183
|
+
},
|
|
184
|
+
|
|
185
|
+
// 右侧按钮内容
|
|
186
|
+
rightOptions: {
|
|
187
|
+
type: Array,
|
|
188
|
+
default () {
|
|
189
|
+
return []
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
},
|
|
194
|
+
// #ifndef VUE3
|
|
195
|
+
// TODO vue2
|
|
196
|
+
destroyed() {
|
|
197
|
+
if (this.__isUnmounted) return
|
|
198
|
+
this.uninstall()
|
|
199
|
+
},
|
|
200
|
+
// #endif
|
|
201
|
+
// #ifdef VUE3
|
|
202
|
+
// TODO vue3
|
|
203
|
+
unmounted() {
|
|
204
|
+
this.__isUnmounted = true
|
|
205
|
+
this.uninstall()
|
|
206
|
+
},
|
|
207
|
+
// #endif
|
|
208
|
+
|
|
209
|
+
methods: {
|
|
210
|
+
uninstall() {
|
|
211
|
+
if (this.swipeaction) {
|
|
212
|
+
this.swipeaction.children.forEach((item, index) => {
|
|
213
|
+
if (item === this) {
|
|
214
|
+
this.swipeaction.children.splice(index, 1)
|
|
215
|
+
}
|
|
216
|
+
})
|
|
217
|
+
}
|
|
218
|
+
},
|
|
219
|
+
/**
|
|
220
|
+
* 获取父元素实例
|
|
221
|
+
*/
|
|
222
|
+
getSwipeAction(name = 'uniSwipeAction') {
|
|
223
|
+
let parent = this.$parent;
|
|
224
|
+
let parentName = parent.$options.name;
|
|
225
|
+
while (parentName !== name) {
|
|
226
|
+
parent = parent.$parent;
|
|
227
|
+
if (!parent) return false;
|
|
228
|
+
parentName = parent.$options.name;
|
|
229
|
+
}
|
|
230
|
+
return parent;
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
</script>
|
|
235
|
+
<style lang="scss">
|
|
236
|
+
.uni-swipe {
|
|
237
|
+
position: relative;
|
|
238
|
+
/* #ifndef APP-NVUE */
|
|
239
|
+
overflow: hidden;
|
|
240
|
+
/* #endif */
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
.uni-swipe_box {
|
|
244
|
+
/* #ifndef APP-NVUE */
|
|
245
|
+
display: flex;
|
|
246
|
+
flex-shrink: 0;
|
|
247
|
+
// touch-action: none;
|
|
248
|
+
/* #endif */
|
|
249
|
+
position: relative;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
.uni-swipe_content {
|
|
253
|
+
// border: 1px red solid;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
.uni-swipe_text--center {
|
|
257
|
+
width: 100%;
|
|
258
|
+
/* #ifndef APP-NVUE */
|
|
259
|
+
cursor: grab;
|
|
260
|
+
/* #endif */
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
.uni-swipe_button-group {
|
|
264
|
+
/* #ifndef APP-NVUE */
|
|
265
|
+
box-sizing: border-box;
|
|
266
|
+
display: flex;
|
|
267
|
+
/* #endif */
|
|
268
|
+
flex-direction: row;
|
|
269
|
+
position: absolute;
|
|
270
|
+
top: 0;
|
|
271
|
+
bottom: 0;
|
|
272
|
+
/* #ifdef H5 */
|
|
273
|
+
cursor: pointer;
|
|
274
|
+
/* #endif */
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
.button-group--left {
|
|
278
|
+
left: 0;
|
|
279
|
+
transform: translateX(-100%)
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
.button-group--right {
|
|
283
|
+
right: 0;
|
|
284
|
+
transform: translateX(100%)
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
.uni-swipe_button {
|
|
288
|
+
/* #ifdef APP-NVUE */
|
|
289
|
+
flex: 1;
|
|
290
|
+
/* #endif */
|
|
291
|
+
/* #ifndef APP-NVUE */
|
|
292
|
+
display: flex;
|
|
293
|
+
/* #endif */
|
|
294
|
+
flex-direction: row;
|
|
295
|
+
justify-content: center;
|
|
296
|
+
align-items: center;
|
|
297
|
+
padding: 0 20px;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
.uni-swipe_button-text {
|
|
301
|
+
/* #ifndef APP-NVUE */
|
|
302
|
+
flex-shrink: 0;
|
|
303
|
+
/* #endif */
|
|
304
|
+
font-size: 14px;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
.ani {
|
|
308
|
+
transition-property: transform;
|
|
309
|
+
transition-duration: 0.3s;
|
|
310
|
+
transition-timing-function: cubic-bezier(0.165, 0.84, 0.44, 1);
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
/* #ifdef MP-ALIPAY */
|
|
314
|
+
.movable-area {
|
|
315
|
+
/* width: 100%; */
|
|
316
|
+
height: 45px;
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
.movable-view {
|
|
320
|
+
display: flex;
|
|
321
|
+
/* justify-content: center; */
|
|
322
|
+
position: relative;
|
|
323
|
+
flex: 1;
|
|
324
|
+
height: 45px;
|
|
325
|
+
z-index: 2;
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
.movable-view-button {
|
|
329
|
+
display: flex;
|
|
330
|
+
flex-shrink: 0;
|
|
331
|
+
flex-direction: row;
|
|
332
|
+
height: 100%;
|
|
333
|
+
background: #C0C0C0;
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
/* .transition {
|
|
337
|
+
transition: all 0.3s;
|
|
338
|
+
} */
|
|
339
|
+
|
|
340
|
+
.movable-view-box {
|
|
341
|
+
flex-shrink: 0;
|
|
342
|
+
height: 100%;
|
|
343
|
+
background-color: #fff;
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
/* #endif */
|
|
347
|
+
</style>
|