@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,341 @@
|
|
|
1
|
+
var MIN_DISTANCE = 10;
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* 判断当前是否为H5、app-vue
|
|
5
|
+
*/
|
|
6
|
+
var IS_HTML5 = false
|
|
7
|
+
if (typeof window === 'object') IS_HTML5 = true
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* 监听页面内值的变化,主要用于动态开关swipe-action
|
|
11
|
+
* @param {Object} newValue
|
|
12
|
+
* @param {Object} oldValue
|
|
13
|
+
* @param {Object} ownerInstance
|
|
14
|
+
* @param {Object} instance
|
|
15
|
+
*/
|
|
16
|
+
function showWatch(newVal, oldVal, ownerInstance, instance) {
|
|
17
|
+
var state = instance.getState()
|
|
18
|
+
getDom(instance, ownerInstance)
|
|
19
|
+
if (newVal && newVal !== 'none') {
|
|
20
|
+
openState(newVal, instance, ownerInstance)
|
|
21
|
+
return
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
if (state.left) {
|
|
25
|
+
openState('none', instance, ownerInstance)
|
|
26
|
+
}
|
|
27
|
+
resetTouchStatus(instance)
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* 开始触摸操作
|
|
32
|
+
* @param {Object} e
|
|
33
|
+
* @param {Object} ins
|
|
34
|
+
*/
|
|
35
|
+
function touchstart(e, ownerInstance) {
|
|
36
|
+
var instance = e.instance;
|
|
37
|
+
var disabled = instance.getDataset().disabled
|
|
38
|
+
var state = instance.getState();
|
|
39
|
+
getDom(instance, ownerInstance)
|
|
40
|
+
// fix by mehaotian, TODO 兼容 app-vue 获取dataset为字符串 , h5 获取 为 undefined 的问题,待框架修复
|
|
41
|
+
disabled = (typeof(disabled) === 'string' ? JSON.parse(disabled) : disabled) || false;
|
|
42
|
+
if (disabled) return
|
|
43
|
+
// 开始触摸时移除动画类
|
|
44
|
+
instance.requestAnimationFrame(function() {
|
|
45
|
+
instance.removeClass('ani');
|
|
46
|
+
ownerInstance.callMethod('closeSwipe');
|
|
47
|
+
})
|
|
48
|
+
|
|
49
|
+
// 记录上次的位置
|
|
50
|
+
state.x = state.left || 0
|
|
51
|
+
// 计算滑动开始位置
|
|
52
|
+
stopTouchStart(e, ownerInstance)
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* 开始滑动操作
|
|
57
|
+
* @param {Object} e
|
|
58
|
+
* @param {Object} ownerInstance
|
|
59
|
+
*/
|
|
60
|
+
function touchmove(e, ownerInstance) {
|
|
61
|
+
var instance = e.instance;
|
|
62
|
+
var disabled = instance.getDataset().disabled
|
|
63
|
+
var state = instance.getState()
|
|
64
|
+
// fix by mehaotian, TODO 兼容 app-vue 获取dataset为字符串 , h5 获取 为 undefined 的问题,待框架修复
|
|
65
|
+
disabled = (typeof(disabled) === 'string' ? JSON.parse(disabled) : disabled) || false;
|
|
66
|
+
if (disabled) return
|
|
67
|
+
// 是否可以滑动页面
|
|
68
|
+
stopTouchMove(e);
|
|
69
|
+
if (state.direction !== 'horizontal') {
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
if (e.preventDefault) {
|
|
74
|
+
// 阻止页面滚动
|
|
75
|
+
e.preventDefault()
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
move(state.x + state.deltaX, instance, ownerInstance)
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* 结束触摸操作
|
|
83
|
+
* @param {Object} e
|
|
84
|
+
* @param {Object} ownerInstance
|
|
85
|
+
*/
|
|
86
|
+
function touchend(e, ownerInstance) {
|
|
87
|
+
var instance = e.instance;
|
|
88
|
+
var disabled = instance.getDataset().disabled
|
|
89
|
+
var state = instance.getState()
|
|
90
|
+
// fix by mehaotian, TODO 兼容 app-vue 获取dataset为字符串 , h5 获取 为 undefined 的问题,待框架修复
|
|
91
|
+
disabled = (typeof(disabled) === 'string' ? JSON.parse(disabled) : disabled) || false;
|
|
92
|
+
|
|
93
|
+
if (disabled) return
|
|
94
|
+
// 滑动过程中触摸结束,通过阙值判断是开启还是关闭
|
|
95
|
+
// fixed by mehaotian 定时器解决点击按钮,touchend 触发比 click 事件时机早的问题 ,主要是 ios13
|
|
96
|
+
moveDirection(state.left, instance, ownerInstance)
|
|
97
|
+
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* 设置移动距离
|
|
102
|
+
* @param {Object} value
|
|
103
|
+
* @param {Object} instance
|
|
104
|
+
* @param {Object} ownerInstance
|
|
105
|
+
*/
|
|
106
|
+
function move(value, instance, ownerInstance) {
|
|
107
|
+
value = value || 0
|
|
108
|
+
var state = instance.getState()
|
|
109
|
+
var leftWidth = state.leftWidth
|
|
110
|
+
var rightWidth = state.rightWidth
|
|
111
|
+
// 获取可滑动范围
|
|
112
|
+
state.left = range(value, -rightWidth, leftWidth);
|
|
113
|
+
instance.requestAnimationFrame(function() {
|
|
114
|
+
instance.setStyle({
|
|
115
|
+
transform: 'translateX(' + state.left + 'px)',
|
|
116
|
+
'-webkit-transform': 'translateX(' + state.left + 'px)'
|
|
117
|
+
})
|
|
118
|
+
})
|
|
119
|
+
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* 获取元素信息
|
|
124
|
+
* @param {Object} instance
|
|
125
|
+
* @param {Object} ownerInstance
|
|
126
|
+
*/
|
|
127
|
+
function getDom(instance, ownerInstance) {
|
|
128
|
+
var state = instance.getState()
|
|
129
|
+
var leftDom = ownerInstance.selectComponent('.button-group--left')
|
|
130
|
+
var rightDom = ownerInstance.selectComponent('.button-group--right')
|
|
131
|
+
var leftStyles = {
|
|
132
|
+
width: 0
|
|
133
|
+
}
|
|
134
|
+
var rightStyles = {
|
|
135
|
+
width: 0
|
|
136
|
+
}
|
|
137
|
+
leftStyles = leftDom.getBoundingClientRect()
|
|
138
|
+
rightStyles = rightDom.getBoundingClientRect()
|
|
139
|
+
|
|
140
|
+
state.leftWidth = leftStyles.width || 0
|
|
141
|
+
state.rightWidth = rightStyles.width || 0
|
|
142
|
+
state.threshold = instance.getDataset().threshold
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* 获取范围
|
|
147
|
+
* @param {Object} num
|
|
148
|
+
* @param {Object} min
|
|
149
|
+
* @param {Object} max
|
|
150
|
+
*/
|
|
151
|
+
function range(num, min, max) {
|
|
152
|
+
return Math.min(Math.max(num, min), max);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* 移动方向判断
|
|
158
|
+
* @param {Object} left
|
|
159
|
+
* @param {Object} value
|
|
160
|
+
* @param {Object} ownerInstance
|
|
161
|
+
* @param {Object} ins
|
|
162
|
+
*/
|
|
163
|
+
function moveDirection(left, ins, ownerInstance) {
|
|
164
|
+
var state = ins.getState()
|
|
165
|
+
var threshold = state.threshold
|
|
166
|
+
var position = state.position
|
|
167
|
+
var isopen = state.isopen || 'none'
|
|
168
|
+
var leftWidth = state.leftWidth
|
|
169
|
+
var rightWidth = state.rightWidth
|
|
170
|
+
if (state.deltaX === 0) {
|
|
171
|
+
openState('none', ins, ownerInstance)
|
|
172
|
+
return
|
|
173
|
+
}
|
|
174
|
+
if ((isopen === 'none' && rightWidth > 0 && -left > threshold) || (isopen !== 'none' && rightWidth > 0 &&
|
|
175
|
+
rightWidth +
|
|
176
|
+
left < threshold)) {
|
|
177
|
+
// right
|
|
178
|
+
openState('right', ins, ownerInstance)
|
|
179
|
+
} else if ((isopen === 'none' && leftWidth > 0 && left > threshold) || (isopen !== 'none' && leftWidth > 0 &&
|
|
180
|
+
leftWidth - left < threshold)) {
|
|
181
|
+
// left
|
|
182
|
+
openState('left', ins, ownerInstance)
|
|
183
|
+
} else {
|
|
184
|
+
// default
|
|
185
|
+
openState('none', ins, ownerInstance)
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* 开启状态
|
|
192
|
+
* @param {Boolean} type
|
|
193
|
+
* @param {Object} ins
|
|
194
|
+
* @param {Object} ownerInstance
|
|
195
|
+
*/
|
|
196
|
+
function openState(type, ins, ownerInstance) {
|
|
197
|
+
var state = ins.getState()
|
|
198
|
+
var leftWidth = state.leftWidth
|
|
199
|
+
var rightWidth = state.rightWidth
|
|
200
|
+
var left = ''
|
|
201
|
+
state.isopen = state.isopen ? state.isopen : 'none'
|
|
202
|
+
switch (type) {
|
|
203
|
+
case "left":
|
|
204
|
+
left = leftWidth
|
|
205
|
+
break
|
|
206
|
+
case "right":
|
|
207
|
+
left = -rightWidth
|
|
208
|
+
break
|
|
209
|
+
default:
|
|
210
|
+
left = 0
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
// && !state.throttle
|
|
214
|
+
|
|
215
|
+
if (state.isopen !== type) {
|
|
216
|
+
state.throttle = true
|
|
217
|
+
ownerInstance.callMethod('change', {
|
|
218
|
+
open: type
|
|
219
|
+
})
|
|
220
|
+
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
state.isopen = type
|
|
224
|
+
// 添加动画类
|
|
225
|
+
ins.requestAnimationFrame(function() {
|
|
226
|
+
ins.addClass('ani');
|
|
227
|
+
move(left, ins, ownerInstance)
|
|
228
|
+
})
|
|
229
|
+
// 设置最终移动位置,理论上只要进入到这个函数,肯定是要打开的
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
|
|
233
|
+
function getDirection(x, y) {
|
|
234
|
+
if (x > y && x > MIN_DISTANCE) {
|
|
235
|
+
return 'horizontal';
|
|
236
|
+
}
|
|
237
|
+
if (y > x && y > MIN_DISTANCE) {
|
|
238
|
+
return 'vertical';
|
|
239
|
+
}
|
|
240
|
+
return '';
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* 重置滑动状态
|
|
245
|
+
* @param {Object} event
|
|
246
|
+
*/
|
|
247
|
+
function resetTouchStatus(instance) {
|
|
248
|
+
var state = instance.getState();
|
|
249
|
+
state.direction = '';
|
|
250
|
+
state.deltaX = 0;
|
|
251
|
+
state.deltaY = 0;
|
|
252
|
+
state.offsetX = 0;
|
|
253
|
+
state.offsetY = 0;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
/**
|
|
257
|
+
* 设置滑动开始位置
|
|
258
|
+
* @param {Object} event
|
|
259
|
+
*/
|
|
260
|
+
function stopTouchStart(event) {
|
|
261
|
+
var instance = event.instance;
|
|
262
|
+
var state = instance.getState();
|
|
263
|
+
resetTouchStatus(instance);
|
|
264
|
+
var touch = event.touches[0];
|
|
265
|
+
if (IS_HTML5 && isPC()) {
|
|
266
|
+
touch = event;
|
|
267
|
+
}
|
|
268
|
+
state.startX = touch.clientX;
|
|
269
|
+
state.startY = touch.clientY;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
/**
|
|
273
|
+
* 滑动中,是否禁止打开
|
|
274
|
+
* @param {Object} event
|
|
275
|
+
*/
|
|
276
|
+
function stopTouchMove(event) {
|
|
277
|
+
var instance = event.instance;
|
|
278
|
+
var state = instance.getState();
|
|
279
|
+
var touch = event.touches[0];
|
|
280
|
+
if (IS_HTML5 && isPC()) {
|
|
281
|
+
touch = event;
|
|
282
|
+
}
|
|
283
|
+
state.deltaX = touch.clientX - state.startX;
|
|
284
|
+
state.deltaY = touch.clientY - state.startY;
|
|
285
|
+
state.offsetY = Math.abs(state.deltaY);
|
|
286
|
+
state.offsetX = Math.abs(state.deltaX);
|
|
287
|
+
state.direction = state.direction || getDirection(state.offsetX, state.offsetY);
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
function isPC() {
|
|
291
|
+
var userAgentInfo = navigator.userAgent;
|
|
292
|
+
var Agents = ["Android", "iPhone", "SymbianOS", "Windows Phone", "iPad", "iPod"];
|
|
293
|
+
var flag = true;
|
|
294
|
+
for (var v = 0; v < Agents.length - 1; v++) {
|
|
295
|
+
if (userAgentInfo.indexOf(Agents[v]) > 0) {
|
|
296
|
+
flag = false;
|
|
297
|
+
break;
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
return flag;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
var movable = false
|
|
304
|
+
|
|
305
|
+
function mousedown(e, ins) {
|
|
306
|
+
if (!IS_HTML5) return
|
|
307
|
+
if (!isPC()) return
|
|
308
|
+
touchstart(e, ins)
|
|
309
|
+
movable = true
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
function mousemove(e, ins) {
|
|
313
|
+
if (!IS_HTML5) return
|
|
314
|
+
if (!isPC()) return
|
|
315
|
+
if (!movable) return
|
|
316
|
+
touchmove(e, ins)
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
function mouseup(e, ins) {
|
|
320
|
+
if (!IS_HTML5) return
|
|
321
|
+
if (!isPC()) return
|
|
322
|
+
touchend(e, ins)
|
|
323
|
+
movable = false
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
function mouseleave(e, ins) {
|
|
327
|
+
if (!IS_HTML5) return
|
|
328
|
+
if (!isPC()) return
|
|
329
|
+
movable = false
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
module.exports = {
|
|
333
|
+
showWatch: showWatch,
|
|
334
|
+
touchstart: touchstart,
|
|
335
|
+
touchmove: touchmove,
|
|
336
|
+
touchend: touchend,
|
|
337
|
+
mousedown: mousedown,
|
|
338
|
+
mousemove: mousemove,
|
|
339
|
+
mouseup: mouseup,
|
|
340
|
+
mouseleave: mouseleave
|
|
341
|
+
}
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view class="uni-swiper__warp">
|
|
3
|
+
<slot />
|
|
4
|
+
<view v-if="mode === 'default'" :style="{'bottom':dots.bottom + 'px'}" class="uni-swiper__dots-box" key='default'>
|
|
5
|
+
<view v-for="(item,index) in info" @click="clickItem(index)" :style="{
|
|
6
|
+
'width': (index === current? dots.width*2:dots.width ) + 'px','height':dots.width/2 +'px' ,'background-color':index !== current?dots.backgroundColor:dots.selectedBackgroundColor,'border-radius':'0px'}"
|
|
7
|
+
:key="index" class="uni-swiper__dots-item uni-swiper__dots-bar" />
|
|
8
|
+
</view>
|
|
9
|
+
<view v-if="mode === 'dot'" :style="{'bottom':dots.bottom + 'px'}" class="uni-swiper__dots-box" key='dot'>
|
|
10
|
+
<view v-for="(item,index) in info" @click="clickItem(index)" :style="{
|
|
11
|
+
'width': dots.width + 'px','height':dots.height +'px' ,'background-color':index !== current?dots.backgroundColor:dots.selectedBackgroundColor,'border':index !==current ? dots.border:dots.selectedBorder}"
|
|
12
|
+
:key="index" class="uni-swiper__dots-item" />
|
|
13
|
+
</view>
|
|
14
|
+
<view v-if="mode === 'round'" :style="{'bottom':dots.bottom + 'px'}" class="uni-swiper__dots-box" key='round'>
|
|
15
|
+
<view v-for="(item,index) in info" @click="clickItem(index)" :class="[index === current&&'uni-swiper__dots-long']" :style="{
|
|
16
|
+
'width':(index === current? dots.width*3:dots.width ) + 'px','height':dots.height +'px' ,'background-color':index !== current?dots.backgroundColor:dots.selectedBackgroundColor,'border':index !==current ? dots.border:dots.selectedBorder}"
|
|
17
|
+
:key="index" class="uni-swiper__dots-item " />
|
|
18
|
+
</view>
|
|
19
|
+
<view v-if="mode === 'nav'" key='nav' :style="{'background-color':dotsStyles.backgroundColor,'bottom':'0'}" class="uni-swiper__dots-box uni-swiper__dots-nav">
|
|
20
|
+
<text :style="{'color':dotsStyles.color}" class="uni-swiper__dots-nav-item">{{ (current+1)+"/"+info.length +' ' +info[current][field] }}</text>
|
|
21
|
+
</view>
|
|
22
|
+
<view v-if="mode === 'indexes'" key='indexes' :style="{'bottom':dots.bottom + 'px'}" class="uni-swiper__dots-box">
|
|
23
|
+
<view v-for="(item,index) in info" @click="clickItem(index)" :style="{
|
|
24
|
+
'width':dots.width + 'px','height':dots.height +'px' ,'color':index === current?dots.selectedColor:dots.color,'background-color':index !== current?dots.backgroundColor:dots.selectedBackgroundColor,'border':index !==current ? dots.border:dots.selectedBorder}"
|
|
25
|
+
:key="index" class="uni-swiper__dots-item uni-swiper__dots-indexes"><text class="uni-swiper__dots-indexes-text">{{ index+1 }}</text></view>
|
|
26
|
+
</view>
|
|
27
|
+
</view>
|
|
28
|
+
</template>
|
|
29
|
+
|
|
30
|
+
<script>
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* SwiperDod 轮播图指示点
|
|
34
|
+
* @description 自定义轮播图指示点
|
|
35
|
+
* @tutorial https://ext.dcloud.net.cn/plugin?id=284
|
|
36
|
+
* @property {Number} current 当前指示点索引,必须是通过 `swiper` 的 `change` 事件获取到的 `e.detail.current`
|
|
37
|
+
* @property {String} mode = [default|round|nav|indexes] 指示点的类型
|
|
38
|
+
* @value defualt 默认指示点
|
|
39
|
+
* @value round 圆形指示点
|
|
40
|
+
* @value nav 条形指示点
|
|
41
|
+
* @value indexes 索引指示点
|
|
42
|
+
* @property {String} field mode 为 nav 时,显示的内容字段(mode = nav 时必填)
|
|
43
|
+
* @property {String} info 轮播图的数据,通过数组长度决定指示点个数
|
|
44
|
+
* @property {Object} dotsStyles 指示点样式
|
|
45
|
+
* @event {Function} clickItem 组件触发点击事件时触发,e={currentIndex}
|
|
46
|
+
*/
|
|
47
|
+
|
|
48
|
+
export default {
|
|
49
|
+
name: 'UniSwiperDot',
|
|
50
|
+
emits:['clickItem'],
|
|
51
|
+
props: {
|
|
52
|
+
info: {
|
|
53
|
+
type: Array,
|
|
54
|
+
default () {
|
|
55
|
+
return []
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
current: {
|
|
59
|
+
type: Number,
|
|
60
|
+
default: 0
|
|
61
|
+
},
|
|
62
|
+
dotsStyles: {
|
|
63
|
+
type: Object,
|
|
64
|
+
default () {
|
|
65
|
+
return {}
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
// 类型 :default(默认) indexes long nav
|
|
69
|
+
mode: {
|
|
70
|
+
type: String,
|
|
71
|
+
default: 'default'
|
|
72
|
+
},
|
|
73
|
+
// 只在 nav 模式下生效,变量名称
|
|
74
|
+
field: {
|
|
75
|
+
type: String,
|
|
76
|
+
default: ''
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
data() {
|
|
80
|
+
return {
|
|
81
|
+
dots: {
|
|
82
|
+
width: 6,
|
|
83
|
+
height: 6,
|
|
84
|
+
bottom: 10,
|
|
85
|
+
color: '#fff',
|
|
86
|
+
backgroundColor: 'rgba(0, 0, 0, .3)',
|
|
87
|
+
border: '1px rgba(0, 0, 0, .3) solid',
|
|
88
|
+
selectedBackgroundColor: '#333',
|
|
89
|
+
selectedBorder: '1px rgba(0, 0, 0, .9) solid'
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
watch: {
|
|
94
|
+
dotsStyles(newVal) {
|
|
95
|
+
this.dots = Object.assign(this.dots, this.dotsStyles)
|
|
96
|
+
},
|
|
97
|
+
mode(newVal) {
|
|
98
|
+
if (newVal === 'indexes') {
|
|
99
|
+
this.dots.width = 14
|
|
100
|
+
this.dots.height = 14
|
|
101
|
+
} else {
|
|
102
|
+
this.dots.width = 6
|
|
103
|
+
this.dots.height = 6
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
},
|
|
108
|
+
created() {
|
|
109
|
+
if (this.mode === 'indexes') {
|
|
110
|
+
this.dots.width = 12
|
|
111
|
+
this.dots.height = 12
|
|
112
|
+
}
|
|
113
|
+
this.dots = Object.assign(this.dots, this.dotsStyles)
|
|
114
|
+
},
|
|
115
|
+
methods: {
|
|
116
|
+
clickItem(index) {
|
|
117
|
+
this.$emit('clickItem', index)
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
</script>
|
|
122
|
+
|
|
123
|
+
<style lang="scss">
|
|
124
|
+
.uni-swiper__warp {
|
|
125
|
+
/* #ifndef APP-NVUE */
|
|
126
|
+
display: flex;
|
|
127
|
+
/* #endif */
|
|
128
|
+
flex: 1;
|
|
129
|
+
flex-direction: column;
|
|
130
|
+
position: relative;
|
|
131
|
+
overflow: hidden;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
.uni-swiper__dots-box {
|
|
135
|
+
position: absolute;
|
|
136
|
+
bottom: 10px;
|
|
137
|
+
left: 0;
|
|
138
|
+
right: 0;
|
|
139
|
+
/* #ifndef APP-NVUE */
|
|
140
|
+
display: flex;
|
|
141
|
+
/* #endif */
|
|
142
|
+
flex: 1;
|
|
143
|
+
flex-direction: row;
|
|
144
|
+
justify-content: center;
|
|
145
|
+
align-items: center;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
.uni-swiper__dots-item {
|
|
149
|
+
width: 8px;
|
|
150
|
+
border-radius: 100px;
|
|
151
|
+
margin-left: 6px;
|
|
152
|
+
background-color: rgba(0, 0, 0, 0.4);
|
|
153
|
+
/* #ifndef APP-NVUE */
|
|
154
|
+
cursor: pointer;
|
|
155
|
+
/* #endif */
|
|
156
|
+
/* #ifdef H5 */
|
|
157
|
+
// border-width: 5px 0;
|
|
158
|
+
// border-style: solid;
|
|
159
|
+
// border-color: transparent;
|
|
160
|
+
// background-clip: padding-box;
|
|
161
|
+
/* #endif */
|
|
162
|
+
// transition: width 0.2s linear; 不要取消注释,不然会不能变色
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
.uni-swiper__dots-item:first-child {
|
|
166
|
+
margin: 0;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
.uni-swiper__dots-default {
|
|
170
|
+
border-radius: 100px;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
.uni-swiper__dots-long {
|
|
174
|
+
border-radius: 50px;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
.uni-swiper__dots-bar {
|
|
178
|
+
border-radius: 50px;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
.uni-swiper__dots-nav {
|
|
182
|
+
bottom: 0px;
|
|
183
|
+
// height: 26px;
|
|
184
|
+
padding: 8px 0;
|
|
185
|
+
/* #ifndef APP-NVUE */
|
|
186
|
+
display: flex;
|
|
187
|
+
/* #endif */
|
|
188
|
+
flex: 1;
|
|
189
|
+
flex-direction: row;
|
|
190
|
+
justify-content: flex-start;
|
|
191
|
+
align-items: center;
|
|
192
|
+
background-color: rgba(0, 0, 0, 0.2);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
.uni-swiper__dots-nav-item {
|
|
196
|
+
/* overflow: hidden;
|
|
197
|
+
text-overflow: ellipsis;
|
|
198
|
+
white-space: nowrap; */
|
|
199
|
+
font-size: 14px;
|
|
200
|
+
color: #fff;
|
|
201
|
+
margin: 0 15px;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
.uni-swiper__dots-indexes {
|
|
205
|
+
/* #ifndef APP-NVUE */
|
|
206
|
+
display: flex;
|
|
207
|
+
/* #endif */
|
|
208
|
+
// flex: 1;
|
|
209
|
+
justify-content: center;
|
|
210
|
+
align-items: center;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
.uni-swiper__dots-indexes-text {
|
|
214
|
+
color: #fff;
|
|
215
|
+
font-size: 12px;
|
|
216
|
+
line-height: 14px;
|
|
217
|
+
}
|
|
218
|
+
</style>
|