@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,269 @@
1
+ <template>
2
+ <view class="uni-steps">
3
+ <view :class="[direction==='column'?'uni-steps__column':'uni-steps__row']">
4
+ <view :class="[direction==='column'?'uni-steps__column-text-container':'uni-steps__row-text-container']">
5
+ <view v-for="(item,index) in options" :key="index"
6
+ :class="[direction==='column'?'uni-steps__column-text':'uni-steps__row-text']">
7
+ <text :style="{color:index === active?activeColor:deactiveColor}"
8
+ :class="[direction==='column'?'uni-steps__column-title':'uni-steps__row-title']">{{item.title}}</text>
9
+ <text :style="{color: deactiveColor}"
10
+ :class="[direction==='column'?'uni-steps__column-desc':'uni-steps__row-desc']">{{item.desc}}</text>
11
+ </view>
12
+ </view>
13
+ <view :class="[direction==='column'?'uni-steps__column-container':'uni-steps__row-container']">
14
+ <view :class="[direction==='column'?'uni-steps__column-line-item':'uni-steps__row-line-item']"
15
+ v-for="(item,index) in options" :key="index">
16
+ <view
17
+ :class="[direction==='column'?'uni-steps__column-line':'uni-steps__row-line',direction==='column'?'uni-steps__column-line--before':'uni-steps__row-line--before']"
18
+ :style="{backgroundColor:index<=active&&index!==0?activeColor:index===0?'transparent':deactiveColor}">
19
+ </view>
20
+ <view :class="[direction==='column'?'uni-steps__column-check':'uni-steps__row-check']"
21
+ v-if="index === active">
22
+ <uni-icons :color="activeColor" :type="activeIcon" size="14"></uni-icons>
23
+ </view>
24
+ <view v-else :class="[direction==='column'?'uni-steps__column-circle':'uni-steps__row-circle']"
25
+ :style="{backgroundColor:index<active?activeColor:deactiveColor}"></view>
26
+ <view
27
+ :class="[direction==='column'?'uni-steps__column-line':'uni-steps__row-line',direction==='column'?'uni-steps__column-line--after':'uni-steps__row-line--after']"
28
+ :style="{backgroundColor:index<active&&index!==options.length-1?activeColor:index===options.length-1?'transparent':deactiveColor}">
29
+ </view>
30
+ </view>
31
+ </view>
32
+ </view>
33
+ </view>
34
+ </template>
35
+
36
+ <script>
37
+ /**
38
+ * Steps 步骤条
39
+ * @description 评分组件
40
+ * @tutorial https://ext.dcloud.net.cn/plugin?id=34
41
+ * @property {Number} active 当前步骤
42
+ * @property {String} direction = [row|column] 当前步骤
43
+ * @value row 横向
44
+ * @value column 纵向
45
+ * @property {String} activeColor 选中状态的颜色
46
+ * @property {Array} options 数据源,格式为:[{title:'xxx',desc:'xxx'},{title:'xxx',desc:'xxx'}]
47
+ */
48
+
49
+ export default {
50
+ name: 'UniSteps',
51
+ props: {
52
+ direction: {
53
+ // 排列方向 row column
54
+ type: String,
55
+ default: 'row'
56
+ },
57
+ activeColor: {
58
+ // 激活状态颜色
59
+ type: String,
60
+ default: '#2979FF'
61
+ },
62
+ deactiveColor: {
63
+ // 未激活状态颜色
64
+ type: String,
65
+ default: '#B7BDC6'
66
+ },
67
+ active: {
68
+ // 当前步骤
69
+ type: Number,
70
+ default: 0
71
+ },
72
+ activeIcon: {
73
+ // 当前步骤
74
+ type: String,
75
+ default: 'checkbox-filled'
76
+ },
77
+ options: {
78
+ type: Array,
79
+ default () {
80
+ return []
81
+ }
82
+ } // 数据
83
+ },
84
+ data() {
85
+ return {}
86
+ }
87
+ }
88
+ </script>
89
+
90
+ <style lang="scss">
91
+ $uni-primary: #2979ff !default;
92
+ $uni-border-color:#EDEDED;
93
+ .uni-steps {
94
+ /* #ifndef APP-NVUE */
95
+ display: flex;
96
+ width: 100%;
97
+ /* #endif */
98
+ /* #ifdef APP-NVUE */
99
+ flex: 1;
100
+ /* #endif */
101
+ flex-direction: column;
102
+ }
103
+
104
+ .uni-steps__row {
105
+ /* #ifndef APP-NVUE */
106
+ display: flex;
107
+ /* #endif */
108
+ flex-direction: column;
109
+ }
110
+
111
+ .uni-steps__column {
112
+ /* #ifndef APP-NVUE */
113
+ display: flex;
114
+ /* #endif */
115
+ flex-direction: row-reverse;
116
+ }
117
+
118
+ .uni-steps__row-text-container {
119
+ /* #ifndef APP-NVUE */
120
+ display: flex;
121
+ /* #endif */
122
+ flex-direction: row;
123
+ align-items: flex-end;
124
+ margin-bottom: 8px;
125
+ }
126
+
127
+ .uni-steps__column-text-container {
128
+ /* #ifndef APP-NVUE */
129
+ display: flex;
130
+ /* #endif */
131
+ flex-direction: column;
132
+ flex: 1;
133
+ }
134
+
135
+ .uni-steps__row-text {
136
+ /* #ifndef APP-NVUE */
137
+ display: inline-flex;
138
+ /* #endif */
139
+ flex: 1;
140
+ flex-direction: column;
141
+ }
142
+
143
+ .uni-steps__column-text {
144
+ padding: 6px 0px;
145
+ border-bottom-style: solid;
146
+ border-bottom-width: 1px;
147
+ border-bottom-color: $uni-border-color;
148
+ /* #ifndef APP-NVUE */
149
+ display: flex;
150
+ /* #endif */
151
+ flex-direction: column;
152
+ }
153
+
154
+ .uni-steps__row-title {
155
+ font-size: 14px;
156
+ line-height: 16px;
157
+ text-align: center;
158
+ }
159
+
160
+ .uni-steps__column-title {
161
+ font-size: 14px;
162
+ text-align: left;
163
+ line-height: 18px;
164
+ }
165
+
166
+ .uni-steps__row-desc {
167
+ font-size: 12px;
168
+ line-height: 14px;
169
+ text-align: center;
170
+ }
171
+
172
+ .uni-steps__column-desc {
173
+ font-size: 12px;
174
+ text-align: left;
175
+ line-height: 18px;
176
+ }
177
+
178
+ .uni-steps__row-container {
179
+ /* #ifndef APP-NVUE */
180
+ display: flex;
181
+ /* #endif */
182
+ flex-direction: row;
183
+ }
184
+
185
+ .uni-steps__column-container {
186
+ /* #ifndef APP-NVUE */
187
+ display: inline-flex;
188
+ /* #endif */
189
+ width: 30px;
190
+ flex-direction: column;
191
+ }
192
+
193
+ .uni-steps__row-line-item {
194
+ /* #ifndef APP-NVUE */
195
+ display: inline-flex;
196
+ /* #endif */
197
+ flex-direction: row;
198
+ flex: 1;
199
+ height: 14px;
200
+ line-height: 14px;
201
+ align-items: center;
202
+ justify-content: center;
203
+ }
204
+
205
+ .uni-steps__column-line-item {
206
+ /* #ifndef APP-NVUE */
207
+ display: flex;
208
+ /* #endif */
209
+ flex-direction: column;
210
+ flex: 1;
211
+ align-items: center;
212
+ justify-content: center;
213
+ }
214
+
215
+ .uni-steps__row-line {
216
+ flex: 1;
217
+ height: 1px;
218
+ background-color: #B7BDC6;
219
+ }
220
+
221
+ .uni-steps__column-line {
222
+ width: 1px;
223
+ background-color: #B7BDC6;
224
+ }
225
+
226
+ .uni-steps__row-line--after {
227
+ transform: translateX(1px);
228
+ }
229
+
230
+ .uni-steps__column-line--after {
231
+ flex: 1;
232
+ transform: translate(0px, 1px);
233
+ }
234
+
235
+ .uni-steps__row-line--before {
236
+ transform: translateX(-1px);
237
+ }
238
+
239
+ .uni-steps__column-line--before {
240
+ height: 6px;
241
+ transform: translate(0px, -13px);
242
+ }
243
+
244
+ .uni-steps__row-circle {
245
+ width: 5px;
246
+ height: 5px;
247
+ border-radius: 50%;
248
+ background-color: #B7BDC6;
249
+ margin: 0px 3px;
250
+ }
251
+
252
+ .uni-steps__column-circle {
253
+ width: 5px;
254
+ height: 5px;
255
+ border-radius: 50%;
256
+ background-color: #B7BDC6;
257
+ margin: 4px 0px 5px 0px;
258
+ }
259
+
260
+ .uni-steps__row-check {
261
+ margin: 0px 6px;
262
+ }
263
+
264
+ .uni-steps__column-check {
265
+ height: 14px;
266
+ line-height: 14px;
267
+ margin: 2px 0px;
268
+ }
269
+ </style>
@@ -0,0 +1,60 @@
1
+ <template>
2
+ <view>
3
+ <slot></slot>
4
+ </view>
5
+ </template>
6
+
7
+ <script>
8
+ /**
9
+ * SwipeAction 滑动操作
10
+ * @description 通过滑动触发选项的容器
11
+ * @tutorial https://ext.dcloud.net.cn/plugin?id=181
12
+ */
13
+ export default {
14
+ name:"uniSwipeAction",
15
+ data() {
16
+ return {};
17
+ },
18
+ created() {
19
+ this.children = [];
20
+ },
21
+ methods: {
22
+ // 公开给用户使用,重制组件样式
23
+ resize(){
24
+ // wxs 会自己计算组件大小,所以无需执行下面代码
25
+ // #ifndef APP-VUE || H5 || MP-WEIXIN
26
+ this.children.forEach(vm=>{
27
+ vm.init()
28
+ })
29
+ // #endif
30
+ },
31
+ // 公开给用户使用,关闭全部 已经打开的组件
32
+ closeAll(){
33
+ this.children.forEach(vm=>{
34
+ // #ifdef APP-VUE || H5 || MP-WEIXIN
35
+ vm.is_show = 'none'
36
+ // #endif
37
+
38
+ // #ifndef APP-VUE || H5 || MP-WEIXIN
39
+ vm.close()
40
+ // #endif
41
+ })
42
+ },
43
+ closeOther(vm) {
44
+ if (this.openItem && this.openItem !== vm) {
45
+ // #ifdef APP-VUE || H5 || MP-WEIXIN
46
+ this.openItem.is_show = 'none'
47
+ // #endif
48
+
49
+ // #ifndef APP-VUE || H5 || MP-WEIXIN
50
+ this.openItem.close()
51
+ // #endif
52
+ }
53
+ // 记录上一个打开的 swipe-action-item ,用于 auto-close
54
+ this.openItem = vm
55
+ }
56
+ }
57
+ };
58
+ </script>
59
+
60
+ <style></style>
@@ -0,0 +1,302 @@
1
+ let bindIngXMixins = {}
2
+
3
+ // #ifdef APP-NVUE
4
+ const BindingX = uni.requireNativePlugin('bindingx');
5
+ const dom = uni.requireNativePlugin('dom');
6
+ const animation = uni.requireNativePlugin('animation');
7
+
8
+ bindIngXMixins = {
9
+ data() {
10
+ return {}
11
+ },
12
+
13
+ watch: {
14
+ show(newVal) {
15
+ if (this.autoClose) return
16
+ if (this.stop) return
17
+ this.stop = true
18
+ if (newVal) {
19
+ this.open(newVal)
20
+ } else {
21
+ this.close()
22
+ }
23
+ },
24
+ leftOptions() {
25
+ this.getSelectorQuery()
26
+ this.init()
27
+ },
28
+ rightOptions(newVal) {
29
+ this.init()
30
+ }
31
+ },
32
+ created() {
33
+ this.swipeaction = this.getSwipeAction()
34
+ if (this.swipeaction && Array.isArray(this.swipeaction.children)) {
35
+ this.swipeaction.children.push(this)
36
+ }
37
+ },
38
+ mounted() {
39
+ this.box = this.getEl(this.$refs['selector-box--hock'])
40
+ this.selector = this.getEl(this.$refs['selector-content--hock']);
41
+ this.leftButton = this.getEl(this.$refs['selector-left-button--hock']);
42
+ this.rightButton = this.getEl(this.$refs['selector-right-button--hock']);
43
+ this.init()
44
+ },
45
+ // beforeDestroy() {
46
+ // this.swipeaction.children.forEach((item, index) => {
47
+ // if (item === this) {
48
+ // this.swipeaction.children.splice(index, 1)
49
+ // }
50
+ // })
51
+ // },
52
+ methods: {
53
+ init() {
54
+ this.$nextTick(() => {
55
+ this.x = 0
56
+ this.button = {
57
+ show: false
58
+ }
59
+ setTimeout(() => {
60
+ this.getSelectorQuery()
61
+ }, 200)
62
+ })
63
+ },
64
+ onClick(index, item, position) {
65
+ this.$emit('click', {
66
+ content: item,
67
+ index,
68
+ position
69
+ })
70
+ },
71
+ touchstart(e) {
72
+ // fix by mehaotian 禁止滑动
73
+ if (this.disabled) return
74
+ // 每次只触发一次,避免多次监听造成闪烁
75
+ if (this.stop) return
76
+ this.stop = true
77
+ if (this.autoClose && this.swipeaction) {
78
+ this.swipeaction.closeOther(this)
79
+ }
80
+
81
+ const leftWidth = this.button.left.width
82
+ const rightWidth = this.button.right.width
83
+ let expression = this.range(this.x, -rightWidth, leftWidth)
84
+ let leftExpression = this.range(this.x - leftWidth, -leftWidth, 0)
85
+ let rightExpression = this.range(this.x + rightWidth, 0, rightWidth)
86
+
87
+ this.eventpan = BindingX.bind({
88
+ anchor: this.box,
89
+ eventType: 'pan',
90
+ props: [{
91
+ element: this.selector,
92
+ property: 'transform.translateX',
93
+ expression
94
+ }, {
95
+ element: this.leftButton,
96
+ property: 'transform.translateX',
97
+ expression: leftExpression
98
+ }, {
99
+ element: this.rightButton,
100
+ property: 'transform.translateX',
101
+ expression: rightExpression
102
+ }, ]
103
+ }, (e) => {
104
+ // nope
105
+ if (e.state === 'end') {
106
+ this.x = e.deltaX + this.x;
107
+ this.isclick = true
108
+ this.bindTiming(e.deltaX)
109
+ }
110
+ });
111
+ },
112
+ touchend(e) {
113
+ if (this.isopen !== 'none' && !this.isclick) {
114
+ this.open('none')
115
+ }
116
+ },
117
+ bindTiming(x) {
118
+ const left = this.x
119
+ const leftWidth = this.button.left.width
120
+ const rightWidth = this.button.right.width
121
+ const threshold = this.threshold
122
+ if (!this.isopen || this.isopen === 'none') {
123
+ if (left > threshold) {
124
+ this.open('left')
125
+ } else if (left < -threshold) {
126
+ this.open('right')
127
+ } else {
128
+ this.open('none')
129
+ }
130
+ } else {
131
+ if ((x > -leftWidth && x < 0) || x > rightWidth) {
132
+ if ((x > -threshold && x < 0) || (x - rightWidth > threshold)) {
133
+ this.open('left')
134
+ } else {
135
+ this.open('none')
136
+ }
137
+ } else {
138
+ if ((x < threshold && x > 0) || (x + leftWidth < -threshold)) {
139
+ this.open('right')
140
+ } else {
141
+ this.open('none')
142
+ }
143
+ }
144
+ }
145
+ },
146
+
147
+ /**
148
+ * 移动范围
149
+ * @param {Object} num
150
+ * @param {Object} mix
151
+ * @param {Object} max
152
+ */
153
+ range(num, mix, max) {
154
+ return `min(max(x+${num}, ${mix}), ${max})`
155
+ },
156
+
157
+ /**
158
+ * 开启swipe
159
+ */
160
+ open(type) {
161
+ this.animation(type)
162
+ },
163
+
164
+ /**
165
+ * 关闭swipe
166
+ */
167
+ close() {
168
+ this.animation('none')
169
+ },
170
+
171
+ /**
172
+ * 开启关闭动画
173
+ * @param {Object} type
174
+ */
175
+ animation(type) {
176
+ const time = 300
177
+ const leftWidth = this.button.left.width
178
+ const rightWidth = this.button.right.width
179
+ if (this.eventpan && this.eventpan.token) {
180
+ BindingX.unbind({
181
+ token: this.eventpan.token,
182
+ eventType: 'pan'
183
+ })
184
+ }
185
+
186
+ switch (type) {
187
+ case 'left':
188
+ Promise.all([
189
+ this.move(this.selector, leftWidth),
190
+ this.move(this.leftButton, 0),
191
+ this.move(this.rightButton, rightWidth * 2)
192
+ ]).then(() => {
193
+ this.setEmit(leftWidth, type)
194
+ })
195
+ break
196
+ case 'right':
197
+ Promise.all([
198
+ this.move(this.selector, -rightWidth),
199
+ this.move(this.leftButton, -leftWidth * 2),
200
+ this.move(this.rightButton, 0)
201
+ ]).then(() => {
202
+ this.setEmit(-rightWidth, type)
203
+ })
204
+ break
205
+ default:
206
+ Promise.all([
207
+ this.move(this.selector, 0),
208
+ this.move(this.leftButton, -leftWidth),
209
+ this.move(this.rightButton, rightWidth)
210
+ ]).then(() => {
211
+ this.setEmit(0, type)
212
+ })
213
+
214
+ }
215
+ },
216
+ setEmit(x, type) {
217
+ const leftWidth = this.button.left.width
218
+ const rightWidth = this.button.right.width
219
+ this.isopen = this.isopen || 'none'
220
+ this.stop = false
221
+ this.isclick = false
222
+ // 只有状态不一致才会返回结果
223
+ if (this.isopen !== type && this.x !== x) {
224
+ if (type === 'left' && leftWidth > 0) {
225
+ this.$emit('change', 'left')
226
+ }
227
+ if (type === 'right' && rightWidth > 0) {
228
+ this.$emit('change', 'right')
229
+ }
230
+ if (type === 'none') {
231
+ this.$emit('change', 'none')
232
+ }
233
+ }
234
+ this.x = x
235
+ this.isopen = type
236
+ },
237
+ move(ref, value) {
238
+ return new Promise((resolve, reject) => {
239
+ animation.transition(ref, {
240
+ styles: {
241
+ transform: `translateX(${value})`,
242
+ },
243
+ duration: 150, //ms
244
+ timingFunction: 'linear',
245
+ needLayout: false,
246
+ delay: 0 //ms
247
+ }, function(res) {
248
+ resolve(res)
249
+ })
250
+ })
251
+
252
+ },
253
+
254
+ /**
255
+ * 获取ref
256
+ * @param {Object} el
257
+ */
258
+ getEl(el) {
259
+ return el.ref
260
+ },
261
+ /**
262
+ * 获取节点信息
263
+ */
264
+ getSelectorQuery() {
265
+ Promise.all([
266
+ this.getDom('left'),
267
+ this.getDom('right'),
268
+ ]).then((data) => {
269
+ let show = 'none'
270
+ if (this.autoClose) {
271
+ show = 'none'
272
+ } else {
273
+ show = this.show
274
+ }
275
+
276
+ if (show === 'none') {
277
+ // this.close()
278
+ } else {
279
+ this.open(show)
280
+ }
281
+
282
+ })
283
+
284
+ },
285
+ getDom(str) {
286
+ return new Promise((resolve, reject) => {
287
+ dom.getComponentRect(this.$refs[`selector-${str}-button--hock`], (data) => {
288
+ if (data) {
289
+ this.button[str] = data.size
290
+ resolve(data)
291
+ } else {
292
+ reject()
293
+ }
294
+ })
295
+ })
296
+ }
297
+ }
298
+ }
299
+
300
+ // #endif
301
+
302
+ export default bindIngXMixins
@@ -0,0 +1,12 @@
1
+ export function isPC() {
2
+ var userAgentInfo = navigator.userAgent;
3
+ var Agents = ["Android", "iPhone", "SymbianOS", "Windows Phone", "iPad", "iPod"];
4
+ var flag = true;
5
+ for (let v = 0; v < Agents.length - 1; v++) {
6
+ if (userAgentInfo.indexOf(Agents[v]) > 0) {
7
+ flag = false;
8
+ break;
9
+ }
10
+ }
11
+ return flag;
12
+ }