@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,360 @@
1
+ import CALENDAR from './calendar.js'
2
+
3
+ class Calendar {
4
+ constructor({
5
+ date,
6
+ selected,
7
+ startDate,
8
+ endDate,
9
+ range
10
+ } = {}) {
11
+ // 当前日期
12
+ this.date = this.getDate(new Date()) // 当前初入日期
13
+ // 打点信息
14
+ this.selected = selected || [];
15
+ // 范围开始
16
+ this.startDate = startDate
17
+ // 范围结束
18
+ this.endDate = endDate
19
+ this.range = range
20
+ // 多选状态
21
+ this.cleanMultipleStatus()
22
+ // 每周日期
23
+ this.weeks = {}
24
+ // this._getWeek(this.date.fullDate)
25
+ }
26
+ /**
27
+ * 设置日期
28
+ * @param {Object} date
29
+ */
30
+ setDate(date) {
31
+ this.selectDate = this.getDate(date)
32
+ this._getWeek(this.selectDate.fullDate)
33
+ }
34
+
35
+ /**
36
+ * 清理多选状态
37
+ */
38
+ cleanMultipleStatus() {
39
+ this.multipleStatus = {
40
+ before: '',
41
+ after: '',
42
+ data: []
43
+ }
44
+ }
45
+
46
+ /**
47
+ * 重置开始日期
48
+ */
49
+ resetSatrtDate(startDate) {
50
+ // 范围开始
51
+ this.startDate = startDate
52
+
53
+ }
54
+
55
+ /**
56
+ * 重置结束日期
57
+ */
58
+ resetEndDate(endDate) {
59
+ // 范围结束
60
+ this.endDate = endDate
61
+ }
62
+
63
+ /**
64
+ * 获取任意时间
65
+ */
66
+ getDate(date, AddDayCount = 0, str = 'day') {
67
+ if (!date) {
68
+ date = new Date()
69
+ }
70
+ if (typeof date !== 'object') {
71
+ date = date.replace(/-/g, '/')
72
+ }
73
+ const dd = new Date(date)
74
+ switch (str) {
75
+ case 'day':
76
+ dd.setDate(dd.getDate() + AddDayCount) // 获取AddDayCount天后的日期
77
+ break
78
+ case 'month':
79
+ if (dd.getDate() === 31 && AddDayCount>0) {
80
+ dd.setDate(dd.getDate() + AddDayCount)
81
+ } else {
82
+ const preMonth = dd.getMonth()
83
+ dd.setMonth(preMonth + AddDayCount) // 获取AddDayCount天后的日期
84
+ const nextMonth = dd.getMonth()
85
+ // 处理 pre 切换月份目标月份为2月没有当前日(30 31) 切换错误问题
86
+ if(AddDayCount<0 && preMonth!==0 && nextMonth-preMonth>AddDayCount){
87
+ dd.setMonth(nextMonth+(nextMonth-preMonth+AddDayCount))
88
+ }
89
+ // 处理 next 切换月份目标月份为2月没有当前日(30 31) 切换错误问题
90
+ if(AddDayCount>0 && nextMonth-preMonth>AddDayCount){
91
+ dd.setMonth(nextMonth-(nextMonth-preMonth-AddDayCount))
92
+ }
93
+ }
94
+ break
95
+ case 'year':
96
+ dd.setFullYear(dd.getFullYear() + AddDayCount) // 获取AddDayCount天后的日期
97
+ break
98
+ }
99
+ const y = dd.getFullYear()
100
+ const m = dd.getMonth() + 1 < 10 ? '0' + (dd.getMonth() + 1) : dd.getMonth() + 1 // 获取当前月份的日期,不足10补0
101
+ const d = dd.getDate() < 10 ? '0' + dd.getDate() : dd.getDate() // 获取当前几号,不足10补0
102
+ return {
103
+ fullDate: y + '-' + m + '-' + d,
104
+ year: y,
105
+ month: m,
106
+ date: d,
107
+ day: dd.getDay()
108
+ }
109
+ }
110
+
111
+
112
+ /**
113
+ * 获取上月剩余天数
114
+ */
115
+ _getLastMonthDays(firstDay, full) {
116
+ let dateArr = []
117
+ for (let i = firstDay; i > 0; i--) {
118
+ const beforeDate = new Date(full.year, full.month - 1, -i + 1).getDate()
119
+ dateArr.push({
120
+ date: beforeDate,
121
+ month: full.month - 1,
122
+ lunar: this.getlunar(full.year, full.month - 1, beforeDate),
123
+ disable: true
124
+ })
125
+ }
126
+ return dateArr
127
+ }
128
+ /**
129
+ * 获取本月天数
130
+ */
131
+ _currentMonthDys(dateData, full) {
132
+ let dateArr = []
133
+ let fullDate = this.date.fullDate
134
+ for (let i = 1; i <= dateData; i++) {
135
+ let nowDate = full.year + '-' + (full.month < 10 ?
136
+ full.month : full.month) + '-' + (i < 10 ?
137
+ '0' + i : i)
138
+ // 是否今天
139
+ let isDay = fullDate === nowDate
140
+ // 获取打点信息
141
+ let info = this.selected && this.selected.find((item) => {
142
+ if (this.dateEqual(nowDate, item.date)) {
143
+ return item
144
+ }
145
+ })
146
+
147
+ // 日期禁用
148
+ let disableBefore = true
149
+ let disableAfter = true
150
+ if (this.startDate) {
151
+ // let dateCompBefore = this.dateCompare(this.startDate, fullDate)
152
+ // disableBefore = this.dateCompare(dateCompBefore ? this.startDate : fullDate, nowDate)
153
+ disableBefore = this.dateCompare(this.startDate, nowDate)
154
+ }
155
+
156
+ if (this.endDate) {
157
+ // let dateCompAfter = this.dateCompare(fullDate, this.endDate)
158
+ // disableAfter = this.dateCompare(nowDate, dateCompAfter ? this.endDate : fullDate)
159
+ disableAfter = this.dateCompare(nowDate, this.endDate)
160
+ }
161
+ let multiples = this.multipleStatus.data
162
+ let checked = false
163
+ let multiplesStatus = -1
164
+ if (this.range) {
165
+ if (multiples) {
166
+ multiplesStatus = multiples.findIndex((item) => {
167
+ return this.dateEqual(item, nowDate)
168
+ })
169
+ }
170
+ if (multiplesStatus !== -1) {
171
+ checked = true
172
+ }
173
+ }
174
+ let data = {
175
+ fullDate: nowDate,
176
+ year: full.year,
177
+ date: i,
178
+ multiple: this.range ? checked : false,
179
+ beforeMultiple: this.dateEqual(this.multipleStatus.before, nowDate),
180
+ afterMultiple: this.dateEqual(this.multipleStatus.after, nowDate),
181
+ month: full.month,
182
+ lunar: this.getlunar(full.year, full.month, i),
183
+ disable: !(disableBefore && disableAfter),
184
+ isDay
185
+ }
186
+ if (info) {
187
+ data.extraInfo = info
188
+ }
189
+
190
+ dateArr.push(data)
191
+ }
192
+ return dateArr
193
+ }
194
+ /**
195
+ * 获取下月天数
196
+ */
197
+ _getNextMonthDays(surplus, full) {
198
+ let dateArr = []
199
+ for (let i = 1; i < surplus + 1; i++) {
200
+ dateArr.push({
201
+ date: i,
202
+ month: Number(full.month) + 1,
203
+ lunar: this.getlunar(full.year, Number(full.month) + 1, i),
204
+ disable: true
205
+ })
206
+ }
207
+ return dateArr
208
+ }
209
+
210
+ /**
211
+ * 获取当前日期详情
212
+ * @param {Object} date
213
+ */
214
+ getInfo(date) {
215
+ if (!date) {
216
+ date = new Date()
217
+ }
218
+ const dateInfo = this.canlender.find(item => item.fullDate === this.getDate(date).fullDate)
219
+ return dateInfo
220
+ }
221
+
222
+ /**
223
+ * 比较时间大小
224
+ */
225
+ dateCompare(startDate, endDate) {
226
+ // 计算截止时间
227
+ startDate = new Date(startDate.replace('-', '/').replace('-', '/'))
228
+ // 计算详细项的截止时间
229
+ endDate = new Date(endDate.replace('-', '/').replace('-', '/'))
230
+ if (startDate <= endDate) {
231
+ return true
232
+ } else {
233
+ return false
234
+ }
235
+ }
236
+
237
+ /**
238
+ * 比较时间是否相等
239
+ */
240
+ dateEqual(before, after) {
241
+ // 计算截止时间
242
+ before = new Date(before.replace('-', '/').replace('-', '/'))
243
+ // 计算详细项的截止时间
244
+ after = new Date(after.replace('-', '/').replace('-', '/'))
245
+ if (before.getTime() - after.getTime() === 0) {
246
+ return true
247
+ } else {
248
+ return false
249
+ }
250
+ }
251
+
252
+
253
+ /**
254
+ * 获取日期范围内所有日期
255
+ * @param {Object} begin
256
+ * @param {Object} end
257
+ */
258
+ geDateAll(begin, end) {
259
+ var arr = []
260
+ var ab = begin.split('-')
261
+ var ae = end.split('-')
262
+ var db = new Date()
263
+ db.setFullYear(ab[0], ab[1] - 1, ab[2])
264
+ var de = new Date()
265
+ de.setFullYear(ae[0], ae[1] - 1, ae[2])
266
+ var unixDb = db.getTime() - 24 * 60 * 60 * 1000
267
+ var unixDe = de.getTime() - 24 * 60 * 60 * 1000
268
+ for (var k = unixDb; k <= unixDe;) {
269
+ k = k + 24 * 60 * 60 * 1000
270
+ arr.push(this.getDate(new Date(parseInt(k))).fullDate)
271
+ }
272
+ return arr
273
+ }
274
+ /**
275
+ * 计算阴历日期显示
276
+ */
277
+ getlunar(year, month, date) {
278
+ return CALENDAR.solar2lunar(year, month, date)
279
+ }
280
+ /**
281
+ * 设置打点
282
+ */
283
+ setSelectInfo(data, value) {
284
+ this.selected = value
285
+ this._getWeek(data)
286
+ }
287
+
288
+ /**
289
+ * 获取多选状态
290
+ */
291
+ setMultiple(fullDate) {
292
+ let {
293
+ before,
294
+ after
295
+ } = this.multipleStatus
296
+
297
+ if (!this.range) return
298
+ if (before && after) {
299
+ this.multipleStatus.before = ''
300
+ this.multipleStatus.after = ''
301
+ this.multipleStatus.data = []
302
+ } else {
303
+ if (!before) {
304
+ this.multipleStatus.before = fullDate
305
+ } else {
306
+ this.multipleStatus.after = fullDate
307
+ if (this.dateCompare(this.multipleStatus.before, this.multipleStatus.after)) {
308
+ this.multipleStatus.data = this.geDateAll(this.multipleStatus.before, this.multipleStatus.after);
309
+ } else {
310
+ this.multipleStatus.data = this.geDateAll(this.multipleStatus.after, this.multipleStatus.before);
311
+ }
312
+ }
313
+ }
314
+ this._getWeek(fullDate)
315
+ }
316
+
317
+ /**
318
+ * 获取每周数据
319
+ * @param {Object} dateData
320
+ */
321
+ _getWeek(dateData) {
322
+ const {
323
+ year,
324
+ month
325
+ } = this.getDate(dateData)
326
+ let firstDay = new Date(year, month - 1, 1).getDay()
327
+ let currentDay = new Date(year, month, 0).getDate()
328
+ let dates = {
329
+ lastMonthDays: this._getLastMonthDays(firstDay, this.getDate(dateData)), // 上个月末尾几天
330
+ currentMonthDys: this._currentMonthDys(currentDay, this.getDate(dateData)), // 本月天数
331
+ nextMonthDays: [], // 下个月开始几天
332
+ weeks: []
333
+ }
334
+ let canlender = []
335
+ const surplus = 42 - (dates.lastMonthDays.length + dates.currentMonthDys.length)
336
+ dates.nextMonthDays = this._getNextMonthDays(surplus, this.getDate(dateData))
337
+ canlender = canlender.concat(dates.lastMonthDays, dates.currentMonthDys, dates.nextMonthDays)
338
+ let weeks = {}
339
+ // 拼接数组 上个月开始几天 + 本月天数+ 下个月开始几天
340
+ for (let i = 0; i < canlender.length; i++) {
341
+ if (i % 7 === 0) {
342
+ weeks[parseInt(i / 7)] = new Array(7)
343
+ }
344
+ weeks[parseInt(i / 7)][i % 7] = canlender[i]
345
+ }
346
+ this.canlender = canlender
347
+ this.weeks = weeks
348
+ }
349
+
350
+ //静态方法
351
+ // static init(date) {
352
+ // if (!this.instance) {
353
+ // this.instance = new Calendar(date);
354
+ // }
355
+ // return this.instance;
356
+ // }
357
+ }
358
+
359
+
360
+ export default Calendar
@@ -0,0 +1,281 @@
1
+ <template>
2
+ <view
3
+ class="uni-card"
4
+ :class="{ 'uni-card--full': isFull, 'uni-card--shadow': isShadow, 'uni-card--border': border }"
5
+ :style="{ margin: isFull ? 0 : margin, padding: spacing, 'box-shadow': isShadow ? shadow : '' }"
6
+ >
7
+ <!-- 封面 -->
8
+ <slot name="cover">
9
+ <view v-if="cover" class="uni-card__cover">
10
+ <image class="uni-card__cover-image" mode="widthFix" @click="onClick('cover')" :src="cover"></image>
11
+ </view>
12
+ </slot>
13
+ <slot name="title">
14
+ <view v-if="title || extra" class="uni-card__header">
15
+ <!-- 卡片标题 -->
16
+ <view class="uni-card__header-box" @click="onClick('title')">
17
+ <view v-if="thumbnail" class="uni-card__header-avatar">
18
+ <image class="uni-card__header-avatar-image" :src="thumbnail" mode="aspectFit" />
19
+ </view>
20
+ <view class="uni-card__header-content">
21
+ <text class="uni-card__header-content-title uni-ellipsis">{{ title }}</text>
22
+ <text v-if="title && subTitle" class="uni-card__header-content-subtitle uni-ellipsis">{{ subTitle }} </text>
23
+ </view>
24
+ </view>
25
+ <view class="uni-card__header-extra" @click="onClick('extra')">
26
+ <slot name="extra">
27
+ <text class="uni-card__header-extra-text">{{ extra }}</text>
28
+ </slot>
29
+ </view>
30
+ </view>
31
+ </slot>
32
+ <!-- 卡片内容 -->
33
+ <view class="uni-card__content" :style="{ padding: padding }" @click="onClick('content')">
34
+ <slot></slot>
35
+ </view>
36
+ <view class="uni-card__actions" @click="onClick('actions')">
37
+ <slot name="actions"></slot>
38
+ </view>
39
+ </view>
40
+ </template>
41
+
42
+ <script>
43
+ import { defineComponent } from 'vue';
44
+
45
+ /**
46
+ * Card 卡片
47
+ * @description 卡片视图组件
48
+ * @tutorial https://ext.dcloud.net.cn/plugin?id=22
49
+ * @property {String} title 标题文字
50
+ * @property {String} subTitle 副标题
51
+ * @property {Number} padding 内容内边距
52
+ * @property {Number} margin 卡片外边距
53
+ * @property {Number} spacing 卡片内边距
54
+ * @property {String} extra 标题额外信息
55
+ * @property {String} cover 封面图(本地路径需要引入)
56
+ * @property {String} thumbnail 标题左侧缩略图
57
+ * @property {Boolean} is-full = [true | false] 卡片内容是否通栏,为 true 时将去除padding值
58
+ * @property {Boolean} is-shadow = [true | false] 卡片内容是否开启阴影
59
+ * @property {String} shadow 卡片阴影
60
+ * @property {Boolean} border 卡片边框
61
+ * @event {Function} click 点击 Card 触发事件
62
+ */
63
+ export default defineComponent({
64
+ name: 'UniCard',
65
+ emits: ['click'],
66
+ props: {
67
+ title: {
68
+ type: String,
69
+ default: '',
70
+ },
71
+ subTitle: {
72
+ type: String,
73
+ default: '',
74
+ },
75
+ padding: {
76
+ type: String,
77
+ default: '10px',
78
+ },
79
+ margin: {
80
+ type: String,
81
+ default: '15px',
82
+ },
83
+ spacing: {
84
+ type: String,
85
+ default: '0 10px',
86
+ },
87
+ extra: {
88
+ type: String,
89
+ default: '',
90
+ },
91
+ cover: {
92
+ type: String,
93
+ default: '',
94
+ },
95
+ thumbnail: {
96
+ type: String,
97
+ default: '',
98
+ },
99
+ isFull: {
100
+ // 内容区域是否通栏
101
+ type: Boolean,
102
+ default: false,
103
+ },
104
+ isShadow: {
105
+ // 是否开启阴影
106
+ type: Boolean,
107
+ default: true,
108
+ },
109
+ shadow: {
110
+ type: String,
111
+ default: '0px 0px 3px 1px rgba(0, 0, 0, 0.08)',
112
+ },
113
+ border: {
114
+ type: Boolean,
115
+ default: true,
116
+ },
117
+ },
118
+ methods: {
119
+ onClick(type) {
120
+ this.$emit('click', type);
121
+ },
122
+ },
123
+ });
124
+ </script>
125
+
126
+ <style lang="scss">
127
+ $uni-border-3: #ebeef5 !default;
128
+ $uni-shadow-base: 0 0px 6px 1px
129
+ rgba(
130
+ $color: #a5a5a5,
131
+ $alpha: 0.2,
132
+ ) !default;
133
+ $uni-main-color: #3a3a3a !default;
134
+ $uni-base-color: #6a6a6a !default;
135
+ $uni-secondary-color: #909399 !default;
136
+ $uni-spacing-sm: 8px !default;
137
+ $uni-border-color: $uni-border-3;
138
+ $uni-shadow: $uni-shadow-base;
139
+ $uni-card-title: 15px;
140
+ $uni-cart-title-color: $uni-main-color;
141
+ $uni-card-subtitle: 12px;
142
+ $uni-cart-subtitle-color: $uni-secondary-color;
143
+ $uni-card-spacing: 10px;
144
+ $uni-card-content-color: $uni-base-color;
145
+
146
+ .uni-card {
147
+ margin: $uni-card-spacing;
148
+ border-radius: 4px;
149
+ overflow: hidden;
150
+ font-family: Helvetica Neue, Helvetica, PingFang SC, Hiragino Sans GB, Microsoft YaHei, SimSun, sans-serif;
151
+ background-color: #fff;
152
+ flex: 1;
153
+
154
+ .uni-card__cover {
155
+ position: relative;
156
+ margin-top: $uni-card-spacing;
157
+ flex-direction: row;
158
+ overflow: hidden;
159
+ border-radius: 4px;
160
+
161
+ .uni-card__cover-image {
162
+ flex: 1;
163
+ // width: 100%;
164
+ /* #ifndef APP-PLUS */
165
+ vertical-align: middle;
166
+ /* #endif */
167
+ }
168
+ }
169
+
170
+ .uni-card__header {
171
+ display: flex;
172
+ border-bottom: 1px $uni-border-color solid;
173
+ flex-direction: row;
174
+ align-items: center;
175
+ padding: $uni-card-spacing;
176
+ overflow: hidden;
177
+
178
+ .uni-card__header-box {
179
+ /* #ifndef APP-NVUE */
180
+ display: flex;
181
+ /* #endif */
182
+ flex: 1;
183
+ flex-direction: row;
184
+ align-items: center;
185
+ overflow: hidden;
186
+ }
187
+
188
+ .uni-card__header-avatar {
189
+ width: 40px;
190
+ height: 40px;
191
+ overflow: hidden;
192
+ border-radius: 5px;
193
+ margin-right: $uni-card-spacing;
194
+
195
+ .uni-card__header-avatar-image {
196
+ flex: 1;
197
+ width: 40px;
198
+ height: 40px;
199
+ }
200
+ }
201
+
202
+ .uni-card__header-content {
203
+ /* #ifndef APP-NVUE */
204
+ display: flex;
205
+ /* #endif */
206
+ flex-direction: column;
207
+ justify-content: center;
208
+ flex: 1;
209
+ // height: 40px;
210
+ overflow: hidden;
211
+
212
+ .uni-card__header-content-title {
213
+ font-size: $uni-card-title;
214
+ color: $uni-cart-title-color;
215
+ // line-height: 22px;
216
+ }
217
+
218
+ .uni-card__header-content-subtitle {
219
+ font-size: $uni-card-subtitle;
220
+ margin-top: 5px;
221
+ color: $uni-cart-subtitle-color;
222
+ }
223
+ }
224
+
225
+ .uni-card__header-extra {
226
+ line-height: 12px;
227
+
228
+ .uni-card__header-extra-text {
229
+ font-size: 12px;
230
+ color: $uni-cart-subtitle-color;
231
+ }
232
+ }
233
+ }
234
+
235
+ .uni-card__content {
236
+ padding: $uni-card-spacing;
237
+ font-size: 14px;
238
+ color: $uni-card-content-color;
239
+ line-height: 22px;
240
+ }
241
+
242
+ .uni-card__actions {
243
+ font-size: 12px;
244
+ }
245
+ }
246
+
247
+ .uni-card--border {
248
+ border: 1px solid $uni-border-color;
249
+ }
250
+
251
+ .uni-card--shadow {
252
+ position: relative;
253
+ /* #ifndef APP-NVUE */
254
+ box-shadow: $uni-shadow;
255
+ /* #endif */
256
+ }
257
+
258
+ .uni-card--full {
259
+ margin: 0;
260
+ border-left-width: 0;
261
+ border-left-width: 0;
262
+ border-radius: 0;
263
+ }
264
+
265
+ /* #ifndef APP-NVUE */
266
+ .uni-card--full:after {
267
+ border-radius: 0;
268
+ }
269
+
270
+ /* #endif */
271
+ .uni-ellipsis {
272
+ /* #ifndef APP-NVUE */
273
+ overflow: hidden;
274
+ white-space: nowrap;
275
+ text-overflow: ellipsis;
276
+ /* #endif */
277
+ /* #ifdef APP-NVUE */
278
+ lines: 1;
279
+ /* #endif */
280
+ }
281
+ </style>