@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,195 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
data() {
|
|
3
|
+
return {
|
|
4
|
+
x: 0,
|
|
5
|
+
transition: false,
|
|
6
|
+
width: 0,
|
|
7
|
+
viewWidth: 0,
|
|
8
|
+
swipeShow: 0
|
|
9
|
+
}
|
|
10
|
+
},
|
|
11
|
+
watch: {
|
|
12
|
+
show(newVal) {
|
|
13
|
+
if (this.autoClose) return
|
|
14
|
+
if (newVal && newVal !== 'none') {
|
|
15
|
+
this.transition = true
|
|
16
|
+
this.open(newVal)
|
|
17
|
+
} else {
|
|
18
|
+
this.close()
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
created() {
|
|
23
|
+
this.swipeaction = this.getSwipeAction()
|
|
24
|
+
if (this.swipeaction && Array.isArray(this.swipeaction.children)) {
|
|
25
|
+
this.swipeaction.children.push(this)
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
mounted() {
|
|
29
|
+
this.isopen = false
|
|
30
|
+
setTimeout(() => {
|
|
31
|
+
this.getQuerySelect()
|
|
32
|
+
}, 50)
|
|
33
|
+
},
|
|
34
|
+
methods: {
|
|
35
|
+
appTouchStart(e) {
|
|
36
|
+
const {
|
|
37
|
+
clientX
|
|
38
|
+
} = e.changedTouches[0]
|
|
39
|
+
this.clientX = clientX
|
|
40
|
+
this.timestamp = new Date().getTime()
|
|
41
|
+
},
|
|
42
|
+
appTouchEnd(e, index, item, position) {
|
|
43
|
+
const {
|
|
44
|
+
clientX
|
|
45
|
+
} = e.changedTouches[0]
|
|
46
|
+
// fixed by xxxx 模拟点击事件,解决 ios 13 点击区域错位的问题
|
|
47
|
+
let diff = Math.abs(this.clientX - clientX)
|
|
48
|
+
let time = (new Date().getTime()) - this.timestamp
|
|
49
|
+
if (diff < 40 && time < 300) {
|
|
50
|
+
this.$emit('click', {
|
|
51
|
+
content: item,
|
|
52
|
+
index,
|
|
53
|
+
position
|
|
54
|
+
})
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
/**
|
|
58
|
+
* 移动触发
|
|
59
|
+
* @param {Object} e
|
|
60
|
+
*/
|
|
61
|
+
onChange(e) {
|
|
62
|
+
this.moveX = e.detail.x
|
|
63
|
+
this.isclose = false
|
|
64
|
+
},
|
|
65
|
+
touchstart(e) {
|
|
66
|
+
this.transition = false
|
|
67
|
+
this.isclose = true
|
|
68
|
+
if (this.autoClose && this.swipeaction) {
|
|
69
|
+
this.swipeaction.closeOther(this)
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
touchmove(e) {},
|
|
73
|
+
touchend(e) {
|
|
74
|
+
// 0的位置什么都不执行
|
|
75
|
+
if (this.isclose && this.isopen === 'none') return
|
|
76
|
+
if (this.isclose && this.isopen !== 'none') {
|
|
77
|
+
this.transition = true
|
|
78
|
+
this.close()
|
|
79
|
+
} else {
|
|
80
|
+
this.move(this.moveX + this.leftWidth)
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* 移动
|
|
86
|
+
* @param {Object} moveX
|
|
87
|
+
*/
|
|
88
|
+
move(moveX) {
|
|
89
|
+
// 打开关闭的处理逻辑不太一样
|
|
90
|
+
this.transition = true
|
|
91
|
+
// 未打开状态
|
|
92
|
+
if (!this.isopen || this.isopen === 'none') {
|
|
93
|
+
if (moveX > this.threshold) {
|
|
94
|
+
this.open('left')
|
|
95
|
+
} else if (moveX < -this.threshold) {
|
|
96
|
+
this.open('right')
|
|
97
|
+
} else {
|
|
98
|
+
this.close()
|
|
99
|
+
}
|
|
100
|
+
} else {
|
|
101
|
+
if (moveX < 0 && moveX < this.rightWidth) {
|
|
102
|
+
const rightX = this.rightWidth + moveX
|
|
103
|
+
if (rightX < this.threshold) {
|
|
104
|
+
this.open('right')
|
|
105
|
+
} else {
|
|
106
|
+
this.close()
|
|
107
|
+
}
|
|
108
|
+
} else if (moveX > 0 && moveX < this.leftWidth) {
|
|
109
|
+
const leftX = this.leftWidth - moveX
|
|
110
|
+
if (leftX < this.threshold) {
|
|
111
|
+
this.open('left')
|
|
112
|
+
} else {
|
|
113
|
+
this.close()
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
},
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* 打开
|
|
123
|
+
*/
|
|
124
|
+
open(type) {
|
|
125
|
+
this.x = this.moveX
|
|
126
|
+
this.animation(type)
|
|
127
|
+
},
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* 关闭
|
|
131
|
+
*/
|
|
132
|
+
close() {
|
|
133
|
+
this.x = this.moveX
|
|
134
|
+
// TODO 解决 x 值不更新的问题,所以会多触发一次 nextTick ,待优化
|
|
135
|
+
this.$nextTick(() => {
|
|
136
|
+
this.x = -this.leftWidth
|
|
137
|
+
if (this.isopen !== 'none') {
|
|
138
|
+
this.$emit('change', 'none')
|
|
139
|
+
}
|
|
140
|
+
this.isopen = 'none'
|
|
141
|
+
})
|
|
142
|
+
},
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* 执行结束动画
|
|
146
|
+
* @param {Object} type
|
|
147
|
+
*/
|
|
148
|
+
animation(type) {
|
|
149
|
+
this.$nextTick(() => {
|
|
150
|
+
if (type === 'left') {
|
|
151
|
+
this.x = 0
|
|
152
|
+
} else {
|
|
153
|
+
this.x = -this.rightWidth - this.leftWidth
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
if (this.isopen !== type) {
|
|
157
|
+
this.$emit('change', type)
|
|
158
|
+
}
|
|
159
|
+
this.isopen = type
|
|
160
|
+
})
|
|
161
|
+
|
|
162
|
+
},
|
|
163
|
+
getSlide(x) {},
|
|
164
|
+
getQuerySelect() {
|
|
165
|
+
const query = uni.createSelectorQuery().in(this);
|
|
166
|
+
query.selectAll('.movable-view--hock').boundingClientRect(data => {
|
|
167
|
+
this.leftWidth = data[1].width
|
|
168
|
+
this.rightWidth = data[2].width
|
|
169
|
+
this.width = data[0].width
|
|
170
|
+
this.viewWidth = this.width + this.rightWidth + this.leftWidth
|
|
171
|
+
if (this.leftWidth === 0) {
|
|
172
|
+
// TODO 疑似bug ,初始化的时候如果x 是0,会导致移动位置错误,所以让元素超出一点
|
|
173
|
+
this.x = -0.1
|
|
174
|
+
} else {
|
|
175
|
+
this.x = -this.leftWidth
|
|
176
|
+
}
|
|
177
|
+
this.moveX = this.x
|
|
178
|
+
this.$nextTick(() => {
|
|
179
|
+
this.swipeShow = 1
|
|
180
|
+
})
|
|
181
|
+
|
|
182
|
+
if (!this.buttonWidth) {
|
|
183
|
+
this.disabledView = true
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
if (this.autoClose) return
|
|
187
|
+
if (this.show !== 'none') {
|
|
188
|
+
this.transition = true
|
|
189
|
+
this.open(this.shows)
|
|
190
|
+
}
|
|
191
|
+
}).exec();
|
|
192
|
+
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
}
|
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
let otherMixins = {}
|
|
2
|
+
|
|
3
|
+
// #ifndef APP-PLUS|| MP-WEIXIN || H5
|
|
4
|
+
const MIN_DISTANCE = 10;
|
|
5
|
+
otherMixins = {
|
|
6
|
+
data() {
|
|
7
|
+
// TODO 随机生生元素ID,解决百度小程序获取同一个元素位置信息的bug
|
|
8
|
+
const elClass = `Uni_${Math.ceil(Math.random() * 10e5).toString(36)}`
|
|
9
|
+
return {
|
|
10
|
+
uniShow: false,
|
|
11
|
+
left: 0,
|
|
12
|
+
buttonShow: 'none',
|
|
13
|
+
ani: false,
|
|
14
|
+
moveLeft: '',
|
|
15
|
+
elClass
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
watch: {
|
|
19
|
+
show(newVal) {
|
|
20
|
+
if (this.autoClose) return
|
|
21
|
+
this.openState(newVal)
|
|
22
|
+
},
|
|
23
|
+
left() {
|
|
24
|
+
this.moveLeft = `translateX(${this.left}px)`
|
|
25
|
+
},
|
|
26
|
+
buttonShow(newVal) {
|
|
27
|
+
if (this.autoClose) return
|
|
28
|
+
this.openState(newVal)
|
|
29
|
+
},
|
|
30
|
+
leftOptions() {
|
|
31
|
+
this.init()
|
|
32
|
+
},
|
|
33
|
+
rightOptions() {
|
|
34
|
+
this.init()
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
mounted() {
|
|
38
|
+
this.swipeaction = this.getSwipeAction()
|
|
39
|
+
if (this.swipeaction && Array.isArray(this.swipeaction.children)) {
|
|
40
|
+
this.swipeaction.children.push(this)
|
|
41
|
+
}
|
|
42
|
+
this.init()
|
|
43
|
+
},
|
|
44
|
+
methods: {
|
|
45
|
+
init() {
|
|
46
|
+
clearTimeout(this.timer)
|
|
47
|
+
this.timer = setTimeout(() => {
|
|
48
|
+
this.getSelectorQuery()
|
|
49
|
+
}, 100)
|
|
50
|
+
// 移动距离
|
|
51
|
+
this.left = 0
|
|
52
|
+
this.x = 0
|
|
53
|
+
},
|
|
54
|
+
|
|
55
|
+
closeSwipe(e) {
|
|
56
|
+
if (this.autoClose && this.swipeaction) {
|
|
57
|
+
this.swipeaction.closeOther(this)
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
appTouchStart(e) {
|
|
61
|
+
const {
|
|
62
|
+
clientX
|
|
63
|
+
} = e.changedTouches[0]
|
|
64
|
+
this.clientX = clientX
|
|
65
|
+
this.timestamp = new Date().getTime()
|
|
66
|
+
},
|
|
67
|
+
appTouchEnd(e, index, item, position) {
|
|
68
|
+
const {
|
|
69
|
+
clientX
|
|
70
|
+
} = e.changedTouches[0]
|
|
71
|
+
// fixed by xxxx 模拟点击事件,解决 ios 13 点击区域错位的问题
|
|
72
|
+
let diff = Math.abs(this.clientX - clientX)
|
|
73
|
+
let time = (new Date().getTime()) - this.timestamp
|
|
74
|
+
if (diff < 40 && time < 300) {
|
|
75
|
+
this.$emit('click', {
|
|
76
|
+
content: item,
|
|
77
|
+
index,
|
|
78
|
+
position
|
|
79
|
+
})
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
touchstart(e) {
|
|
83
|
+
if (this.disabled) return
|
|
84
|
+
this.ani = false
|
|
85
|
+
this.x = this.left || 0
|
|
86
|
+
this.stopTouchStart(e)
|
|
87
|
+
this.autoClose && this.closeSwipe()
|
|
88
|
+
},
|
|
89
|
+
touchmove(e) {
|
|
90
|
+
if (this.disabled) return
|
|
91
|
+
// 是否可以滑动页面
|
|
92
|
+
this.stopTouchMove(e);
|
|
93
|
+
if (this.direction !== 'horizontal') {
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
this.move(this.x + this.deltaX)
|
|
97
|
+
return false
|
|
98
|
+
},
|
|
99
|
+
touchend() {
|
|
100
|
+
if (this.disabled) return
|
|
101
|
+
this.moveDirection(this.left)
|
|
102
|
+
},
|
|
103
|
+
/**
|
|
104
|
+
* 设置移动距离
|
|
105
|
+
* @param {Object} value
|
|
106
|
+
*/
|
|
107
|
+
move(value) {
|
|
108
|
+
value = value || 0
|
|
109
|
+
const leftWidth = this.leftWidth
|
|
110
|
+
const rightWidth = this.rightWidth
|
|
111
|
+
// 获取可滑动范围
|
|
112
|
+
this.left = this.range(value, -rightWidth, leftWidth);
|
|
113
|
+
},
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* 获取范围
|
|
117
|
+
* @param {Object} num
|
|
118
|
+
* @param {Object} min
|
|
119
|
+
* @param {Object} max
|
|
120
|
+
*/
|
|
121
|
+
range(num, min, max) {
|
|
122
|
+
return Math.min(Math.max(num, min), max);
|
|
123
|
+
},
|
|
124
|
+
/**
|
|
125
|
+
* 移动方向判断
|
|
126
|
+
* @param {Object} left
|
|
127
|
+
* @param {Object} value
|
|
128
|
+
*/
|
|
129
|
+
moveDirection(left) {
|
|
130
|
+
const threshold = this.threshold
|
|
131
|
+
const isopen = this.isopen || 'none'
|
|
132
|
+
const leftWidth = this.leftWidth
|
|
133
|
+
const rightWidth = this.rightWidth
|
|
134
|
+
if (this.deltaX === 0) {
|
|
135
|
+
this.openState('none')
|
|
136
|
+
return
|
|
137
|
+
}
|
|
138
|
+
if ((isopen === 'none' && rightWidth > 0 && -left > threshold) || (isopen !== 'none' && rightWidth >
|
|
139
|
+
0 && rightWidth +
|
|
140
|
+
left < threshold)) {
|
|
141
|
+
// right
|
|
142
|
+
this.openState('right')
|
|
143
|
+
} else if ((isopen === 'none' && leftWidth > 0 && left > threshold) || (isopen !== 'none' && leftWidth >
|
|
144
|
+
0 &&
|
|
145
|
+
leftWidth - left < threshold)) {
|
|
146
|
+
// left
|
|
147
|
+
this.openState('left')
|
|
148
|
+
} else {
|
|
149
|
+
// default
|
|
150
|
+
this.openState('none')
|
|
151
|
+
}
|
|
152
|
+
},
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* 开启状态
|
|
156
|
+
* @param {Boolean} type
|
|
157
|
+
*/
|
|
158
|
+
openState(type) {
|
|
159
|
+
const leftWidth = this.leftWidth
|
|
160
|
+
const rightWidth = this.rightWidth
|
|
161
|
+
let left = ''
|
|
162
|
+
this.isopen = this.isopen ? this.isopen : 'none'
|
|
163
|
+
switch (type) {
|
|
164
|
+
case "left":
|
|
165
|
+
left = leftWidth
|
|
166
|
+
break
|
|
167
|
+
case "right":
|
|
168
|
+
left = -rightWidth
|
|
169
|
+
break
|
|
170
|
+
default:
|
|
171
|
+
left = 0
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
if (this.isopen !== type) {
|
|
176
|
+
this.throttle = true
|
|
177
|
+
this.$emit('change', type)
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
this.isopen = type
|
|
181
|
+
// 添加动画类
|
|
182
|
+
this.ani = true
|
|
183
|
+
this.$nextTick(() => {
|
|
184
|
+
this.move(left)
|
|
185
|
+
})
|
|
186
|
+
// 设置最终移动位置,理论上只要进入到这个函数,肯定是要打开的
|
|
187
|
+
},
|
|
188
|
+
close() {
|
|
189
|
+
this.openState('none')
|
|
190
|
+
},
|
|
191
|
+
getDirection(x, y) {
|
|
192
|
+
if (x > y && x > MIN_DISTANCE) {
|
|
193
|
+
return 'horizontal';
|
|
194
|
+
}
|
|
195
|
+
if (y > x && y > MIN_DISTANCE) {
|
|
196
|
+
return 'vertical';
|
|
197
|
+
}
|
|
198
|
+
return '';
|
|
199
|
+
},
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* 重置滑动状态
|
|
203
|
+
* @param {Object} event
|
|
204
|
+
*/
|
|
205
|
+
resetTouchStatus() {
|
|
206
|
+
this.direction = '';
|
|
207
|
+
this.deltaX = 0;
|
|
208
|
+
this.deltaY = 0;
|
|
209
|
+
this.offsetX = 0;
|
|
210
|
+
this.offsetY = 0;
|
|
211
|
+
},
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* 设置滑动开始位置
|
|
215
|
+
* @param {Object} event
|
|
216
|
+
*/
|
|
217
|
+
stopTouchStart(event) {
|
|
218
|
+
this.resetTouchStatus();
|
|
219
|
+
const touch = event.touches[0];
|
|
220
|
+
this.startX = touch.clientX;
|
|
221
|
+
this.startY = touch.clientY;
|
|
222
|
+
},
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* 滑动中,是否禁止打开
|
|
226
|
+
* @param {Object} event
|
|
227
|
+
*/
|
|
228
|
+
stopTouchMove(event) {
|
|
229
|
+
const touch = event.touches[0];
|
|
230
|
+
this.deltaX = touch.clientX - this.startX;
|
|
231
|
+
this.deltaY = touch.clientY - this.startY;
|
|
232
|
+
this.offsetX = Math.abs(this.deltaX);
|
|
233
|
+
this.offsetY = Math.abs(this.deltaY);
|
|
234
|
+
this.direction = this.direction || this.getDirection(this.offsetX, this.offsetY);
|
|
235
|
+
},
|
|
236
|
+
|
|
237
|
+
getSelectorQuery() {
|
|
238
|
+
const views = uni.createSelectorQuery().in(this)
|
|
239
|
+
views
|
|
240
|
+
.selectAll('.' + this.elClass)
|
|
241
|
+
.boundingClientRect(data => {
|
|
242
|
+
if (data.length === 0) return
|
|
243
|
+
let show = 'none'
|
|
244
|
+
if (this.autoClose) {
|
|
245
|
+
show = 'none'
|
|
246
|
+
} else {
|
|
247
|
+
show = this.show
|
|
248
|
+
}
|
|
249
|
+
this.leftWidth = data[0].width || 0
|
|
250
|
+
this.rightWidth = data[1].width || 0
|
|
251
|
+
this.buttonShow = show
|
|
252
|
+
})
|
|
253
|
+
.exec()
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
// #endif
|
|
259
|
+
|
|
260
|
+
export default otherMixins
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
let mpMixins = {}
|
|
2
|
+
let is_pc = null
|
|
3
|
+
// #ifdef H5
|
|
4
|
+
import {
|
|
5
|
+
isPC
|
|
6
|
+
} from "./isPC"
|
|
7
|
+
is_pc = isPC()
|
|
8
|
+
// #endif
|
|
9
|
+
// #ifdef APP-VUE|| MP-WEIXIN || H5
|
|
10
|
+
|
|
11
|
+
mpMixins = {
|
|
12
|
+
data() {
|
|
13
|
+
return {
|
|
14
|
+
is_show: 'none'
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
watch: {
|
|
18
|
+
show(newVal) {
|
|
19
|
+
this.is_show = this.show
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
created() {
|
|
23
|
+
this.swipeaction = this.getSwipeAction()
|
|
24
|
+
if (this.swipeaction && Array.isArray(this.swipeaction.children)) {
|
|
25
|
+
this.swipeaction.children.push(this)
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
mounted() {
|
|
29
|
+
this.is_show = this.show
|
|
30
|
+
},
|
|
31
|
+
methods: {
|
|
32
|
+
// wxs 中调用
|
|
33
|
+
closeSwipe(e) {
|
|
34
|
+
if (this.autoClose && this.swipeaction) {
|
|
35
|
+
this.swipeaction.closeOther(this)
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
|
|
39
|
+
change(e) {
|
|
40
|
+
this.$emit('change', e.open)
|
|
41
|
+
if (this.is_show !== e.open) {
|
|
42
|
+
this.is_show = e.open
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
|
|
46
|
+
appTouchStart(e) {
|
|
47
|
+
if (is_pc) return
|
|
48
|
+
const {
|
|
49
|
+
clientX
|
|
50
|
+
} = e.changedTouches[0]
|
|
51
|
+
this.clientX = clientX
|
|
52
|
+
this.timestamp = new Date().getTime()
|
|
53
|
+
},
|
|
54
|
+
appTouchEnd(e, index, item, position) {
|
|
55
|
+
if (is_pc) return
|
|
56
|
+
const {
|
|
57
|
+
clientX
|
|
58
|
+
} = e.changedTouches[0]
|
|
59
|
+
// fixed by xxxx 模拟点击事件,解决 ios 13 点击区域错位的问题
|
|
60
|
+
let diff = Math.abs(this.clientX - clientX)
|
|
61
|
+
let time = (new Date().getTime()) - this.timestamp
|
|
62
|
+
if (diff < 40 && time < 300) {
|
|
63
|
+
this.$emit('click', {
|
|
64
|
+
content: item,
|
|
65
|
+
index,
|
|
66
|
+
position
|
|
67
|
+
})
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
onClickForPC(index, item, position) {
|
|
71
|
+
if (!is_pc) return
|
|
72
|
+
// #ifdef H5
|
|
73
|
+
this.$emit('click', {
|
|
74
|
+
content: item,
|
|
75
|
+
index,
|
|
76
|
+
position
|
|
77
|
+
})
|
|
78
|
+
// #endif
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// #endif
|
|
84
|
+
export default mpMixins
|