@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.
Files changed (166) hide show
  1. package/README.md +1 -0
  2. package/dist/index.css +1 -0
  3. package/dist/kengic-uni.js +5 -0
  4. package/dist/src/consts/i18n/en.d.ts +45 -0
  5. package/dist/src/consts/i18n/index.d.ts +90 -0
  6. package/dist/src/consts/i18n/zh_CN.d.ts +45 -0
  7. package/dist/src/consts/index.d.ts +1 -0
  8. package/dist/src/index.d.ts +2 -0
  9. package/dist/src/utils/index.d.ts +1 -0
  10. package/dist/src/utils/kg.util.d.ts +5 -0
  11. package/dist/uni-ui/index.ts +11 -0
  12. package/dist/uni-ui/uni-badge/uni-badge.vue +253 -0
  13. package/dist/uni-ui/uni-breadcrumb/uni-breadcrumb.vue +41 -0
  14. package/dist/uni-ui/uni-breadcrumb-item/uni-breadcrumb-item.vue +121 -0
  15. package/dist/uni-ui/uni-calendar/calendar.js +546 -0
  16. package/dist/uni-ui/uni-calendar/i18n/en.json +12 -0
  17. package/dist/uni-ui/uni-calendar/i18n/index.js +8 -0
  18. package/dist/uni-ui/uni-calendar/i18n/zh-Hans.json +12 -0
  19. package/dist/uni-ui/uni-calendar/i18n/zh-Hant.json +12 -0
  20. package/dist/uni-ui/uni-calendar/uni-calendar-item.vue +187 -0
  21. package/dist/uni-ui/uni-calendar/uni-calendar.vue +566 -0
  22. package/dist/uni-ui/uni-calendar/util.js +360 -0
  23. package/dist/uni-ui/uni-card/uni-card.vue +281 -0
  24. package/dist/uni-ui/uni-col/uni-col.vue +317 -0
  25. package/dist/uni-ui/uni-collapse/uni-collapse.vue +147 -0
  26. package/dist/uni-ui/uni-collapse-item/uni-collapse-item.vue +402 -0
  27. package/dist/uni-ui/uni-combox/uni-combox.vue +294 -0
  28. package/dist/uni-ui/uni-countdown/i18n/en.json +6 -0
  29. package/dist/uni-ui/uni-countdown/i18n/index.js +8 -0
  30. package/dist/uni-ui/uni-countdown/i18n/zh-Hans.json +6 -0
  31. package/dist/uni-ui/uni-countdown/i18n/zh-Hant.json +6 -0
  32. package/dist/uni-ui/uni-countdown/uni-countdown.vue +267 -0
  33. package/dist/uni-ui/uni-data-checkbox/uni-data-checkbox.vue +821 -0
  34. package/dist/uni-ui/uni-data-picker/keypress.js +45 -0
  35. package/dist/uni-ui/uni-data-picker/uni-data-picker.vue +551 -0
  36. package/dist/uni-ui/uni-data-pickerview/uni-data-picker.js +622 -0
  37. package/dist/uni-ui/uni-data-pickerview/uni-data-pickerview.vue +323 -0
  38. package/dist/uni-ui/uni-data-select/uni-data-select.vue +517 -0
  39. package/dist/uni-ui/uni-dateformat/date-format.js +200 -0
  40. package/dist/uni-ui/uni-dateformat/uni-dateformat.vue +88 -0
  41. package/dist/uni-ui/uni-datetime-picker/calendar-item.vue +177 -0
  42. package/dist/uni-ui/uni-datetime-picker/calendar.vue +928 -0
  43. package/dist/uni-ui/uni-datetime-picker/i18n/en.json +22 -0
  44. package/dist/uni-ui/uni-datetime-picker/i18n/index.js +8 -0
  45. package/dist/uni-ui/uni-datetime-picker/i18n/zh-Hans.json +22 -0
  46. package/dist/uni-ui/uni-datetime-picker/i18n/zh-Hant.json +22 -0
  47. package/dist/uni-ui/uni-datetime-picker/time-picker.vue +934 -0
  48. package/dist/uni-ui/uni-datetime-picker/uni-datetime-picker.vue +1026 -0
  49. package/dist/uni-ui/uni-datetime-picker/util.js +403 -0
  50. package/dist/uni-ui/uni-drawer/keypress.js +45 -0
  51. package/dist/uni-ui/uni-drawer/uni-drawer.vue +181 -0
  52. package/dist/uni-ui/uni-easyinput/common.js +56 -0
  53. package/dist/uni-ui/uni-easyinput/uni-easyinput.vue +660 -0
  54. package/dist/uni-ui/uni-fab/uni-fab.vue +491 -0
  55. package/dist/uni-ui/uni-fav/i18n/en.json +4 -0
  56. package/dist/uni-ui/uni-fav/i18n/index.js +8 -0
  57. package/dist/uni-ui/uni-fav/i18n/zh-Hans.json +4 -0
  58. package/dist/uni-ui/uni-fav/i18n/zh-Hant.json +4 -0
  59. package/dist/uni-ui/uni-fav/uni-fav.vue +161 -0
  60. package/dist/uni-ui/uni-file-picker/choose-and-upload-file.js +224 -0
  61. package/dist/uni-ui/uni-file-picker/uni-file-picker.vue +667 -0
  62. package/dist/uni-ui/uni-file-picker/upload-file.vue +325 -0
  63. package/dist/uni-ui/uni-file-picker/upload-image.vue +292 -0
  64. package/dist/uni-ui/uni-file-picker/utils.js +109 -0
  65. package/dist/uni-ui/uni-forms/uni-forms.vue +398 -0
  66. package/dist/uni-ui/uni-forms/utils.js +293 -0
  67. package/dist/uni-ui/uni-forms/validate.js +486 -0
  68. package/dist/uni-ui/uni-forms-item/uni-forms-item.vue +601 -0
  69. package/dist/uni-ui/uni-goods-nav/i18n/en.json +6 -0
  70. package/dist/uni-ui/uni-goods-nav/i18n/index.js +8 -0
  71. package/dist/uni-ui/uni-goods-nav/i18n/zh-Hans.json +6 -0
  72. package/dist/uni-ui/uni-goods-nav/i18n/zh-Hant.json +6 -0
  73. package/dist/uni-ui/uni-goods-nav/uni-goods-nav.vue +229 -0
  74. package/dist/uni-ui/uni-grid/uni-grid.vue +143 -0
  75. package/dist/uni-ui/uni-grid-item/uni-grid-item.vue +129 -0
  76. package/dist/uni-ui/uni-group/uni-group.vue +134 -0
  77. package/dist/uni-ui/uni-icons/icons.js +1169 -0
  78. package/dist/uni-ui/uni-icons/uni-icons.vue +96 -0
  79. package/dist/uni-ui/uni-icons/uniicons.css +663 -0
  80. package/dist/uni-ui/uni-icons/uniicons.ttf +0 -0
  81. package/dist/uni-ui/uni-indexed-list/uni-indexed-list-item.vue +144 -0
  82. package/dist/uni-ui/uni-indexed-list/uni-indexed-list.vue +367 -0
  83. package/dist/uni-ui/uni-link/uni-link.vue +128 -0
  84. package/dist/uni-ui/uni-list/uni-list.vue +123 -0
  85. package/dist/uni-ui/uni-list/uni-refresh.vue +65 -0
  86. package/dist/uni-ui/uni-list/uni-refresh.wxs +87 -0
  87. package/dist/uni-ui/uni-list-ad/uni-list-ad.vue +107 -0
  88. package/dist/uni-ui/uni-list-chat/uni-list-chat.scss +58 -0
  89. package/dist/uni-ui/uni-list-chat/uni-list-chat.vue +593 -0
  90. package/dist/uni-ui/uni-list-item/uni-list-item.vue +534 -0
  91. package/dist/uni-ui/uni-load-more/i18n/en.json +5 -0
  92. package/dist/uni-ui/uni-load-more/i18n/index.js +8 -0
  93. package/dist/uni-ui/uni-load-more/i18n/zh-Hans.json +5 -0
  94. package/dist/uni-ui/uni-load-more/i18n/zh-Hant.json +5 -0
  95. package/dist/uni-ui/uni-load-more/uni-load-more.vue +399 -0
  96. package/dist/uni-ui/uni-nav-bar/uni-nav-bar.vue +357 -0
  97. package/dist/uni-ui/uni-nav-bar/uni-status-bar.vue +24 -0
  98. package/dist/uni-ui/uni-notice-bar/uni-notice-bar.vue +426 -0
  99. package/dist/uni-ui/uni-number-box/uni-number-box.vue +221 -0
  100. package/dist/uni-ui/uni-pagination/i18n/en.json +5 -0
  101. package/dist/uni-ui/uni-pagination/i18n/es.json +5 -0
  102. package/dist/uni-ui/uni-pagination/i18n/fr.json +5 -0
  103. package/dist/uni-ui/uni-pagination/i18n/index.js +12 -0
  104. package/dist/uni-ui/uni-pagination/i18n/zh-Hans.json +5 -0
  105. package/dist/uni-ui/uni-pagination/i18n/zh-Hant.json +5 -0
  106. package/dist/uni-ui/uni-pagination/uni-pagination.vue +465 -0
  107. package/dist/uni-ui/uni-popup/i18n/en.json +7 -0
  108. package/dist/uni-ui/uni-popup/i18n/index.js +9 -0
  109. package/dist/uni-ui/uni-popup/i18n/zh-Hans.json +7 -0
  110. package/dist/uni-ui/uni-popup/i18n/zh-Hant.json +7 -0
  111. package/dist/uni-ui/uni-popup/keypress.js +45 -0
  112. package/dist/uni-ui/uni-popup/popup.js +23 -0
  113. package/dist/uni-ui/uni-popup/uni-popup.vue +464 -0
  114. package/dist/uni-ui/uni-popup-dialog/keypress.js +45 -0
  115. package/dist/uni-ui/uni-popup-dialog/uni-popup-dialog.vue +275 -0
  116. package/dist/uni-ui/uni-popup-message/uni-popup-message.vue +143 -0
  117. package/dist/uni-ui/uni-popup-share/uni-popup-share.vue +187 -0
  118. package/dist/uni-ui/uni-rate/uni-rate.vue +365 -0
  119. package/dist/uni-ui/uni-row/uni-row.vue +190 -0
  120. package/dist/uni-ui/uni-scss/changelog.md +8 -0
  121. package/dist/uni-ui/uni-scss/index.scss +1 -0
  122. package/dist/uni-ui/uni-scss/package.json +82 -0
  123. package/dist/uni-ui/uni-scss/readme.md +4 -0
  124. package/dist/uni-ui/uni-scss/styles/index.scss +7 -0
  125. package/dist/uni-ui/uni-scss/styles/setting/_border.scss +3 -0
  126. package/dist/uni-ui/uni-scss/styles/setting/_color.scss +66 -0
  127. package/dist/uni-ui/uni-scss/styles/setting/_radius.scss +55 -0
  128. package/dist/uni-ui/uni-scss/styles/setting/_space.scss +56 -0
  129. package/dist/uni-ui/uni-scss/styles/setting/_styles.scss +167 -0
  130. package/dist/uni-ui/uni-scss/styles/setting/_text.scss +24 -0
  131. package/dist/uni-ui/uni-scss/styles/setting/_variables.scss +146 -0
  132. package/dist/uni-ui/uni-scss/styles/tools/functions.scss +19 -0
  133. package/dist/uni-ui/uni-scss/theme.scss +31 -0
  134. package/dist/uni-ui/uni-scss/variables.scss +62 -0
  135. package/dist/uni-ui/uni-search-bar/i18n/en.json +4 -0
  136. package/dist/uni-ui/uni-search-bar/i18n/index.js +8 -0
  137. package/dist/uni-ui/uni-search-bar/i18n/zh-Hans.json +4 -0
  138. package/dist/uni-ui/uni-search-bar/i18n/zh-Hant.json +4 -0
  139. package/dist/uni-ui/uni-search-bar/uni-search-bar.vue +298 -0
  140. package/dist/uni-ui/uni-section/uni-section.vue +167 -0
  141. package/dist/uni-ui/uni-segmented-control/uni-segmented-control.vue +145 -0
  142. package/dist/uni-ui/uni-steps/uni-steps.vue +269 -0
  143. package/dist/uni-ui/uni-swipe-action/uni-swipe-action.vue +60 -0
  144. package/dist/uni-ui/uni-swipe-action-item/bindingx.js +302 -0
  145. package/dist/uni-ui/uni-swipe-action-item/isPC.js +12 -0
  146. package/dist/uni-ui/uni-swipe-action-item/mpalipay.js +195 -0
  147. package/dist/uni-ui/uni-swipe-action-item/mpother.js +260 -0
  148. package/dist/uni-ui/uni-swipe-action-item/mpwxs.js +84 -0
  149. package/dist/uni-ui/uni-swipe-action-item/render.js +270 -0
  150. package/dist/uni-ui/uni-swipe-action-item/uni-swipe-action-item.vue +347 -0
  151. package/dist/uni-ui/uni-swipe-action-item/wx.wxs +341 -0
  152. package/dist/uni-ui/uni-swiper-dot/uni-swiper-dot.vue +218 -0
  153. package/dist/uni-ui/uni-table/uni-table.vue +455 -0
  154. package/dist/uni-ui/uni-tag/uni-tag.vue +252 -0
  155. package/dist/uni-ui/uni-tbody/uni-tbody.vue +29 -0
  156. package/dist/uni-ui/uni-td/uni-td.vue +90 -0
  157. package/dist/uni-ui/uni-th/filter-dropdown.vue +511 -0
  158. package/dist/uni-ui/uni-th/uni-th.vue +285 -0
  159. package/dist/uni-ui/uni-thead/uni-thead.vue +129 -0
  160. package/dist/uni-ui/uni-title/uni-title.vue +171 -0
  161. package/dist/uni-ui/uni-tooltip/uni-tooltip.vue +68 -0
  162. package/dist/uni-ui/uni-tr/table-checkbox.vue +179 -0
  163. package/dist/uni-ui/uni-tr/uni-tr.vue +171 -0
  164. package/dist/uni-ui/uni-transition/createAnimation.js +131 -0
  165. package/dist/uni-ui/uni-transition/uni-transition.vue +281 -0
  166. 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